// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.

package shared

import (
	"encoding/json"
	"fmt"
	"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/internal/utils"
)

type ServiceDetails string

const (
	ServiceDetailsEscalationPolicies               ServiceDetails = "escalation_policies"
	ServiceDetailsTeams                            ServiceDetails = "teams"
	ServiceDetailsIntegrations                     ServiceDetails = "integrations"
	ServiceDetailsAutoPauseNotificationsParameters ServiceDetails = "auto_pause_notifications_parameters"
)

func (e ServiceDetails) ToPointer() *ServiceDetails {
	return &e
}
func (e *ServiceDetails) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "escalation_policies":
		fallthrough
	case "teams":
		fallthrough
	case "integrations":
		fallthrough
	case "auto_pause_notifications_parameters":
		*e = ServiceDetails(v)
		return nil
	default:
		return fmt.Errorf("invalid value for ServiceDetails: %v", v)
	}
}

type Pagerduty string

const (
	PagerdutyPagerduty Pagerduty = "pagerduty"
)

func (e Pagerduty) ToPointer() *Pagerduty {
	return &e
}
func (e *Pagerduty) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "pagerduty":
		*e = Pagerduty(v)
		return nil
	default:
		return fmt.Errorf("invalid value for Pagerduty: %v", v)
	}
}

type SourcePagerduty struct {
	// Fetch pipelines updated in the last number of days
	CutoffDays *int64 `default:"90" json:"cutoff_days"`
	// A default severity category if not present
	DefaultSeverity *string `json:"default_severity,omitempty"`
	// List of PagerDuty service names to ignore incidents from. If not set, all incidents will be pulled.
	ExcludeServices []string `json:"exclude_services,omitempty"`
	// If true, will return a subset of log entries that show only the most important changes to the incident.
	IncidentLogEntriesOverview *bool `default:"true" json:"incident_log_entries_overview"`
	// Maximum number of PagerDuty API request retries to perform upon connection errors. The source will pause for an exponentially increasing number of seconds before retrying.
	MaxRetries *int64 `default:"5" json:"max_retries"`
	// page size to use when querying PagerDuty API
	PageSize *int64 `default:"25" json:"page_size"`
	// List of PagerDuty service additional details to include.
	ServiceDetails []ServiceDetails `json:"service_details,omitempty"`
	// API key for PagerDuty API authentication
	Token      string    `json:"token"`
	sourceType Pagerduty `const:"pagerduty" json:"sourceType"`
}

func (s SourcePagerduty) MarshalJSON() ([]byte, error) {
	return utils.MarshalJSON(s, "", false)
}

func (s *SourcePagerduty) UnmarshalJSON(data []byte) error {
	if err := utils.UnmarshalJSON(data, &s, "", false, false); err != nil {
		return err
	}
	return nil
}

func (o *SourcePagerduty) GetCutoffDays() *int64 {
	if o == nil {
		return nil
	}
	return o.CutoffDays
}

func (o *SourcePagerduty) GetDefaultSeverity() *string {
	if o == nil {
		return nil
	}
	return o.DefaultSeverity
}

func (o *SourcePagerduty) GetExcludeServices() []string {
	if o == nil {
		return nil
	}
	return o.ExcludeServices
}

func (o *SourcePagerduty) GetIncidentLogEntriesOverview() *bool {
	if o == nil {
		return nil
	}
	return o.IncidentLogEntriesOverview
}

func (o *SourcePagerduty) GetMaxRetries() *int64 {
	if o == nil {
		return nil
	}
	return o.MaxRetries
}

func (o *SourcePagerduty) GetPageSize() *int64 {
	if o == nil {
		return nil
	}
	return o.PageSize
}

func (o *SourcePagerduty) GetServiceDetails() []ServiceDetails {
	if o == nil {
		return nil
	}
	return o.ServiceDetails
}

func (o *SourcePagerduty) GetToken() string {
	if o == nil {
		return ""
	}
	return o.Token
}

func (o *SourcePagerduty) GetSourceType() Pagerduty {
	return PagerdutyPagerduty
}
