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

// FileFormat - The Format of the file which should be replicated (Warning: some formats may be experimental, please refer to the docs).
type FileFormat string

const (
	FileFormatCsv         FileFormat = "csv"
	FileFormatJSON        FileFormat = "json"
	FileFormatJsonl       FileFormat = "jsonl"
	FileFormatExcel       FileFormat = "excel"
	FileFormatExcelBinary FileFormat = "excel_binary"
	FileFormatFwf         FileFormat = "fwf"
	FileFormatFeather     FileFormat = "feather"
	FileFormatParquet     FileFormat = "parquet"
	FileFormatYaml        FileFormat = "yaml"
)

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

// SourceFileSchemasProviderStorageProvider8Storage - WARNING: Note that the local storage URL available for reading must start with the local mount "/local/" at the moment until we implement more advanced docker mounting options.
type SourceFileSchemasProviderStorageProvider8Storage string

const (
	SourceFileSchemasProviderStorageProvider8StorageLocal SourceFileSchemasProviderStorageProvider8Storage = "local"
)

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

type LocalFilesystemLimited struct {
	// WARNING: Note that the local storage URL available for reading must start with the local mount "/local/" at the moment until we implement more advanced docker mounting options.
	storage SourceFileSchemasProviderStorageProvider8Storage `const:"local" json:"storage"`
}

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

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

func (o *LocalFilesystemLimited) GetStorage() SourceFileSchemasProviderStorageProvider8Storage {
	return SourceFileSchemasProviderStorageProvider8StorageLocal
}

type SourceFileSchemasProviderStorageProvider7Storage string

const (
	SourceFileSchemasProviderStorageProvider7StorageSftp SourceFileSchemasProviderStorageProvider7Storage = "SFTP"
)

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

type SFTPSecureFileTransferProtocol struct {
	Host     string                                           `json:"host"`
	Password *string                                          `json:"password,omitempty"`
	Port     *string                                          `default:"22" json:"port"`
	storage  SourceFileSchemasProviderStorageProvider7Storage `const:"SFTP" json:"storage"`
	User     string                                           `json:"user"`
}

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

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

func (o *SFTPSecureFileTransferProtocol) GetHost() string {
	if o == nil {
		return ""
	}
	return o.Host
}

func (o *SFTPSecureFileTransferProtocol) GetPassword() *string {
	if o == nil {
		return nil
	}
	return o.Password
}

func (o *SFTPSecureFileTransferProtocol) GetPort() *string {
	if o == nil {
		return nil
	}
	return o.Port
}

func (o *SFTPSecureFileTransferProtocol) GetStorage() SourceFileSchemasProviderStorageProvider7Storage {
	return SourceFileSchemasProviderStorageProvider7StorageSftp
}

func (o *SFTPSecureFileTransferProtocol) GetUser() string {
	if o == nil {
		return ""
	}
	return o.User
}

type SourceFileSchemasProviderStorageProvider6Storage string

const (
	SourceFileSchemasProviderStorageProvider6StorageScp SourceFileSchemasProviderStorageProvider6Storage = "SCP"
)

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

type SCPSecureCopyProtocol struct {
	Host     string                                           `json:"host"`
	Password *string                                          `json:"password,omitempty"`
	Port     *string                                          `default:"22" json:"port"`
	storage  SourceFileSchemasProviderStorageProvider6Storage `const:"SCP" json:"storage"`
	User     string                                           `json:"user"`
}

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

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

func (o *SCPSecureCopyProtocol) GetHost() string {
	if o == nil {
		return ""
	}
	return o.Host
}

func (o *SCPSecureCopyProtocol) GetPassword() *string {
	if o == nil {
		return nil
	}
	return o.Password
}

func (o *SCPSecureCopyProtocol) GetPort() *string {
	if o == nil {
		return nil
	}
	return o.Port
}

func (o *SCPSecureCopyProtocol) GetStorage() SourceFileSchemasProviderStorageProvider6Storage {
	return SourceFileSchemasProviderStorageProvider6StorageScp
}

func (o *SCPSecureCopyProtocol) GetUser() string {
	if o == nil {
		return ""
	}
	return o.User
}

type SourceFileSchemasProviderStorageProviderStorage string

const (
	SourceFileSchemasProviderStorageProviderStorageSSH SourceFileSchemasProviderStorageProviderStorage = "SSH"
)

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

type SSHSecureShell struct {
	Host     string                                          `json:"host"`
	Password *string                                         `json:"password,omitempty"`
	Port     *string                                         `default:"22" json:"port"`
	storage  SourceFileSchemasProviderStorageProviderStorage `const:"SSH" json:"storage"`
	User     string                                          `json:"user"`
}

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

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

