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

func (r *DestinationSnowflakeCortexResourceModel) ToSharedDestinationSnowflakeCortexCreateRequest() *shared.DestinationSnowflakeCortexCreateRequest {
	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 embedding shared.DestinationSnowflakeCortexEmbedding
	var destinationSnowflakeCortexOpenAI *shared.DestinationSnowflakeCortexOpenAI
	if r.Configuration.Embedding.OpenAI != nil {
		var openaiKey string
		openaiKey = r.Configuration.Embedding.OpenAI.OpenaiKey.ValueString()

		destinationSnowflakeCortexOpenAI = &shared.DestinationSnowflakeCortexOpenAI{
			OpenaiKey: openaiKey,
		}
	}
	if destinationSnowflakeCortexOpenAI != nil {
		embedding = shared.DestinationSnowflakeCortexEmbedding{
			DestinationSnowflakeCortexOpenAI: destinationSnowflakeCortexOpenAI,
		}
	}
	var destinationSnowflakeCortexCohere *shared.DestinationSnowflakeCortexCohere
	if r.Configuration.Embedding.Cohere != nil {
		var cohereKey string
		cohereKey = r.Configuration.Embedding.Cohere.CohereKey.ValueString()

		destinationSnowflakeCortexCohere = &shared.DestinationSnowflakeCortexCohere{
			CohereKey: cohereKey,
		}
	}
	if destinationSnowflakeCortexCohere != nil {
		embedding = shared.DestinationSnowflakeCortexEmbedding{
			DestinationSnowflakeCortexCohere: destinationSnowflakeCortexCohere,
		}
	}
	var destinationSnowflakeCortexFake *shared.DestinationSnowflakeCortexFake
	if r.Configuration.Embedding.Fake != nil {
		destinationSnowflakeCortexFake = &shared.DestinationSnowflakeCortexFake{}
	}
	if destinationSnowflakeCortexFake != nil {
		embedding = shared.DestinationSnowflakeCortexEmbedding{
			DestinationSnowflakeCortexFake: destinationSnowflakeCortexFake,
		}
	}
	var destinationSnowflakeCortexAzureOpenAI *shared.DestinationSnowflakeCortexAzureOpenAI
	if r.Configuration.Embedding.AzureOpenAI != nil {
		var apiBase string
		apiBase = r.Configuration.Embedding.AzureOpenAI.APIBase.ValueString()

		var deployment string
		deployment = r.Configuration.Embedding.AzureOpenAI.Deployment.ValueString()

		var openaiKey1 string
		openaiKey1 = r.Configuration.Embedding.AzureOpenAI.OpenaiKey.ValueString()

		destinationSnowflakeCortexAzureOpenAI = &shared.DestinationSnowflakeCortexAzureOpenAI{
			APIBase:    apiBase,
			Deployment: deployment,
			OpenaiKey:  openaiKey1,
		}
	}
	if destinationSnowflakeCortexAzureOpenAI != nil {
		embedding = shared.DestinationSnowflakeCortexEmbedding{
			DestinationSnowflakeCortexAzureOpenAI: destinationSnowflakeCortexAzureOpenAI,
		}
	}
	var destinationSnowflakeCortexOpenAICompatible *shared.DestinationSnowflakeCortexOpenAICompatible
	if r.Configuration.Embedding.OpenAICompatible != nil {
		apiKey := new(string)
		if !r.Configuration.Embedding.OpenAICompatible.APIKey.IsUnknown() && !r.Configuration.Embedding.OpenAICompatible.APIKey.IsNull() {
			*apiKey = r.Configuration.Embedding.OpenAICompatible.APIKey.ValueString()
		} else {
			apiKey = nil
		}
		var baseURL string
		baseURL = r.Configuration.Embedding.OpenAICompatible.BaseURL.ValueString()

		var dimensions int64
		dimensions = r.Configuration.Embedding.OpenAICompatible.Dimensions.ValueInt64()

		modelName := new(string)
		if !r.Configuration.Embedding.OpenAICompatible.ModelName.IsUnknown() && !r.Configuration.Embedding.OpenAICompatible.ModelName.IsNull() {
			*modelName = r.Configuration.Embedding.OpenAICompatible.ModelName.ValueString()
		} else {
			modelName = nil
		}
		destinationSnowflakeCortexOpenAICompatible = &shared.DestinationSnowflakeCortexOpenAICompatible{
			APIKey:     apiKey,
			BaseURL:    baseURL,
			Dimensions: dimensions,
			ModelName:  modelName,
		}
	}
	if destinationSnowflakeCortexOpenAICompatible != nil {
		embedding = shared.DestinationSnowflakeCortexEmbedding{
			DestinationSnowflakeCortexOpenAICompatible: destinationSnowflakeCortexOpenAICompatible,
		}
	}
	var password string
	password = r.Configuration.Indexing.Credentials.Password.ValueString()

	credentials := shared.DestinationSnowflakeCortexCredentials{
		Password: password,
	}
	var database string
	database = r.Configuration.Indexing.Database.ValueString()

	var defaultSchema string
	defaultSchema = r.Configuration.Indexing.DefaultSchema.ValueString()

	var host string
	host = r.Configuration.Indexing.Host.ValueString()

	var role string
	role = r.Configuration.Indexing.Role.ValueString()

	var username string
	username = r.Configuration.Indexing.Username.ValueString()

	var warehouse string
	warehouse = r.Configuration.Indexing.Warehouse.ValueString()

	indexing := shared.SnowflakeConnection{
		Credentials:   credentials,
		Database:      database,
		DefaultSchema: defaultSchema,
		Host:          host,
		Role:          role,
		Username:      username,
		Warehouse:     warehouse,
	}
	omitRawText := new(bool)
	if !r.Configuration.OmitRawText.IsUnknown() && !r.Configuration.OmitRawText.IsNull() {
		*omitRawText = r.Configuration.OmitRawText.ValueBool()
	} else {
		omitRawText = nil
	}
	chunkOverlap := new(int64)
	if !r.Configuration.Processing.ChunkOverlap.IsUnknown() && !r.Configuration.Processing.ChunkOverlap.IsNull() {
		*chunkOverlap = r.Configuration.Processing.ChunkOverlap.ValueInt64()
	} else {
		chunkOverlap = nil
	}
	var chunkSize int64
	chunkSize = r.Configuration.Processing.ChunkSize.ValueInt64()

	var fieldNameMappings []shared.DestinationSnowflakeCortexFieldNameMappingConfigModel = []shared.DestinationSnowflakeCortexFieldNameMappingConfigModel{}
	for _, fieldNameMappingsItem := range r.Configuration.Processing.FieldNameMappings {
		var fromField string
		fromField = fieldNameMappingsItem.FromField.ValueString()

		var toField string
		toField = fieldNameMappingsItem.ToField.ValueString()

		fieldNameMappings = append(fieldNameMappings, shared.DestinationSnowflakeCortexFieldNameMappingConfigModel{
			FromField: fromField,
			ToField:   toField,
		})
	}
	var metadataFields []string = []string{}
	for _, metadataFieldsItem := range r.Configuration.Processing.MetadataFields {
		metadataFields = append(metadataFields, metadataFieldsItem.ValueString())
	}
	var textFields []string = []string{}
	for _, textFieldsItem := range r.Configuration.Processing.TextFields {
		textFields = append(textFields, textFieldsItem.ValueString())
	}
	var textSplitter *shared.DestinationSnowflakeCortexTextSplitter
	if r.Configuration.Processing.TextSplitter != nil {
		var destinationSnowflakeCortexBySeparator *shared.DestinationSnowflakeCortexBySeparator
		if r.Configuration.Processing.TextSplitter.BySeparator != nil {
			keepSeparator := new(bool)
			if !r.Configuration.Processing.TextSplitter.BySeparator.KeepSeparator.IsUnknown() && !r.Configuration.Processing.TextSplitter.BySeparator.KeepSeparator.IsNull() {
				*keepSeparator = r.Configuration.Processing.TextSplitter.BySeparator.KeepSeparator.ValueBool()
			} else {
				keepSeparator = nil
			}
			var separators []string = []string{}
			for _, separatorsItem := range r.Configuration.Processing.TextSplitter.BySeparator.Separators {
				separators = append(separators, separatorsItem.ValueString())
			}
			destinationSnowflakeCortexBySeparator = &shared.DestinationSnowflakeCortexBySeparator{
				KeepSeparator: keepSeparator,
				Separators:    separators,
			}
		}
		if destinationSnowflakeCortexBySeparator != nil {
			textSplitter = &shared.DestinationSnowflakeCortexTextSplitter{
				DestinationSnowflakeCortexBySeparator: destinationSnowflakeCortexBySeparator,
			}
		}
		var destinationSnowflakeCortexByMarkdownHeader *shared.DestinationSnowflakeCortexByMarkdownHeader
		if r.Configuration.Processing.TextSplitter.ByMarkdownHeader != nil {
			splitLevel := new(int64)
			if !r.Configuration.Processing.TextSplitter.ByMarkdownHeader.SplitLevel.IsUnknown() && !r.Configuration.Processing.TextSplitter.ByMarkdownHeader.SplitLevel.IsNull() {
				*splitLevel = r.Configuration.Processing.TextSplitter.ByMarkdownHeader.SplitLevel.ValueInt64()
			} else {
				splitLevel = nil
			}
			destinationSnowflakeCortexByMarkdownHeader = &shared.DestinationSnowflakeCortexByMarkdownHeader{
				SplitLevel: splitLevel,
			}
		}
		if destinationSnowflakeCortexByMarkdownHeader != nil {
			textSplitter = &shared.DestinationSnowflakeCortexTextSplitter{
				DestinationSnowflakeCortexByMarkdownHeader: destinationSnowflakeCortexByMarkdownHeader,
			}
		}
		var destinationSnowflakeCortexByProgrammingLanguage *shared.DestinationSnowflakeCortexByProgrammingLanguage
		if r.Configuration.Processing.TextSplitter.ByProgrammingLanguage != nil {
			language := shared.DestinationSnowflakeCortexLanguage(r.Configuration.Processing.TextSplitter.ByProgrammingLanguage.Language.ValueString())
			destinationSnowflakeCortexByProgrammingLanguage = &shared.DestinationSnowflakeCortexByProgrammingLanguage{
				Language: language,
			}
		}
		if destinationSnowflakeCortexByProgrammingLanguage != nil {
			textSplitter = &shared.DestinationSnowflakeCortexTextSplitter{
				DestinationSnowflakeCortexByProgrammingLanguage: destinationSnowflakeCortexByProgrammingLanguage,
			}
		}
	}
	processing := shared.DestinationSnowflakeCortexProcessingConfigModel{
		ChunkOverlap:      chunkOverlap,
		ChunkSize:         chunkSize,
		FieldNameMappings: fieldNameMappings,
		MetadataFields:    metadataFields,
		TextFields:        textFields,
		TextSplitter:      textSplitter,
	}
	configuration := shared.DestinationSnowflakeCortex{
		Embedding:   embedding,
		Indexing:    indexing,
		OmitRawText: omitRawText,
		Processing:  processing,
	}
	out := shared.DestinationSnowflakeCortexCreateRequest{
		Name:          name,
		DefinitionID:  definitionID,
		WorkspaceID:   workspaceID,
		Configuration: configuration,
	}
	return &out
}

