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

const (
	SourceGcsUpdateSchemasAuthTypeService SourceGcsUpdateSchemasAuthType = "Service"
)

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

type SourceGcsUpdateServiceAccountAuthentication struct {
	authType *SourceGcsUpdateSchemasAuthType `const:"Service" json:"auth_type"`
	// Enter your Google Cloud <a href="https://cloud.google.com/iam/docs/creating-managing-service-account-keys#creating_service_account_keys">service account key</a> in JSON format
	ServiceAccount string `json:"service_account"`
}

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

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

func (o *SourceGcsUpdateServiceAccountAuthentication) GetAuthType() *SourceGcsUpdateSchemasAuthType {
	return SourceGcsUpdateSchemasAuthTypeService.ToPointer()
}

func (o *SourceGcsUpdateServiceAccountAuthentication) GetServiceAccount() string {
	if o == nil {
		return ""
	}
	return o.ServiceAccount
}

type SourceGcsUpdateAuthType string

const (
	SourceGcsUpdateAuthTypeClient SourceGcsUpdateAuthType = "Client"
)

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

type SourceGcsUpdateAuthenticateViaGoogleOAuth struct {
	// Access Token
	AccessToken string                   `json:"access_token"`
	authType    *SourceGcsUpdateAuthType `const:"Client" json:"auth_type"`
	// Client ID
	ClientID string `json:"client_id"`
	// Client Secret
	ClientSecret string `json:"client_secret"`
	// Access Token
	RefreshToken string `json:"refresh_token"`
}

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

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

func (o *SourceGcsUpdateAuthenticateViaGoogleOAuth) GetAccessToken() string {
	if o == nil {
		return ""
	}
	return o.AccessToken
}

func (o *SourceGcsUpdateAuthenticateViaGoogleOAuth) GetAuthType() *SourceGcsUpdateAuthType {
	return SourceGcsUpdateAuthTypeClient.ToPointer()
}

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

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

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

type SourceGcsUpdateAuthenticationType string

const (
	SourceGcsUpdateAuthenticationTypeSourceGcsUpdateAuthenticateViaGoogleOAuth   SourceGcsUpdateAuthenticationType = "source-gcs-update_Authenticate via Google (OAuth)"
	SourceGcsUpdateAuthenticationTypeSourceGcsUpdateServiceAccountAuthentication SourceGcsUpdateAuthenticationType = "source-gcs-update_Service Account Authentication."
)

// SourceGcsUpdateAuthentication - Credentials for connecting to the Google Cloud Storage API
type SourceGcsUpdateAuthentication struct {
	SourceGcsUpdateAuthenticateViaGoogleOAuth   *SourceGcsUpdateAuthenticateViaGoogleOAuth   `queryParam:"inline"`
	SourceGcsUpdateServiceAccountAuthentication *SourceGcsUpdateServiceAccountAuthentication `queryParam:"inline"`

	Type SourceGcsUpdateAuthenticationType
}

func CreateSourceGcsUpdateAuthenticationSourceGcsUpdateAuthenticateViaGoogleOAuth(sourceGcsUpdateAuthenticateViaGoogleOAuth SourceGcsUpdateAuthenticateViaGoogleOAuth) SourceGcsUpdateAuthentication {
	typ := SourceGcsUpdateAuthenticationTypeSourceGcsUpdateAuthenticateViaGoogleOAuth

	return SourceGcsUpdateAuthentication{
		SourceGcsUpdateAuthenticateViaGoogleOAuth: &sourceGcsUpdateAuthenticateViaGoogleOAuth,
		Type: typ,
	}
}

