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

const (
	SourceMicrosoftSharepointSchemasAuthTypeService SourceMicrosoftSharepointSchemasAuthType = "Service"
)

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

// SourceMicrosoftSharepointServiceKeyAuthentication - ServiceCredentials class for service key authentication.
// This class is structured similarly to OAuthCredentials but for a different authentication method.
type SourceMicrosoftSharepointServiceKeyAuthentication struct {
	authType *SourceMicrosoftSharepointSchemasAuthType `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 SharePoint 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 SourceMicrosoftSharepointServiceKeyAuthentication) MarshalJSON() ([]byte, error) {
	return utils.MarshalJSON(s, "", false)
}

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

func (o *SourceMicrosoftSharepointServiceKeyAuthentication) GetAuthType() *SourceMicrosoftSharepointSchemasAuthType {
	return SourceMicrosoftSharepointSchemasAuthTypeService.ToPointer()
}

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

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

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

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

type SourceMicrosoftSharepointAuthType string

const (
	SourceMicrosoftSharepointAuthTypeClient SourceMicrosoftSharepointAuthType = "Client"
)

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

// SourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth - OAuthCredentials class to hold authentication details for Microsoft OAuth authentication.
// This class uses pydantic for data validation and settings management.
type SourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth struct {
	authType *SourceMicrosoftSharepointAuthType `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,omitempty"`
	// Tenant ID of the Microsoft SharePoint user
	TenantID string `json:"tenant_id"`
}

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

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

func (o *SourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth) GetAuthType() *SourceMicrosoftSharepointAuthType {
	return SourceMicrosoftSharepointAuthTypeClient.ToPointer()
}

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

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

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

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

type SourceMicrosoftSharepointAuthenticationType string

const (
	SourceMicrosoftSharepointAuthenticationTypeSourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth SourceMicrosoftSharepointAuthenticationType = "source-microsoft-sharepoint_Authenticate via Microsoft (OAuth)"
	SourceMicrosoftSharepointAuthenticationTypeSourceMicrosoftSharepointServiceKeyAuthentication      SourceMicrosoftSharepointAuthenticationType = "source-microsoft-sharepoint_Service Key Authentication"
)

// SourceMicrosoftSharepointAuthentication - Credentials for connecting to the One Drive API
type SourceMicrosoftSharepointAuthentication struct {
	SourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth *SourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth `queryParam:"inline"`
	SourceMicrosoftSharepointServiceKeyAuthentication      *SourceMicrosoftSharepointServiceKeyAuthentication      `queryParam:"inline"`

	Type SourceMicrosoftSharepointAuthenticationType
}

func CreateSourceMicrosoftSharepointAuthenticationSourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth(sourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth SourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth) SourceMicrosoftSharepointAuthentication {
	typ := SourceMicrosoftSharepointAuthenticationTypeSourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth

	return SourceMicrosoftSharepointAuthentication{
		SourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth: &sourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth,
		Type: typ,
	}
}

func CreateSourceMicrosoftSharepointAuthenticationSourceMicrosoftSharepointServiceKeyAuthentication(sourceMicrosoftSharepointServiceKeyAuthentication SourceMicrosoftSharepointServiceKeyAuthentication) SourceMicrosoftSharepointAuthentication {
	typ := SourceMicrosoftSharepointAuthenticationTypeSourceMicrosoftSharepointServiceKeyAuthentication

	return SourceMicrosoftSharepointAuthentication{
		SourceMicrosoftSharepointServiceKeyAuthentication: &sourceMicrosoftSharepointServiceKeyAuthentication,
		Type: typ,
	}
}

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

	var sourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth SourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth = SourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth, "", true, true); err == nil {
		u.SourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth = &sourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth
		u.Type = SourceMicrosoftSharepointAuthenticationTypeSourceMicrosoftSharepointAuthenticateViaMicrosoftOAuth
		return nil
	}

	var sourceMicrosoftSharepointServiceKeyAuthentication SourceMicrosoftSharepointServiceKeyAuthentication = SourceMicrosoftSharepointServiceKeyAuthentication{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftSharepointServiceKeyAuthentication, "", true, true); err == nil {
		u.SourceMicrosoftSharepointServiceKeyAuthentication = &sourceMicrosoftSharepointServiceKeyAuthentication
		u.Type = SourceMicrosoftSharepointAuthenticationTypeSourceMicrosoftSharepointServiceKeyAuthentication
		return nil
	}

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

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

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

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