func (r *DestinationSnowflakeCortexResourceModel) RefreshFromSharedDestinationResponse(resp *shared.DestinationResponse) {
	if resp != nil {
		r.CreatedAt = types.Int64Value(resp.CreatedAt)
		r.DefinitionID = types.StringValue(resp.DefinitionID)
		r.DestinationID = types.StringValue(resp.DestinationID)
		r.DestinationType = types.StringValue(resp.DestinationType)
		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.WorkspaceID = types.StringValue(resp.WorkspaceID)
	}
}

func (r *DestinationSnowflakeCortexResourceModel) ToSharedDestinationSnowflakeCortexPutRequest() *shared.DestinationSnowflakeCortexPutRequest {
	var name string
	name = r.Name.ValueString()

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

	var embedding shared.DestinationSnowflakeCortexUpdateEmbedding
	var destinationSnowflakeCortexUpdateOpenAI *shared.DestinationSnowflakeCortexUpdateOpenAI
	if r.Configuration.Embedding.OpenAI != nil {
		var openaiKey string
		openaiKey = r.Configuration.Embedding.OpenAI.OpenaiKey.ValueString()

		destinationSnowflakeCortexUpdateOpenAI = &shared.DestinationSnowflakeCortexUpdateOpenAI{
			OpenaiKey: openaiKey,
		}
	}
	if destinationSnowflakeCortexUpdateOpenAI != nil {
		embedding = shared.DestinationSnowflakeCortexUpdateEmbedding{
			DestinationSnowflakeCortexUpdateOpenAI: destinationSnowflakeCortexUpdateOpenAI,
		}
	}
	var destinationSnowflakeCortexUpdateCohere *shared.DestinationSnowflakeCortexUpdateCohere
	if r.Configuration.Embedding.Cohere != nil {
		var cohereKey string
		cohereKey = r.Configuration.Embedding.Cohere.CohereKey.ValueString()

		destinationSnowflakeCortexUpdateCohere = &shared.DestinationSnowflakeCortexUpdateCohere{
			CohereKey: cohereKey,
		}
	}
	if destinationSnowflakeCortexUpdateCohere != nil {
		embedding = shared.DestinationSnowflakeCortexUpdateEmbedding{
			DestinationSnowflakeCortexUpdateCohere: destinationSnowflakeCortexUpdateCohere,
		}
	}
	var destinationSnowflakeCortexUpdateFake *shared.DestinationSnowflakeCortexUpdateFake
	if r.Configuration.Embedding.Fake != nil {
		destinationSnowflakeCortexUpdateFake = &shared.DestinationSnowflakeCortexUpdateFake{}
	}
	if destinationSnowflakeCortexUpdateFake != nil {
		embedding = shared.DestinationSnowflakeCortexUpdateEmbedding{
			DestinationSnowflakeCortexUpdateFake: destinationSnowflakeCortexUpdateFake,
		}
	}
	var destinationSnowflakeCortexUpdateAzureOpenAI *shared.DestinationSnowflakeCortexUpdateAzureOpenAI
	if r.Configuration.Embedding.AzureOpenAI != nil {
		var apiBase string
		apiBase = r.Configuration.Embedding.AzureOpenAI.APIBase.ValueString()

		var deployment string
		deployment = r.Configuration.Embedding.AzureOpenAI.Deployment.ValueString()

		var openaiKey1 string
		openaiKey1 = r.Configuration.Embedding.AzureOpenAI.OpenaiKey.ValueString()

		destinationSnowflakeCortexUpdateAzureOpenAI = &shared.DestinationSnowflakeCortexUpdateAzureOpenAI{
			APIBase:    apiBase,
			Deployment: deployment,
			OpenaiKey:  openaiKey1,
		}
	}
	if destinationSnowflakeCortexUpdateAzureOpenAI != nil {
		embedding = shared.DestinationSnowflakeCortexUpdateEmbedding{
			DestinationSnowflakeCortexUpdateAzureOpenAI: destinationSnowflakeCortexUpdateAzureOpenAI,
		}
	}
	var destinationSnowflakeCortexUpdateOpenAICompatible *shared.DestinationSnowflakeCortexUpdateOpenAICompatible
	if r.Configuration.Embedding.OpenAICompatible != nil {
		apiKey := new(string)
		if !r.Configuration.Embedding.OpenAICompatible.APIKey.IsUnknown() && !r.Configuration.Embedding.OpenAICompatible.APIKey.IsNull() {
			*apiKey = r.Configuration.Embedding.OpenAICompatible.APIKey.ValueString()
		} else {
			apiKey = nil
		}
		var baseURL string
		baseURL = r.Configuration.Embedding.OpenAICompatible.BaseURL.ValueString()

		var dimensions int64
		dimensions = r.Configuration.Embedding.OpenAICompatible.Dimensions.ValueInt64()

		modelName := new(string)
		if !r.Configuration.Embedding.OpenAICompatible.ModelName.IsUnknown() && !r.Configuration.Embedding.OpenAICompatible.ModelName.IsNull() {
			*modelName = r.Configuration.Embedding.OpenAICompatible.ModelName.ValueString()
		} else {
			modelName = nil
		}
		destinationSnowflakeCortexUpdateOpenAICompatible = &shared.DestinationSnowflakeCortexUpdateOpenAICompatible{
			APIKey:     apiKey,
			BaseURL:    baseURL,
			Dimensions: dimensions,
			ModelName:  modelName,
		}
	}
	if destinationSnowflakeCortexUpdateOpenAICompatible != nil {
		embedding = shared.DestinationSnowflakeCortexUpdateEmbedding{
			DestinationSnowflakeCortexUpdateOpenAICompatible: destinationSnowflakeCortexUpdateOpenAICompatible,
		}
	}
	var password string
	password = r.Configuration.Indexing.Credentials.Password.ValueString()

	credentials := shared.DestinationSnowflakeCortexUpdateCredentials{
		Password: password,
	}
	var database string
	database = r.Configuration.Indexing.Database.ValueString()

	var defaultSchema string
	defaultSchema = r.Configuration.Indexing.DefaultSchema.ValueString()

	var host string
	host = r.Configuration.Indexing.Host.ValueString()

	var role string
	role = r.Configuration.Indexing.Role.ValueString()

	var username string
	username = r.Configuration.Indexing.Username.ValueString()

	var warehouse string
	warehouse = r.Configuration.Indexing.Warehouse.ValueString()

	indexing := shared.DestinationSnowflakeCortexUpdateSnowflakeConnection{
		Credentials:   credentials,
		Database:      database,
		DefaultSchema: defaultSchema,
		Host:          host,
		Role:          role,
		Username:      username,
		Warehouse:     warehouse,
	}
	omitRawText := new(bool)
	if !r.Configuration.OmitRawText.IsUnknown() && !r.Configuration.OmitRawText.IsNull() {
		*omitRawText = r.Configuration.OmitRawText.ValueBool()
	} else {
		omitRawText = nil
	}
	chunkOverlap := new(int64)
	if !r.Configuration.Processing.ChunkOverlap.IsUnknown() && !r.Configuration.Processing.ChunkOverlap.IsNull() {
		*chunkOverlap = r.Configuration.Processing.ChunkOverlap.ValueInt64()
	} else {
		chunkOverlap = nil
	}
	var chunkSize int64
	chunkSize = r.Configuration.Processing.ChunkSize.ValueInt64()

	var fieldNameMappings []shared.DestinationSnowflakeCortexUpdateFieldNameMappingConfigModel = []shared.DestinationSnowflakeCortexUpdateFieldNameMappingConfigModel{}
	for _, fieldNameMappingsItem := range r.Configuration.Processing.FieldNameMappings {
		var fromField string
		fromField = fieldNameMappingsItem.FromField.ValueString()

		var toField string
		toField = fieldNameMappingsItem.ToField.ValueString()

		fieldNameMappings = append(fieldNameMappings, shared.DestinationSnowflakeCortexUpdateFieldNameMappingConfigModel{
			FromField: fromField,
			ToField:   toField,
		})
	}
	var metadataFields []string = []string{}
	for _, metadataFieldsItem := range r.Configuration.Processing.MetadataFields {
		metadataFields = append(metadataFields, metadataFieldsItem.ValueString())
	}
	var textFields []string = []string{}
	for _, textFieldsItem := range r.Configuration.Processing.TextFields {
		textFields = append(textFields, textFieldsItem.ValueString())
	}
	var textSplitter *shared.DestinationSnowflakeCortexUpdateTextSplitter
	if r.Configuration.Processing.TextSplitter != nil {
		var destinationSnowflakeCortexUpdateBySeparator *shared.DestinationSnowflakeCortexUpdateBySeparator
		if r.Configuration.Processing.TextSplitter.BySeparator != nil {
			keepSeparator := new(bool)
			if !r.Configuration.Processing.TextSplitter.BySeparator.KeepSeparator.IsUnknown() && !r.Configuration.Processing.TextSplitter.BySeparator.KeepSeparator.IsNull() {
				*keepSeparator = r.Configuration.Processing.TextSplitter.BySeparator.KeepSeparator.ValueBool()
			} else {
				keepSeparator = nil
			}
			var separators []string = []string{}
			for _, separatorsItem := range r.Configuration.Processing.TextSplitter.BySeparator.Separators {
				separators = append(separators, separatorsItem.ValueString())
			}
			destinationSnowflakeCortexUpdateBySeparator = &shared.DestinationSnowflakeCortexUpdateBySeparator{
				KeepSeparator: keepSeparator,
				Separators:    separators,
			}
		}
		if destinationSnowflakeCortexUpdateBySeparator != nil {
			textSplitter = &shared.DestinationSnowflakeCortexUpdateTextSplitter{
				DestinationSnowflakeCortexUpdateBySeparator: destinationSnowflakeCortexUpdateBySeparator,
			}
		}
		var destinationSnowflakeCortexUpdateByMarkdownHeader *shared.DestinationSnowflakeCortexUpdateByMarkdownHeader
		if r.Configuration.Processing.TextSplitter.ByMarkdownHeader != nil {
			splitLevel := new(int64)
			if !r.Configuration.Processing.TextSplitter.ByMarkdownHeader.SplitLevel.IsUnknown() && !r.Configuration.Processing.TextSplitter.ByMarkdownHeader.SplitLevel.IsNull() {
				*splitLevel = r.Configuration.Processing.TextSplitter.ByMarkdownHeader.SplitLevel.ValueInt64()
			} else {
				splitLevel = nil
			}
			destinationSnowflakeCortexUpdateByMarkdownHeader = &shared.DestinationSnowflakeCortexUpdateByMarkdownHeader{
				SplitLevel: splitLevel,
			}
		}
		if destinationSnowflakeCortexUpdateByMarkdownHeader != nil {
			textSplitter = &shared.DestinationSnowflakeCortexUpdateTextSplitter{
				DestinationSnowflakeCortexUpdateByMarkdownHeader: destinationSnowflakeCortexUpdateByMarkdownHeader,
			}
		}
		var destinationSnowflakeCortexUpdateByProgrammingLanguage *shared.DestinationSnowflakeCortexUpdateByProgrammingLanguage
		if r.Configuration.Processing.TextSplitter.ByProgrammingLanguage != nil {
			language := shared.DestinationSnowflakeCortexUpdateLanguage(r.Configuration.Processing.TextSplitter.ByProgrammingLanguage.Language.ValueString())
			destinationSnowflakeCortexUpdateByProgrammingLanguage = &shared.DestinationSnowflakeCortexUpdateByProgrammingLanguage{
				Language: language,
			}
		}
		if destinationSnowflakeCortexUpdateByProgrammingLanguage != nil {
			textSplitter = &shared.DestinationSnowflakeCortexUpdateTextSplitter{
				DestinationSnowflakeCortexUpdateByProgrammingLanguage: destinationSnowflakeCortexUpdateByProgrammingLanguage,
			}
		}
	}
	processing := shared.DestinationSnowflakeCortexUpdateProcessingConfigModel{
		ChunkOverlap:      chunkOverlap,
		ChunkSize:         chunkSize,
		FieldNameMappings: fieldNameMappings,
		MetadataFields:    metadataFields,
		TextFields:        textFields,
		TextSplitter:      textSplitter,
	}
	configuration := shared.DestinationSnowflakeCortexUpdate{
		Embedding:   embedding,
		Indexing:    indexing,
		OmitRawText: omitRawText,
		Processing:  processing,
	}
	out := shared.DestinationSnowflakeCortexPutRequest{
		Name:          name,
		WorkspaceID:   workspaceID,
		Configuration: configuration,
	}
	return &out
}