func CreateSourceGcsUpdateAuthenticationSourceGcsUpdateServiceAccountAuthentication(sourceGcsUpdateServiceAccountAuthentication SourceGcsUpdateServiceAccountAuthentication) SourceGcsUpdateAuthentication {
	typ := SourceGcsUpdateAuthenticationTypeSourceGcsUpdateServiceAccountAuthentication

	return SourceGcsUpdateAuthentication{
		SourceGcsUpdateServiceAccountAuthentication: &sourceGcsUpdateServiceAccountAuthentication,
		Type: typ,
	}
}

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

	var sourceGcsUpdateServiceAccountAuthentication SourceGcsUpdateServiceAccountAuthentication = SourceGcsUpdateServiceAccountAuthentication{}
	if err := utils.UnmarshalJSON(data, &sourceGcsUpdateServiceAccountAuthentication, "", true, true); err == nil {
		u.SourceGcsUpdateServiceAccountAuthentication = &sourceGcsUpdateServiceAccountAuthentication
		u.Type = SourceGcsUpdateAuthenticationTypeSourceGcsUpdateServiceAccountAuthentication
		return nil
	}

	var sourceGcsUpdateAuthenticateViaGoogleOAuth SourceGcsUpdateAuthenticateViaGoogleOAuth = SourceGcsUpdateAuthenticateViaGoogleOAuth{}
	if err := utils.UnmarshalJSON(data, &sourceGcsUpdateAuthenticateViaGoogleOAuth, "", true, true); err == nil {
		u.SourceGcsUpdateAuthenticateViaGoogleOAuth = &sourceGcsUpdateAuthenticateViaGoogleOAuth
		u.Type = SourceGcsUpdateAuthenticationTypeSourceGcsUpdateAuthenticateViaGoogleOAuth
		return nil
	}

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

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

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

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

type SourceGcsUpdateSchemasStreamsFormatFormat6Filetype string

const (
	SourceGcsUpdateSchemasStreamsFormatFormat6FiletypeExcel SourceGcsUpdateSchemasStreamsFormatFormat6Filetype = "excel"
)

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

type SourceGcsUpdateExcelFormat struct {
	filetype *SourceGcsUpdateSchemasStreamsFormatFormat6Filetype `const:"excel" json:"filetype"`
}

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

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

func (o *SourceGcsUpdateExcelFormat) GetFiletype() *SourceGcsUpdateSchemasStreamsFormatFormat6Filetype {
	return SourceGcsUpdateSchemasStreamsFormatFormat6FiletypeExcel.ToPointer()
}

type SourceGcsUpdateSchemasStreamsFormatFormatFiletype string

const (
	SourceGcsUpdateSchemasStreamsFormatFormatFiletypeUnstructured SourceGcsUpdateSchemasStreamsFormatFormatFiletype = "unstructured"
)

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

type SourceGcsUpdateSchemasMode string

const (
	SourceGcsUpdateSchemasModeAPI SourceGcsUpdateSchemasMode = "api"
)

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

type SourceGcsUpdateAPIParameterConfigModel struct {
	// The name of the unstructured API parameter to use
	Name string `json:"name"`
	// The value of the parameter
	Value string `json:"value"`
}

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

func (o *SourceGcsUpdateAPIParameterConfigModel) GetValue() string {
	if o == nil {
		return ""
	}
	return o.Value
}

// SourceGcsUpdateViaAPI - Process files via an API, using the `hi_res` mode. This option is useful for increased performance and accuracy, but requires an API key and a hosted instance of unstructured.
type SourceGcsUpdateViaAPI struct {
	// The API key to use matching the environment
	APIKey *string `default:"" json:"api_key"`
	// The URL of the unstructured API to use
	APIURL *string                     `default:"https://api.unstructured.io" json:"api_url"`
	mode   *SourceGcsUpdateSchemasMode `const:"api" json:"mode"`
	// List of parameters send to the API
	Parameters []SourceGcsUpdateAPIParameterConfigModel `json:"parameters,omitempty"`
}

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

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

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

func (o *SourceGcsUpdateViaAPI) GetAPIURL() *string {
	if o == nil {
		return nil
	}
	return o.APIURL
}

