// 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 SourcePagerdutyUpdateServiceDetails string

const (
	SourcePagerdutyUpdateServiceDetailsEscalationPolicies               SourcePagerdutyUpdateServiceDetails = "escalation_policies"
	SourcePagerdutyUpdateServiceDetailsTeams                            SourcePagerdutyUpdateServiceDetails = "teams"
	SourcePagerdutyUpdateServiceDetailsIntegrations                     SourcePagerdutyUpdateServiceDetails = "integrations"
	SourcePagerdutyUpdateServiceDetailsAutoPauseNotificationsParameters SourcePagerdutyUpdateServiceDetails = "auto_pause_notifications_parameters"
)

func (e SourcePagerdutyUpdateServiceDetails) ToPointer() *SourcePagerdutyUpdateServiceDetails {
	return &e
}
func (e *SourcePagerdutyUpdateServiceDetails) 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 = SourcePagerdutyUpdateServiceDetails(v)
		return nil
	default:
		return fmt.Errorf("invalid value for SourcePagerdutyUpdateServiceDetails: %v", v)
	}
}

type SourcePagerdutyUpdate 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 []SourcePagerdutyUpdateServiceDetails `json:"service_details,omitempty"`
	// API key for PagerDuty API authentication
	Token string `json:"token"`
}

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

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

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

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

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

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

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

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

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

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