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

package shared

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

type SourceAzureBlobStorageSchemasCredentialsAuthType string

const (
	SourceAzureBlobStorageSchemasCredentialsAuthTypeStorageAccountKey SourceAzureBlobStorageSchemasCredentialsAuthType = "storage_account_key"
)

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

type AuthenticateViaStorageAccountKey struct {
	authType *SourceAzureBlobStorageSchemasCredentialsAuthType `const:"storage_account_key" json:"auth_type"`
	// The Azure blob storage account key.
	AzureBlobStorageAccountKey string `json:"azure_blob_storage_account_key"`
}

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

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

func (o *AuthenticateViaStorageAccountKey) GetAuthType() *SourceAzureBlobStorageSchemasCredentialsAuthType {
	return SourceAzureBlobStorageSchemasCredentialsAuthTypeStorageAccountKey.ToPointer()
}

func (o *AuthenticateViaStorageAccountKey) GetAzureBlobStorageAccountKey() string {
	if o == nil {
		return ""
	}
	return o.AzureBlobStorageAccountKey
}

type SourceAzureBlobStorageSchemasAuthType string

const (
	SourceAzureBlobStorageSchemasAuthTypeClientCredentials SourceAzureBlobStorageSchemasAuthType = "client_credentials"
)

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

type AuthenticateViaClientCredentials struct {
	// Client ID of your Microsoft developer application
	AppClientID string `json:"app_client_id"`
	// Client Secret of your Microsoft developer application
	AppClientSecret string `json:"app_client_secret"`
	// Tenant ID of the Microsoft Azure Application
	AppTenantID string                                 `json:"app_tenant_id"`
	authType    *SourceAzureBlobStorageSchemasAuthType `const:"client_credentials" json:"auth_type"`
}

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

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

func (o *AuthenticateViaClientCredentials) GetAppClientID() string {
	if o == nil {
		return ""
	}
	return o.AppClientID
}

func (o *AuthenticateViaClientCredentials) GetAppClientSecret() string {
	if o == nil {
		return ""
	}
	return o.AppClientSecret
}

func (o *AuthenticateViaClientCredentials) GetAppTenantID() string {
	if o == nil {
		return ""
	}
	return o.AppTenantID
}

func (o *AuthenticateViaClientCredentials) GetAuthType() *SourceAzureBlobStorageSchemasAuthType {
	return SourceAzureBlobStorageSchemasAuthTypeClientCredentials.ToPointer()
}

type SourceAzureBlobStorageAuthType string

const (
	SourceAzureBlobStorageAuthTypeOauth2 SourceAzureBlobStorageAuthType = "oauth2"
)

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

type AuthenticateViaOauth2 struct {
	authType *SourceAzureBlobStorageAuthType `const:"oauth2" json:"auth_type"`
	// Client ID of your Microsoft developer application
	ClientID string `json:"client_id"`
	// Client Secret of your Microsoft developer application
	ClientSecret string `json:"client_secret"`
	// Refresh Token of your Microsoft developer application
	RefreshToken string `json:"refresh_token"`
	// Tenant ID of the Microsoft Azure Application user
	TenantID string `json:"tenant_id"`
}

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

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

func (o *AuthenticateViaOauth2) GetAuthType() *SourceAzureBlobStorageAuthType {
	return SourceAzureBlobStorageAuthTypeOauth2.ToPointer()
}

func (o *AuthenticateViaOauth2) GetClientID() string {
	if o == nil {
		return ""
	}
	return o.ClientID
}

func (o *AuthenticateViaOauth2) GetClientSecret() string {
	if o == nil {
		return ""
	}
	return o.ClientSecret
}

func (o *AuthenticateViaOauth2) GetRefreshToken() string {
	if o == nil {
		return ""
	}
	return o.RefreshToken
}

func (o *AuthenticateViaOauth2) GetTenantID() string {
	if o == nil {
		return ""
	}
	return o.TenantID
}

type SourceAzureBlobStorageAuthenticationType string

const (
	SourceAzureBlobStorageAuthenticationTypeAuthenticateViaOauth2            SourceAzureBlobStorageAuthenticationType = "Authenticate via Oauth2"
	SourceAzureBlobStorageAuthenticationTypeAuthenticateViaClientCredentials SourceAzureBlobStorageAuthenticationType = "Authenticate via Client Credentials"
	SourceAzureBlobStorageAuthenticationTypeAuthenticateViaStorageAccountKey SourceAzureBlobStorageAuthenticationType = "Authenticate via Storage Account Key"
)

