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

const (
	SourceMicrosoftOnedriveUpdateSchemasAuthTypeService SourceMicrosoftOnedriveUpdateSchemasAuthType = "Service"
)

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

// SourceMicrosoftOnedriveUpdateServiceKeyAuthentication - ServiceCredentials class for service key authentication.
// This class is structured similarly to OAuthCredentials but for a different authentication method.
type SourceMicrosoftOnedriveUpdateServiceKeyAuthentication struct {
	authType *SourceMicrosoftOnedriveUpdateSchemasAuthType `const:"Service" 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"`
	// Tenant ID of the Microsoft OneDrive user
	TenantID string `json:"tenant_id"`
	// Special characters such as a period, comma, space, and the at sign (@) are converted to underscores (_). More details: https://learn.microsoft.com/en-us/sharepoint/list-onedrive-urls
	UserPrincipalName string `json:"user_principal_name"`
}

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

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

func (o *SourceMicrosoftOnedriveUpdateServiceKeyAuthentication) GetAuthType() *SourceMicrosoftOnedriveUpdateSchemasAuthType {
	return SourceMicrosoftOnedriveUpdateSchemasAuthTypeService.ToPointer()
}

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

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

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

func (o *SourceMicrosoftOnedriveUpdateServiceKeyAuthentication) GetUserPrincipalName() string {
	if o == nil {
		return ""
	}
	return o.UserPrincipalName
}

type SourceMicrosoftOnedriveUpdateAuthType string

const (
	SourceMicrosoftOnedriveUpdateAuthTypeClient SourceMicrosoftOnedriveUpdateAuthType = "Client"
)

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

// SourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth - OAuthCredentials class to hold authentication details for Microsoft OAuth authentication.
// This class uses pydantic for data validation and settings management.
type SourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth struct {
	authType *SourceMicrosoftOnedriveUpdateAuthType `const:"Client" 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 OneDrive user
	TenantID string `json:"tenant_id"`
}

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

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

func (o *SourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth) GetAuthType() *SourceMicrosoftOnedriveUpdateAuthType {
	return SourceMicrosoftOnedriveUpdateAuthTypeClient.ToPointer()
}

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

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

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

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

type SourceMicrosoftOnedriveUpdateAuthenticationType string

const (
	SourceMicrosoftOnedriveUpdateAuthenticationTypeSourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth SourceMicrosoftOnedriveUpdateAuthenticationType = "source-microsoft-onedrive-update_Authenticate via Microsoft (OAuth)"
	SourceMicrosoftOnedriveUpdateAuthenticationTypeSourceMicrosoftOnedriveUpdateServiceKeyAuthentication      SourceMicrosoftOnedriveUpdateAuthenticationType = "source-microsoft-onedrive-update_Service Key Authentication"
)

// SourceMicrosoftOnedriveUpdateAuthentication - Credentials for connecting to the One Drive API
type SourceMicrosoftOnedriveUpdateAuthentication struct {
	SourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth *SourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth `queryParam:"inline"`
	SourceMicrosoftOnedriveUpdateServiceKeyAuthentication      *SourceMicrosoftOnedriveUpdateServiceKeyAuthentication      `queryParam:"inline"`

	Type SourceMicrosoftOnedriveUpdateAuthenticationType
}

func CreateSourceMicrosoftOnedriveUpdateAuthenticationSourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth(sourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth SourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth) SourceMicrosoftOnedriveUpdateAuthentication {
	typ := SourceMicrosoftOnedriveUpdateAuthenticationTypeSourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth

	return SourceMicrosoftOnedriveUpdateAuthentication{
		SourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth: &sourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth,
		Type: typ,
	}
}

func CreateSourceMicrosoftOnedriveUpdateAuthenticationSourceMicrosoftOnedriveUpdateServiceKeyAuthentication(sourceMicrosoftOnedriveUpdateServiceKeyAuthentication SourceMicrosoftOnedriveUpdateServiceKeyAuthentication) SourceMicrosoftOnedriveUpdateAuthentication {
	typ := SourceMicrosoftOnedriveUpdateAuthenticationTypeSourceMicrosoftOnedriveUpdateServiceKeyAuthentication

	return SourceMicrosoftOnedriveUpdateAuthentication{
		SourceMicrosoftOnedriveUpdateServiceKeyAuthentication: &sourceMicrosoftOnedriveUpdateServiceKeyAuthentication,
		Type: typ,
	}
}

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

	var sourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth SourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth = SourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth, "", true, true); err == nil {
		u.SourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth = &sourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth
		u.Type = SourceMicrosoftOnedriveUpdateAuthenticationTypeSourceMicrosoftOnedriveUpdateAuthenticateViaMicrosoftOAuth
		return nil
	}

	var sourceMicrosoftOnedriveUpdateServiceKeyAuthentication SourceMicrosoftOnedriveUpdateServiceKeyAuthentication = SourceMicrosoftOnedriveUpdateServiceKeyAuthentication{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftOnedriveUpdateServiceKeyAuthentication, "", true, true); err == nil {
		u.SourceMicrosoftOnedriveUpdateServiceKeyAuthentication = &sourceMicrosoftOnedriveUpdateServiceKeyAuthentication
		u.Type = SourceMicrosoftOnedriveUpdateAuthenticationTypeSourceMicrosoftOnedriveUpdateServiceKeyAuthentication
		return nil
	}

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

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

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

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

// SourceMicrosoftOnedriveUpdateSearchScope - Specifies the location(s) to search for files. Valid options are 'ACCESSIBLE_DRIVES' to search in the selected OneDrive drive, 'SHARED_ITEMS' for shared items the user has access to, and 'ALL' to search both.
type SourceMicrosoftOnedriveUpdateSearchScope string

const (
	SourceMicrosoftOnedriveUpdateSearchScopeAccessibleDrives SourceMicrosoftOnedriveUpdateSearchScope = "ACCESSIBLE_DRIVES"
	SourceMicrosoftOnedriveUpdateSearchScopeSharedItems      SourceMicrosoftOnedriveUpdateSearchScope = "SHARED_ITEMS"
	SourceMicrosoftOnedriveUpdateSearchScopeAll              SourceMicrosoftOnedriveUpdateSearchScope = "ALL"
)

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

type SourceMicrosoftOnedriveUpdateSchemasStreamsFormatFormatFiletype string

const (
	SourceMicrosoftOnedriveUpdateSchemasStreamsFormatFormatFiletypeUnstructured SourceMicrosoftOnedriveUpdateSchemasStreamsFormatFormatFiletype = "unstructured"
)

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

type SourceMicrosoftOnedriveUpdateMode string

const (
	SourceMicrosoftOnedriveUpdateModeLocal SourceMicrosoftOnedriveUpdateMode = "local"
)

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

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

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

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

func (o *SourceMicrosoftOnedriveUpdateLocal) GetMode() *SourceMicrosoftOnedriveUpdateMode {
	return SourceMicrosoftOnedriveUpdateModeLocal.ToPointer()
}

type SourceMicrosoftOnedriveUpdateProcessingType string

const (
	SourceMicrosoftOnedriveUpdateProcessingTypeSourceMicrosoftOnedriveUpdateLocal SourceMicrosoftOnedriveUpdateProcessingType = "source-microsoft-onedrive-update_Local"
)

// SourceMicrosoftOnedriveUpdateProcessing - Processing configuration
type SourceMicrosoftOnedriveUpdateProcessing struct {
	SourceMicrosoftOnedriveUpdateLocal *SourceMicrosoftOnedriveUpdateLocal `queryParam:"inline"`

	Type SourceMicrosoftOnedriveUpdateProcessingType
}

func CreateSourceMicrosoftOnedriveUpdateProcessingSourceMicrosoftOnedriveUpdateLocal(sourceMicrosoftOnedriveUpdateLocal SourceMicrosoftOnedriveUpdateLocal) SourceMicrosoftOnedriveUpdateProcessing {
	typ := SourceMicrosoftOnedriveUpdateProcessingTypeSourceMicrosoftOnedriveUpdateLocal

	return SourceMicrosoftOnedriveUpdateProcessing{
		SourceMicrosoftOnedriveUpdateLocal: &sourceMicrosoftOnedriveUpdateLocal,
		Type:                               typ,
	}
}

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

	var sourceMicrosoftOnedriveUpdateLocal SourceMicrosoftOnedriveUpdateLocal = SourceMicrosoftOnedriveUpdateLocal{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftOnedriveUpdateLocal, "", true, true); err == nil {
		u.SourceMicrosoftOnedriveUpdateLocal = &sourceMicrosoftOnedriveUpdateLocal
		u.Type = SourceMicrosoftOnedriveUpdateProcessingTypeSourceMicrosoftOnedriveUpdateLocal
		return nil
	}

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

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

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

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

const (
	SourceMicrosoftOnedriveUpdateParsingStrategyAuto    SourceMicrosoftOnedriveUpdateParsingStrategy = "auto"
	SourceMicrosoftOnedriveUpdateParsingStrategyFast    SourceMicrosoftOnedriveUpdateParsingStrategy = "fast"
	SourceMicrosoftOnedriveUpdateParsingStrategyOcrOnly SourceMicrosoftOnedriveUpdateParsingStrategy = "ocr_only"
	SourceMicrosoftOnedriveUpdateParsingStrategyHiRes   SourceMicrosoftOnedriveUpdateParsingStrategy = "hi_res"
)

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

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

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

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

func (o *SourceMicrosoftOnedriveUpdateUnstructuredDocumentFormat) GetFiletype() *SourceMicrosoftOnedriveUpdateSchemasStreamsFormatFormatFiletype {
	return SourceMicrosoftOnedriveUpdateSchemasStreamsFormatFormatFiletypeUnstructured.ToPointer()
}

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

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

func (o *SourceMicrosoftOnedriveUpdateUnstructuredDocumentFormat) GetStrategy() *SourceMicrosoftOnedriveUpdateParsingStrategy {
	if o == nil {
		return nil
	}
	return o.Strategy
}

type SourceMicrosoftOnedriveUpdateSchemasStreamsFormatFiletype string

const (
	SourceMicrosoftOnedriveUpdateSchemasStreamsFormatFiletypeParquet SourceMicrosoftOnedriveUpdateSchemasStreamsFormatFiletype = "parquet"
)

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

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

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

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

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

func (o *SourceMicrosoftOnedriveUpdateParquetFormat) GetFiletype() *SourceMicrosoftOnedriveUpdateSchemasStreamsFormatFiletype {
	return SourceMicrosoftOnedriveUpdateSchemasStreamsFormatFiletypeParquet.ToPointer()
}

type SourceMicrosoftOnedriveUpdateSchemasStreamsFiletype string

const (
	SourceMicrosoftOnedriveUpdateSchemasStreamsFiletypeJsonl SourceMicrosoftOnedriveUpdateSchemasStreamsFiletype = "jsonl"
)

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

type SourceMicrosoftOnedriveUpdateJsonlFormat struct {
	filetype *SourceMicrosoftOnedriveUpdateSchemasStreamsFiletype `const:"jsonl" json:"filetype"`
}

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

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

func (o *SourceMicrosoftOnedriveUpdateJsonlFormat) GetFiletype() *SourceMicrosoftOnedriveUpdateSchemasStreamsFiletype {
	return SourceMicrosoftOnedriveUpdateSchemasStreamsFiletypeJsonl.ToPointer()
}

type SourceMicrosoftOnedriveUpdateSchemasFiletype string

const (
	SourceMicrosoftOnedriveUpdateSchemasFiletypeCsv SourceMicrosoftOnedriveUpdateSchemasFiletype = "csv"
)

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

type SourceMicrosoftOnedriveUpdateSchemasStreamsHeaderDefinitionType string

const (
	SourceMicrosoftOnedriveUpdateSchemasStreamsHeaderDefinitionTypeUserProvided SourceMicrosoftOnedriveUpdateSchemasStreamsHeaderDefinitionType = "User Provided"
)

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

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

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

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

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

func (o *SourceMicrosoftOnedriveUpdateUserProvided) GetHeaderDefinitionType() *SourceMicrosoftOnedriveUpdateSchemasStreamsHeaderDefinitionType {
	return SourceMicrosoftOnedriveUpdateSchemasStreamsHeaderDefinitionTypeUserProvided.ToPointer()
}

type SourceMicrosoftOnedriveUpdateSchemasHeaderDefinitionType string

const (
	SourceMicrosoftOnedriveUpdateSchemasHeaderDefinitionTypeAutogenerated SourceMicrosoftOnedriveUpdateSchemasHeaderDefinitionType = "Autogenerated"
)

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

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

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

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

func (o *SourceMicrosoftOnedriveUpdateAutogenerated) GetHeaderDefinitionType() *SourceMicrosoftOnedriveUpdateSchemasHeaderDefinitionType {
	return SourceMicrosoftOnedriveUpdateSchemasHeaderDefinitionTypeAutogenerated.ToPointer()
}

type SourceMicrosoftOnedriveUpdateHeaderDefinitionType string

const (
	SourceMicrosoftOnedriveUpdateHeaderDefinitionTypeFromCsv SourceMicrosoftOnedriveUpdateHeaderDefinitionType = "From CSV"
)

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

type SourceMicrosoftOnedriveUpdateFromCSV struct {
	headerDefinitionType *SourceMicrosoftOnedriveUpdateHeaderDefinitionType `const:"From CSV" json:"header_definition_type"`
}

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

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

func (o *SourceMicrosoftOnedriveUpdateFromCSV) GetHeaderDefinitionType() *SourceMicrosoftOnedriveUpdateHeaderDefinitionType {
	return SourceMicrosoftOnedriveUpdateHeaderDefinitionTypeFromCsv.ToPointer()
}

type SourceMicrosoftOnedriveUpdateCSVHeaderDefinitionType string

const (
	SourceMicrosoftOnedriveUpdateCSVHeaderDefinitionTypeSourceMicrosoftOnedriveUpdateFromCSV       SourceMicrosoftOnedriveUpdateCSVHeaderDefinitionType = "source-microsoft-onedrive-update_From CSV"
	SourceMicrosoftOnedriveUpdateCSVHeaderDefinitionTypeSourceMicrosoftOnedriveUpdateAutogenerated SourceMicrosoftOnedriveUpdateCSVHeaderDefinitionType = "source-microsoft-onedrive-update_Autogenerated"
	SourceMicrosoftOnedriveUpdateCSVHeaderDefinitionTypeSourceMicrosoftOnedriveUpdateUserProvided  SourceMicrosoftOnedriveUpdateCSVHeaderDefinitionType = "source-microsoft-onedrive-update_User Provided"
)

// SourceMicrosoftOnedriveUpdateCSVHeaderDefinition - 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 SourceMicrosoftOnedriveUpdateCSVHeaderDefinition struct {
	SourceMicrosoftOnedriveUpdateFromCSV       *SourceMicrosoftOnedriveUpdateFromCSV       `queryParam:"inline"`
	SourceMicrosoftOnedriveUpdateAutogenerated *SourceMicrosoftOnedriveUpdateAutogenerated `queryParam:"inline"`
	SourceMicrosoftOnedriveUpdateUserProvided  *SourceMicrosoftOnedriveUpdateUserProvided  `queryParam:"inline"`

	Type SourceMicrosoftOnedriveUpdateCSVHeaderDefinitionType
}

func CreateSourceMicrosoftOnedriveUpdateCSVHeaderDefinitionSourceMicrosoftOnedriveUpdateFromCSV(sourceMicrosoftOnedriveUpdateFromCSV SourceMicrosoftOnedriveUpdateFromCSV) SourceMicrosoftOnedriveUpdateCSVHeaderDefinition {
	typ := SourceMicrosoftOnedriveUpdateCSVHeaderDefinitionTypeSourceMicrosoftOnedriveUpdateFromCSV

	return SourceMicrosoftOnedriveUpdateCSVHeaderDefinition{
		SourceMicrosoftOnedriveUpdateFromCSV: &sourceMicrosoftOnedriveUpdateFromCSV,
		Type:                                 typ,
	}
}

func CreateSourceMicrosoftOnedriveUpdateCSVHeaderDefinitionSourceMicrosoftOnedriveUpdateAutogenerated(sourceMicrosoftOnedriveUpdateAutogenerated SourceMicrosoftOnedriveUpdateAutogenerated) SourceMicrosoftOnedriveUpdateCSVHeaderDefinition {
	typ := SourceMicrosoftOnedriveUpdateCSVHeaderDefinitionTypeSourceMicrosoftOnedriveUpdateAutogenerated

	return SourceMicrosoftOnedriveUpdateCSVHeaderDefinition{
		SourceMicrosoftOnedriveUpdateAutogenerated: &sourceMicrosoftOnedriveUpdateAutogenerated,
		Type: typ,
	}
}

func CreateSourceMicrosoftOnedriveUpdateCSVHeaderDefinitionSourceMicrosoftOnedriveUpdateUserProvided(sourceMicrosoftOnedriveUpdateUserProvided SourceMicrosoftOnedriveUpdateUserProvided) SourceMicrosoftOnedriveUpdateCSVHeaderDefinition {
	typ := SourceMicrosoftOnedriveUpdateCSVHeaderDefinitionTypeSourceMicrosoftOnedriveUpdateUserProvided

	return SourceMicrosoftOnedriveUpdateCSVHeaderDefinition{
		SourceMicrosoftOnedriveUpdateUserProvided: &sourceMicrosoftOnedriveUpdateUserProvided,
		Type: typ,
	}
}

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

	var sourceMicrosoftOnedriveUpdateFromCSV SourceMicrosoftOnedriveUpdateFromCSV = SourceMicrosoftOnedriveUpdateFromCSV{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftOnedriveUpdateFromCSV, "", true, true); err == nil {
		u.SourceMicrosoftOnedriveUpdateFromCSV = &sourceMicrosoftOnedriveUpdateFromCSV
		u.Type = SourceMicrosoftOnedriveUpdateCSVHeaderDefinitionTypeSourceMicrosoftOnedriveUpdateFromCSV
		return nil
	}

	var sourceMicrosoftOnedriveUpdateAutogenerated SourceMicrosoftOnedriveUpdateAutogenerated = SourceMicrosoftOnedriveUpdateAutogenerated{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftOnedriveUpdateAutogenerated, "", true, true); err == nil {
		u.SourceMicrosoftOnedriveUpdateAutogenerated = &sourceMicrosoftOnedriveUpdateAutogenerated
		u.Type = SourceMicrosoftOnedriveUpdateCSVHeaderDefinitionTypeSourceMicrosoftOnedriveUpdateAutogenerated
		return nil
	}

	var sourceMicrosoftOnedriveUpdateUserProvided SourceMicrosoftOnedriveUpdateUserProvided = SourceMicrosoftOnedriveUpdateUserProvided{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftOnedriveUpdateUserProvided, "", true, true); err == nil {
		u.SourceMicrosoftOnedriveUpdateUserProvided = &sourceMicrosoftOnedriveUpdateUserProvided
		u.Type = SourceMicrosoftOnedriveUpdateCSVHeaderDefinitionTypeSourceMicrosoftOnedriveUpdateUserProvided
		return nil
	}

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

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

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

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

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

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

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

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

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

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

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

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

func (o *SourceMicrosoftOnedriveUpdateCSVFormat) GetFiletype() *SourceMicrosoftOnedriveUpdateSchemasFiletype {
	return SourceMicrosoftOnedriveUpdateSchemasFiletypeCsv.ToPointer()
}

func (o *SourceMicrosoftOnedriveUpdateCSVFormat) GetHeaderDefinition() *SourceMicrosoftOnedriveUpdateCSVHeaderDefinition {
	if o == nil {
		return nil
	}
	return o.HeaderDefinition
}

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

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

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

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

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

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

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

type SourceMicrosoftOnedriveUpdateFiletype string

const (
	SourceMicrosoftOnedriveUpdateFiletypeAvro SourceMicrosoftOnedriveUpdateFiletype = "avro"
)

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

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

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

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

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

func (o *SourceMicrosoftOnedriveUpdateAvroFormat) GetFiletype() *SourceMicrosoftOnedriveUpdateFiletype {
	return SourceMicrosoftOnedriveUpdateFiletypeAvro.ToPointer()
}

type SourceMicrosoftOnedriveUpdateFormatType string

const (
	SourceMicrosoftOnedriveUpdateFormatTypeSourceMicrosoftOnedriveUpdateAvroFormat                 SourceMicrosoftOnedriveUpdateFormatType = "source-microsoft-onedrive-update_Avro Format"
	SourceMicrosoftOnedriveUpdateFormatTypeSourceMicrosoftOnedriveUpdateCSVFormat                  SourceMicrosoftOnedriveUpdateFormatType = "source-microsoft-onedrive-update_CSV Format"
	SourceMicrosoftOnedriveUpdateFormatTypeSourceMicrosoftOnedriveUpdateJsonlFormat                SourceMicrosoftOnedriveUpdateFormatType = "source-microsoft-onedrive-update_Jsonl Format"
	SourceMicrosoftOnedriveUpdateFormatTypeSourceMicrosoftOnedriveUpdateParquetFormat              SourceMicrosoftOnedriveUpdateFormatType = "source-microsoft-onedrive-update_Parquet Format"
	SourceMicrosoftOnedriveUpdateFormatTypeSourceMicrosoftOnedriveUpdateUnstructuredDocumentFormat SourceMicrosoftOnedriveUpdateFormatType = "source-microsoft-onedrive-update_Unstructured Document Format"
)

// SourceMicrosoftOnedriveUpdateFormat - The configuration options that are used to alter how to read incoming files that deviate from the standard formatting.
type SourceMicrosoftOnedriveUpdateFormat struct {
	SourceMicrosoftOnedriveUpdateAvroFormat                 *SourceMicrosoftOnedriveUpdateAvroFormat                 `queryParam:"inline"`
	SourceMicrosoftOnedriveUpdateCSVFormat                  *SourceMicrosoftOnedriveUpdateCSVFormat                  `queryParam:"inline"`
	SourceMicrosoftOnedriveUpdateJsonlFormat                *SourceMicrosoftOnedriveUpdateJsonlFormat                `queryParam:"inline"`
	SourceMicrosoftOnedriveUpdateParquetFormat              *SourceMicrosoftOnedriveUpdateParquetFormat              `queryParam:"inline"`
	SourceMicrosoftOnedriveUpdateUnstructuredDocumentFormat *SourceMicrosoftOnedriveUpdateUnstructuredDocumentFormat `queryParam:"inline"`

	Type SourceMicrosoftOnedriveUpdateFormatType
}

func CreateSourceMicrosoftOnedriveUpdateFormatSourceMicrosoftOnedriveUpdateAvroFormat(sourceMicrosoftOnedriveUpdateAvroFormat SourceMicrosoftOnedriveUpdateAvroFormat) SourceMicrosoftOnedriveUpdateFormat {
	typ := SourceMicrosoftOnedriveUpdateFormatTypeSourceMicrosoftOnedriveUpdateAvroFormat

	return SourceMicrosoftOnedriveUpdateFormat{
		SourceMicrosoftOnedriveUpdateAvroFormat: &sourceMicrosoftOnedriveUpdateAvroFormat,
		Type:                                    typ,
	}
}

func CreateSourceMicrosoftOnedriveUpdateFormatSourceMicrosoftOnedriveUpdateCSVFormat(sourceMicrosoftOnedriveUpdateCSVFormat SourceMicrosoftOnedriveUpdateCSVFormat) SourceMicrosoftOnedriveUpdateFormat {
	typ := SourceMicrosoftOnedriveUpdateFormatTypeSourceMicrosoftOnedriveUpdateCSVFormat

	return SourceMicrosoftOnedriveUpdateFormat{
		SourceMicrosoftOnedriveUpdateCSVFormat: &sourceMicrosoftOnedriveUpdateCSVFormat,
		Type:                                   typ,
	}
}

func CreateSourceMicrosoftOnedriveUpdateFormatSourceMicrosoftOnedriveUpdateJsonlFormat(sourceMicrosoftOnedriveUpdateJsonlFormat SourceMicrosoftOnedriveUpdateJsonlFormat) SourceMicrosoftOnedriveUpdateFormat {
	typ := SourceMicrosoftOnedriveUpdateFormatTypeSourceMicrosoftOnedriveUpdateJsonlFormat

	return SourceMicrosoftOnedriveUpdateFormat{
		SourceMicrosoftOnedriveUpdateJsonlFormat: &sourceMicrosoftOnedriveUpdateJsonlFormat,
		Type:                                     typ,
	}
}

func CreateSourceMicrosoftOnedriveUpdateFormatSourceMicrosoftOnedriveUpdateParquetFormat(sourceMicrosoftOnedriveUpdateParquetFormat SourceMicrosoftOnedriveUpdateParquetFormat) SourceMicrosoftOnedriveUpdateFormat {
	typ := SourceMicrosoftOnedriveUpdateFormatTypeSourceMicrosoftOnedriveUpdateParquetFormat

	return SourceMicrosoftOnedriveUpdateFormat{
		SourceMicrosoftOnedriveUpdateParquetFormat: &sourceMicrosoftOnedriveUpdateParquetFormat,
		Type: typ,
	}
}

func CreateSourceMicrosoftOnedriveUpdateFormatSourceMicrosoftOnedriveUpdateUnstructuredDocumentFormat(sourceMicrosoftOnedriveUpdateUnstructuredDocumentFormat SourceMicrosoftOnedriveUpdateUnstructuredDocumentFormat) SourceMicrosoftOnedriveUpdateFormat {
	typ := SourceMicrosoftOnedriveUpdateFormatTypeSourceMicrosoftOnedriveUpdateUnstructuredDocumentFormat

	return SourceMicrosoftOnedriveUpdateFormat{
		SourceMicrosoftOnedriveUpdateUnstructuredDocumentFormat: &sourceMicrosoftOnedriveUpdateUnstructuredDocumentFormat,
		Type: typ,
	}
}

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

	var sourceMicrosoftOnedriveUpdateJsonlFormat SourceMicrosoftOnedriveUpdateJsonlFormat = SourceMicrosoftOnedriveUpdateJsonlFormat{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftOnedriveUpdateJsonlFormat, "", true, true); err == nil {
		u.SourceMicrosoftOnedriveUpdateJsonlFormat = &sourceMicrosoftOnedriveUpdateJsonlFormat
		u.Type = SourceMicrosoftOnedriveUpdateFormatTypeSourceMicrosoftOnedriveUpdateJsonlFormat
		return nil
	}

	var sourceMicrosoftOnedriveUpdateAvroFormat SourceMicrosoftOnedriveUpdateAvroFormat = SourceMicrosoftOnedriveUpdateAvroFormat{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftOnedriveUpdateAvroFormat, "", true, true); err == nil {
		u.SourceMicrosoftOnedriveUpdateAvroFormat = &sourceMicrosoftOnedriveUpdateAvroFormat
		u.Type = SourceMicrosoftOnedriveUpdateFormatTypeSourceMicrosoftOnedriveUpdateAvroFormat
		return nil
	}

	var sourceMicrosoftOnedriveUpdateParquetFormat SourceMicrosoftOnedriveUpdateParquetFormat = SourceMicrosoftOnedriveUpdateParquetFormat{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftOnedriveUpdateParquetFormat, "", true, true); err == nil {
		u.SourceMicrosoftOnedriveUpdateParquetFormat = &sourceMicrosoftOnedriveUpdateParquetFormat
		u.Type = SourceMicrosoftOnedriveUpdateFormatTypeSourceMicrosoftOnedriveUpdateParquetFormat
		return nil
	}

	var sourceMicrosoftOnedriveUpdateUnstructuredDocumentFormat SourceMicrosoftOnedriveUpdateUnstructuredDocumentFormat = SourceMicrosoftOnedriveUpdateUnstructuredDocumentFormat{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftOnedriveUpdateUnstructuredDocumentFormat, "", true, true); err == nil {
		u.SourceMicrosoftOnedriveUpdateUnstructuredDocumentFormat = &sourceMicrosoftOnedriveUpdateUnstructuredDocumentFormat
		u.Type = SourceMicrosoftOnedriveUpdateFormatTypeSourceMicrosoftOnedriveUpdateUnstructuredDocumentFormat
		return nil
	}

	var sourceMicrosoftOnedriveUpdateCSVFormat SourceMicrosoftOnedriveUpdateCSVFormat = SourceMicrosoftOnedriveUpdateCSVFormat{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftOnedriveUpdateCSVFormat, "", true, true); err == nil {
		u.SourceMicrosoftOnedriveUpdateCSVFormat = &sourceMicrosoftOnedriveUpdateCSVFormat
		u.Type = SourceMicrosoftOnedriveUpdateFormatTypeSourceMicrosoftOnedriveUpdateCSVFormat
		return nil
	}

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

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

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

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

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

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

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

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

const (
	SourceMicrosoftOnedriveUpdateValidationPolicyEmitRecord      SourceMicrosoftOnedriveUpdateValidationPolicy = "Emit Record"
	SourceMicrosoftOnedriveUpdateValidationPolicySkipRecord      SourceMicrosoftOnedriveUpdateValidationPolicy = "Skip Record"
	SourceMicrosoftOnedriveUpdateValidationPolicyWaitForDiscover SourceMicrosoftOnedriveUpdateValidationPolicy = "Wait for Discover"
)

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

type SourceMicrosoftOnedriveUpdateFileBasedStreamConfig 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 SourceMicrosoftOnedriveUpdateFormat `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"`
	// 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 *SourceMicrosoftOnedriveUpdateValidationPolicy `default:"Emit Record" json:"validation_policy"`
}

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

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

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

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

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

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

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

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

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

