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

package provider

import (
	tfTypes "github.com/airbytehq/terraform-provider-airbyte/internal/provider/types"
	"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/models/shared"
	"github.com/hashicorp/terraform-plugin-framework/types"
	"time"
)

func (r *SourceAzureBlobStorageResourceModel) ToSharedSourceAzureBlobStorageCreateRequest() *shared.SourceAzureBlobStorageCreateRequest {
	var name string
	name = r.Name.ValueString()

	definitionID := new(string)
	if !r.DefinitionID.IsUnknown() && !r.DefinitionID.IsNull() {
		*definitionID = r.DefinitionID.ValueString()
	} else {
		definitionID = nil
	}
	var workspaceID string
	workspaceID = r.WorkspaceID.ValueString()

	var azureBlobStorageAccountName string
	azureBlobStorageAccountName = r.Configuration.AzureBlobStorageAccountName.ValueString()

	var azureBlobStorageContainerName string
	azureBlobStorageContainerName = r.Configuration.AzureBlobStorageContainerName.ValueString()

	azureBlobStorageEndpoint := new(string)
	if !r.Configuration.AzureBlobStorageEndpoint.IsUnknown() && !r.Configuration.AzureBlobStorageEndpoint.IsNull() {
		*azureBlobStorageEndpoint = r.Configuration.AzureBlobStorageEndpoint.ValueString()
	} else {
		azureBlobStorageEndpoint = nil
	}
	var credentials shared.SourceAzureBlobStorageAuthentication
	var authenticateViaOauth2 *shared.AuthenticateViaOauth2
	if r.Configuration.Credentials.AuthenticateViaOauth2 != nil {
		var clientID string
		clientID = r.Configuration.Credentials.AuthenticateViaOauth2.ClientID.ValueString()

		var clientSecret string
		clientSecret = r.Configuration.Credentials.AuthenticateViaOauth2.ClientSecret.ValueString()

		var refreshToken string
		refreshToken = r.Configuration.Credentials.AuthenticateViaOauth2.RefreshToken.ValueString()

		var tenantID string
		tenantID = r.Configuration.Credentials.AuthenticateViaOauth2.TenantID.ValueString()

		authenticateViaOauth2 = &shared.AuthenticateViaOauth2{
			ClientID:     clientID,
			ClientSecret: clientSecret,
			RefreshToken: refreshToken,
			TenantID:     tenantID,
		}
	}
	if authenticateViaOauth2 != nil {
		credentials = shared.SourceAzureBlobStorageAuthentication{
			AuthenticateViaOauth2: authenticateViaOauth2,
		}
	}
	var authenticateViaClientCredentials *shared.AuthenticateViaClientCredentials
	if r.Configuration.Credentials.AuthenticateViaClientCredentials != nil {
		var appClientID string
		appClientID = r.Configuration.Credentials.AuthenticateViaClientCredentials.AppClientID.ValueString()

		var appClientSecret string
		appClientSecret = r.Configuration.Credentials.AuthenticateViaClientCredentials.AppClientSecret.ValueString()

		var appTenantID string
		appTenantID = r.Configuration.Credentials.AuthenticateViaClientCredentials.AppTenantID.ValueString()

		authenticateViaClientCredentials = &shared.AuthenticateViaClientCredentials{
			AppClientID:     appClientID,
			AppClientSecret: appClientSecret,
			AppTenantID:     appTenantID,
		}
	}
	if authenticateViaClientCredentials != nil {
		credentials = shared.SourceAzureBlobStorageAuthentication{
			AuthenticateViaClientCredentials: authenticateViaClientCredentials,
		}
	}
	var authenticateViaStorageAccountKey *shared.AuthenticateViaStorageAccountKey
	if r.Configuration.Credentials.AuthenticateViaStorageAccountKey != nil {
		var azureBlobStorageAccountKey string
		azureBlobStorageAccountKey = r.Configuration.Credentials.AuthenticateViaStorageAccountKey.AzureBlobStorageAccountKey.ValueString()

		authenticateViaStorageAccountKey = &shared.AuthenticateViaStorageAccountKey{
			AzureBlobStorageAccountKey: azureBlobStorageAccountKey,
		}
	}
	if authenticateViaStorageAccountKey != nil {
		credentials = shared.SourceAzureBlobStorageAuthentication{
			AuthenticateViaStorageAccountKey: authenticateViaStorageAccountKey,
		}
	}
	startDate := new(time.Time)
	if !r.Configuration.StartDate.IsUnknown() && !r.Configuration.StartDate.IsNull() {
		*startDate, _ = time.Parse(time.RFC3339Nano, r.Configuration.StartDate.ValueString())
	} else {
		startDate = nil
	}
	var streams []shared.FileBasedStreamConfig = []shared.FileBasedStreamConfig{}
	for _, streamsItem := range r.Configuration.Streams {
		daysToSyncIfHistoryIsFull := new(int64)
		if !streamsItem.DaysToSyncIfHistoryIsFull.IsUnknown() && !streamsItem.DaysToSyncIfHistoryIsFull.IsNull() {
			*daysToSyncIfHistoryIsFull = streamsItem.DaysToSyncIfHistoryIsFull.ValueInt64()
		} else {
			daysToSyncIfHistoryIsFull = nil
		}
		var format shared.Format
		var avroFormat *shared.AvroFormat
		if streamsItem.Format.AvroFormat != nil {
			doubleAsString := new(bool)
			if !streamsItem.Format.AvroFormat.DoubleAsString.IsUnknown() && !streamsItem.Format.AvroFormat.DoubleAsString.IsNull() {
				*doubleAsString = streamsItem.Format.AvroFormat.DoubleAsString.ValueBool()
			} else {
				doubleAsString = nil
			}
			avroFormat = &shared.AvroFormat{
				DoubleAsString: doubleAsString,
			}
		}
		if avroFormat != nil {
			format = shared.Format{
				AvroFormat: avroFormat,
			}
		}
		var csvFormat *shared.CSVFormat
		if streamsItem.Format.CSVFormat != nil {
			delimiter := new(string)
			if !streamsItem.Format.CSVFormat.Delimiter.IsUnknown() && !streamsItem.Format.CSVFormat.Delimiter.IsNull() {
				*delimiter = streamsItem.Format.CSVFormat.Delimiter.ValueString()
			} else {
				delimiter = nil
			}
			doubleQuote := new(bool)
			if !streamsItem.Format.CSVFormat.DoubleQuote.IsUnknown() && !streamsItem.Format.CSVFormat.DoubleQuote.IsNull() {
				*doubleQuote = streamsItem.Format.CSVFormat.DoubleQuote.ValueBool()
			} else {
				doubleQuote = nil
			}
			encoding := new(string)
			if !streamsItem.Format.CSVFormat.Encoding.IsUnknown() && !streamsItem.Format.CSVFormat.Encoding.IsNull() {
				*encoding = streamsItem.Format.CSVFormat.Encoding.ValueString()
			} else {
				encoding = nil
			}
			escapeChar := new(string)
			if !streamsItem.Format.CSVFormat.EscapeChar.IsUnknown() && !streamsItem.Format.CSVFormat.EscapeChar.IsNull() {
				*escapeChar = streamsItem.Format.CSVFormat.EscapeChar.ValueString()
			} else {
				escapeChar = nil
			}
			var falseValues []string = []string{}
			for _, falseValuesItem := range streamsItem.Format.CSVFormat.FalseValues {
				falseValues = append(falseValues, falseValuesItem.ValueString())
			}
			var headerDefinition *shared.CSVHeaderDefinition
			if streamsItem.Format.CSVFormat.HeaderDefinition != nil {
				var fromCSV *shared.FromCSV
				if streamsItem.Format.CSVFormat.HeaderDefinition.FromCSV != nil {
					fromCSV = &shared.FromCSV{}
				}
				if fromCSV != nil {
					headerDefinition = &shared.CSVHeaderDefinition{
						FromCSV: fromCSV,
					}
				}
				var autogenerated *shared.Autogenerated
				if streamsItem.Format.CSVFormat.HeaderDefinition.Autogenerated != nil {
					autogenerated = &shared.Autogenerated{}
				}
				if autogenerated != nil {
					headerDefinition = &shared.CSVHeaderDefinition{
						Autogenerated: autogenerated,
					}
				}
				var userProvided *shared.UserProvided
				if streamsItem.Format.CSVFormat.HeaderDefinition.UserProvided != nil {
					var columnNames []string = []string{}
					for _, columnNamesItem := range streamsItem.Format.CSVFormat.HeaderDefinition.UserProvided.ColumnNames {
						columnNames = append(columnNames, columnNamesItem.ValueString())
					}
					userProvided = &shared.UserProvided{
						ColumnNames: columnNames,
					}
				}
				if userProvided != nil {
					headerDefinition = &shared.CSVHeaderDefinition{
						UserProvided: userProvided,
					}
				}
			}
			ignoreErrorsOnFieldsMismatch := new(bool)
			if !streamsItem.Format.CSVFormat.IgnoreErrorsOnFieldsMismatch.IsUnknown() && !streamsItem.Format.CSVFormat.IgnoreErrorsOnFieldsMismatch.IsNull() {
				*ignoreErrorsOnFieldsMismatch = streamsItem.Format.CSVFormat.IgnoreErrorsOnFieldsMismatch.ValueBool()
			} else {
				ignoreErrorsOnFieldsMismatch = nil
			}
			var nullValues []string = []string{}
			for _, nullValuesItem := range streamsItem.Format.CSVFormat.NullValues {
				nullValues = append(nullValues, nullValuesItem.ValueString())
			}
			quoteChar := new(string)
			if !streamsItem.Format.CSVFormat.QuoteChar.IsUnknown() && !streamsItem.Format.CSVFormat.QuoteChar.IsNull() {
				*quoteChar = streamsItem.Format.CSVFormat.QuoteChar.ValueString()
			} else {
				quoteChar = nil
			}
			skipRowsAfterHeader := new(int64)
			if !streamsItem.Format.CSVFormat.SkipRowsAfterHeader.IsUnknown() && !streamsItem.Format.CSVFormat.SkipRowsAfterHeader.IsNull() {
				*skipRowsAfterHeader = streamsItem.Format.CSVFormat.SkipRowsAfterHeader.ValueInt64()
			} else {
				skipRowsAfterHeader = nil
			}
			skipRowsBeforeHeader := new(int64)
			if !streamsItem.Format.CSVFormat.SkipRowsBeforeHeader.IsUnknown() && !streamsItem.Format.CSVFormat.SkipRowsBeforeHeader.IsNull() {
				*skipRowsBeforeHeader = streamsItem.Format.CSVFormat.SkipRowsBeforeHeader.ValueInt64()
			} else {
				skipRowsBeforeHeader = nil
			}
			stringsCanBeNull := new(bool)
			if !streamsItem.Format.CSVFormat.StringsCanBeNull.IsUnknown() && !streamsItem.Format.CSVFormat.StringsCanBeNull.IsNull() {
				*stringsCanBeNull = streamsItem.Format.CSVFormat.StringsCanBeNull.ValueBool()
			} else {
				stringsCanBeNull = nil
			}
			var trueValues []string = []string{}
			for _, trueValuesItem := range streamsItem.Format.CSVFormat.TrueValues {
				trueValues = append(trueValues, trueValuesItem.ValueString())
			}
			csvFormat = &shared.CSVFormat{
				Delimiter:                    delimiter,
				DoubleQuote:                  doubleQuote,
				Encoding:                     encoding,
				EscapeChar:                   escapeChar,
				FalseValues:                  falseValues,
				HeaderDefinition:             headerDefinition,
				IgnoreErrorsOnFieldsMismatch: ignoreErrorsOnFieldsMismatch,
				NullValues:                   nullValues,
				QuoteChar:                    quoteChar,
				SkipRowsAfterHeader:          skipRowsAfterHeader,
				SkipRowsBeforeHeader:         skipRowsBeforeHeader,
				StringsCanBeNull:             stringsCanBeNull,
				TrueValues:                   trueValues,
			}
		}
		if csvFormat != nil {
			format = shared.Format{
				CSVFormat: csvFormat,
			}
		}
		var jsonlFormat *shared.JsonlFormat
		if streamsItem.Format.JsonlFormat != nil {
			jsonlFormat = &shared.JsonlFormat{}
		}
		if jsonlFormat != nil {
			format = shared.Format{
				JsonlFormat: jsonlFormat,
			}
		}
		var parquetFormat *shared.ParquetFormat
		if streamsItem.Format.ParquetFormat != nil {
			decimalAsFloat := new(bool)
			if !streamsItem.Format.ParquetFormat.DecimalAsFloat.IsUnknown() && !streamsItem.Format.ParquetFormat.DecimalAsFloat.IsNull() {
				*decimalAsFloat = streamsItem.Format.ParquetFormat.DecimalAsFloat.ValueBool()
			} else {
				decimalAsFloat = nil
			}
			parquetFormat = &shared.ParquetFormat{
				DecimalAsFloat: decimalAsFloat,
			}
		}
		if parquetFormat != nil {
			format = shared.Format{
				ParquetFormat: parquetFormat,
			}
		}
		var unstructuredDocumentFormat *shared.UnstructuredDocumentFormat
		if streamsItem.Format.UnstructuredDocumentFormat != nil {
			var processing *shared.Processing
			if streamsItem.Format.UnstructuredDocumentFormat.Processing != nil {
				var local *shared.Local
				if streamsItem.Format.UnstructuredDocumentFormat.Processing.Local != nil {
					local = &shared.Local{}
				}
				if local != nil {
					processing = &shared.Processing{
						Local: local,
					}
				}
			}
			skipUnprocessableFiles := new(bool)
			if !streamsItem.Format.UnstructuredDocumentFormat.SkipUnprocessableFiles.IsUnknown() && !streamsItem.Format.UnstructuredDocumentFormat.SkipUnprocessableFiles.IsNull() {
				*skipUnprocessableFiles = streamsItem.Format.UnstructuredDocumentFormat.SkipUnprocessableFiles.ValueBool()
			} else {
				skipUnprocessableFiles = nil
			}
			strategy := new(shared.ParsingStrategy)
			if !streamsItem.Format.UnstructuredDocumentFormat.Strategy.IsUnknown() && !streamsItem.Format.UnstructuredDocumentFormat.Strategy.IsNull() {
				*strategy = shared.ParsingStrategy(streamsItem.Format.UnstructuredDocumentFormat.Strategy.ValueString())
			} else {
				strategy = nil
			}
			unstructuredDocumentFormat = &shared.UnstructuredDocumentFormat{
				Processing:             processing,
				SkipUnprocessableFiles: skipUnprocessableFiles,
				Strategy:               strategy,
			}
		}
		if unstructuredDocumentFormat != nil {
			format = shared.Format{
				UnstructuredDocumentFormat: unstructuredDocumentFormat,
			}
		}
		var globs []string = []string{}
		for _, globsItem := range streamsItem.Globs {
			globs = append(globs, globsItem.ValueString())
		}
		inputSchema := new(string)
		if !streamsItem.InputSchema.IsUnknown() && !streamsItem.InputSchema.IsNull() {
			*inputSchema = streamsItem.InputSchema.ValueString()
		} else {
			inputSchema = nil
		}
		var name1 string
		name1 = streamsItem.Name.ValueString()

		recentNFilesToReadForSchemaDiscovery := new(int64)
		if !streamsItem.RecentNFilesToReadForSchemaDiscovery.IsUnknown() && !streamsItem.RecentNFilesToReadForSchemaDiscovery.IsNull() {
			*recentNFilesToReadForSchemaDiscovery = streamsItem.RecentNFilesToReadForSchemaDiscovery.ValueInt64()
		} else {
			recentNFilesToReadForSchemaDiscovery = nil
		}
		schemaless := new(bool)
		if !streamsItem.Schemaless.IsUnknown() && !streamsItem.Schemaless.IsNull() {
			*schemaless = streamsItem.Schemaless.ValueBool()
		} else {
			schemaless = nil
		}
		validationPolicy := new(shared.ValidationPolicy)
		if !streamsItem.ValidationPolicy.IsUnknown() && !streamsItem.ValidationPolicy.IsNull() {
			*validationPolicy = shared.ValidationPolicy(streamsItem.ValidationPolicy.ValueString())
		} else {
			validationPolicy = nil
		}
		streams = append(streams, shared.FileBasedStreamConfig{
			DaysToSyncIfHistoryIsFull:            daysToSyncIfHistoryIsFull,
			Format:                               format,
			Globs:                                globs,
			InputSchema:                          inputSchema,
			Name:                                 name1,
			RecentNFilesToReadForSchemaDiscovery: recentNFilesToReadForSchemaDiscovery,
			Schemaless:                           schemaless,
			ValidationPolicy:                     validationPolicy,
		})
	}
	configuration := shared.SourceAzureBlobStorage{
		AzureBlobStorageAccountName:   azureBlobStorageAccountName,
		AzureBlobStorageContainerName: azureBlobStorageContainerName,
		AzureBlobStorageEndpoint:      azureBlobStorageEndpoint,
		Credentials:                   credentials,
		StartDate:                     startDate,
		Streams:                       streams,
	}
	secretID := new(string)
	if !r.SecretID.IsUnknown() && !r.SecretID.IsNull() {
		*secretID = r.SecretID.ValueString()
	} else {
		secretID = nil
	}
	out := shared.SourceAzureBlobStorageCreateRequest{
		Name:          name,
		DefinitionID:  definitionID,
		WorkspaceID:   workspaceID,
		Configuration: configuration,
		SecretID:      secretID,
	}
	return &out
}