// SourceAzureBlobStorageAuthentication - Credentials for connecting to the Azure Blob Storage
type SourceAzureBlobStorageAuthentication struct {
	AuthenticateViaOauth2            *AuthenticateViaOauth2            `queryParam:"inline"`
	AuthenticateViaClientCredentials *AuthenticateViaClientCredentials `queryParam:"inline"`
	AuthenticateViaStorageAccountKey *AuthenticateViaStorageAccountKey `queryParam:"inline"`

	Type SourceAzureBlobStorageAuthenticationType
}

func CreateSourceAzureBlobStorageAuthenticationAuthenticateViaOauth2(authenticateViaOauth2 AuthenticateViaOauth2) SourceAzureBlobStorageAuthentication {
	typ := SourceAzureBlobStorageAuthenticationTypeAuthenticateViaOauth2

	return SourceAzureBlobStorageAuthentication{
		AuthenticateViaOauth2: &authenticateViaOauth2,
		Type:                  typ,
	}
}

func CreateSourceAzureBlobStorageAuthenticationAuthenticateViaClientCredentials(authenticateViaClientCredentials AuthenticateViaClientCredentials) SourceAzureBlobStorageAuthentication {
	typ := SourceAzureBlobStorageAuthenticationTypeAuthenticateViaClientCredentials

	return SourceAzureBlobStorageAuthentication{
		AuthenticateViaClientCredentials: &authenticateViaClientCredentials,
		Type:                             typ,
	}
}

func CreateSourceAzureBlobStorageAuthenticationAuthenticateViaStorageAccountKey(authenticateViaStorageAccountKey AuthenticateViaStorageAccountKey) SourceAzureBlobStorageAuthentication {
	typ := SourceAzureBlobStorageAuthenticationTypeAuthenticateViaStorageAccountKey

	return SourceAzureBlobStorageAuthentication{
		AuthenticateViaStorageAccountKey: &authenticateViaStorageAccountKey,
		Type:                             typ,
	}
}

func (u *SourceAzureBlobStorageAuthentication) UnmarshalJSON(data []byte) error {

	var authenticateViaStorageAccountKey AuthenticateViaStorageAccountKey = AuthenticateViaStorageAccountKey{}
	if err := utils.UnmarshalJSON(data, &authenticateViaStorageAccountKey, "", true, true); err == nil {
		u.AuthenticateViaStorageAccountKey = &authenticateViaStorageAccountKey
		u.Type = SourceAzureBlobStorageAuthenticationTypeAuthenticateViaStorageAccountKey
		return nil
	}

	var authenticateViaClientCredentials AuthenticateViaClientCredentials = AuthenticateViaClientCredentials{}
	if err := utils.UnmarshalJSON(data, &authenticateViaClientCredentials, "", true, true); err == nil {
		u.AuthenticateViaClientCredentials = &authenticateViaClientCredentials
		u.Type = SourceAzureBlobStorageAuthenticationTypeAuthenticateViaClientCredentials
		return nil
	}

	var authenticateViaOauth2 AuthenticateViaOauth2 = AuthenticateViaOauth2{}
	if err := utils.UnmarshalJSON(data, &authenticateViaOauth2, "", true, true); err == nil {
		u.AuthenticateViaOauth2 = &authenticateViaOauth2
		u.Type = SourceAzureBlobStorageAuthenticationTypeAuthenticateViaOauth2
		return nil
	}

	return fmt.Errorf("could not unmarshal `%s` into any supported union types for SourceAzureBlobStorageAuthentication", string(data))
}

func (u SourceAzureBlobStorageAuthentication) MarshalJSON() ([]byte, error) {
	if u.AuthenticateViaOauth2 != nil {
		return utils.MarshalJSON(u.AuthenticateViaOauth2, "", true)
	}

	if u.AuthenticateViaClientCredentials != nil {
		return utils.MarshalJSON(u.AuthenticateViaClientCredentials, "", true)
	}

	if u.AuthenticateViaStorageAccountKey != nil {
		return utils.MarshalJSON(u.AuthenticateViaStorageAccountKey, "", true)
	}

	return nil, errors.New("could not marshal union type SourceAzureBlobStorageAuthentication: all fields are null")
}

type SourceAzureBlobStorageSchemasStreamsFormatFiletype string

const (
	SourceAzureBlobStorageSchemasStreamsFormatFiletypeUnstructured SourceAzureBlobStorageSchemasStreamsFormatFiletype = "unstructured"
)

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

type SourceAzureBlobStorageMode string

