// 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 *DestinationWeaviateResourceModel) ToSharedDestinationWeaviateCreateRequest() *shared.DestinationWeaviateCreateRequest {
	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.DestinationWeaviateEmbedding
	var noExternalEmbedding *shared.NoExternalEmbedding
	if r.Configuration.Embedding.NoExternalEmbedding != nil {
		noExternalEmbedding = &shared.NoExternalEmbedding{}
	}
	if noExternalEmbedding != nil {
		embedding = shared.DestinationWeaviateEmbedding{
			NoExternalEmbedding: noExternalEmbedding,
		}
	}
	var destinationWeaviateAzureOpenAI *shared.DestinationWeaviateAzureOpenAI
	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 openaiKey string
		openaiKey = r.Configuration.Embedding.AzureOpenAI.OpenaiKey.ValueString()

		destinationWeaviateAzureOpenAI = &shared.DestinationWeaviateAzureOpenAI{
			APIBase:    apiBase,
			Deployment: deployment,
			OpenaiKey:  openaiKey,
		}
	}
	if destinationWeaviateAzureOpenAI != nil {
		embedding = shared.DestinationWeaviateEmbedding{
			DestinationWeaviateAzureOpenAI: destinationWeaviateAzureOpenAI,
		}
	}
	var destinationWeaviateOpenAI *shared.DestinationWeaviateOpenAI
	if r.Configuration.Embedding.OpenAI != nil {
		var openaiKey1 string
		openaiKey1 = r.Configuration.Embedding.OpenAI.OpenaiKey.ValueString()

		destinationWeaviateOpenAI = &shared.DestinationWeaviateOpenAI{
			OpenaiKey: openaiKey1,
		}
	}
	if destinationWeaviateOpenAI != nil {
		embedding = shared.DestinationWeaviateEmbedding{
			DestinationWeaviateOpenAI: destinationWeaviateOpenAI,
		}
	}
	var destinationWeaviateCohere *shared.DestinationWeaviateCohere
	if r.Configuration.Embedding.Cohere != nil {
		var cohereKey string
		cohereKey = r.Configuration.Embedding.Cohere.CohereKey.ValueString()

		destinationWeaviateCohere = &shared.DestinationWeaviateCohere{
			CohereKey: cohereKey,
		}
	}
	if destinationWeaviateCohere != nil {
		embedding = shared.DestinationWeaviateEmbedding{
			DestinationWeaviateCohere: destinationWeaviateCohere,
		}
	}
	var fromField *shared.FromField
	if r.Configuration.Embedding.FromField != nil {
		var dimensions int64
		dimensions = r.Configuration.Embedding.FromField.Dimensions.ValueInt64()

		var fieldName string
		fieldName = r.Configuration.Embedding.FromField.FieldName.ValueString()

		fromField = &shared.FromField{
			Dimensions: dimensions,
			FieldName:  fieldName,
		}
	}
	if fromField != nil {
		embedding = shared.DestinationWeaviateEmbedding{
			FromField: fromField,
		}
	}
	var destinationWeaviateFake *shared.DestinationWeaviateFake
	if r.Configuration.Embedding.Fake != nil {
		destinationWeaviateFake = &shared.DestinationWeaviateFake{}
	}
	if destinationWeaviateFake != nil {
		embedding = shared.DestinationWeaviateEmbedding{
			DestinationWeaviateFake: destinationWeaviateFake,
		}
	}
	var destinationWeaviateOpenAICompatible *shared.DestinationWeaviateOpenAICompatible
	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 dimensions1 int64
		dimensions1 = 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
		}
		destinationWeaviateOpenAICompatible = &shared.DestinationWeaviateOpenAICompatible{
			APIKey:     apiKey,
			BaseURL:    baseURL,
			Dimensions: dimensions1,
			ModelName:  modelName,
		}
	}
	if destinationWeaviateOpenAICompatible != nil {
		embedding = shared.DestinationWeaviateEmbedding{
			DestinationWeaviateOpenAICompatible: destinationWeaviateOpenAICompatible,
		}
	}
	var additionalHeaders []shared.Header = []shared.Header{}
	for _, additionalHeadersItem := range r.Configuration.Indexing.AdditionalHeaders {
		var headerKey string
		headerKey = additionalHeadersItem.HeaderKey.ValueString()

		var value string
		value = additionalHeadersItem.Value.ValueString()

		additionalHeaders = append(additionalHeaders, shared.Header{
			HeaderKey: headerKey,
			Value:     value,
		})
	}
	var auth shared.DestinationWeaviateAuthentication
	var destinationWeaviateAPIToken *shared.DestinationWeaviateAPIToken
	if r.Configuration.Indexing.Auth.APIToken != nil {
		var token string
		token = r.Configuration.Indexing.Auth.APIToken.Token.ValueString()

		destinationWeaviateAPIToken = &shared.DestinationWeaviateAPIToken{
			Token: token,
		}
	}
	if destinationWeaviateAPIToken != nil {
		auth = shared.DestinationWeaviateAuthentication{
			DestinationWeaviateAPIToken: destinationWeaviateAPIToken,
		}
	}
	var destinationWeaviateUsernamePassword *shared.DestinationWeaviateUsernamePassword
	if r.Configuration.Indexing.Auth.UsernamePassword != nil {
		var password string
		password = r.Configuration.Indexing.Auth.UsernamePassword.Password.ValueString()

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

		destinationWeaviateUsernamePassword = &shared.DestinationWeaviateUsernamePassword{
			Password: password,
			Username: username,
		}
	}
	if destinationWeaviateUsernamePassword != nil {
		auth = shared.DestinationWeaviateAuthentication{
			DestinationWeaviateUsernamePassword: destinationWeaviateUsernamePassword,
		}
	}
	var noAuthentication *shared.NoAuthentication
	if r.Configuration.Indexing.Auth.NoAuthentication != nil {
		noAuthentication = &shared.NoAuthentication{}
	}
	if noAuthentication != nil {
		auth = shared.DestinationWeaviateAuthentication{
			NoAuthentication: noAuthentication,
		}
	}
	batchSize := new(int64)
	if !r.Configuration.Indexing.BatchSize.IsUnknown() && !r.Configuration.Indexing.BatchSize.IsNull() {
		*batchSize = r.Configuration.Indexing.BatchSize.ValueInt64()
	} else {
		batchSize = nil
	}
	defaultVectorizer := new(shared.DefaultVectorizer)
	if !r.Configuration.Indexing.DefaultVectorizer.IsUnknown() && !r.Configuration.Indexing.DefaultVectorizer.IsNull() {
		*defaultVectorizer = shared.DefaultVectorizer(r.Configuration.Indexing.DefaultVectorizer.ValueString())
	} else {
		defaultVectorizer = nil
	}
	var host string
	host = r.Configuration.Indexing.Host.ValueString()

	tenantID := new(string)
	if !r.Configuration.Indexing.TenantID.IsUnknown() && !r.Configuration.Indexing.TenantID.IsNull() {
		*tenantID = r.Configuration.Indexing.TenantID.ValueString()
	} else {
		tenantID = nil
	}
	textField := new(string)
	if !r.Configuration.Indexing.TextField.IsUnknown() && !r.Configuration.Indexing.TextField.IsNull() {
		*textField = r.Configuration.Indexing.TextField.ValueString()
	} else {
		textField = nil
	}
	indexing := shared.DestinationWeaviateIndexing{
		AdditionalHeaders: additionalHeaders,
		Auth:              auth,
		BatchSize:         batchSize,
		DefaultVectorizer: defaultVectorizer,
		Host:              host,
		TenantID:          tenantID,
		TextField:         textField,
	}
	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.DestinationWeaviateFieldNameMappingConfigModel = []shared.DestinationWeaviateFieldNameMappingConfigModel{}
	for _, fieldNameMappingsItem := range r.Configuration.Processing.FieldNameMappings {
		var fromField1 string
		fromField1 = fieldNameMappingsItem.FromField.ValueString()

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

		fieldNameMappings = append(fieldNameMappings, shared.DestinationWeaviateFieldNameMappingConfigModel{
			FromField: fromField1,
			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.DestinationWeaviateTextSplitter
	if r.Configuration.Processing.TextSplitter != nil {
		var destinationWeaviateBySeparator *shared.DestinationWeaviateBySeparator
		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())
			}
			destinationWeaviateBySeparator = &shared.DestinationWeaviateBySeparator{
				KeepSeparator: keepSeparator,
				Separators:    separators,
			}
		}
		if destinationWeaviateBySeparator != nil {
			textSplitter = &shared.DestinationWeaviateTextSplitter{
				DestinationWeaviateBySeparator: destinationWeaviateBySeparator,
			}
		}
		var destinationWeaviateByMarkdownHeader *shared.DestinationWeaviateByMarkdownHeader
		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
			}
			destinationWeaviateByMarkdownHeader = &shared.DestinationWeaviateByMarkdownHeader{
				SplitLevel: splitLevel,
			}
		}
		if destinationWeaviateByMarkdownHeader != nil {
			textSplitter = &shared.DestinationWeaviateTextSplitter{
				DestinationWeaviateByMarkdownHeader: destinationWeaviateByMarkdownHeader,
			}
		}
		var destinationWeaviateByProgrammingLanguage *shared.DestinationWeaviateByProgrammingLanguage
		if r.Configuration.Processing.TextSplitter.ByProgrammingLanguage != nil {
			language := shared.DestinationWeaviateLanguage(r.Configuration.Processing.TextSplitter.ByProgrammingLanguage.Language.ValueString())
			destinationWeaviateByProgrammingLanguage = &shared.DestinationWeaviateByProgrammingLanguage{
				Language: language,
			}
		}
		if destinationWeaviateByProgrammingLanguage != nil {
			textSplitter = &shared.DestinationWeaviateTextSplitter{
				DestinationWeaviateByProgrammingLanguage: destinationWeaviateByProgrammingLanguage,
			}
		}
	}
	processing := shared.DestinationWeaviateProcessingConfigModel{
		ChunkOverlap:      chunkOverlap,
		ChunkSize:         chunkSize,
		FieldNameMappings: fieldNameMappings,
		MetadataFields:    metadataFields,
		TextFields:        textFields,
		TextSplitter:      textSplitter,
	}
	configuration := shared.DestinationWeaviate{
		Embedding:   embedding,
		Indexing:    indexing,
		OmitRawText: omitRawText,
		Processing:  processing,
	}
	out := shared.DestinationWeaviateCreateRequest{
		Name:          name,
		DefinitionID:  definitionID,
		WorkspaceID:   workspaceID,
		Configuration: configuration,
	}
	return &out
}