type SourceMicrosoftSharepointSchemasDeliveryType string

const (
	SourceMicrosoftSharepointSchemasDeliveryTypeUseFileTransfer SourceMicrosoftSharepointSchemasDeliveryType = "use_file_transfer"
)

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

// SourceMicrosoftSharepointCopyRawFiles - Copy raw files without parsing their contents. Bits are copied into the destination exactly as they appeared in the source. Recommended for use with unstructured text data, non-text and compressed files.
type SourceMicrosoftSharepointCopyRawFiles struct {
	deliveryType *SourceMicrosoftSharepointSchemasDeliveryType `const:"use_file_transfer" json:"delivery_type"`
	// If enabled, sends subdirectory folder structure along with source file names to the destination. Otherwise, files will be synced by their names only. This option is ignored when file-based replication is not enabled.
	PreserveDirectoryStructure *bool `default:"true" json:"preserve_directory_structure"`
}

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

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

func (o *SourceMicrosoftSharepointCopyRawFiles) GetDeliveryType() *SourceMicrosoftSharepointSchemasDeliveryType {
	return SourceMicrosoftSharepointSchemasDeliveryTypeUseFileTransfer.ToPointer()
}

func (o *SourceMicrosoftSharepointCopyRawFiles) GetPreserveDirectoryStructure() *bool {
	if o == nil {
		return nil
	}
	return o.PreserveDirectoryStructure
}

type SourceMicrosoftSharepointDeliveryType string

const (
	SourceMicrosoftSharepointDeliveryTypeUseRecordsTransfer SourceMicrosoftSharepointDeliveryType = "use_records_transfer"
)

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

// SourceMicrosoftSharepointReplicateRecords - Recommended - Extract and load structured records into your destination of choice. This is the classic method of moving data in Airbyte. It allows for blocking and hashing individual fields or files from a structured schema. Data can be flattened, typed and deduped depending on the destination.
type SourceMicrosoftSharepointReplicateRecords struct {
	deliveryType *SourceMicrosoftSharepointDeliveryType `const:"use_records_transfer" json:"delivery_type"`
}

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

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

func (o *SourceMicrosoftSharepointReplicateRecords) GetDeliveryType() *SourceMicrosoftSharepointDeliveryType {
	return SourceMicrosoftSharepointDeliveryTypeUseRecordsTransfer.ToPointer()
}

type SourceMicrosoftSharepointDeliveryMethodType string

const (
	SourceMicrosoftSharepointDeliveryMethodTypeSourceMicrosoftSharepointReplicateRecords SourceMicrosoftSharepointDeliveryMethodType = "source-microsoft-sharepoint_Replicate Records"
	SourceMicrosoftSharepointDeliveryMethodTypeSourceMicrosoftSharepointCopyRawFiles     SourceMicrosoftSharepointDeliveryMethodType = "source-microsoft-sharepoint_Copy Raw Files"
)

type SourceMicrosoftSharepointDeliveryMethod struct {
	SourceMicrosoftSharepointReplicateRecords *SourceMicrosoftSharepointReplicateRecords `queryParam:"inline"`
	SourceMicrosoftSharepointCopyRawFiles     *SourceMicrosoftSharepointCopyRawFiles     `queryParam:"inline"`

	Type SourceMicrosoftSharepointDeliveryMethodType
}

func CreateSourceMicrosoftSharepointDeliveryMethodSourceMicrosoftSharepointReplicateRecords(sourceMicrosoftSharepointReplicateRecords SourceMicrosoftSharepointReplicateRecords) SourceMicrosoftSharepointDeliveryMethod {
	typ := SourceMicrosoftSharepointDeliveryMethodTypeSourceMicrosoftSharepointReplicateRecords

	return SourceMicrosoftSharepointDeliveryMethod{
		SourceMicrosoftSharepointReplicateRecords: &sourceMicrosoftSharepointReplicateRecords,
		Type: typ,
	}
}