const (
	SourceAzureBlobStorageModeLocal SourceAzureBlobStorageMode = "local"
)

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

// Local - Process files locally, supporting `fast` and `ocr` modes. This is the default option.
type Local struct {
	mode *SourceAzureBlobStorageMode `const:"local" json:"mode"`
}

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

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

func (o *Local) GetMode() *SourceAzureBlobStorageMode {
	return SourceAzureBlobStorageModeLocal.ToPointer()
}

type ProcessingType string

const (
	ProcessingTypeLocal ProcessingType = "Local"
)

// Processing configuration
type Processing struct {
	Local *Local `queryParam:"inline"`

	Type ProcessingType
}

func CreateProcessingLocal(local Local) Processing {
	typ := ProcessingTypeLocal

	return Processing{
		Local: &local,
		Type:  typ,
	}
}

func (u *Processing) UnmarshalJSON(data []byte) error {

	var local Local = Local{}
	if err := utils.UnmarshalJSON(data, &local, "", true, true); err == nil {
		u.Local = &local
		u.Type = ProcessingTypeLocal
		return nil
	}

	return fmt.Errorf("could not unmarshal `%s` into any supported union types for Processing", string(data))
}

func (u Processing) MarshalJSON() ([]byte, error) {
	if u.Local != nil {
		return utils.MarshalJSON(u.Local, "", true)
	}

	return nil, errors.New("could not marshal union type Processing: all fields are null")
}

// ParsingStrategy - The strategy used to parse documents. `fast` extracts text directly from the document which doesn't work for all files. `ocr_only` is more reliable, but slower. `hi_res` is the most reliable, but requires an API key and a hosted instance of unstructured and can't be used with local mode. See the unstructured.io documentation for more details: https://unstructured-io.github.io/unstructured/core/partition.html#partition-pdf
type ParsingStrategy string

const (
	ParsingStrategyAuto    ParsingStrategy = "auto"
	ParsingStrategyFast    ParsingStrategy = "fast"
	ParsingStrategyOcrOnly ParsingStrategy = "ocr_only"
	ParsingStrategyHiRes   ParsingStrategy = "hi_res"
)

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

// UnstructuredDocumentFormat - Extract text from document formats (.pdf, .docx, .md, .pptx) and emit as one record per file.
type UnstructuredDocumentFormat struct {
	filetype *SourceAzureBlobStorageSchemasStreamsFormatFiletype `const:"unstructured" json:"filetype"`
	// Processing configuration
	Processing *Processing `json:"processing,omitempty"`
	// If true, skip files that cannot be parsed and pass the error message along as the _ab_source_file_parse_error field. If false, fail the sync.
	SkipUnprocessableFiles *bool `default:"true" json:"skip_unprocessable_files"`
	// The strategy used to parse documents. `fast` extracts text directly from the document which doesn't work for all files. `ocr_only` is more reliable, but slower. `hi_res` is the most reliable, but requires an API key and a hosted instance of unstructured and can't be used with local mode. See the unstructured.io documentation for more details: https://unstructured-io.github.io/unstructured/core/partition.html#partition-pdf
	Strategy *ParsingStrategy `default:"auto" json:"strategy"`
}

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

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

func (o *UnstructuredDocumentFormat) GetFiletype() *SourceAzureBlobStorageSchemasStreamsFormatFiletype {
	return SourceAzureBlobStorageSchemasStreamsFormatFiletypeUnstructured.ToPointer()
}

func (o *UnstructuredDocumentFormat) GetProcessing() *Processing {
	if o == nil {
		return nil
	}
	return o.Processing
}

func (o *UnstructuredDocumentFormat) GetSkipUnprocessableFiles() *bool {
	if o == nil {
		return nil
	}
	return o.SkipUnprocessableFiles
}

func (o *UnstructuredDocumentFormat) GetStrategy() *ParsingStrategy {
	if o == nil {
		return nil
	}
	return o.Strategy
}

type SourceAzureBlobStorageSchemasStreamsFiletype string

const (
	SourceAzureBlobStorageSchemasStreamsFiletypeParquet SourceAzureBlobStorageSchemasStreamsFiletype = "parquet"
)

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

type ParquetFormat struct {
	// Whether to convert decimal fields to floats. There is a loss of precision when converting decimals to floats, so this is not recommended.
	DecimalAsFloat *bool                                         `default:"false" json:"decimal_as_float"`
	filetype       *SourceAzureBlobStorageSchemasStreamsFiletype `const:"parquet" json:"filetype"`
}

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

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