func (r *SourceAzureBlobStorageResourceModel) RefreshFromSharedSourceResponse(resp *shared.SourceResponse) {
	if resp != nil {
		r.CreatedAt = types.Int64Value(resp.CreatedAt)
		r.DefinitionID = types.StringValue(resp.DefinitionID)
		r.Name = types.StringValue(resp.Name)
		if resp.ResourceAllocation == nil {
			r.ResourceAllocation = nil
		} else {
			r.ResourceAllocation = &tfTypes.ScopedResourceRequirements{}
			if resp.ResourceAllocation.Default == nil {
				r.ResourceAllocation.Default = nil
			} else {
				r.ResourceAllocation.Default = &tfTypes.ResourceRequirements{}
				r.ResourceAllocation.Default.CPULimit = types.StringPointerValue(resp.ResourceAllocation.Default.CPULimit)
				r.ResourceAllocation.Default.CPURequest = types.StringPointerValue(resp.ResourceAllocation.Default.CPURequest)
				r.ResourceAllocation.Default.EphemeralStorageLimit = types.StringPointerValue(resp.ResourceAllocation.Default.EphemeralStorageLimit)
				r.ResourceAllocation.Default.EphemeralStorageRequest = types.StringPointerValue(resp.ResourceAllocation.Default.EphemeralStorageRequest)
				r.ResourceAllocation.Default.MemoryLimit = types.StringPointerValue(resp.ResourceAllocation.Default.MemoryLimit)
				r.ResourceAllocation.Default.MemoryRequest = types.StringPointerValue(resp.ResourceAllocation.Default.MemoryRequest)
			}
			r.ResourceAllocation.JobSpecific = []tfTypes.JobTypeResourceLimit{}
			if len(r.ResourceAllocation.JobSpecific) > len(resp.ResourceAllocation.JobSpecific) {
				r.ResourceAllocation.JobSpecific = r.ResourceAllocation.JobSpecific[:len(resp.ResourceAllocation.JobSpecific)]
			}
			for jobSpecificCount, jobSpecificItem := range resp.ResourceAllocation.JobSpecific {
				var jobSpecific1 tfTypes.JobTypeResourceLimit
				jobSpecific1.JobType = types.StringValue(string(jobSpecificItem.JobType))
				jobSpecific1.ResourceRequirements.CPULimit = types.StringPointerValue(jobSpecificItem.ResourceRequirements.CPULimit)
				jobSpecific1.ResourceRequirements.CPURequest = types.StringPointerValue(jobSpecificItem.ResourceRequirements.CPURequest)
				jobSpecific1.ResourceRequirements.EphemeralStorageLimit = types.StringPointerValue(jobSpecificItem.ResourceRequirements.EphemeralStorageLimit)
				jobSpecific1.ResourceRequirements.EphemeralStorageRequest = types.StringPointerValue(jobSpecificItem.ResourceRequirements.EphemeralStorageRequest)
				jobSpecific1.ResourceRequirements.MemoryLimit = types.StringPointerValue(jobSpecificItem.ResourceRequirements.MemoryLimit)
				jobSpecific1.ResourceRequirements.MemoryRequest = types.StringPointerValue(jobSpecificItem.ResourceRequirements.MemoryRequest)
				if jobSpecificCount+1 > len(r.ResourceAllocation.JobSpecific) {
					r.ResourceAllocation.JobSpecific = append(r.ResourceAllocation.JobSpecific, jobSpecific1)
				} else {
					r.ResourceAllocation.JobSpecific[jobSpecificCount].JobType = jobSpecific1.JobType
					r.ResourceAllocation.JobSpecific[jobSpecificCount].ResourceRequirements = jobSpecific1.ResourceRequirements
				}
			}
		}
		r.SourceID = types.StringValue(resp.SourceID)
		r.SourceType = types.StringValue(resp.SourceType)
		r.WorkspaceID = types.StringValue(resp.WorkspaceID)
	}
}