func CreateSourceMicrosoftSharepointDeliveryMethodSourceMicrosoftSharepointCopyRawFiles(sourceMicrosoftSharepointCopyRawFiles SourceMicrosoftSharepointCopyRawFiles) SourceMicrosoftSharepointDeliveryMethod {
	typ := SourceMicrosoftSharepointDeliveryMethodTypeSourceMicrosoftSharepointCopyRawFiles

	return SourceMicrosoftSharepointDeliveryMethod{
		SourceMicrosoftSharepointCopyRawFiles: &sourceMicrosoftSharepointCopyRawFiles,
		Type:                                  typ,
	}
}

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

	var sourceMicrosoftSharepointReplicateRecords SourceMicrosoftSharepointReplicateRecords = SourceMicrosoftSharepointReplicateRecords{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftSharepointReplicateRecords, "", true, true); err == nil {
		u.SourceMicrosoftSharepointReplicateRecords = &sourceMicrosoftSharepointReplicateRecords
		u.Type = SourceMicrosoftSharepointDeliveryMethodTypeSourceMicrosoftSharepointReplicateRecords
		return nil
	}

	var sourceMicrosoftSharepointCopyRawFiles SourceMicrosoftSharepointCopyRawFiles = SourceMicrosoftSharepointCopyRawFiles{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftSharepointCopyRawFiles, "", true, true); err == nil {
		u.SourceMicrosoftSharepointCopyRawFiles = &sourceMicrosoftSharepointCopyRawFiles
		u.Type = SourceMicrosoftSharepointDeliveryMethodTypeSourceMicrosoftSharepointCopyRawFiles
		return nil
	}

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

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

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

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

// SourceMicrosoftSharepointSearchScope - Specifies the location(s) to search for files. Valid options are 'ACCESSIBLE_DRIVES' for all SharePoint drives the user can access, 'SHARED_ITEMS' for shared items the user has access to, and 'ALL' to search both.
type SourceMicrosoftSharepointSearchScope string

const (
	SourceMicrosoftSharepointSearchScopeAccessibleDrives SourceMicrosoftSharepointSearchScope = "ACCESSIBLE_DRIVES"
	SourceMicrosoftSharepointSearchScopeSharedItems      SourceMicrosoftSharepointSearchScope = "SHARED_ITEMS"
	SourceMicrosoftSharepointSearchScopeAll              SourceMicrosoftSharepointSearchScope = "ALL"
)

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

type SourceMicrosoftSharepointSchemasStreamsFormatFormat6Filetype string

const (
	SourceMicrosoftSharepointSchemasStreamsFormatFormat6FiletypeExcel SourceMicrosoftSharepointSchemasStreamsFormatFormat6Filetype = "excel"
)

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

type SourceMicrosoftSharepointExcelFormat struct {
	filetype *SourceMicrosoftSharepointSchemasStreamsFormatFormat6Filetype `const:"excel" json:"filetype"`
}

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

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

func (o *SourceMicrosoftSharepointExcelFormat) GetFiletype() *SourceMicrosoftSharepointSchemasStreamsFormatFormat6Filetype {
	return SourceMicrosoftSharepointSchemasStreamsFormatFormat6FiletypeExcel.ToPointer()
}

type SourceMicrosoftSharepointSchemasStreamsFormatFormatFiletype string

const (
	SourceMicrosoftSharepointSchemasStreamsFormatFormatFiletypeUnstructured SourceMicrosoftSharepointSchemasStreamsFormatFormatFiletype = "unstructured"
)

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

type SourceMicrosoftSharepointMode string

const (
	SourceMicrosoftSharepointModeLocal SourceMicrosoftSharepointMode = "local"
)

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

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

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

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

func (o *SourceMicrosoftSharepointLocal) GetMode() *SourceMicrosoftSharepointMode {
	return SourceMicrosoftSharepointModeLocal.ToPointer()
}

type SourceMicrosoftSharepointProcessingType string

const (
	SourceMicrosoftSharepointProcessingTypeSourceMicrosoftSharepointLocal SourceMicrosoftSharepointProcessingType = "source-microsoft-sharepoint_Local"
)

// SourceMicrosoftSharepointProcessing - Processing configuration
type SourceMicrosoftSharepointProcessing struct {
	SourceMicrosoftSharepointLocal *SourceMicrosoftSharepointLocal `queryParam:"inline"`

	Type SourceMicrosoftSharepointProcessingType
}

func CreateSourceMicrosoftSharepointProcessingSourceMicrosoftSharepointLocal(sourceMicrosoftSharepointLocal SourceMicrosoftSharepointLocal) SourceMicrosoftSharepointProcessing {
	typ := SourceMicrosoftSharepointProcessingTypeSourceMicrosoftSharepointLocal

	return SourceMicrosoftSharepointProcessing{
		SourceMicrosoftSharepointLocal: &sourceMicrosoftSharepointLocal,
		Type:                           typ,
	}
}

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

	var sourceMicrosoftSharepointLocal SourceMicrosoftSharepointLocal = SourceMicrosoftSharepointLocal{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftSharepointLocal, "", true, true); err == nil {
		u.SourceMicrosoftSharepointLocal = &sourceMicrosoftSharepointLocal
		u.Type = SourceMicrosoftSharepointProcessingTypeSourceMicrosoftSharepointLocal
		return nil
	}

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

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

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

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