func (o *SSHSecureShell) GetHost() string {
	if o == nil {
		return ""
	}
	return o.Host
}

func (o *SSHSecureShell) GetPassword() *string {
	if o == nil {
		return nil
	}
	return o.Password
}

func (o *SSHSecureShell) GetPort() *string {
	if o == nil {
		return nil
	}
	return o.Port
}

func (o *SSHSecureShell) GetStorage() SourceFileSchemasProviderStorageProviderStorage {
	return SourceFileSchemasProviderStorageProviderStorageSSH
}

func (o *SSHSecureShell) GetUser() string {
	if o == nil {
		return ""
	}
	return o.User
}

type SourceFileSchemasProviderStorage string

const (
	SourceFileSchemasProviderStorageAzBlob SourceFileSchemasProviderStorage = "AzBlob"
)

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

type AzBlobAzureBlobStorage struct {
	// To access Azure Blob Storage, this connector would need credentials with the proper permissions. One option is a SAS (Shared Access Signature) token. If accessing publicly available data, this field is not necessary.
	SasToken *string `json:"sas_token,omitempty"`
	// To access Azure Blob Storage, this connector would need credentials with the proper permissions. One option is a storage account shared key (aka account key or access key). If accessing publicly available data, this field is not necessary.
	SharedKey *string                          `json:"shared_key,omitempty"`
	storage   SourceFileSchemasProviderStorage `const:"AzBlob" json:"storage"`
	// The globally unique name of the storage account that the desired blob sits within. See <a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-account-overview" target="_blank">here</a> for more details.
	StorageAccount string `json:"storage_account"`
}

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

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

func (o *AzBlobAzureBlobStorage) GetSasToken() *string {
	if o == nil {
		return nil
	}
	return o.SasToken
}

func (o *AzBlobAzureBlobStorage) GetSharedKey() *string {
	if o == nil {
		return nil
	}
	return o.SharedKey
}

func (o *AzBlobAzureBlobStorage) GetStorage() SourceFileSchemasProviderStorage {
	return SourceFileSchemasProviderStorageAzBlob
}

func (o *AzBlobAzureBlobStorage) GetStorageAccount() string {
	if o == nil {
		return ""
	}
	return o.StorageAccount
}

type SourceFileSchemasStorage string

const (
	SourceFileSchemasStorageS3 SourceFileSchemasStorage = "S3"
)

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

type S3AmazonWebServices struct {
	// In order to access private Buckets stored on AWS S3, this connector would need credentials with the proper permissions. If accessing publicly available data, this field is not necessary.
	AwsAccessKeyID *string `json:"aws_access_key_id,omitempty"`
	// In order to access private Buckets stored on AWS S3, this connector would need credentials with the proper permissions. If accessing publicly available data, this field is not necessary.
	AwsSecretAccessKey *string                  `json:"aws_secret_access_key,omitempty"`
	storage            SourceFileSchemasStorage `const:"S3" json:"storage"`
}

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

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

func (o *S3AmazonWebServices) GetAwsAccessKeyID() *string {
	if o == nil {
		return nil
	}
	return o.AwsAccessKeyID
}

func (o *S3AmazonWebServices) GetAwsSecretAccessKey() *string {
	if o == nil {
		return nil
	}
	return o.AwsSecretAccessKey
}

func (o *S3AmazonWebServices) GetStorage() SourceFileSchemasStorage {
	return SourceFileSchemasStorageS3
}

type SourceFileStorage string

const (
	SourceFileStorageGcs SourceFileStorage = "GCS"
)

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

type GCSGoogleCloudStorage struct {
	// In order to access private Buckets stored on Google Cloud, this connector would need a service account json credentials with the proper permissions as described <a href="https://cloud.google.com/iam/docs/service-accounts" target="_blank">here</a>. Please generate the credentials.json file and copy/paste its content to this field (expecting JSON formats). If accessing publicly available data, this field is not necessary.
	ServiceAccountJSON *string           `json:"service_account_json,omitempty"`
	storage            SourceFileStorage `const:"GCS" json:"storage"`
}

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

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

func (o *GCSGoogleCloudStorage) GetServiceAccountJSON() *string {
	if o == nil {
		return nil
	}
	return o.ServiceAccountJSON
}

func (o *GCSGoogleCloudStorage) GetStorage() SourceFileStorage {
	return SourceFileStorageGcs
}

type Storage string

const (
	StorageHTTPS Storage = "HTTPS"
)

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

type HTTPSPublicWeb struct {
	storage Storage `const:"HTTPS" json:"storage"`
	// Add User-Agent to request
	UserAgent *bool `default:"false" json:"user_agent"`
}

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

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