func (o *ParquetFormat) GetDecimalAsFloat() *bool {
	if o == nil {
		return nil
	}
	return o.DecimalAsFloat
}

func (o *ParquetFormat) GetFiletype() *SourceAzureBlobStorageSchemasStreamsFiletype {
	return SourceAzureBlobStorageSchemasStreamsFiletypeParquet.ToPointer()
}

type SourceAzureBlobStorageSchemasFiletype string

const (
	SourceAzureBlobStorageSchemasFiletypeJsonl SourceAzureBlobStorageSchemasFiletype = "jsonl"
)

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

type JsonlFormat struct {
	filetype *SourceAzureBlobStorageSchemasFiletype `const:"jsonl" json:"filetype"`
}

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

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

func (o *JsonlFormat) GetFiletype() *SourceAzureBlobStorageSchemasFiletype {
	return SourceAzureBlobStorageSchemasFiletypeJsonl.ToPointer()
}

type SourceAzureBlobStorageFiletype string

const (
	SourceAzureBlobStorageFiletypeCsv SourceAzureBlobStorageFiletype = "csv"
)

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

type SourceAzureBlobStorageSchemasHeaderDefinitionType string

const (
	SourceAzureBlobStorageSchemasHeaderDefinitionTypeUserProvided SourceAzureBlobStorageSchemasHeaderDefinitionType = "User Provided"
)

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

type UserProvided struct {
	// The column names that will be used while emitting the CSV records
	ColumnNames          []string                                           `json:"column_names"`
	headerDefinitionType *SourceAzureBlobStorageSchemasHeaderDefinitionType `const:"User Provided" json:"header_definition_type"`
}

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

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

func (o *UserProvided) GetColumnNames() []string {
	if o == nil {
		return []string{}
	}
	return o.ColumnNames
}

func (o *UserProvided) GetHeaderDefinitionType() *SourceAzureBlobStorageSchemasHeaderDefinitionType {
	return SourceAzureBlobStorageSchemasHeaderDefinitionTypeUserProvided.ToPointer()
}

type SourceAzureBlobStorageHeaderDefinitionType string

const (
	SourceAzureBlobStorageHeaderDefinitionTypeAutogenerated SourceAzureBlobStorageHeaderDefinitionType = "Autogenerated"
)

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

type Autogenerated struct {
	headerDefinitionType *SourceAzureBlobStorageHeaderDefinitionType `const:"Autogenerated" json:"header_definition_type"`
}

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

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

func (o *Autogenerated) GetHeaderDefinitionType() *SourceAzureBlobStorageHeaderDefinitionType {
	return SourceAzureBlobStorageHeaderDefinitionTypeAutogenerated.ToPointer()
}

type HeaderDefinitionType string

const (
	HeaderDefinitionTypeFromCsv HeaderDefinitionType = "From CSV"
)

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

type FromCSV struct {
	headerDefinitionType *HeaderDefinitionType `const:"From CSV" json:"header_definition_type"`
}

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

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

func (o *FromCSV) GetHeaderDefinitionType() *HeaderDefinitionType {
	return HeaderDefinitionTypeFromCsv.ToPointer()
}

type CSVHeaderDefinitionType string

const (
	CSVHeaderDefinitionTypeFromCSV       CSVHeaderDefinitionType = "From CSV"
	CSVHeaderDefinitionTypeAutogenerated CSVHeaderDefinitionType = "Autogenerated"
	CSVHeaderDefinitionTypeUserProvided  CSVHeaderDefinitionType = "User Provided"
)

// CSVHeaderDefinition - How headers will be defined. `User Provided` assumes the CSV does not have a header row and uses the headers provided and `Autogenerated` assumes the CSV does not have a header row and the CDK will generate headers using for `f{i}` where `i` is the index starting from 0. Else, the default behavior is to use the header from the CSV file. If a user wants to autogenerate or provide column names for a CSV having headers, they can skip rows.
type CSVHeaderDefinition struct {
	FromCSV       *FromCSV       `queryParam:"inline"`
	Autogenerated *Autogenerated `queryParam:"inline"`
	UserProvided  *UserProvided  `queryParam:"inline"`

	Type CSVHeaderDefinitionType
}

func CreateCSVHeaderDefinitionFromCSV(fromCSV FromCSV) CSVHeaderDefinition {
	typ := CSVHeaderDefinitionTypeFromCSV

	return CSVHeaderDefinition{
		FromCSV: &fromCSV,
		Type:    typ,
	}
}