// SourceMicrosoftOnedriveUpdate - SourceMicrosoftOneDriveSpec class for Microsoft OneDrive Source Specification.
// This class combines the authentication details with additional configuration for the OneDrive API.
type SourceMicrosoftOnedriveUpdate struct {
	// Credentials for connecting to the One Drive API
	Credentials SourceMicrosoftOnedriveUpdateAuthentication `json:"credentials"`
	// Name of the Microsoft OneDrive drive where the file(s) exist.
	DriveName *string `default:"OneDrive" json:"drive_name"`
	// Path to a specific folder within the drives to search for files. Leave empty to search all folders of the drives. This does not apply to shared items.
	FolderPath *string `default:"." json:"folder_path"`
	// Specifies the location(s) to search for files. Valid options are 'ACCESSIBLE_DRIVES' to search in the selected OneDrive drive, 'SHARED_ITEMS' for shared items the user has access to, and 'ALL' to search both.
	SearchScope *SourceMicrosoftOnedriveUpdateSearchScope `default:"ALL" json:"search_scope"`
	// 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 []SourceMicrosoftOnedriveUpdateFileBasedStreamConfig `json:"streams"`
}

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

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

func (o *SourceMicrosoftOnedriveUpdate) GetCredentials() SourceMicrosoftOnedriveUpdateAuthentication {
	if o == nil {
		return SourceMicrosoftOnedriveUpdateAuthentication{}
	}
	return o.Credentials
}

func (o *SourceMicrosoftOnedriveUpdate) GetDriveName() *string {
	if o == nil {
		return nil
	}
	return o.DriveName
}

func (o *SourceMicrosoftOnedriveUpdate) GetFolderPath() *string {
	if o == nil {
		return nil
	}
	return o.FolderPath
}

func (o *SourceMicrosoftOnedriveUpdate) GetSearchScope() *SourceMicrosoftOnedriveUpdateSearchScope {
	if o == nil {
		return nil
	}
	return o.SearchScope
}

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

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