func (o *HTTPSPublicWeb) GetStorage() Storage {
	return StorageHTTPS
}

func (o *HTTPSPublicWeb) GetUserAgent() *bool {
	if o == nil {
		return nil
	}
	return o.UserAgent
}

type StorageProviderType string

const (
	StorageProviderTypeHTTPSPublicWeb                 StorageProviderType = "HTTPS: Public Web"
	StorageProviderTypeGCSGoogleCloudStorage          StorageProviderType = "GCS: Google Cloud Storage"
	StorageProviderTypeS3AmazonWebServices            StorageProviderType = "S3: Amazon Web Services"
	StorageProviderTypeAzBlobAzureBlobStorage         StorageProviderType = "AzBlob: Azure Blob Storage"
	StorageProviderTypeSSHSecureShell                 StorageProviderType = "SSH: Secure Shell"
	StorageProviderTypeSCPSecureCopyProtocol          StorageProviderType = "SCP: Secure copy protocol"
	StorageProviderTypeSFTPSecureFileTransferProtocol StorageProviderType = "SFTP: Secure File Transfer Protocol"
	StorageProviderTypeLocalFilesystemLimited         StorageProviderType = "Local Filesystem (limited)"
)

// StorageProvider - The storage Provider or Location of the file(s) which should be replicated.
type StorageProvider struct {
	HTTPSPublicWeb                 *HTTPSPublicWeb                 `queryParam:"inline"`
	GCSGoogleCloudStorage          *GCSGoogleCloudStorage          `queryParam:"inline"`
	S3AmazonWebServices            *S3AmazonWebServices            `queryParam:"inline"`
	AzBlobAzureBlobStorage         *AzBlobAzureBlobStorage         `queryParam:"inline"`
	SSHSecureShell                 *SSHSecureShell                 `queryParam:"inline"`
	SCPSecureCopyProtocol          *SCPSecureCopyProtocol          `queryParam:"inline"`
	SFTPSecureFileTransferProtocol *SFTPSecureFileTransferProtocol `queryParam:"inline"`
	LocalFilesystemLimited         *LocalFilesystemLimited         `queryParam:"inline"`

	Type StorageProviderType
}

func CreateStorageProviderHTTPSPublicWeb(httpsPublicWeb HTTPSPublicWeb) StorageProvider {
	typ := StorageProviderTypeHTTPSPublicWeb

	return StorageProvider{
		HTTPSPublicWeb: &httpsPublicWeb,
		Type:           typ,
	}
}

func CreateStorageProviderGCSGoogleCloudStorage(gcsGoogleCloudStorage GCSGoogleCloudStorage) StorageProvider {
	typ := StorageProviderTypeGCSGoogleCloudStorage

	return StorageProvider{
		GCSGoogleCloudStorage: &gcsGoogleCloudStorage,
		Type:                  typ,
	}
}

func CreateStorageProviderS3AmazonWebServices(s3AmazonWebServices S3AmazonWebServices) StorageProvider {
	typ := StorageProviderTypeS3AmazonWebServices

	return StorageProvider{
		S3AmazonWebServices: &s3AmazonWebServices,
		Type:                typ,
	}
}

func CreateStorageProviderAzBlobAzureBlobStorage(azBlobAzureBlobStorage AzBlobAzureBlobStorage) StorageProvider {
	typ := StorageProviderTypeAzBlobAzureBlobStorage

	return StorageProvider{
		AzBlobAzureBlobStorage: &azBlobAzureBlobStorage,
		Type:                   typ,
	}
}

func CreateStorageProviderSSHSecureShell(sshSecureShell SSHSecureShell) StorageProvider {
	typ := StorageProviderTypeSSHSecureShell

	return StorageProvider{
		SSHSecureShell: &sshSecureShell,
		Type:           typ,
	}
}

func CreateStorageProviderSCPSecureCopyProtocol(scpSecureCopyProtocol SCPSecureCopyProtocol) StorageProvider {
	typ := StorageProviderTypeSCPSecureCopyProtocol

	return StorageProvider{
		SCPSecureCopyProtocol: &scpSecureCopyProtocol,
		Type:                  typ,
	}
}

func CreateStorageProviderSFTPSecureFileTransferProtocol(sftpSecureFileTransferProtocol SFTPSecureFileTransferProtocol) StorageProvider {
	typ := StorageProviderTypeSFTPSecureFileTransferProtocol

	return StorageProvider{
		SFTPSecureFileTransferProtocol: &sftpSecureFileTransferProtocol,
		Type:                           typ,
	}
}