func CreateCSVHeaderDefinitionAutogenerated(autogenerated Autogenerated) CSVHeaderDefinition {
	typ := CSVHeaderDefinitionTypeAutogenerated

	return CSVHeaderDefinition{
		Autogenerated: &autogenerated,
		Type:          typ,
	}
}

func CreateCSVHeaderDefinitionUserProvided(userProvided UserProvided) CSVHeaderDefinition {
	typ := CSVHeaderDefinitionTypeUserProvided

	return CSVHeaderDefinition{
		UserProvided: &userProvided,
		Type:         typ,
	}
}

func (u *CSVHeaderDefinition) UnmarshalJSON(data []byte) error {

	var fromCSV FromCSV = FromCSV{}
	if err := utils.UnmarshalJSON(data, &fromCSV, "", true, true); err == nil {
		u.FromCSV = &fromCSV
		u.Type = CSVHeaderDefinitionTypeFromCSV
		return nil
	}

	var autogenerated Autogenerated = Autogenerated{}
	if err := utils.UnmarshalJSON(data, &autogenerated, "", true, true); err == nil {
		u.Autogenerated = &autogenerated
		u.Type = CSVHeaderDefinitionTypeAutogenerated
		return nil
	}

	var userProvided UserProvided = UserProvided{}
	if err := utils.UnmarshalJSON(data, &userProvided, "", true, true); err == nil {
		u.UserProvided = &userProvided
		u.Type = CSVHeaderDefinitionTypeUserProvided
		return nil
	}

	return fmt.Errorf("could not unmarshal `%s` into any supported union types for CSVHeaderDefinition", string(data))
}

func (u CSVHeaderDefinition) MarshalJSON() ([]byte, error) {
	if u.FromCSV != nil {
		return utils.MarshalJSON(u.FromCSV, "", true)
	}

	if u.Autogenerated != nil {
		return utils.MarshalJSON(u.Autogenerated, "", true)
	}

	if u.UserProvided != nil {
		return utils.MarshalJSON(u.UserProvided, "", true)
	}

	return nil, errors.New("could not marshal union type CSVHeaderDefinition: all fields are null")
}

type CSVFormat struct {
	// The character delimiting individual cells in the CSV data. This may only be a 1-character string. For tab-delimited data enter '\t'.
	Delimiter *string `default:"," json:"delimiter"`
	// Whether two quotes in a quoted CSV value denote a single quote in the data.
	DoubleQuote *bool `default:"true" json:"double_quote"`
	// The character encoding of the CSV data. Leave blank to default to <strong>UTF8</strong>. See <a href="https://docs.python.org/3/library/codecs.html#standard-encodings" target="_blank">list of python encodings</a> for allowable options.
	Encoding *string `default:"utf8" json:"encoding"`
	// The character used for escaping special characters. To disallow escaping, leave this field blank.
	EscapeChar *string `json:"escape_char,omitempty"`
	// A set of case-sensitive strings that should be interpreted as false values.
	FalseValues []string                        `json:"false_values,omitempty"`
	filetype    *SourceAzureBlobStorageFiletype `const:"csv" json:"filetype"`
	// How headers will be defined. `User Provided` assumes the CSV does not have a header row and uses the headers provided and `Autogenerated` assumes the CSV does not have a header row and the CDK will generate headers using for `f{i}` where `i` is the index starting from 0. Else, the default behavior is to use the header from the CSV file. If a user wants to autogenerate or provide column names for a CSV having headers, they can skip rows.
	HeaderDefinition *CSVHeaderDefinition `json:"header_definition,omitempty"`
	// Whether to ignore errors that occur when the number of fields in the CSV does not match the number of columns in the schema.
	IgnoreErrorsOnFieldsMismatch *bool `default:"false" json:"ignore_errors_on_fields_mismatch"`
	// A set of case-sensitive strings that should be interpreted as null values. For example, if the value 'NA' should be interpreted as null, enter 'NA' in this field.
	NullValues []string `json:"null_values,omitempty"`
	// The character used for quoting CSV values. To disallow quoting, make this field blank.
	QuoteChar *string `default:"\"" json:"quote_char"`
	// The number of rows to skip after the header row.
	SkipRowsAfterHeader *int64 `default:"0" json:"skip_rows_after_header"`
	// The number of rows to skip before the header row. For example, if the header row is on the 3rd row, enter 2 in this field.
	SkipRowsBeforeHeader *int64 `default:"0" json:"skip_rows_before_header"`
	// Whether strings can be interpreted as null values. If true, strings that match the null_values set will be interpreted as null. If false, strings that match the null_values set will be interpreted as the string itself.
	StringsCanBeNull *bool `default:"true" json:"strings_can_be_null"`
	// A set of case-sensitive strings that should be interpreted as true values.
	TrueValues []string `json:"true_values,omitempty"`
}

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

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