func (o *SourceGcsUpdateViaAPI) GetMode() *SourceGcsUpdateSchemasMode {
	return SourceGcsUpdateSchemasModeAPI.ToPointer()
}

func (o *SourceGcsUpdateViaAPI) GetParameters() []SourceGcsUpdateAPIParameterConfigModel {
	if o == nil {
		return nil
	}
	return o.Parameters
}

type SourceGcsUpdateMode string

const (
	SourceGcsUpdateModeLocal SourceGcsUpdateMode = "local"
)

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

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

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

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

func (o *SourceGcsUpdateLocal) GetMode() *SourceGcsUpdateMode {
	return SourceGcsUpdateModeLocal.ToPointer()
}

type SourceGcsUpdateProcessingType string

const (
	SourceGcsUpdateProcessingTypeSourceGcsUpdateLocal  SourceGcsUpdateProcessingType = "source-gcs-update_Local"
	SourceGcsUpdateProcessingTypeSourceGcsUpdateViaAPI SourceGcsUpdateProcessingType = "source-gcs-update_via API"
)

// SourceGcsUpdateProcessing - Processing configuration
type SourceGcsUpdateProcessing struct {
	SourceGcsUpdateLocal  *SourceGcsUpdateLocal  `queryParam:"inline"`
	SourceGcsUpdateViaAPI *SourceGcsUpdateViaAPI `queryParam:"inline"`

	Type SourceGcsUpdateProcessingType
}

func CreateSourceGcsUpdateProcessingSourceGcsUpdateLocal(sourceGcsUpdateLocal SourceGcsUpdateLocal) SourceGcsUpdateProcessing {
	typ := SourceGcsUpdateProcessingTypeSourceGcsUpdateLocal

	return SourceGcsUpdateProcessing{
		SourceGcsUpdateLocal: &sourceGcsUpdateLocal,
		Type:                 typ,
	}
}

func CreateSourceGcsUpdateProcessingSourceGcsUpdateViaAPI(sourceGcsUpdateViaAPI SourceGcsUpdateViaAPI) SourceGcsUpdateProcessing {
	typ := SourceGcsUpdateProcessingTypeSourceGcsUpdateViaAPI

	return SourceGcsUpdateProcessing{
		SourceGcsUpdateViaAPI: &sourceGcsUpdateViaAPI,
		Type:                  typ,
	}
}

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

	var sourceGcsUpdateLocal SourceGcsUpdateLocal = SourceGcsUpdateLocal{}
	if err := utils.UnmarshalJSON(data, &sourceGcsUpdateLocal, "", true, true); err == nil {
		u.SourceGcsUpdateLocal = &sourceGcsUpdateLocal
		u.Type = SourceGcsUpdateProcessingTypeSourceGcsUpdateLocal
		return nil
	}

	var sourceGcsUpdateViaAPI SourceGcsUpdateViaAPI = SourceGcsUpdateViaAPI{}
	if err := utils.UnmarshalJSON(data, &sourceGcsUpdateViaAPI, "", true, true); err == nil {
		u.SourceGcsUpdateViaAPI = &sourceGcsUpdateViaAPI
		u.Type = SourceGcsUpdateProcessingTypeSourceGcsUpdateViaAPI
		return nil
	}

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

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

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

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

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

const (
	SourceGcsUpdateParsingStrategyAuto    SourceGcsUpdateParsingStrategy = "auto"
	SourceGcsUpdateParsingStrategyFast    SourceGcsUpdateParsingStrategy = "fast"
	SourceGcsUpdateParsingStrategyOcrOnly SourceGcsUpdateParsingStrategy = "ocr_only"
	SourceGcsUpdateParsingStrategyHiRes   SourceGcsUpdateParsingStrategy = "hi_res"
)

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