func CreateStorageProviderLocalFilesystemLimited(localFilesystemLimited LocalFilesystemLimited) StorageProvider {
	typ := StorageProviderTypeLocalFilesystemLimited

	return StorageProvider{
		LocalFilesystemLimited: &localFilesystemLimited,
		Type:                   typ,
	}
}

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

	var localFilesystemLimited LocalFilesystemLimited = LocalFilesystemLimited{}
	if err := utils.UnmarshalJSON(data, &localFilesystemLimited, "", true, true); err == nil {
		u.LocalFilesystemLimited = &localFilesystemLimited
		u.Type = StorageProviderTypeLocalFilesystemLimited
		return nil
	}

	var httpsPublicWeb HTTPSPublicWeb = HTTPSPublicWeb{}
	if err := utils.UnmarshalJSON(data, &httpsPublicWeb, "", true, true); err == nil {
		u.HTTPSPublicWeb = &httpsPublicWeb
		u.Type = StorageProviderTypeHTTPSPublicWeb
		return nil
	}

	var gcsGoogleCloudStorage GCSGoogleCloudStorage = GCSGoogleCloudStorage{}
	if err := utils.UnmarshalJSON(data, &gcsGoogleCloudStorage, "", true, true); err == nil {
		u.GCSGoogleCloudStorage = &gcsGoogleCloudStorage
		u.Type = StorageProviderTypeGCSGoogleCloudStorage
		return nil
	}

	var s3AmazonWebServices S3AmazonWebServices = S3AmazonWebServices{}
	if err := utils.UnmarshalJSON(data, &s3AmazonWebServices, "", true, true); err == nil {
		u.S3AmazonWebServices = &s3AmazonWebServices
		u.Type = StorageProviderTypeS3AmazonWebServices
		return nil
	}

	var azBlobAzureBlobStorage AzBlobAzureBlobStorage = AzBlobAzureBlobStorage{}
	if err := utils.UnmarshalJSON(data, &azBlobAzureBlobStorage, "", true, true); err == nil {
		u.AzBlobAzureBlobStorage = &azBlobAzureBlobStorage
		u.Type = StorageProviderTypeAzBlobAzureBlobStorage
		return nil
	}

	var sshSecureShell SSHSecureShell = SSHSecureShell{}
	if err := utils.UnmarshalJSON(data, &sshSecureShell, "", true, true); err == nil {
		u.SSHSecureShell = &sshSecureShell
		u.Type = StorageProviderTypeSSHSecureShell
		return nil
	}

	var scpSecureCopyProtocol SCPSecureCopyProtocol = SCPSecureCopyProtocol{}
	if err := utils.UnmarshalJSON(data, &scpSecureCopyProtocol, "", true, true); err == nil {
		u.SCPSecureCopyProtocol = &scpSecureCopyProtocol
		u.Type = StorageProviderTypeSCPSecureCopyProtocol
		return nil
	}

	var sftpSecureFileTransferProtocol SFTPSecureFileTransferProtocol = SFTPSecureFileTransferProtocol{}
	if err := utils.UnmarshalJSON(data, &sftpSecureFileTransferProtocol, "", true, true); err == nil {
		u.SFTPSecureFileTransferProtocol = &sftpSecureFileTransferProtocol
		u.Type = StorageProviderTypeSFTPSecureFileTransferProtocol
		return nil
	}

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

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

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

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

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

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

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

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

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

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

type File string

const (
	FileFile File = "file"
)

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

type SourceFile struct {
	// The Name of the final table to replicate this file into (should include letters, numbers dash and underscores only).
	DatasetName string `json:"dataset_name"`
	// The Format of the file which should be replicated (Warning: some formats may be experimental, please refer to the docs).
	Format *FileFormat `default:"csv" json:"format"`
	// The storage Provider or Location of the file(s) which should be replicated.
	Provider StorageProvider `json:"provider"`
	// This should be a string in JSON format. It depends on the chosen file format to provide additional options and tune its behavior.
	ReaderOptions *string `json:"reader_options,omitempty"`
	// The URL path to access the file which should be replicated.
	URL        string `json:"url"`
	sourceType File   `const:"file" json:"sourceType"`
}

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

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

func (o *SourceFile) GetDatasetName() string {
	if o == nil {
		return ""
	}
	return o.DatasetName
}

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

func (o *SourceFile) GetProvider() StorageProvider {
	if o == nil {
		return StorageProvider{}
	}
	return o.Provider
}

func (o *SourceFile) GetReaderOptions() *string {
	if o == nil {
		return nil
	}
	return o.ReaderOptions
}

func (o *SourceFile) GetURL() string {
	if o == nil {
		return ""
	}
	return o.URL
}

func (o *SourceFile) GetSourceType() File {
	return FileFile
}