func (r *DestinationWeaviateResourceModel) 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 *DestinationWeaviateResourceModel) ToSharedDestinationWeaviatePutRequest() *shared.DestinationWeaviatePutRequest {
	var name string
	name = r.Name.ValueString()

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

	var embedding shared.DestinationWeaviateUpdateEmbedding
	var destinationWeaviateUpdateNoExternalEmbedding *shared.DestinationWeaviateUpdateNoExternalEmbedding
	if r.Configuration.Embedding.NoExternalEmbedding != nil {
		destinationWeaviateUpdateNoExternalEmbedding = &shared.DestinationWeaviateUpdateNoExternalEmbedding{}
	}
	if destinationWeaviateUpdateNoExternalEmbedding != nil {
		embedding = shared.DestinationWeaviateUpdateEmbedding{
			DestinationWeaviateUpdateNoExternalEmbedding: destinationWeaviateUpdateNoExternalEmbedding,
		}
	}
	var destinationWeaviateUpdateAzureOpenAI *shared.DestinationWeaviateUpdateAzureOpenAI
	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 openaiKey string
		openaiKey = r.Configuration.Embedding.AzureOpenAI.OpenaiKey.ValueString()

		destinationWeaviateUpdateAzureOpenAI = &shared.DestinationWeaviateUpdateAzureOpenAI{
			APIBase:    apiBase,
			Deployment: deployment,
			OpenaiKey:  openaiKey,
		}
	}
	if destinationWeaviateUpdateAzureOpenAI != nil {
		embedding = shared.DestinationWeaviateUpdateEmbedding{
			DestinationWeaviateUpdateAzureOpenAI: destinationWeaviateUpdateAzureOpenAI,
		}
	}
	var destinationWeaviateUpdateOpenAI *shared.DestinationWeaviateUpdateOpenAI
	if r.Configuration.Embedding.OpenAI != nil {
		var openaiKey1 string
		openaiKey1 = r.Configuration.Embedding.OpenAI.OpenaiKey.ValueString()

		destinationWeaviateUpdateOpenAI = &shared.DestinationWeaviateUpdateOpenAI{
			OpenaiKey: openaiKey1,
		}
	}
	if destinationWeaviateUpdateOpenAI != nil {
		embedding = shared.DestinationWeaviateUpdateEmbedding{
			DestinationWeaviateUpdateOpenAI: destinationWeaviateUpdateOpenAI,
		}
	}
	var destinationWeaviateUpdateCohere *shared.DestinationWeaviateUpdateCohere
	if r.Configuration.Embedding.Cohere != nil {
		var cohereKey string
		cohereKey = r.Configuration.Embedding.Cohere.CohereKey.ValueString()

		destinationWeaviateUpdateCohere = &shared.DestinationWeaviateUpdateCohere{
			CohereKey: cohereKey,
		}
	}
	if destinationWeaviateUpdateCohere != nil {
		embedding = shared.DestinationWeaviateUpdateEmbedding{
			DestinationWeaviateUpdateCohere: destinationWeaviateUpdateCohere,
		}
	}
	var destinationWeaviateUpdateFromField *shared.DestinationWeaviateUpdateFromField
	if r.Configuration.Embedding.FromField != nil {
		var dimensions int64
		dimensions = r.Configuration.Embedding.FromField.Dimensions.ValueInt64()

		var fieldName string
		fieldName = r.Configuration.Embedding.FromField.FieldName.ValueString()

		destinationWeaviateUpdateFromField = &shared.DestinationWeaviateUpdateFromField{
			Dimensions: dimensions,
			FieldName:  fieldName,
		}
	}
	if destinationWeaviateUpdateFromField != nil {
		embedding = shared.DestinationWeaviateUpdateEmbedding{
			DestinationWeaviateUpdateFromField: destinationWeaviateUpdateFromField,
		}
	}
	var destinationWeaviateUpdateFake *shared.DestinationWeaviateUpdateFake
	if r.Configuration.Embedding.Fake != nil {
		destinationWeaviateUpdateFake = &shared.DestinationWeaviateUpdateFake{}
	}
	if destinationWeaviateUpdateFake != nil {
		embedding = shared.DestinationWeaviateUpdateEmbedding{
			DestinationWeaviateUpdateFake: destinationWeaviateUpdateFake,
		}
	}
	var destinationWeaviateUpdateOpenAICompatible *shared.DestinationWeaviateUpdateOpenAICompatible
	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 dimensions1 int64
		dimensions1 = 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
		}
		destinationWeaviateUpdateOpenAICompatible = &shared.DestinationWeaviateUpdateOpenAICompatible{
			APIKey:     apiKey,
			BaseURL:    baseURL,
			Dimensions: dimensions1,
			ModelName:  modelName,
		}
	}
	if destinationWeaviateUpdateOpenAICompatible != nil {
		embedding = shared.DestinationWeaviateUpdateEmbedding{
			DestinationWeaviateUpdateOpenAICompatible: destinationWeaviateUpdateOpenAICompatible,
		}
	}
	var additionalHeaders []shared.DestinationWeaviateUpdateHeader = []shared.DestinationWeaviateUpdateHeader{}
	for _, additionalHeadersItem := range r.Configuration.Indexing.AdditionalHeaders {
		var headerKey string
		headerKey = additionalHeadersItem.HeaderKey.ValueString()

		var value string
		value = additionalHeadersItem.Value.ValueString()

		additionalHeaders = append(additionalHeaders, shared.DestinationWeaviateUpdateHeader{
			HeaderKey: headerKey,
			Value:     value,
		})
	}
	var auth shared.DestinationWeaviateUpdateAuthentication
	var destinationWeaviateUpdateAPIToken *shared.DestinationWeaviateUpdateAPIToken
	if r.Configuration.Indexing.Auth.APIToken != nil {
		var token string
		token = r.Configuration.Indexing.Auth.APIToken.Token.ValueString()

		destinationWeaviateUpdateAPIToken = &shared.DestinationWeaviateUpdateAPIToken{
			Token: token,
		}
	}
	if destinationWeaviateUpdateAPIToken != nil {
		auth = shared.DestinationWeaviateUpdateAuthentication{
			DestinationWeaviateUpdateAPIToken: destinationWeaviateUpdateAPIToken,
		}
	}
	var destinationWeaviateUpdateUsernamePassword *shared.DestinationWeaviateUpdateUsernamePassword
	if r.Configuration.Indexing.Auth.UsernamePassword != nil {
		var password string
		password = r.Configuration.Indexing.Auth.UsernamePassword.Password.ValueString()

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

		destinationWeaviateUpdateUsernamePassword = &shared.DestinationWeaviateUpdateUsernamePassword{
			Password: password,
			Username: username,
		}
	}
	if destinationWeaviateUpdateUsernamePassword != nil {
		auth = shared.DestinationWeaviateUpdateAuthentication{
			DestinationWeaviateUpdateUsernamePassword: destinationWeaviateUpdateUsernamePassword,
		}
	}
	var destinationWeaviateUpdateNoAuthentication *shared.DestinationWeaviateUpdateNoAuthentication
	if r.Configuration.Indexing.Auth.NoAuthentication != nil {
		destinationWeaviateUpdateNoAuthentication = &shared.DestinationWeaviateUpdateNoAuthentication{}
	}
	if destinationWeaviateUpdateNoAuthentication != nil {
		auth = shared.DestinationWeaviateUpdateAuthentication{
			DestinationWeaviateUpdateNoAuthentication: destinationWeaviateUpdateNoAuthentication,
		}
	}
	batchSize := new(int64)
	if !r.Configuration.Indexing.BatchSize.IsUnknown() && !r.Configuration.Indexing.BatchSize.IsNull() {
		*batchSize = r.Configuration.Indexing.BatchSize.ValueInt64()
	} else {
		batchSize = nil
	}
	defaultVectorizer := new(shared.DestinationWeaviateUpdateDefaultVectorizer)
	if !r.Configuration.Indexing.DefaultVectorizer.IsUnknown() && !r.Configuration.Indexing.DefaultVectorizer.IsNull() {
		*defaultVectorizer = shared.DestinationWeaviateUpdateDefaultVectorizer(r.Configuration.Indexing.DefaultVectorizer.ValueString())
	} else {
		defaultVectorizer = nil
	}
	var host string
	host = r.Configuration.Indexing.Host.ValueString()

	tenantID := new(string)
	if !r.Configuration.Indexing.TenantID.IsUnknown() && !r.Configuration.Indexing.TenantID.IsNull() {
		*tenantID = r.Configuration.Indexing.TenantID.ValueString()
	} else {
		tenantID = nil
	}
	textField := new(string)
	if !r.Configuration.Indexing.TextField.IsUnknown() && !r.Configuration.Indexing.TextField.IsNull() {
		*textField = r.Configuration.Indexing.TextField.ValueString()
	} else {
		textField = nil
	}
	indexing := shared.DestinationWeaviateUpdateIndexing{
		AdditionalHeaders: additionalHeaders,
		Auth:              auth,
		BatchSize:         batchSize,
		DefaultVectorizer: defaultVectorizer,
		Host:              host,
		TenantID:          tenantID,
		TextField:         textField,
	}
	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.DestinationWeaviateUpdateFieldNameMappingConfigModel = []shared.DestinationWeaviateUpdateFieldNameMappingConfigModel{}
	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.DestinationWeaviateUpdateFieldNameMappingConfigModel{
			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.DestinationWeaviateUpdateTextSplitter
	if r.Configuration.Processing.TextSplitter != nil {
		var destinationWeaviateUpdateBySeparator *shared.DestinationWeaviateUpdateBySeparator
		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())
			}
			destinationWeaviateUpdateBySeparator = &shared.DestinationWeaviateUpdateBySeparator{
				KeepSeparator: keepSeparator,
				Separators:    separators,
			}
		}
		if destinationWeaviateUpdateBySeparator != nil {
			textSplitter = &shared.DestinationWeaviateUpdateTextSplitter{
				DestinationWeaviateUpdateBySeparator: destinationWeaviateUpdateBySeparator,
			}
		}
		var destinationWeaviateUpdateByMarkdownHeader *shared.DestinationWeaviateUpdateByMarkdownHeader
		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
			}
			destinationWeaviateUpdateByMarkdownHeader = &shared.DestinationWeaviateUpdateByMarkdownHeader{
				SplitLevel: splitLevel,
			}
		}
		if destinationWeaviateUpdateByMarkdownHeader != nil {
			textSplitter = &shared.DestinationWeaviateUpdateTextSplitter{
				DestinationWeaviateUpdateByMarkdownHeader: destinationWeaviateUpdateByMarkdownHeader,
			}
		}
		var destinationWeaviateUpdateByProgrammingLanguage *shared.DestinationWeaviateUpdateByProgrammingLanguage
		if r.Configuration.Processing.TextSplitter.ByProgrammingLanguage != nil {
			language := shared.DestinationWeaviateUpdateLanguage(r.Configuration.Processing.TextSplitter.ByProgrammingLanguage.Language.ValueString())
			destinationWeaviateUpdateByProgrammingLanguage = &shared.DestinationWeaviateUpdateByProgrammingLanguage{
				Language: language,
			}
		}
		if destinationWeaviateUpdateByProgrammingLanguage != nil {
			textSplitter = &shared.DestinationWeaviateUpdateTextSplitter{
				DestinationWeaviateUpdateByProgrammingLanguage: destinationWeaviateUpdateByProgrammingLanguage,
			}
		}
	}
	processing := shared.DestinationWeaviateUpdateProcessingConfigModel{
		ChunkOverlap:      chunkOverlap,
		ChunkSize:         chunkSize,
		FieldNameMappings: fieldNameMappings,
		MetadataFields:    metadataFields,
		TextFields:        textFields,
		TextSplitter:      textSplitter,
	}
	configuration := shared.DestinationWeaviateUpdate{
		Embedding:   embedding,
		Indexing:    indexing,
		OmitRawText: omitRawText,
		Processing:  processing,
	}
	out := shared.DestinationWeaviatePutRequest{
		Name:          name,
		WorkspaceID:   workspaceID,
		Configuration: configuration,
	}
	return &out
}