func (o *CSVFormat) GetDelimiter() *string {
	if o == nil {
		return nil
	}
	return o.Delimiter
}

func (o *CSVFormat) GetDoubleQuote() *bool {
	if o == nil {
		return nil
	}
	return o.DoubleQuote
}

func (o *CSVFormat) GetEncoding() *string {
	if o == nil {
		return nil
	}
	return o.Encoding
}

func (o *CSVFormat) GetEscapeChar() *string {
	if o == nil {
		return nil
	}
	return o.EscapeChar
}

func (o *CSVFormat) GetFalseValues() []string {
	if o == nil {
		return nil
	}
	return o.FalseValues
}

func (o *CSVFormat) GetFiletype() *SourceAzureBlobStorageFiletype {
	return SourceAzureBlobStorageFiletypeCsv.ToPointer()
}

func (o *CSVFormat) GetHeaderDefinition() *CSVHeaderDefinition {
	if o == nil {
		return nil
	}
	return o.HeaderDefinition
}

func (o *CSVFormat) GetIgnoreErrorsOnFieldsMismatch() *bool {
	if o == nil {
		return nil
	}
	return o.IgnoreErrorsOnFieldsMismatch
}

func (o *CSVFormat) GetNullValues() []string {
	if o == nil {
		return nil
	}
	return o.NullValues
}

func (o *CSVFormat) GetQuoteChar() *string {
	if o == nil {
		return nil
	}
	return o.QuoteChar
}

func (o *CSVFormat) GetSkipRowsAfterHeader() *int64 {
	if o == nil {
		return nil
	}
	return o.SkipRowsAfterHeader
}

func (o *CSVFormat) GetSkipRowsBeforeHeader() *int64 {
	if o == nil {
		return nil
	}
	return o.SkipRowsBeforeHeader
}

func (o *CSVFormat) GetStringsCanBeNull() *bool {
	if o == nil {
		return nil
	}
	return o.StringsCanBeNull
}

func (o *CSVFormat) GetTrueValues() []string {
	if o == nil {
		return nil
	}
	return o.TrueValues
}

type Filetype string

const (
	FiletypeAvro Filetype = "avro"
)

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

type AvroFormat struct {
	// Whether to convert double fields to strings. This is recommended if you have decimal numbers with a high degree of precision because there can be a loss precision when handling floating point numbers.
	DoubleAsString *bool     `default:"false" json:"double_as_string"`
	filetype       *Filetype `const:"avro" json:"filetype"`
}

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

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

func (o *AvroFormat) GetDoubleAsString() *bool {
	if o == nil {
		return nil
	}
	return o.DoubleAsString
}

func (o *AvroFormat) GetFiletype() *Filetype {
	return FiletypeAvro.ToPointer()
}

type FormatUnionType string

const (
	FormatUnionTypeAvroFormat                 FormatUnionType = "Avro Format"
	FormatUnionTypeCSVFormat                  FormatUnionType = "CSV Format"
	FormatUnionTypeJsonlFormat                FormatUnionType = "Jsonl Format"
	FormatUnionTypeParquetFormat              FormatUnionType = "Parquet Format"
	FormatUnionTypeUnstructuredDocumentFormat FormatUnionType = "Unstructured Document Format"
)

// Format - The configuration options that are used to alter how to read incoming files that deviate from the standard formatting.
type Format struct {
	AvroFormat                 *AvroFormat                 `queryParam:"inline"`
	CSVFormat                  *CSVFormat                  `queryParam:"inline"`
	JsonlFormat                *JsonlFormat                `queryParam:"inline"`
	ParquetFormat              *ParquetFormat              `queryParam:"inline"`
	UnstructuredDocumentFormat *UnstructuredDocumentFormat `queryParam:"inline"`

	Type FormatUnionType
}

func CreateFormatAvroFormat(avroFormat AvroFormat) Format {
	typ := FormatUnionTypeAvroFormat

	return Format{
		AvroFormat: &avroFormat,
		Type:       typ,
	}
}

func CreateFormatCSVFormat(csvFormat CSVFormat) Format {
	typ := FormatUnionTypeCSVFormat

	return Format{
		CSVFormat: &csvFormat,
		Type:      typ,
	}
}