const (
	SourceMicrosoftSharepointParsingStrategyAuto    SourceMicrosoftSharepointParsingStrategy = "auto"
	SourceMicrosoftSharepointParsingStrategyFast    SourceMicrosoftSharepointParsingStrategy = "fast"
	SourceMicrosoftSharepointParsingStrategyOcrOnly SourceMicrosoftSharepointParsingStrategy = "ocr_only"
	SourceMicrosoftSharepointParsingStrategyHiRes   SourceMicrosoftSharepointParsingStrategy = "hi_res"
)

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

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

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

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

func (o *SourceMicrosoftSharepointUnstructuredDocumentFormat) GetFiletype() *SourceMicrosoftSharepointSchemasStreamsFormatFormatFiletype {
	return SourceMicrosoftSharepointSchemasStreamsFormatFormatFiletypeUnstructured.ToPointer()
}

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

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

func (o *SourceMicrosoftSharepointUnstructuredDocumentFormat) GetStrategy() *SourceMicrosoftSharepointParsingStrategy {
	if o == nil {
		return nil
	}
	return o.Strategy
}

type SourceMicrosoftSharepointSchemasStreamsFormatFiletype string

const (
	SourceMicrosoftSharepointSchemasStreamsFormatFiletypeParquet SourceMicrosoftSharepointSchemasStreamsFormatFiletype = "parquet"
)

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

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

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

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

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

func (o *SourceMicrosoftSharepointParquetFormat) GetFiletype() *SourceMicrosoftSharepointSchemasStreamsFormatFiletype {
	return SourceMicrosoftSharepointSchemasStreamsFormatFiletypeParquet.ToPointer()
}

type SourceMicrosoftSharepointSchemasStreamsFiletype string

const (
	SourceMicrosoftSharepointSchemasStreamsFiletypeJsonl SourceMicrosoftSharepointSchemasStreamsFiletype = "jsonl"
)

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

type SourceMicrosoftSharepointJsonlFormat struct {
	filetype *SourceMicrosoftSharepointSchemasStreamsFiletype `const:"jsonl" json:"filetype"`
}

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

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

func (o *SourceMicrosoftSharepointJsonlFormat) GetFiletype() *SourceMicrosoftSharepointSchemasStreamsFiletype {
	return SourceMicrosoftSharepointSchemasStreamsFiletypeJsonl.ToPointer()
}

type SourceMicrosoftSharepointSchemasFiletype string

const (
	SourceMicrosoftSharepointSchemasFiletypeCsv SourceMicrosoftSharepointSchemasFiletype = "csv"
)

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

type SourceMicrosoftSharepointSchemasStreamsHeaderDefinitionType string

const (
	SourceMicrosoftSharepointSchemasStreamsHeaderDefinitionTypeUserProvided SourceMicrosoftSharepointSchemasStreamsHeaderDefinitionType = "User Provided"
)

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

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

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

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

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

func (o *SourceMicrosoftSharepointUserProvided) GetHeaderDefinitionType() *SourceMicrosoftSharepointSchemasStreamsHeaderDefinitionType {
	return SourceMicrosoftSharepointSchemasStreamsHeaderDefinitionTypeUserProvided.ToPointer()
}

type SourceMicrosoftSharepointSchemasHeaderDefinitionType string

const (
	SourceMicrosoftSharepointSchemasHeaderDefinitionTypeAutogenerated SourceMicrosoftSharepointSchemasHeaderDefinitionType = "Autogenerated"
)

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

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

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

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

func (o *SourceMicrosoftSharepointAutogenerated) GetHeaderDefinitionType() *SourceMicrosoftSharepointSchemasHeaderDefinitionType {
	return SourceMicrosoftSharepointSchemasHeaderDefinitionTypeAutogenerated.ToPointer()
}

type SourceMicrosoftSharepointHeaderDefinitionType string

const (
	SourceMicrosoftSharepointHeaderDefinitionTypeFromCsv SourceMicrosoftSharepointHeaderDefinitionType = "From CSV"
)

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

type SourceMicrosoftSharepointFromCSV struct {
	headerDefinitionType *SourceMicrosoftSharepointHeaderDefinitionType `const:"From CSV" json:"header_definition_type"`
}

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

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