func (r *SourceAzureBlobStorageResourceModel) ToSharedSourceAzureBlobStoragePutRequest() *shared.SourceAzureBlobStoragePutRequest {
	var name string
	name = r.Name.ValueString()

	var workspaceID string
	workspaceID = r.WorkspaceID.ValueString()

	var azureBlobStorageAccountName string
	azureBlobStorageAccountName = r.Configuration.AzureBlobStorageAccountName.ValueString()

	var azureBlobStorageContainerName string
	azureBlobStorageContainerName = r.Configuration.AzureBlobStorageContainerName.ValueString()

	azureBlobStorageEndpoint := new(string)
	if !r.Configuration.AzureBlobStorageEndpoint.IsUnknown() && !r.Configuration.AzureBlobStorageEndpoint.IsNull() {
		*azureBlobStorageEndpoint = r.Configuration.AzureBlobStorageEndpoint.ValueString()
	} else {
		azureBlobStorageEndpoint = nil
	}
	var credentials shared.SourceAzureBlobStorageUpdateAuthentication
	var sourceAzureBlobStorageUpdateAuthenticateViaOauth2 *shared.SourceAzureBlobStorageUpdateAuthenticateViaOauth2
	if r.Configuration.Credentials.AuthenticateViaOauth2 != nil {
		var clientID string
		clientID = r.Configuration.Credentials.AuthenticateViaOauth2.ClientID.ValueString()

		var clientSecret string
		clientSecret = r.Configuration.Credentials.AuthenticateViaOauth2.ClientSecret.ValueString()

		var refreshToken string
		refreshToken = r.Configuration.Credentials.AuthenticateViaOauth2.RefreshToken.ValueString()

		var tenantID string
		tenantID = r.Configuration.Credentials.AuthenticateViaOauth2.TenantID.ValueString()

		sourceAzureBlobStorageUpdateAuthenticateViaOauth2 = &shared.SourceAzureBlobStorageUpdateAuthenticateViaOauth2{
			ClientID:     clientID,
			ClientSecret: clientSecret,
			RefreshToken: refreshToken,
			TenantID:     tenantID,
		}
	}
	if sourceAzureBlobStorageUpdateAuthenticateViaOauth2 != nil {
		credentials = shared.SourceAzureBlobStorageUpdateAuthentication{
			SourceAzureBlobStorageUpdateAuthenticateViaOauth2: sourceAzureBlobStorageUpdateAuthenticateViaOauth2,
		}
	}
	var sourceAzureBlobStorageUpdateAuthenticateViaClientCredentials *shared.SourceAzureBlobStorageUpdateAuthenticateViaClientCredentials
	if r.Configuration.Credentials.AuthenticateViaClientCredentials != nil {
		var appClientID string
		appClientID = r.Configuration.Credentials.AuthenticateViaClientCredentials.AppClientID.ValueString()

		var appClientSecret string
		appClientSecret = r.Configuration.Credentials.AuthenticateViaClientCredentials.AppClientSecret.ValueString()

		var appTenantID string
		appTenantID = r.Configuration.Credentials.AuthenticateViaClientCredentials.AppTenantID.ValueString()

		sourceAzureBlobStorageUpdateAuthenticateViaClientCredentials = &shared.SourceAzureBlobStorageUpdateAuthenticateViaClientCredentials{
			AppClientID:     appClientID,
			AppClientSecret: appClientSecret,
			AppTenantID:     appTenantID,
		}
	}
	if sourceAzureBlobStorageUpdateAuthenticateViaClientCredentials != nil {
		credentials = shared.SourceAzureBlobStorageUpdateAuthentication{
			SourceAzureBlobStorageUpdateAuthenticateViaClientCredentials: sourceAzureBlobStorageUpdateAuthenticateViaClientCredentials,
		}
	}
	var sourceAzureBlobStorageUpdateAuthenticateViaStorageAccountKey *shared.SourceAzureBlobStorageUpdateAuthenticateViaStorageAccountKey
	if r.Configuration.Credentials.AuthenticateViaStorageAccountKey != nil {
		var azureBlobStorageAccountKey string
		azureBlobStorageAccountKey = r.Configuration.Credentials.AuthenticateViaStorageAccountKey.AzureBlobStorageAccountKey.ValueString()

		sourceAzureBlobStorageUpdateAuthenticateViaStorageAccountKey = &shared.SourceAzureBlobStorageUpdateAuthenticateViaStorageAccountKey{
			AzureBlobStorageAccountKey: azureBlobStorageAccountKey,
		}
	}
	if sourceAzureBlobStorageUpdateAuthenticateViaStorageAccountKey != nil {
		credentials = shared.SourceAzureBlobStorageUpdateAuthentication{
			SourceAzureBlobStorageUpdateAuthenticateViaStorageAccountKey: sourceAzureBlobStorageUpdateAuthenticateViaStorageAccountKey,
		}
	}
	startDate := new(time.Time)
	if !r.Configuration.StartDate.IsUnknown() && !r.Configuration.StartDate.IsNull() {
		*startDate, _ = time.Parse(time.RFC3339Nano, r.Configuration.StartDate.ValueString())
	} else {
		startDate = nil
	}
	var streams []shared.SourceAzureBlobStorageUpdateFileBasedStreamConfig = []shared.SourceAzureBlobStorageUpdateFileBasedStreamConfig{}
	for _, streamsItem := range r.Configuration.Streams {
		daysToSyncIfHistoryIsFull := new(int64)
		if !streamsItem.DaysToSyncIfHistoryIsFull.IsUnknown() && !streamsItem.DaysToSyncIfHistoryIsFull.IsNull() {
			*daysToSyncIfHistoryIsFull = streamsItem.DaysToSyncIfHistoryIsFull.ValueInt64()
		} else {
			daysToSyncIfHistoryIsFull = nil
		}
		var format shared.SourceAzureBlobStorageUpdateFormat
		var sourceAzureBlobStorageUpdateAvroFormat *shared.SourceAzureBlobStorageUpdateAvroFormat
		if streamsItem.Format.AvroFormat != nil {
			doubleAsString := new(bool)
			if !streamsItem.Format.AvroFormat.DoubleAsString.IsUnknown() && !streamsItem.Format.AvroFormat.DoubleAsString.IsNull() {
				*doubleAsString = streamsItem.Format.AvroFormat.DoubleAsString.ValueBool()
			} else {
				doubleAsString = nil
			}
			sourceAzureBlobStorageUpdateAvroFormat = &shared.SourceAzureBlobStorageUpdateAvroFormat{
				DoubleAsString: doubleAsString,
			}
		}
		if sourceAzureBlobStorageUpdateAvroFormat != nil {
			format = shared.SourceAzureBlobStorageUpdateFormat{
				SourceAzureBlobStorageUpdateAvroFormat: sourceAzureBlobStorageUpdateAvroFormat,
			}
		}
		var sourceAzureBlobStorageUpdateCSVFormat *shared.SourceAzureBlobStorageUpdateCSVFormat
		if streamsItem.Format.CSVFormat != nil {
			delimiter := new(string)
			if !streamsItem.Format.CSVFormat.Delimiter.IsUnknown() && !streamsItem.Format.CSVFormat.Delimiter.IsNull() {
				*delimiter = streamsItem.Format.CSVFormat.Delimiter.ValueString()
			} else {
				delimiter = nil
			}
			doubleQuote := new(bool)
			if !streamsItem.Format.CSVFormat.DoubleQuote.IsUnknown() && !streamsItem.Format.CSVFormat.DoubleQuote.IsNull() {
				*doubleQuote = streamsItem.Format.CSVFormat.DoubleQuote.ValueBool()
			} else {
				doubleQuote = nil
			}
			encoding := new(string)
			if !streamsItem.Format.CSVFormat.Encoding.IsUnknown() && !streamsItem.Format.CSVFormat.Encoding.IsNull() {
				*encoding = streamsItem.Format.CSVFormat.Encoding.ValueString()
			} else {
				encoding = nil
			}
			escapeChar := new(string)
			if !streamsItem.Format.CSVFormat.EscapeChar.IsUnknown() && !streamsItem.Format.CSVFormat.EscapeChar.IsNull() {
				*escapeChar = streamsItem.Format.CSVFormat.EscapeChar.ValueString()
			} else {
				escapeChar = nil
			}
			var falseValues []string = []string{}
			for _, falseValuesItem := range streamsItem.Format.CSVFormat.FalseValues {
				falseValues = append(falseValues, falseValuesItem.ValueString())
			}
			var headerDefinition *shared.SourceAzureBlobStorageUpdateCSVHeaderDefinition
			if streamsItem.Format.CSVFormat.HeaderDefinition != nil {
				var sourceAzureBlobStorageUpdateFromCSV *shared.SourceAzureBlobStorageUpdateFromCSV
				if streamsItem.Format.CSVFormat.HeaderDefinition.FromCSV != nil {
					sourceAzureBlobStorageUpdateFromCSV = &shared.SourceAzureBlobStorageUpdateFromCSV{}
				}
				if sourceAzureBlobStorageUpdateFromCSV != nil {
					headerDefinition = &shared.SourceAzureBlobStorageUpdateCSVHeaderDefinition{
						SourceAzureBlobStorageUpdateFromCSV: sourceAzureBlobStorageUpdateFromCSV,
					}
				}
				var sourceAzureBlobStorageUpdateAutogenerated *shared.SourceAzureBlobStorageUpdateAutogenerated
				if streamsItem.Format.CSVFormat.HeaderDefinition.Autogenerated != nil {
					sourceAzureBlobStorageUpdateAutogenerated = &shared.SourceAzureBlobStorageUpdateAutogenerated{}
				}
				if sourceAzureBlobStorageUpdateAutogenerated != nil {
					headerDefinition = &shared.SourceAzureBlobStorageUpdateCSVHeaderDefinition{
						SourceAzureBlobStorageUpdateAutogenerated: sourceAzureBlobStorageUpdateAutogenerated,
					}
				}
				var sourceAzureBlobStorageUpdateUserProvided *shared.SourceAzureBlobStorageUpdateUserProvided
				if streamsItem.Format.CSVFormat.HeaderDefinition.UserProvided != nil {
					var columnNames []string = []string{}
					for _, columnNamesItem := range streamsItem.Format.CSVFormat.HeaderDefinition.UserProvided.ColumnNames {
						columnNames = append(columnNames, columnNamesItem.ValueString())
					}
					sourceAzureBlobStorageUpdateUserProvided = &shared.SourceAzureBlobStorageUpdateUserProvided{
						ColumnNames: columnNames,
					}
				}
				if sourceAzureBlobStorageUpdateUserProvided != nil {
					headerDefinition = &shared.SourceAzureBlobStorageUpdateCSVHeaderDefinition{
						SourceAzureBlobStorageUpdateUserProvided: sourceAzureBlobStorageUpdateUserProvided,
					}
				}
			}
			ignoreErrorsOnFieldsMismatch := new(bool)
			if !streamsItem.Format.CSVFormat.IgnoreErrorsOnFieldsMismatch.IsUnknown() && !streamsItem.Format.CSVFormat.IgnoreErrorsOnFieldsMismatch.IsNull() {
				*ignoreErrorsOnFieldsMismatch = streamsItem.Format.CSVFormat.IgnoreErrorsOnFieldsMismatch.ValueBool()
			} else {
				ignoreErrorsOnFieldsMismatch = nil
			}
			var nullValues []string = []string{}
			for _, nullValuesItem := range streamsItem.Format.CSVFormat.NullValues {
				nullValues = append(nullValues, nullValuesItem.ValueString())
			}
			quoteChar := new(string)
			if !streamsItem.Format.CSVFormat.QuoteChar.IsUnknown() && !streamsItem.Format.CSVFormat.QuoteChar.IsNull() {
				*quoteChar = streamsItem.Format.CSVFormat.QuoteChar.ValueString()
			} else {
				quoteChar = nil
			}
			skipRowsAfterHeader := new(int64)
			if !streamsItem.Format.CSVFormat.SkipRowsAfterHeader.IsUnknown() && !streamsItem.Format.CSVFormat.SkipRowsAfterHeader.IsNull() {
				*skipRowsAfterHeader = streamsItem.Format.CSVFormat.SkipRowsAfterHeader.ValueInt64()
			} else {
				skipRowsAfterHeader = nil
			}
			skipRowsBeforeHeader := new(int64)
			if !streamsItem.Format.CSVFormat.SkipRowsBeforeHeader.IsUnknown() && !streamsItem.Format.CSVFormat.SkipRowsBeforeHeader.IsNull() {
				*skipRowsBeforeHeader = streamsItem.Format.CSVFormat.SkipRowsBeforeHeader.ValueInt64()
			} else {
				skipRowsBeforeHeader = nil
			}
			stringsCanBeNull := new(bool)
			if !streamsItem.Format.CSVFormat.StringsCanBeNull.IsUnknown() && !streamsItem.Format.CSVFormat.StringsCanBeNull.IsNull() {
				*stringsCanBeNull = streamsItem.Format.CSVFormat.StringsCanBeNull.ValueBool()
			} else {
				stringsCanBeNull = nil
			}
			var trueValues []string = []string{}
			for _, trueValuesItem := range streamsItem.Format.CSVFormat.TrueValues {
				trueValues = append(trueValues, trueValuesItem.ValueString())
			}
			sourceAzureBlobStorageUpdateCSVFormat = &shared.SourceAzureBlobStorageUpdateCSVFormat{
				Delimiter:                    delimiter,
				DoubleQuote:                  doubleQuote,
				Encoding:                     encoding,
				EscapeChar:                   escapeChar,
				FalseValues:                  falseValues,
				HeaderDefinition:             headerDefinition,
				IgnoreErrorsOnFieldsMismatch: ignoreErrorsOnFieldsMismatch,
				NullValues:                   nullValues,
				QuoteChar:                    quoteChar,
				SkipRowsAfterHeader:          skipRowsAfterHeader,
				SkipRowsBeforeHeader:         skipRowsBeforeHeader,
				StringsCanBeNull:             stringsCanBeNull,
				TrueValues:                   trueValues,
			}
		}
		if sourceAzureBlobStorageUpdateCSVFormat != nil {
			format = shared.SourceAzureBlobStorageUpdateFormat{
				SourceAzureBlobStorageUpdateCSVFormat: sourceAzureBlobStorageUpdateCSVFormat,
			}
		}
		var sourceAzureBlobStorageUpdateJsonlFormat *shared.SourceAzureBlobStorageUpdateJsonlFormat
		if streamsItem.Format.JsonlFormat != nil {
			sourceAzureBlobStorageUpdateJsonlFormat = &shared.SourceAzureBlobStorageUpdateJsonlFormat{}
		}
		if sourceAzureBlobStorageUpdateJsonlFormat != nil {
			format = shared.SourceAzureBlobStorageUpdateFormat{
				SourceAzureBlobStorageUpdateJsonlFormat: sourceAzureBlobStorageUpdateJsonlFormat,
			}
		}
		var sourceAzureBlobStorageUpdateParquetFormat *shared.SourceAzureBlobStorageUpdateParquetFormat
		if streamsItem.Format.ParquetFormat != nil {
			decimalAsFloat := new(bool)
			if !streamsItem.Format.ParquetFormat.DecimalAsFloat.IsUnknown() && !streamsItem.Format.ParquetFormat.DecimalAsFloat.IsNull() {
				*decimalAsFloat = streamsItem.Format.ParquetFormat.DecimalAsFloat.ValueBool()
			} else {
				decimalAsFloat = nil
			}
			sourceAzureBlobStorageUpdateParquetFormat = &shared.SourceAzureBlobStorageUpdateParquetFormat{
				DecimalAsFloat: decimalAsFloat,
			}
		}
		if sourceAzureBlobStorageUpdateParquetFormat != nil {
			format = shared.SourceAzureBlobStorageUpdateFormat{
				SourceAzureBlobStorageUpdateParquetFormat: sourceAzureBlobStorageUpdateParquetFormat,
			}
		}
		var sourceAzureBlobStorageUpdateUnstructuredDocumentFormat *shared.SourceAzureBlobStorageUpdateUnstructuredDocumentFormat
		if streamsItem.Format.UnstructuredDocumentFormat != nil {
			var processing *shared.SourceAzureBlobStorageUpdateProcessing
			if streamsItem.Format.UnstructuredDocumentFormat.Processing != nil {
				var sourceAzureBlobStorageUpdateLocal *shared.SourceAzureBlobStorageUpdateLocal
				if streamsItem.Format.UnstructuredDocumentFormat.Processing.Local != nil {
					sourceAzureBlobStorageUpdateLocal = &shared.SourceAzureBlobStorageUpdateLocal{}
				}
				if sourceAzureBlobStorageUpdateLocal != nil {
					processing = &shared.SourceAzureBlobStorageUpdateProcessing{
						SourceAzureBlobStorageUpdateLocal: sourceAzureBlobStorageUpdateLocal,
					}
				}
			}
			skipUnprocessableFiles := new(bool)
			if !streamsItem.Format.UnstructuredDocumentFormat.SkipUnprocessableFiles.IsUnknown() && !streamsItem.Format.UnstructuredDocumentFormat.SkipUnprocessableFiles.IsNull() {
				*skipUnprocessableFiles = streamsItem.Format.UnstructuredDocumentFormat.SkipUnprocessableFiles.ValueBool()
			} else {
				skipUnprocessableFiles = nil
			}
			strategy := new(shared.SourceAzureBlobStorageUpdateParsingStrategy)
			if !streamsItem.Format.UnstructuredDocumentFormat.Strategy.IsUnknown() && !streamsItem.Format.UnstructuredDocumentFormat.Strategy.IsNull() {
				*strategy = shared.SourceAzureBlobStorageUpdateParsingStrategy(streamsItem.Format.UnstructuredDocumentFormat.Strategy.ValueString())
			} else {
				strategy = nil
			}
			sourceAzureBlobStorageUpdateUnstructuredDocumentFormat = &shared.SourceAzureBlobStorageUpdateUnstructuredDocumentFormat{
				Processing:             processing,
				SkipUnprocessableFiles: skipUnprocessableFiles,
				Strategy:               strategy,
			}
		}
		if sourceAzureBlobStorageUpdateUnstructuredDocumentFormat != nil {
			format = shared.SourceAzureBlobStorageUpdateFormat{
				SourceAzureBlobStorageUpdateUnstructuredDocumentFormat: sourceAzureBlobStorageUpdateUnstructuredDocumentFormat,
			}
		}
		var globs []string = []string{}
		for _, globsItem := range streamsItem.Globs {
			globs = append(globs, globsItem.ValueString())
		}
		inputSchema := new(string)
		if !streamsItem.InputSchema.IsUnknown() && !streamsItem.InputSchema.IsNull() {
			*inputSchema = streamsItem.InputSchema.ValueString()
		} else {
			inputSchema = nil
		}
		var name1 string
		name1 = streamsItem.Name.ValueString()

		recentNFilesToReadForSchemaDiscovery := new(int64)
		if !streamsItem.RecentNFilesToReadForSchemaDiscovery.IsUnknown() && !streamsItem.RecentNFilesToReadForSchemaDiscovery.IsNull() {
			*recentNFilesToReadForSchemaDiscovery = streamsItem.RecentNFilesToReadForSchemaDiscovery.ValueInt64()
		} else {
			recentNFilesToReadForSchemaDiscovery = nil
		}
		schemaless := new(bool)
		if !streamsItem.Schemaless.IsUnknown() && !streamsItem.Schemaless.IsNull() {
			*schemaless = streamsItem.Schemaless.ValueBool()
		} else {
			schemaless = nil
		}
		validationPolicy := new(shared.SourceAzureBlobStorageUpdateValidationPolicy)
		if !streamsItem.ValidationPolicy.IsUnknown() && !streamsItem.ValidationPolicy.IsNull() {
			*validationPolicy = shared.SourceAzureBlobStorageUpdateValidationPolicy(streamsItem.ValidationPolicy.ValueString())
		} else {
			validationPolicy = nil
		}
		streams = append(streams, shared.SourceAzureBlobStorageUpdateFileBasedStreamConfig{
			DaysToSyncIfHistoryIsFull:            daysToSyncIfHistoryIsFull,
			Format:                               format,
			Globs:                                globs,
			InputSchema:                          inputSchema,
			Name:                                 name1,
			RecentNFilesToReadForSchemaDiscovery: recentNFilesToReadForSchemaDiscovery,
			Schemaless:                           schemaless,
			ValidationPolicy:                     validationPolicy,
		})
	}
	configuration := shared.SourceAzureBlobStorageUpdate{
		AzureBlobStorageAccountName:   azureBlobStorageAccountName,
		AzureBlobStorageContainerName: azureBlobStorageContainerName,
		AzureBlobStorageEndpoint:      azureBlobStorageEndpoint,
		Credentials:                   credentials,
		StartDate:                     startDate,
		Streams:                       streams,
	}
	out := shared.SourceAzureBlobStoragePutRequest{
		Name:          name,
		WorkspaceID:   workspaceID,
		Configuration: configuration,
	}
	return &out
}
