// 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"
)

// DataSource - A data source that is powered by the platform.
type DataSource string

const (
	DataSourceMetrics   DataSource = "metrics"
	DataSourceCloudCost DataSource = "cloud_cost"
	DataSourceLogs      DataSource = "logs"
	DataSourceRum       DataSource = "rum"
)

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

type Queries struct {
	// A data source that is powered by the platform.
	DataSource DataSource `json:"data_source"`
	// The variable name for use in queries.
	Name string `json:"name"`
	// A classic query string.
	Query string `json:"query"`
}

func (o *Queries) GetDataSource() DataSource {
	if o == nil {
		return DataSource("")
	}
	return o.DataSource
}

func (o *Queries) GetName() string {
	if o == nil {
		return ""
	}
	return o.Name
}

func (o *Queries) GetQuery() string {
	if o == nil {
		return ""
	}
	return o.Query
}

// Site - The site where Datadog data resides in.
type Site string

const (
	SiteDatadoghqCom    Site = "datadoghq.com"
	SiteUs3DatadoghqCom Site = "us3.datadoghq.com"
	SiteUs5DatadoghqCom Site = "us5.datadoghq.com"
	SiteDatadoghqEu     Site = "datadoghq.eu"
	SiteDdogGovCom      Site = "ddog-gov.com"
)

func (e Site) ToPointer() *Site {
	return &e
}
func (e *Site) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "datadoghq.com":
		fallthrough
	case "us3.datadoghq.com":
		fallthrough
	case "us5.datadoghq.com":
		fallthrough
	case "datadoghq.eu":
		fallthrough
	case "ddog-gov.com":
		*e = Site(v)
		return nil
	default:
		return fmt.Errorf("invalid value for Site: %v", v)
	}
}

type Datadog string

const (
	DatadogDatadog Datadog = "datadog"
)

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

type SourceDatadog struct {
	// Datadog API key
	APIKey string `json:"api_key"`
	// Datadog application key
	ApplicationKey string `json:"application_key"`
	// UTC date and time in the format 2017-01-25T00:00:00Z. Data after this date will  not be replicated. An empty value will represent the current datetime for each  execution. This just applies to Incremental syncs.
	EndDate *string `json:"end_date,omitempty"`
	// Maximum number of records to collect per request.
	MaxRecordsPerRequest *int64 `default:"5000" json:"max_records_per_request"`
	// List of queries to be run and used as inputs.
	Queries []Queries `json:"queries,omitempty"`
	// The search query. This just applies to Incremental syncs. If empty, it'll collect all logs.
	Query *string `json:"query,omitempty"`
	// The site where Datadog data resides in.
	Site *Site `default:"datadoghq.com" json:"site"`
	// UTC date and time in the format 2017-01-25T00:00:00Z. Any data before this date will not be replicated. This just applies to Incremental syncs.
	StartDate  *string `default:"2023-12-01T00:00:00Z" json:"start_date"`
	sourceType Datadog `const:"datadog" json:"sourceType"`
}

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

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

func (o *SourceDatadog) GetAPIKey() string {
	if o == nil {
		return ""
	}
	return o.APIKey
}

func (o *SourceDatadog) GetApplicationKey() string {
	if o == nil {
		return ""
	}
	return o.ApplicationKey
}

func (o *SourceDatadog) GetEndDate() *string {
	if o == nil {
		return nil
	}
	return o.EndDate
}

func (o *SourceDatadog) GetMaxRecordsPerRequest() *int64 {
	if o == nil {
		return nil
	}
	return o.MaxRecordsPerRequest
}

func (o *SourceDatadog) GetQueries() []Queries {
	if o == nil {
		return nil
	}
	return o.Queries
}

func (o *SourceDatadog) GetQuery() *string {
	if o == nil {
		return nil
	}
	return o.Query
}

func (o *SourceDatadog) GetSite() *Site {
	if o == nil {
		return nil
	}
	return o.Site
}

func (o *SourceDatadog) GetStartDate() *string {
	if o == nil {
		return nil
	}
	return o.StartDate
}

func (o *SourceDatadog) GetSourceType() Datadog {
	return DatadogDatadog
}