func CreateFormatJsonlFormat(jsonlFormat JsonlFormat) Format {
	typ := FormatUnionTypeJsonlFormat

	return Format{
		JsonlFormat: &jsonlFormat,
		Type:        typ,
	}
}

func CreateFormatParquetFormat(parquetFormat ParquetFormat) Format {
	typ := FormatUnionTypeParquetFormat

	return Format{
		ParquetFormat: &parquetFormat,
		Type:          typ,
	}
}

func CreateFormatUnstructuredDocumentFormat(unstructuredDocumentFormat UnstructuredDocumentFormat) Format {
	typ := FormatUnionTypeUnstructuredDocumentFormat

	return Format{
		UnstructuredDocumentFormat: &unstructuredDocumentFormat,
		Type:                       typ,
	}
}

func (u *Format) UnmarshalJSON(data []byte) error {

	var jsonlFormat JsonlFormat = JsonlFormat{}
	if err := utils.UnmarshalJSON(data, &jsonlFormat, "", true, true); err == nil {
		u.JsonlFormat = &jsonlFormat
		u.Type = FormatUnionTypeJsonlFormat
		return nil
	}

	var avroFormat AvroFormat = AvroFormat{}
	if err := utils.UnmarshalJSON(data, &avroFormat, "", true, true); err == nil {
		u.AvroFormat = &avroFormat
		u.Type = FormatUnionTypeAvroFormat
		return nil
	}

	var parquetFormat ParquetFormat = ParquetFormat{}
	if err := utils.UnmarshalJSON(data, &parquetFormat, "", true, true); err == nil {
		u.ParquetFormat = &parquetFormat
		u.Type = FormatUnionTypeParquetFormat
		return nil
	}

	var unstructuredDocumentFormat UnstructuredDocumentFormat = UnstructuredDocumentFormat{}
	if err := utils.UnmarshalJSON(data, &unstructuredDocumentFormat, "", true, true); err == nil {
		u.UnstructuredDocumentFormat = &unstructuredDocumentFormat
		u.Type = FormatUnionTypeUnstructuredDocumentFormat
		return nil
	}

	var csvFormat CSVFormat = CSVFormat{}
	if err := utils.UnmarshalJSON(data, &csvFormat, "", true, true); err == nil {
		u.CSVFormat = &csvFormat
		u.Type = FormatUnionTypeCSVFormat
		return nil
	}

	return fmt.Errorf("could not unmarshal `%s` into any supported union types for Format", string(data))
}

func (u Format) MarshalJSON() ([]byte, error) {
	if u.AvroFormat != nil {
		return utils.MarshalJSON(u.AvroFormat, "", true)
	}

	if u.CSVFormat != nil {
		return utils.MarshalJSON(u.CSVFormat, "", true)
	}

	if u.JsonlFormat != nil {
		return utils.MarshalJSON(u.JsonlFormat, "", true)
	}

	if u.ParquetFormat != nil {
		return utils.MarshalJSON(u.ParquetFormat, "", true)
	}

	if u.UnstructuredDocumentFormat != nil {
		return utils.MarshalJSON(u.UnstructuredDocumentFormat, "", true)
	}

	return nil, errors.New("could not marshal union type Format: all fields are null")
}

// ValidationPolicy - The name of the validation policy that dictates sync behavior when a record does not adhere to the stream schema.
type ValidationPolicy string

const (
	ValidationPolicyEmitRecord      ValidationPolicy = "Emit Record"
	ValidationPolicySkipRecord      ValidationPolicy = "Skip Record"
	ValidationPolicyWaitForDiscover ValidationPolicy = "Wait for Discover"
)

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

type FileBasedStreamConfig struct {
	// When the state history of the file store is full, syncs will only read files that were last modified in the provided day range.
	DaysToSyncIfHistoryIsFull *int64 `default:"3" json:"days_to_sync_if_history_is_full"`
	// The configuration options that are used to alter how to read incoming files that deviate from the standard formatting.
	Format Format `json:"format"`
	// The pattern used to specify which files should be selected from the file system. For more information on glob pattern matching look <a href="https://en.wikipedia.org/wiki/Glob_(programming)">here</a>.
	Globs []string `json:"globs,omitempty"`
	// The schema that will be used to validate records extracted from the file. This will override the stream schema that is auto-detected from incoming files.
	InputSchema *string `json:"input_schema,omitempty"`
	// The name of the stream.
	Name string `json:"name"`
	// The number of resent files which will be used to discover the schema for this stream.
	RecentNFilesToReadForSchemaDiscovery *int64 `json:"recent_n_files_to_read_for_schema_discovery,omitempty"`
	// When enabled, syncs will not validate or structure records against the stream's schema.
	Schemaless *bool `default:"false" json:"schemaless"`
	// The name of the validation policy that dictates sync behavior when a record does not adhere to the stream schema.
	ValidationPolicy *ValidationPolicy `default:"Emit Record" json:"validation_policy"`
}

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

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