func (o *SourceMicrosoftSharepointFromCSV) GetHeaderDefinitionType() *SourceMicrosoftSharepointHeaderDefinitionType {
	return SourceMicrosoftSharepointHeaderDefinitionTypeFromCsv.ToPointer()
}

type SourceMicrosoftSharepointCSVHeaderDefinitionType string

const (
	SourceMicrosoftSharepointCSVHeaderDefinitionTypeSourceMicrosoftSharepointFromCSV       SourceMicrosoftSharepointCSVHeaderDefinitionType = "source-microsoft-sharepoint_From CSV"
	SourceMicrosoftSharepointCSVHeaderDefinitionTypeSourceMicrosoftSharepointAutogenerated SourceMicrosoftSharepointCSVHeaderDefinitionType = "source-microsoft-sharepoint_Autogenerated"
	SourceMicrosoftSharepointCSVHeaderDefinitionTypeSourceMicrosoftSharepointUserProvided  SourceMicrosoftSharepointCSVHeaderDefinitionType = "source-microsoft-sharepoint_User Provided"
)

// SourceMicrosoftSharepointCSVHeaderDefinition - 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 SourceMicrosoftSharepointCSVHeaderDefinition struct {
	SourceMicrosoftSharepointFromCSV       *SourceMicrosoftSharepointFromCSV       `queryParam:"inline"`
	SourceMicrosoftSharepointAutogenerated *SourceMicrosoftSharepointAutogenerated `queryParam:"inline"`
	SourceMicrosoftSharepointUserProvided  *SourceMicrosoftSharepointUserProvided  `queryParam:"inline"`

	Type SourceMicrosoftSharepointCSVHeaderDefinitionType
}

func CreateSourceMicrosoftSharepointCSVHeaderDefinitionSourceMicrosoftSharepointFromCSV(sourceMicrosoftSharepointFromCSV SourceMicrosoftSharepointFromCSV) SourceMicrosoftSharepointCSVHeaderDefinition {
	typ := SourceMicrosoftSharepointCSVHeaderDefinitionTypeSourceMicrosoftSharepointFromCSV

	return SourceMicrosoftSharepointCSVHeaderDefinition{
		SourceMicrosoftSharepointFromCSV: &sourceMicrosoftSharepointFromCSV,
		Type:                             typ,
	}
}

func CreateSourceMicrosoftSharepointCSVHeaderDefinitionSourceMicrosoftSharepointAutogenerated(sourceMicrosoftSharepointAutogenerated SourceMicrosoftSharepointAutogenerated) SourceMicrosoftSharepointCSVHeaderDefinition {
	typ := SourceMicrosoftSharepointCSVHeaderDefinitionTypeSourceMicrosoftSharepointAutogenerated

	return SourceMicrosoftSharepointCSVHeaderDefinition{
		SourceMicrosoftSharepointAutogenerated: &sourceMicrosoftSharepointAutogenerated,
		Type:                                   typ,
	}
}

func CreateSourceMicrosoftSharepointCSVHeaderDefinitionSourceMicrosoftSharepointUserProvided(sourceMicrosoftSharepointUserProvided SourceMicrosoftSharepointUserProvided) SourceMicrosoftSharepointCSVHeaderDefinition {
	typ := SourceMicrosoftSharepointCSVHeaderDefinitionTypeSourceMicrosoftSharepointUserProvided

	return SourceMicrosoftSharepointCSVHeaderDefinition{
		SourceMicrosoftSharepointUserProvided: &sourceMicrosoftSharepointUserProvided,
		Type:                                  typ,
	}
}

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

	var sourceMicrosoftSharepointFromCSV SourceMicrosoftSharepointFromCSV = SourceMicrosoftSharepointFromCSV{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftSharepointFromCSV, "", true, true); err == nil {
		u.SourceMicrosoftSharepointFromCSV = &sourceMicrosoftSharepointFromCSV
		u.Type = SourceMicrosoftSharepointCSVHeaderDefinitionTypeSourceMicrosoftSharepointFromCSV
		return nil
	}

	var sourceMicrosoftSharepointAutogenerated SourceMicrosoftSharepointAutogenerated = SourceMicrosoftSharepointAutogenerated{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftSharepointAutogenerated, "", true, true); err == nil {
		u.SourceMicrosoftSharepointAutogenerated = &sourceMicrosoftSharepointAutogenerated
		u.Type = SourceMicrosoftSharepointCSVHeaderDefinitionTypeSourceMicrosoftSharepointAutogenerated
		return nil
	}

	var sourceMicrosoftSharepointUserProvided SourceMicrosoftSharepointUserProvided = SourceMicrosoftSharepointUserProvided{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftSharepointUserProvided, "", true, true); err == nil {
		u.SourceMicrosoftSharepointUserProvided = &sourceMicrosoftSharepointUserProvided
		u.Type = SourceMicrosoftSharepointCSVHeaderDefinitionTypeSourceMicrosoftSharepointUserProvided
		return nil
	}

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

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

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

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

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

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

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

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

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

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

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

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