// SourceGcsUpdateUnstructuredDocumentFormat - Extract text from document formats (.pdf, .docx, .md, .pptx) and emit as one record per file.
type SourceGcsUpdateUnstructuredDocumentFormat struct {
	filetype *SourceGcsUpdateSchemasStreamsFormatFormatFiletype `const:"unstructured" json:"filetype"`
	// Processing configuration
	Processing *SourceGcsUpdateProcessing `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 *SourceGcsUpdateParsingStrategy `default:"auto" json:"strategy"`
}

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

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

func (o *SourceGcsUpdateUnstructuredDocumentFormat) GetFiletype() *SourceGcsUpdateSchemasStreamsFormatFormatFiletype {
	return SourceGcsUpdateSchemasStreamsFormatFormatFiletypeUnstructured.ToPointer()
}

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

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

func (o *SourceGcsUpdateUnstructuredDocumentFormat) GetStrategy() *SourceGcsUpdateParsingStrategy {
	if o == nil {
		return nil
	}
	return o.Strategy
}

type SourceGcsUpdateSchemasStreamsFormatFiletype string

const (
	SourceGcsUpdateSchemasStreamsFormatFiletypeParquet SourceGcsUpdateSchemasStreamsFormatFiletype = "parquet"
)

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

type SourceGcsUpdateParquetFormat 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       *SourceGcsUpdateSchemasStreamsFormatFiletype `const:"parquet" json:"filetype"`
}

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

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

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

func (o *SourceGcsUpdateParquetFormat) GetFiletype() *SourceGcsUpdateSchemasStreamsFormatFiletype {
	return SourceGcsUpdateSchemasStreamsFormatFiletypeParquet.ToPointer()
}

type SourceGcsUpdateSchemasStreamsFiletype string

const (
	SourceGcsUpdateSchemasStreamsFiletypeJsonl SourceGcsUpdateSchemasStreamsFiletype = "jsonl"
)

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

type SourceGcsUpdateJsonlFormat struct {
	filetype *SourceGcsUpdateSchemasStreamsFiletype `const:"jsonl" json:"filetype"`
}

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

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

func (o *SourceGcsUpdateJsonlFormat) GetFiletype() *SourceGcsUpdateSchemasStreamsFiletype {
	return SourceGcsUpdateSchemasStreamsFiletypeJsonl.ToPointer()
}

type SourceGcsUpdateSchemasFiletype string

const (
	SourceGcsUpdateSchemasFiletypeCsv SourceGcsUpdateSchemasFiletype = "csv"
)

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

type SourceGcsUpdateSchemasStreamsHeaderDefinitionType string

const (
	SourceGcsUpdateSchemasStreamsHeaderDefinitionTypeUserProvided SourceGcsUpdateSchemasStreamsHeaderDefinitionType = "User Provided"
)

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

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

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

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

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

func (o *SourceGcsUpdateUserProvided) GetHeaderDefinitionType() *SourceGcsUpdateSchemasStreamsHeaderDefinitionType {
	return SourceGcsUpdateSchemasStreamsHeaderDefinitionTypeUserProvided.ToPointer()
}

type SourceGcsUpdateSchemasHeaderDefinitionType string

const (
	SourceGcsUpdateSchemasHeaderDefinitionTypeAutogenerated SourceGcsUpdateSchemasHeaderDefinitionType = "Autogenerated"
)

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

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

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

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

func (o *SourceGcsUpdateAutogenerated) GetHeaderDefinitionType() *SourceGcsUpdateSchemasHeaderDefinitionType {
	return SourceGcsUpdateSchemasHeaderDefinitionTypeAutogenerated.ToPointer()
}

type SourceGcsUpdateHeaderDefinitionType string

const (
	SourceGcsUpdateHeaderDefinitionTypeFromCsv SourceGcsUpdateHeaderDefinitionType = "From CSV"
)

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

type SourceGcsUpdateFromCSV struct {
	headerDefinitionType *SourceGcsUpdateHeaderDefinitionType `const:"From CSV" json:"header_definition_type"`
}

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

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

func (o *SourceGcsUpdateFromCSV) GetHeaderDefinitionType() *SourceGcsUpdateHeaderDefinitionType {
	return SourceGcsUpdateHeaderDefinitionTypeFromCsv.ToPointer()
}

type SourceGcsUpdateCSVHeaderDefinitionType string

const (
	SourceGcsUpdateCSVHeaderDefinitionTypeSourceGcsUpdateFromCSV       SourceGcsUpdateCSVHeaderDefinitionType = "source-gcs-update_From CSV"
	SourceGcsUpdateCSVHeaderDefinitionTypeSourceGcsUpdateAutogenerated SourceGcsUpdateCSVHeaderDefinitionType = "source-gcs-update_Autogenerated"
	SourceGcsUpdateCSVHeaderDefinitionTypeSourceGcsUpdateUserProvided  SourceGcsUpdateCSVHeaderDefinitionType = "source-gcs-update_User Provided"
)

// SourceGcsUpdateCSVHeaderDefinition - 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 SourceGcsUpdateCSVHeaderDefinition struct {
	SourceGcsUpdateFromCSV       *SourceGcsUpdateFromCSV       `queryParam:"inline"`
	SourceGcsUpdateAutogenerated *SourceGcsUpdateAutogenerated `queryParam:"inline"`
	SourceGcsUpdateUserProvided  *SourceGcsUpdateUserProvided  `queryParam:"inline"`

	Type SourceGcsUpdateCSVHeaderDefinitionType
}

func CreateSourceGcsUpdateCSVHeaderDefinitionSourceGcsUpdateFromCSV(sourceGcsUpdateFromCSV SourceGcsUpdateFromCSV) SourceGcsUpdateCSVHeaderDefinition {
	typ := SourceGcsUpdateCSVHeaderDefinitionTypeSourceGcsUpdateFromCSV

	return SourceGcsUpdateCSVHeaderDefinition{
		SourceGcsUpdateFromCSV: &sourceGcsUpdateFromCSV,
		Type:                   typ,
	}
}

func CreateSourceGcsUpdateCSVHeaderDefinitionSourceGcsUpdateAutogenerated(sourceGcsUpdateAutogenerated SourceGcsUpdateAutogenerated) SourceGcsUpdateCSVHeaderDefinition {
	typ := SourceGcsUpdateCSVHeaderDefinitionTypeSourceGcsUpdateAutogenerated

	return SourceGcsUpdateCSVHeaderDefinition{
		SourceGcsUpdateAutogenerated: &sourceGcsUpdateAutogenerated,
		Type:                         typ,
	}
}

func CreateSourceGcsUpdateCSVHeaderDefinitionSourceGcsUpdateUserProvided(sourceGcsUpdateUserProvided SourceGcsUpdateUserProvided) SourceGcsUpdateCSVHeaderDefinition {
	typ := SourceGcsUpdateCSVHeaderDefinitionTypeSourceGcsUpdateUserProvided

	return SourceGcsUpdateCSVHeaderDefinition{
		SourceGcsUpdateUserProvided: &sourceGcsUpdateUserProvided,
		Type:                        typ,
	}
}

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

	var sourceGcsUpdateFromCSV SourceGcsUpdateFromCSV = SourceGcsUpdateFromCSV{}
	if err := utils.UnmarshalJSON(data, &sourceGcsUpdateFromCSV, "", true, true); err == nil {
		u.SourceGcsUpdateFromCSV = &sourceGcsUpdateFromCSV
		u.Type = SourceGcsUpdateCSVHeaderDefinitionTypeSourceGcsUpdateFromCSV
		return nil
	}

	var sourceGcsUpdateAutogenerated SourceGcsUpdateAutogenerated = SourceGcsUpdateAutogenerated{}
	if err := utils.UnmarshalJSON(data, &sourceGcsUpdateAutogenerated, "", true, true); err == nil {
		u.SourceGcsUpdateAutogenerated = &sourceGcsUpdateAutogenerated
		u.Type = SourceGcsUpdateCSVHeaderDefinitionTypeSourceGcsUpdateAutogenerated
		return nil
	}

	var sourceGcsUpdateUserProvided SourceGcsUpdateUserProvided = SourceGcsUpdateUserProvided{}
	if err := utils.UnmarshalJSON(data, &sourceGcsUpdateUserProvided, "", true, true); err == nil {
		u.SourceGcsUpdateUserProvided = &sourceGcsUpdateUserProvided
		u.Type = SourceGcsUpdateCSVHeaderDefinitionTypeSourceGcsUpdateUserProvided
		return nil
	}

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

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

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

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

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

type SourceGcsUpdateCSVFormat 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    *SourceGcsUpdateSchemasFiletype `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 *SourceGcsUpdateCSVHeaderDefinition `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 (s SourceGcsUpdateCSVFormat) MarshalJSON() ([]byte, error) {
	return utils.MarshalJSON(s, "", false)
}

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

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

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

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

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

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

func (o *SourceGcsUpdateCSVFormat) GetFiletype() *SourceGcsUpdateSchemasFiletype {
	return SourceGcsUpdateSchemasFiletypeCsv.ToPointer()
}

func (o *SourceGcsUpdateCSVFormat) GetHeaderDefinition() *SourceGcsUpdateCSVHeaderDefinition {
	if o == nil {
		return nil
	}
	return o.HeaderDefinition
}

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

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

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

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

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

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

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

type SourceGcsUpdateFiletype string

const (
	SourceGcsUpdateFiletypeAvro SourceGcsUpdateFiletype = "avro"
)

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

type SourceGcsUpdateAvroFormat 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       *SourceGcsUpdateFiletype `const:"avro" json:"filetype"`
}

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

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

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

func (o *SourceGcsUpdateAvroFormat) GetFiletype() *SourceGcsUpdateFiletype {
	return SourceGcsUpdateFiletypeAvro.ToPointer()
}

type SourceGcsUpdateFormatType string

const (
	SourceGcsUpdateFormatTypeSourceGcsUpdateAvroFormat                 SourceGcsUpdateFormatType = "source-gcs-update_Avro Format"
	SourceGcsUpdateFormatTypeSourceGcsUpdateCSVFormat                  SourceGcsUpdateFormatType = "source-gcs-update_CSV Format"
	SourceGcsUpdateFormatTypeSourceGcsUpdateJsonlFormat                SourceGcsUpdateFormatType = "source-gcs-update_Jsonl Format"
	SourceGcsUpdateFormatTypeSourceGcsUpdateParquetFormat              SourceGcsUpdateFormatType = "source-gcs-update_Parquet Format"
	SourceGcsUpdateFormatTypeSourceGcsUpdateUnstructuredDocumentFormat SourceGcsUpdateFormatType = "source-gcs-update_Unstructured Document Format"
	SourceGcsUpdateFormatTypeSourceGcsUpdateExcelFormat                SourceGcsUpdateFormatType = "source-gcs-update_Excel Format"
)

// SourceGcsUpdateFormat - The configuration options that are used to alter how to read incoming files that deviate from the standard formatting.
type SourceGcsUpdateFormat struct {
	SourceGcsUpdateAvroFormat                 *SourceGcsUpdateAvroFormat                 `queryParam:"inline"`
	SourceGcsUpdateCSVFormat                  *SourceGcsUpdateCSVFormat                  `queryParam:"inline"`
	SourceGcsUpdateJsonlFormat                *SourceGcsUpdateJsonlFormat                `queryParam:"inline"`
	SourceGcsUpdateParquetFormat              *SourceGcsUpdateParquetFormat              `queryParam:"inline"`
	SourceGcsUpdateUnstructuredDocumentFormat *SourceGcsUpdateUnstructuredDocumentFormat `queryParam:"inline"`
	SourceGcsUpdateExcelFormat                *SourceGcsUpdateExcelFormat                `queryParam:"inline"`

	Type SourceGcsUpdateFormatType
}

func CreateSourceGcsUpdateFormatSourceGcsUpdateAvroFormat(sourceGcsUpdateAvroFormat SourceGcsUpdateAvroFormat) SourceGcsUpdateFormat {
	typ := SourceGcsUpdateFormatTypeSourceGcsUpdateAvroFormat

	return SourceGcsUpdateFormat{
		SourceGcsUpdateAvroFormat: &sourceGcsUpdateAvroFormat,
		Type:                      typ,
	}
}

func CreateSourceGcsUpdateFormatSourceGcsUpdateCSVFormat(sourceGcsUpdateCSVFormat SourceGcsUpdateCSVFormat) SourceGcsUpdateFormat {
	typ := SourceGcsUpdateFormatTypeSourceGcsUpdateCSVFormat

	return SourceGcsUpdateFormat{
		SourceGcsUpdateCSVFormat: &sourceGcsUpdateCSVFormat,
		Type:                     typ,
	}
}

func CreateSourceGcsUpdateFormatSourceGcsUpdateJsonlFormat(sourceGcsUpdateJsonlFormat SourceGcsUpdateJsonlFormat) SourceGcsUpdateFormat {
	typ := SourceGcsUpdateFormatTypeSourceGcsUpdateJsonlFormat

	return SourceGcsUpdateFormat{
		SourceGcsUpdateJsonlFormat: &sourceGcsUpdateJsonlFormat,
		Type:                       typ,
	}
}

func CreateSourceGcsUpdateFormatSourceGcsUpdateParquetFormat(sourceGcsUpdateParquetFormat SourceGcsUpdateParquetFormat) SourceGcsUpdateFormat {
	typ := SourceGcsUpdateFormatTypeSourceGcsUpdateParquetFormat

	return SourceGcsUpdateFormat{
		SourceGcsUpdateParquetFormat: &sourceGcsUpdateParquetFormat,
		Type:                         typ,
	}
}

func CreateSourceGcsUpdateFormatSourceGcsUpdateUnstructuredDocumentFormat(sourceGcsUpdateUnstructuredDocumentFormat SourceGcsUpdateUnstructuredDocumentFormat) SourceGcsUpdateFormat {
	typ := SourceGcsUpdateFormatTypeSourceGcsUpdateUnstructuredDocumentFormat

	return SourceGcsUpdateFormat{
		SourceGcsUpdateUnstructuredDocumentFormat: &sourceGcsUpdateUnstructuredDocumentFormat,
		Type: typ,
	}
}

func CreateSourceGcsUpdateFormatSourceGcsUpdateExcelFormat(sourceGcsUpdateExcelFormat SourceGcsUpdateExcelFormat) SourceGcsUpdateFormat {
	typ := SourceGcsUpdateFormatTypeSourceGcsUpdateExcelFormat

	return SourceGcsUpdateFormat{
		SourceGcsUpdateExcelFormat: &sourceGcsUpdateExcelFormat,
		Type:                       typ,
	}
}

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

	var sourceGcsUpdateJsonlFormat SourceGcsUpdateJsonlFormat = SourceGcsUpdateJsonlFormat{}
	if err := utils.UnmarshalJSON(data, &sourceGcsUpdateJsonlFormat, "", true, true); err == nil {
		u.SourceGcsUpdateJsonlFormat = &sourceGcsUpdateJsonlFormat
		u.Type = SourceGcsUpdateFormatTypeSourceGcsUpdateJsonlFormat
		return nil
	}

	var sourceGcsUpdateExcelFormat SourceGcsUpdateExcelFormat = SourceGcsUpdateExcelFormat{}
	if err := utils.UnmarshalJSON(data, &sourceGcsUpdateExcelFormat, "", true, true); err == nil {
		u.SourceGcsUpdateExcelFormat = &sourceGcsUpdateExcelFormat
		u.Type = SourceGcsUpdateFormatTypeSourceGcsUpdateExcelFormat
		return nil
	}

	var sourceGcsUpdateAvroFormat SourceGcsUpdateAvroFormat = SourceGcsUpdateAvroFormat{}
	if err := utils.UnmarshalJSON(data, &sourceGcsUpdateAvroFormat, "", true, true); err == nil {
		u.SourceGcsUpdateAvroFormat = &sourceGcsUpdateAvroFormat
		u.Type = SourceGcsUpdateFormatTypeSourceGcsUpdateAvroFormat
		return nil
	}

	var sourceGcsUpdateParquetFormat SourceGcsUpdateParquetFormat = SourceGcsUpdateParquetFormat{}
	if err := utils.UnmarshalJSON(data, &sourceGcsUpdateParquetFormat, "", true, true); err == nil {
		u.SourceGcsUpdateParquetFormat = &sourceGcsUpdateParquetFormat
		u.Type = SourceGcsUpdateFormatTypeSourceGcsUpdateParquetFormat
		return nil
	}

	var sourceGcsUpdateUnstructuredDocumentFormat SourceGcsUpdateUnstructuredDocumentFormat = SourceGcsUpdateUnstructuredDocumentFormat{}
	if err := utils.UnmarshalJSON(data, &sourceGcsUpdateUnstructuredDocumentFormat, "", true, true); err == nil {
		u.SourceGcsUpdateUnstructuredDocumentFormat = &sourceGcsUpdateUnstructuredDocumentFormat
		u.Type = SourceGcsUpdateFormatTypeSourceGcsUpdateUnstructuredDocumentFormat
		return nil
	}

	var sourceGcsUpdateCSVFormat SourceGcsUpdateCSVFormat = SourceGcsUpdateCSVFormat{}
	if err := utils.UnmarshalJSON(data, &sourceGcsUpdateCSVFormat, "", true, true); err == nil {
		u.SourceGcsUpdateCSVFormat = &sourceGcsUpdateCSVFormat
		u.Type = SourceGcsUpdateFormatTypeSourceGcsUpdateCSVFormat
		return nil
	}

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

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

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

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

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

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

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

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

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

const (
	SourceGcsUpdateValidationPolicyEmitRecord      SourceGcsUpdateValidationPolicy = "Emit Record"
	SourceGcsUpdateValidationPolicySkipRecord      SourceGcsUpdateValidationPolicy = "Skip Record"
	SourceGcsUpdateValidationPolicyWaitForDiscover SourceGcsUpdateValidationPolicy = "Wait for Discover"
)

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

type SourceGcsUpdateFileBasedStreamConfig 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 SourceGcsUpdateFormat `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 *SourceGcsUpdateValidationPolicy `default:"Emit Record" json:"validation_policy"`
}

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

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

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

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

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

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

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

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

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

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

// SourceGcsUpdate - 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 GCS configs into file based configs using the File-Based CDK.
type SourceGcsUpdate struct {
	// Name of the GCS bucket where the file(s) exist.
	Bucket string `json:"bucket"`
	// Credentials for connecting to the Google Cloud Storage API
	Credentials SourceGcsUpdateAuthentication `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 []SourceGcsUpdateFileBasedStreamConfig `json:"streams"`
}

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

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

func (o *SourceGcsUpdate) GetBucket() string {
	if o == nil {
		return ""
	}
	return o.Bucket
}

func (o *SourceGcsUpdate) GetCredentials() SourceGcsUpdateAuthentication {
	if o == nil {
		return SourceGcsUpdateAuthentication{}
	}
	return o.Credentials
}

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

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