func (o *FileBasedStreamConfig) GetDaysToSyncIfHistoryIsFull() *int64 {
	if o == nil {
		return nil
	}
	return o.DaysToSyncIfHistoryIsFull
}

func (o *FileBasedStreamConfig) GetFormat() Format {
	if o == nil {
		return Format{}
	}
	return o.Format
}

func (o *FileBasedStreamConfig) GetGlobs() []string {
	if o == nil {
		return nil
	}
	return o.Globs
}

func (o *FileBasedStreamConfig) GetInputSchema() *string {
	if o == nil {
		return nil
	}
	return o.InputSchema
}

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

func (o *FileBasedStreamConfig) GetRecentNFilesToReadForSchemaDiscovery() *int64 {
	if o == nil {
		return nil
	}
	return o.RecentNFilesToReadForSchemaDiscovery
}

func (o *FileBasedStreamConfig) GetSchemaless() *bool {
	if o == nil {
		return nil
	}
	return o.Schemaless
}

func (o *FileBasedStreamConfig) GetValidationPolicy() *ValidationPolicy {
	if o == nil {
		return nil
	}
	return o.ValidationPolicy
}

type AzureBlobStorage string

const (
	AzureBlobStorageAzureBlobStorage AzureBlobStorage = "azure-blob-storage"
)

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

// SourceAzureBlobStorage - NOTE: When this Spec is changed, legacy_config_transformer.py must also be modified to uptake the changes
// because it is responsible for converting legacy Azure Blob Storage v0 configs into v1 configs using the File-Based CDK.
type SourceAzureBlobStorage struct {
	// The account's name of the Azure Blob Storage.
	AzureBlobStorageAccountName string `json:"azure_blob_storage_account_name"`
	// The name of the Azure blob storage container.
	AzureBlobStorageContainerName string `json:"azure_blob_storage_container_name"`
	// This is Azure Blob Storage endpoint domain name. Leave default value (or leave it empty if run container from command line) to use Microsoft native from example.
	AzureBlobStorageEndpoint *string `json:"azure_blob_storage_endpoint,omitempty"`
	// Credentials for connecting to the Azure Blob Storage
	Credentials SourceAzureBlobStorageAuthentication `json:"credentials"`
	// UTC date and time in the format 2017-01-25T00:00:00.000000Z. Any file modified before this date will not be replicated.
	StartDate *time.Time `json:"start_date,omitempty"`
	// Each instance of this configuration defines a <a href="https://docs.airbyte.com/cloud/core-concepts#stream">stream</a>. Use this to define which files belong in the stream, their format, and how they should be parsed and validated. When sending data to warehouse destination such as Snowflake or BigQuery, each stream is a separate table.
	Streams    []FileBasedStreamConfig `json:"streams"`
	sourceType AzureBlobStorage        `const:"azure-blob-storage" json:"sourceType"`
}

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

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

func (o *SourceAzureBlobStorage) GetAzureBlobStorageAccountName() string {
	if o == nil {
		return ""
	}
	return o.AzureBlobStorageAccountName
}

func (o *SourceAzureBlobStorage) GetAzureBlobStorageContainerName() string {
	if o == nil {
		return ""
	}
	return o.AzureBlobStorageContainerName
}

func (o *SourceAzureBlobStorage) GetAzureBlobStorageEndpoint() *string {
	if o == nil {
		return nil
	}
	return o.AzureBlobStorageEndpoint
}

func (o *SourceAzureBlobStorage) GetCredentials() SourceAzureBlobStorageAuthentication {
	if o == nil {
		return SourceAzureBlobStorageAuthentication{}
	}
	return o.Credentials
}

func (o *SourceAzureBlobStorage) GetStartDate() *time.Time {
	if o == nil {
		return nil
	}
	return o.StartDate
}

func (o *SourceAzureBlobStorage) GetStreams() []FileBasedStreamConfig {
	if o == nil {
		return []FileBasedStreamConfig{}
	}
	return o.Streams
}

func (o *SourceAzureBlobStorage) GetSourceType() AzureBlobStorage {
	return AzureBlobStorageAzureBlobStorage
}