func (o *SourceMicrosoftSharepointCSVFormat) GetFiletype() *SourceMicrosoftSharepointSchemasFiletype {
	return SourceMicrosoftSharepointSchemasFiletypeCsv.ToPointer()
}

func (o *SourceMicrosoftSharepointCSVFormat) GetHeaderDefinition() *SourceMicrosoftSharepointCSVHeaderDefinition {
	if o == nil {
		return nil
	}
	return o.HeaderDefinition
}

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

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

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

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

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

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

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

type SourceMicrosoftSharepointFiletype string

const (
	SourceMicrosoftSharepointFiletypeAvro SourceMicrosoftSharepointFiletype = "avro"
)

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

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

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

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

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

func (o *SourceMicrosoftSharepointAvroFormat) GetFiletype() *SourceMicrosoftSharepointFiletype {
	return SourceMicrosoftSharepointFiletypeAvro.ToPointer()
}

type SourceMicrosoftSharepointFormatType string

const (
	SourceMicrosoftSharepointFormatTypeSourceMicrosoftSharepointAvroFormat                 SourceMicrosoftSharepointFormatType = "source-microsoft-sharepoint_Avro Format"
	SourceMicrosoftSharepointFormatTypeSourceMicrosoftSharepointCSVFormat                  SourceMicrosoftSharepointFormatType = "source-microsoft-sharepoint_CSV Format"
	SourceMicrosoftSharepointFormatTypeSourceMicrosoftSharepointJsonlFormat                SourceMicrosoftSharepointFormatType = "source-microsoft-sharepoint_Jsonl Format"
	SourceMicrosoftSharepointFormatTypeSourceMicrosoftSharepointParquetFormat              SourceMicrosoftSharepointFormatType = "source-microsoft-sharepoint_Parquet Format"
	SourceMicrosoftSharepointFormatTypeSourceMicrosoftSharepointUnstructuredDocumentFormat SourceMicrosoftSharepointFormatType = "source-microsoft-sharepoint_Unstructured Document Format"
	SourceMicrosoftSharepointFormatTypeSourceMicrosoftSharepointExcelFormat                SourceMicrosoftSharepointFormatType = "source-microsoft-sharepoint_Excel Format"
)

// SourceMicrosoftSharepointFormat - The configuration options that are used to alter how to read incoming files that deviate from the standard formatting.
type SourceMicrosoftSharepointFormat struct {
	SourceMicrosoftSharepointAvroFormat                 *SourceMicrosoftSharepointAvroFormat                 `queryParam:"inline"`
	SourceMicrosoftSharepointCSVFormat                  *SourceMicrosoftSharepointCSVFormat                  `queryParam:"inline"`
	SourceMicrosoftSharepointJsonlFormat                *SourceMicrosoftSharepointJsonlFormat                `queryParam:"inline"`
	SourceMicrosoftSharepointParquetFormat              *SourceMicrosoftSharepointParquetFormat              `queryParam:"inline"`
	SourceMicrosoftSharepointUnstructuredDocumentFormat *SourceMicrosoftSharepointUnstructuredDocumentFormat `queryParam:"inline"`
	SourceMicrosoftSharepointExcelFormat                *SourceMicrosoftSharepointExcelFormat                `queryParam:"inline"`

	Type SourceMicrosoftSharepointFormatType
}

func CreateSourceMicrosoftSharepointFormatSourceMicrosoftSharepointAvroFormat(sourceMicrosoftSharepointAvroFormat SourceMicrosoftSharepointAvroFormat) SourceMicrosoftSharepointFormat {
	typ := SourceMicrosoftSharepointFormatTypeSourceMicrosoftSharepointAvroFormat

	return SourceMicrosoftSharepointFormat{
		SourceMicrosoftSharepointAvroFormat: &sourceMicrosoftSharepointAvroFormat,
		Type:                                typ,
	}
}

func CreateSourceMicrosoftSharepointFormatSourceMicrosoftSharepointCSVFormat(sourceMicrosoftSharepointCSVFormat SourceMicrosoftSharepointCSVFormat) SourceMicrosoftSharepointFormat {
	typ := SourceMicrosoftSharepointFormatTypeSourceMicrosoftSharepointCSVFormat

	return SourceMicrosoftSharepointFormat{
		SourceMicrosoftSharepointCSVFormat: &sourceMicrosoftSharepointCSVFormat,
		Type:                               typ,
	}
}

func CreateSourceMicrosoftSharepointFormatSourceMicrosoftSharepointJsonlFormat(sourceMicrosoftSharepointJsonlFormat SourceMicrosoftSharepointJsonlFormat) SourceMicrosoftSharepointFormat {
	typ := SourceMicrosoftSharepointFormatTypeSourceMicrosoftSharepointJsonlFormat

	return SourceMicrosoftSharepointFormat{
		SourceMicrosoftSharepointJsonlFormat: &sourceMicrosoftSharepointJsonlFormat,
		Type:                                 typ,
	}
}

func CreateSourceMicrosoftSharepointFormatSourceMicrosoftSharepointParquetFormat(sourceMicrosoftSharepointParquetFormat SourceMicrosoftSharepointParquetFormat) SourceMicrosoftSharepointFormat {
	typ := SourceMicrosoftSharepointFormatTypeSourceMicrosoftSharepointParquetFormat

	return SourceMicrosoftSharepointFormat{
		SourceMicrosoftSharepointParquetFormat: &sourceMicrosoftSharepointParquetFormat,
		Type:                                   typ,
	}
}

func CreateSourceMicrosoftSharepointFormatSourceMicrosoftSharepointUnstructuredDocumentFormat(sourceMicrosoftSharepointUnstructuredDocumentFormat SourceMicrosoftSharepointUnstructuredDocumentFormat) SourceMicrosoftSharepointFormat {
	typ := SourceMicrosoftSharepointFormatTypeSourceMicrosoftSharepointUnstructuredDocumentFormat

	return SourceMicrosoftSharepointFormat{
		SourceMicrosoftSharepointUnstructuredDocumentFormat: &sourceMicrosoftSharepointUnstructuredDocumentFormat,
		Type: typ,
	}
}

func CreateSourceMicrosoftSharepointFormatSourceMicrosoftSharepointExcelFormat(sourceMicrosoftSharepointExcelFormat SourceMicrosoftSharepointExcelFormat) SourceMicrosoftSharepointFormat {
	typ := SourceMicrosoftSharepointFormatTypeSourceMicrosoftSharepointExcelFormat

	return SourceMicrosoftSharepointFormat{
		SourceMicrosoftSharepointExcelFormat: &sourceMicrosoftSharepointExcelFormat,
		Type:                                 typ,
	}
}

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

	var sourceMicrosoftSharepointJsonlFormat SourceMicrosoftSharepointJsonlFormat = SourceMicrosoftSharepointJsonlFormat{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftSharepointJsonlFormat, "", true, true); err == nil {
		u.SourceMicrosoftSharepointJsonlFormat = &sourceMicrosoftSharepointJsonlFormat
		u.Type = SourceMicrosoftSharepointFormatTypeSourceMicrosoftSharepointJsonlFormat
		return nil
	}

	var sourceMicrosoftSharepointExcelFormat SourceMicrosoftSharepointExcelFormat = SourceMicrosoftSharepointExcelFormat{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftSharepointExcelFormat, "", true, true); err == nil {
		u.SourceMicrosoftSharepointExcelFormat = &sourceMicrosoftSharepointExcelFormat
		u.Type = SourceMicrosoftSharepointFormatTypeSourceMicrosoftSharepointExcelFormat
		return nil
	}

	var sourceMicrosoftSharepointAvroFormat SourceMicrosoftSharepointAvroFormat = SourceMicrosoftSharepointAvroFormat{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftSharepointAvroFormat, "", true, true); err == nil {
		u.SourceMicrosoftSharepointAvroFormat = &sourceMicrosoftSharepointAvroFormat
		u.Type = SourceMicrosoftSharepointFormatTypeSourceMicrosoftSharepointAvroFormat
		return nil
	}

	var sourceMicrosoftSharepointParquetFormat SourceMicrosoftSharepointParquetFormat = SourceMicrosoftSharepointParquetFormat{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftSharepointParquetFormat, "", true, true); err == nil {
		u.SourceMicrosoftSharepointParquetFormat = &sourceMicrosoftSharepointParquetFormat
		u.Type = SourceMicrosoftSharepointFormatTypeSourceMicrosoftSharepointParquetFormat
		return nil
	}

	var sourceMicrosoftSharepointUnstructuredDocumentFormat SourceMicrosoftSharepointUnstructuredDocumentFormat = SourceMicrosoftSharepointUnstructuredDocumentFormat{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftSharepointUnstructuredDocumentFormat, "", true, true); err == nil {
		u.SourceMicrosoftSharepointUnstructuredDocumentFormat = &sourceMicrosoftSharepointUnstructuredDocumentFormat
		u.Type = SourceMicrosoftSharepointFormatTypeSourceMicrosoftSharepointUnstructuredDocumentFormat
		return nil
	}

	var sourceMicrosoftSharepointCSVFormat SourceMicrosoftSharepointCSVFormat = SourceMicrosoftSharepointCSVFormat{}
	if err := utils.UnmarshalJSON(data, &sourceMicrosoftSharepointCSVFormat, "", true, true); err == nil {
		u.SourceMicrosoftSharepointCSVFormat = &sourceMicrosoftSharepointCSVFormat
		u.Type = SourceMicrosoftSharepointFormatTypeSourceMicrosoftSharepointCSVFormat
		return nil
	}

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

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

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

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

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

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

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

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

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

const (
	SourceMicrosoftSharepointValidationPolicyEmitRecord      SourceMicrosoftSharepointValidationPolicy = "Emit Record"
	SourceMicrosoftSharepointValidationPolicySkipRecord      SourceMicrosoftSharepointValidationPolicy = "Skip Record"
	SourceMicrosoftSharepointValidationPolicyWaitForDiscover SourceMicrosoftSharepointValidationPolicy = "Wait for Discover"
)

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

type SourceMicrosoftSharepointFileBasedStreamConfig 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 SourceMicrosoftSharepointFormat `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 *SourceMicrosoftSharepointValidationPolicy `default:"Emit Record" json:"validation_policy"`
}

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

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

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

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

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

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

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

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

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

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

type MicrosoftSharepoint string

const (
	MicrosoftSharepointMicrosoftSharepoint MicrosoftSharepoint = "microsoft-sharepoint"
)

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

// SourceMicrosoftSharepoint - SourceMicrosoftSharePointSpec class for Microsoft SharePoint Source Specification.
// This class combines the authentication details with additional configuration for the SharePoint API.
type SourceMicrosoftSharepoint struct {
	// Credentials for connecting to the One Drive API
	Credentials    SourceMicrosoftSharepointAuthentication  `json:"credentials"`
	DeliveryMethod *SourceMicrosoftSharepointDeliveryMethod `json:"delivery_method,omitempty"`
	// 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' for all SharePoint drives the user can access, 'SHARED_ITEMS' for shared items the user has access to, and 'ALL' to search both.
	SearchScope *SourceMicrosoftSharepointSearchScope `default:"ALL" json:"search_scope"`
	// Url of SharePoint site to search for files. Leave empty to search in the main site. Use 'https://<tenant_name>.sharepoint.com/sites/' to iterate over all sites.
	SiteURL *string `default:"" json:"site_url"`
	// 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    []SourceMicrosoftSharepointFileBasedStreamConfig `json:"streams"`
	sourceType MicrosoftSharepoint                              `const:"microsoft-sharepoint" json:"sourceType"`
}

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

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

func (o *SourceMicrosoftSharepoint) GetCredentials() SourceMicrosoftSharepointAuthentication {
	if o == nil {
		return SourceMicrosoftSharepointAuthentication{}
	}
	return o.Credentials
}

func (o *SourceMicrosoftSharepoint) GetDeliveryMethod() *SourceMicrosoftSharepointDeliveryMethod {
	if o == nil {
		return nil
	}
	return o.DeliveryMethod
}

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

func (o *SourceMicrosoftSharepoint) GetSearchScope() *SourceMicrosoftSharepointSearchScope {
	if o == nil {
		return nil
	}
	return o.SearchScope
}

func (o *SourceMicrosoftSharepoint) GetSiteURL() *string {
	if o == nil {
		return nil
	}
	return o.SiteURL
}

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

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

func (o *SourceMicrosoftSharepoint) GetSourceType() MicrosoftSharepoint {
	return MicrosoftSharepointMicrosoftSharepoint
}
