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

package provider

import (
	"encoding/json"
	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 *DestinationMssqlV2ResourceModel) ToSharedDestinationMssqlV2CreateRequest() *shared.DestinationMssqlV2CreateRequest {
	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 database string
	database = r.Configuration.Database.ValueString()

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

	jdbcURLParams := new(string)
	if !r.Configuration.JdbcURLParams.IsUnknown() && !r.Configuration.JdbcURLParams.IsNull() {
		*jdbcURLParams = r.Configuration.JdbcURLParams.ValueString()
	} else {
		jdbcURLParams = nil
	}
	var loadType shared.DestinationMssqlV2LoadType
	var destinationMssqlV2InsertLoad *shared.DestinationMssqlV2InsertLoad
	if r.Configuration.LoadType.InsertLoad != nil {
		loadType1 := new(shared.DestinationMssqlV2SchemasLoadTypeLoadType)
		if !r.Configuration.LoadType.InsertLoad.LoadType.IsUnknown() && !r.Configuration.LoadType.InsertLoad.LoadType.IsNull() {
			*loadType1 = shared.DestinationMssqlV2SchemasLoadTypeLoadType(r.Configuration.LoadType.InsertLoad.LoadType.ValueString())
		} else {
			loadType1 = nil
		}
		var additionalProperties interface{}
		if !r.Configuration.LoadType.InsertLoad.AdditionalProperties.IsUnknown() && !r.Configuration.LoadType.InsertLoad.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.LoadType.InsertLoad.AdditionalProperties.ValueString()), &additionalProperties)
		}
		destinationMssqlV2InsertLoad = &shared.DestinationMssqlV2InsertLoad{
			LoadType:             loadType1,
			AdditionalProperties: additionalProperties,
		}
	}
	if destinationMssqlV2InsertLoad != nil {
		loadType = shared.DestinationMssqlV2LoadType{
			DestinationMssqlV2InsertLoad: destinationMssqlV2InsertLoad,
		}
	}
	var destinationMssqlV2BulkLoad *shared.DestinationMssqlV2BulkLoad
	if r.Configuration.LoadType.BulkLoad != nil {
		var azureBlobStorageAccountName string
		azureBlobStorageAccountName = r.Configuration.LoadType.BulkLoad.AzureBlobStorageAccountName.ValueString()

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

		var bulkLoadDataSource string
		bulkLoadDataSource = r.Configuration.LoadType.BulkLoad.BulkLoadDataSource.ValueString()

		bulkLoadValidateValuesPreLoad := new(bool)
		if !r.Configuration.LoadType.BulkLoad.BulkLoadValidateValuesPreLoad.IsUnknown() && !r.Configuration.LoadType.BulkLoad.BulkLoadValidateValuesPreLoad.IsNull() {
			*bulkLoadValidateValuesPreLoad = r.Configuration.LoadType.BulkLoad.BulkLoadValidateValuesPreLoad.ValueBool()
		} else {
			bulkLoadValidateValuesPreLoad = nil
		}
		loadType2 := new(shared.DestinationMssqlV2SchemasLoadType)
		if !r.Configuration.LoadType.BulkLoad.LoadType.IsUnknown() && !r.Configuration.LoadType.BulkLoad.LoadType.IsNull() {
			*loadType2 = shared.DestinationMssqlV2SchemasLoadType(r.Configuration.LoadType.BulkLoad.LoadType.ValueString())
		} else {
			loadType2 = nil
		}
		var sharedAccessSignature string
		sharedAccessSignature = r.Configuration.LoadType.BulkLoad.SharedAccessSignature.ValueString()

		var additionalProperties1 interface{}
		if !r.Configuration.LoadType.BulkLoad.AdditionalProperties.IsUnknown() && !r.Configuration.LoadType.BulkLoad.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.LoadType.BulkLoad.AdditionalProperties.ValueString()), &additionalProperties1)
		}
		destinationMssqlV2BulkLoad = &shared.DestinationMssqlV2BulkLoad{
			AzureBlobStorageAccountName:   azureBlobStorageAccountName,
			AzureBlobStorageContainerName: azureBlobStorageContainerName,
			BulkLoadDataSource:            bulkLoadDataSource,
			BulkLoadValidateValuesPreLoad: bulkLoadValidateValuesPreLoad,
			LoadType:                      loadType2,
			SharedAccessSignature:         sharedAccessSignature,
			AdditionalProperties:          additionalProperties1,
		}
	}
	if destinationMssqlV2BulkLoad != nil {
		loadType = shared.DestinationMssqlV2LoadType{
			DestinationMssqlV2BulkLoad: destinationMssqlV2BulkLoad,
		}
	}
	password := new(string)
	if !r.Configuration.Password.IsUnknown() && !r.Configuration.Password.IsNull() {
		*password = r.Configuration.Password.ValueString()
	} else {
		password = nil
	}
	var port int64
	port = r.Configuration.Port.ValueInt64()

	schema := new(string)
	if !r.Configuration.Schema.IsUnknown() && !r.Configuration.Schema.IsNull() {
		*schema = r.Configuration.Schema.ValueString()
	} else {
		schema = nil
	}
	var sslMethod shared.DestinationMssqlV2SSLMethod
	var destinationMssqlV2Unencrypted *shared.DestinationMssqlV2Unencrypted
	if r.Configuration.SslMethod.Unencrypted != nil {
		name1 := new(shared.DestinationMssqlV2Name)
		if !r.Configuration.SslMethod.Unencrypted.Name.IsUnknown() && !r.Configuration.SslMethod.Unencrypted.Name.IsNull() {
			*name1 = shared.DestinationMssqlV2Name(r.Configuration.SslMethod.Unencrypted.Name.ValueString())
		} else {
			name1 = nil
		}
		var additionalProperties2 interface{}
		if !r.Configuration.SslMethod.Unencrypted.AdditionalProperties.IsUnknown() && !r.Configuration.SslMethod.Unencrypted.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.SslMethod.Unencrypted.AdditionalProperties.ValueString()), &additionalProperties2)
		}
		destinationMssqlV2Unencrypted = &shared.DestinationMssqlV2Unencrypted{
			Name:                 name1,
			AdditionalProperties: additionalProperties2,
		}
	}
	if destinationMssqlV2Unencrypted != nil {
		sslMethod = shared.DestinationMssqlV2SSLMethod{
			DestinationMssqlV2Unencrypted: destinationMssqlV2Unencrypted,
		}
	}
	var destinationMssqlV2EncryptedTrustServerCertificate *shared.DestinationMssqlV2EncryptedTrustServerCertificate
	if r.Configuration.SslMethod.EncryptedTrustServerCertificate != nil {
		name2 := new(shared.DestinationMssqlV2SchemasName)
		if !r.Configuration.SslMethod.EncryptedTrustServerCertificate.Name.IsUnknown() && !r.Configuration.SslMethod.EncryptedTrustServerCertificate.Name.IsNull() {
			*name2 = shared.DestinationMssqlV2SchemasName(r.Configuration.SslMethod.EncryptedTrustServerCertificate.Name.ValueString())
		} else {
			name2 = nil
		}
		var additionalProperties3 interface{}
		if !r.Configuration.SslMethod.EncryptedTrustServerCertificate.AdditionalProperties.IsUnknown() && !r.Configuration.SslMethod.EncryptedTrustServerCertificate.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.SslMethod.EncryptedTrustServerCertificate.AdditionalProperties.ValueString()), &additionalProperties3)
		}
		destinationMssqlV2EncryptedTrustServerCertificate = &shared.DestinationMssqlV2EncryptedTrustServerCertificate{
			Name:                 name2,
			AdditionalProperties: additionalProperties3,
		}
	}
	if destinationMssqlV2EncryptedTrustServerCertificate != nil {
		sslMethod = shared.DestinationMssqlV2SSLMethod{
			DestinationMssqlV2EncryptedTrustServerCertificate: destinationMssqlV2EncryptedTrustServerCertificate,
		}
	}
	var destinationMssqlV2EncryptedVerifyCertificate *shared.DestinationMssqlV2EncryptedVerifyCertificate
	if r.Configuration.SslMethod.EncryptedVerifyCertificate != nil {
		hostNameInCertificate := new(string)
		if !r.Configuration.SslMethod.EncryptedVerifyCertificate.HostNameInCertificate.IsUnknown() && !r.Configuration.SslMethod.EncryptedVerifyCertificate.HostNameInCertificate.IsNull() {
			*hostNameInCertificate = r.Configuration.SslMethod.EncryptedVerifyCertificate.HostNameInCertificate.ValueString()
		} else {
			hostNameInCertificate = nil
		}
		name3 := new(shared.DestinationMssqlV2SchemasSslMethodName)
		if !r.Configuration.SslMethod.EncryptedVerifyCertificate.Name.IsUnknown() && !r.Configuration.SslMethod.EncryptedVerifyCertificate.Name.IsNull() {
			*name3 = shared.DestinationMssqlV2SchemasSslMethodName(r.Configuration.SslMethod.EncryptedVerifyCertificate.Name.ValueString())
		} else {
			name3 = nil
		}
		trustStoreName := new(string)
		if !r.Configuration.SslMethod.EncryptedVerifyCertificate.TrustStoreName.IsUnknown() && !r.Configuration.SslMethod.EncryptedVerifyCertificate.TrustStoreName.IsNull() {
			*trustStoreName = r.Configuration.SslMethod.EncryptedVerifyCertificate.TrustStoreName.ValueString()
		} else {
			trustStoreName = nil
		}
		trustStorePassword := new(string)
		if !r.Configuration.SslMethod.EncryptedVerifyCertificate.TrustStorePassword.IsUnknown() && !r.Configuration.SslMethod.EncryptedVerifyCertificate.TrustStorePassword.IsNull() {
			*trustStorePassword = r.Configuration.SslMethod.EncryptedVerifyCertificate.TrustStorePassword.ValueString()
		} else {
			trustStorePassword = nil
		}
		var additionalProperties4 interface{}
		if !r.Configuration.SslMethod.EncryptedVerifyCertificate.AdditionalProperties.IsUnknown() && !r.Configuration.SslMethod.EncryptedVerifyCertificate.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.SslMethod.EncryptedVerifyCertificate.AdditionalProperties.ValueString()), &additionalProperties4)
		}
		destinationMssqlV2EncryptedVerifyCertificate = &shared.DestinationMssqlV2EncryptedVerifyCertificate{
			HostNameInCertificate: hostNameInCertificate,
			Name:                  name3,
			TrustStoreName:        trustStoreName,
			TrustStorePassword:    trustStorePassword,
			AdditionalProperties:  additionalProperties4,
		}
	}
	if destinationMssqlV2EncryptedVerifyCertificate != nil {
		sslMethod = shared.DestinationMssqlV2SSLMethod{
			DestinationMssqlV2EncryptedVerifyCertificate: destinationMssqlV2EncryptedVerifyCertificate,
		}
	}
	var user string
	user = r.Configuration.User.ValueString()

	configuration := shared.DestinationMssqlV2{
		Database:      database,
		Host:          host,
		JdbcURLParams: jdbcURLParams,
		LoadType:      loadType,
		Password:      password,
		Port:          port,
		Schema:        schema,
		SslMethod:     sslMethod,
		User:          user,
	}
	out := shared.DestinationMssqlV2CreateRequest{
		Name:          name,
		DefinitionID:  definitionID,
		WorkspaceID:   workspaceID,
		Configuration: configuration,
	}
	return &out
}

func (r *DestinationMssqlV2ResourceModel) 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 *DestinationMssqlV2ResourceModel) ToSharedDestinationMssqlV2PutRequest() *shared.DestinationMssqlV2PutRequest {
	var name string
	name = r.Name.ValueString()

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

	var database string
	database = r.Configuration.Database.ValueString()

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

	jdbcURLParams := new(string)
	if !r.Configuration.JdbcURLParams.IsUnknown() && !r.Configuration.JdbcURLParams.IsNull() {
		*jdbcURLParams = r.Configuration.JdbcURLParams.ValueString()
	} else {
		jdbcURLParams = nil
	}
	var loadType shared.DestinationMssqlV2UpdateLoadType
	var destinationMssqlV2UpdateInsertLoad *shared.DestinationMssqlV2UpdateInsertLoad
	if r.Configuration.LoadType.InsertLoad != nil {
		loadType1 := new(shared.DestinationMssqlV2UpdateSchemasLoadTypeLoadType)
		if !r.Configuration.LoadType.InsertLoad.LoadType.IsUnknown() && !r.Configuration.LoadType.InsertLoad.LoadType.IsNull() {
			*loadType1 = shared.DestinationMssqlV2UpdateSchemasLoadTypeLoadType(r.Configuration.LoadType.InsertLoad.LoadType.ValueString())
		} else {
			loadType1 = nil
		}
		var additionalProperties interface{}
		if !r.Configuration.LoadType.InsertLoad.AdditionalProperties.IsUnknown() && !r.Configuration.LoadType.InsertLoad.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.LoadType.InsertLoad.AdditionalProperties.ValueString()), &additionalProperties)
		}
		destinationMssqlV2UpdateInsertLoad = &shared.DestinationMssqlV2UpdateInsertLoad{
			LoadType:             loadType1,
			AdditionalProperties: additionalProperties,
		}
	}
	if destinationMssqlV2UpdateInsertLoad != nil {
		loadType = shared.DestinationMssqlV2UpdateLoadType{
			DestinationMssqlV2UpdateInsertLoad: destinationMssqlV2UpdateInsertLoad,
		}
	}
	var destinationMssqlV2UpdateBulkLoad *shared.DestinationMssqlV2UpdateBulkLoad
	if r.Configuration.LoadType.BulkLoad != nil {
		var azureBlobStorageAccountName string
		azureBlobStorageAccountName = r.Configuration.LoadType.BulkLoad.AzureBlobStorageAccountName.ValueString()

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

		var bulkLoadDataSource string
		bulkLoadDataSource = r.Configuration.LoadType.BulkLoad.BulkLoadDataSource.ValueString()

		bulkLoadValidateValuesPreLoad := new(bool)
		if !r.Configuration.LoadType.BulkLoad.BulkLoadValidateValuesPreLoad.IsUnknown() && !r.Configuration.LoadType.BulkLoad.BulkLoadValidateValuesPreLoad.IsNull() {
			*bulkLoadValidateValuesPreLoad = r.Configuration.LoadType.BulkLoad.BulkLoadValidateValuesPreLoad.ValueBool()
		} else {
			bulkLoadValidateValuesPreLoad = nil
		}
		loadType2 := new(shared.DestinationMssqlV2UpdateSchemasLoadType)
		if !r.Configuration.LoadType.BulkLoad.LoadType.IsUnknown() && !r.Configuration.LoadType.BulkLoad.LoadType.IsNull() {
			*loadType2 = shared.DestinationMssqlV2UpdateSchemasLoadType(r.Configuration.LoadType.BulkLoad.LoadType.ValueString())
		} else {
			loadType2 = nil
		}
		var sharedAccessSignature string
		sharedAccessSignature = r.Configuration.LoadType.BulkLoad.SharedAccessSignature.ValueString()

		var additionalProperties1 interface{}
		if !r.Configuration.LoadType.BulkLoad.AdditionalProperties.IsUnknown() && !r.Configuration.LoadType.BulkLoad.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.LoadType.BulkLoad.AdditionalProperties.ValueString()), &additionalProperties1)
		}
		destinationMssqlV2UpdateBulkLoad = &shared.DestinationMssqlV2UpdateBulkLoad{
			AzureBlobStorageAccountName:   azureBlobStorageAccountName,
			AzureBlobStorageContainerName: azureBlobStorageContainerName,
			BulkLoadDataSource:            bulkLoadDataSource,
			BulkLoadValidateValuesPreLoad: bulkLoadValidateValuesPreLoad,
			LoadType:                      loadType2,
			SharedAccessSignature:         sharedAccessSignature,
			AdditionalProperties:          additionalProperties1,
		}
	}
	if destinationMssqlV2UpdateBulkLoad != nil {
		loadType = shared.DestinationMssqlV2UpdateLoadType{
			DestinationMssqlV2UpdateBulkLoad: destinationMssqlV2UpdateBulkLoad,
		}
	}
	password := new(string)
	if !r.Configuration.Password.IsUnknown() && !r.Configuration.Password.IsNull() {
		*password = r.Configuration.Password.ValueString()
	} else {
		password = nil
	}
	var port int64
	port = r.Configuration.Port.ValueInt64()

	schema := new(string)
	if !r.Configuration.Schema.IsUnknown() && !r.Configuration.Schema.IsNull() {
		*schema = r.Configuration.Schema.ValueString()
	} else {
		schema = nil
	}
	var sslMethod shared.DestinationMssqlV2UpdateSSLMethod
	var destinationMssqlV2UpdateUnencrypted *shared.DestinationMssqlV2UpdateUnencrypted
	if r.Configuration.SslMethod.Unencrypted != nil {
		name1 := new(shared.DestinationMssqlV2UpdateName)
		if !r.Configuration.SslMethod.Unencrypted.Name.IsUnknown() && !r.Configuration.SslMethod.Unencrypted.Name.IsNull() {
			*name1 = shared.DestinationMssqlV2UpdateName(r.Configuration.SslMethod.Unencrypted.Name.ValueString())
		} else {
			name1 = nil
		}
		var additionalProperties2 interface{}
		if !r.Configuration.SslMethod.Unencrypted.AdditionalProperties.IsUnknown() && !r.Configuration.SslMethod.Unencrypted.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.SslMethod.Unencrypted.AdditionalProperties.ValueString()), &additionalProperties2)
		}
		destinationMssqlV2UpdateUnencrypted = &shared.DestinationMssqlV2UpdateUnencrypted{
			Name:                 name1,
			AdditionalProperties: additionalProperties2,
		}
	}
	if destinationMssqlV2UpdateUnencrypted != nil {
		sslMethod = shared.DestinationMssqlV2UpdateSSLMethod{
			DestinationMssqlV2UpdateUnencrypted: destinationMssqlV2UpdateUnencrypted,
		}
	}
	var destinationMssqlV2UpdateEncryptedTrustServerCertificate *shared.DestinationMssqlV2UpdateEncryptedTrustServerCertificate
	if r.Configuration.SslMethod.EncryptedTrustServerCertificate != nil {
		name2 := new(shared.DestinationMssqlV2UpdateSchemasName)
		if !r.Configuration.SslMethod.EncryptedTrustServerCertificate.Name.IsUnknown() && !r.Configuration.SslMethod.EncryptedTrustServerCertificate.Name.IsNull() {
			*name2 = shared.DestinationMssqlV2UpdateSchemasName(r.Configuration.SslMethod.EncryptedTrustServerCertificate.Name.ValueString())
		} else {
			name2 = nil
		}
		var additionalProperties3 interface{}
		if !r.Configuration.SslMethod.EncryptedTrustServerCertificate.AdditionalProperties.IsUnknown() && !r.Configuration.SslMethod.EncryptedTrustServerCertificate.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.SslMethod.EncryptedTrustServerCertificate.AdditionalProperties.ValueString()), &additionalProperties3)
		}
		destinationMssqlV2UpdateEncryptedTrustServerCertificate = &shared.DestinationMssqlV2UpdateEncryptedTrustServerCertificate{
			Name:                 name2,
			AdditionalProperties: additionalProperties3,
		}
	}
	if destinationMssqlV2UpdateEncryptedTrustServerCertificate != nil {
		sslMethod = shared.DestinationMssqlV2UpdateSSLMethod{
			DestinationMssqlV2UpdateEncryptedTrustServerCertificate: destinationMssqlV2UpdateEncryptedTrustServerCertificate,
		}
	}
	var destinationMssqlV2UpdateEncryptedVerifyCertificate *shared.DestinationMssqlV2UpdateEncryptedVerifyCertificate
	if r.Configuration.SslMethod.EncryptedVerifyCertificate != nil {
		hostNameInCertificate := new(string)
		if !r.Configuration.SslMethod.EncryptedVerifyCertificate.HostNameInCertificate.IsUnknown() && !r.Configuration.SslMethod.EncryptedVerifyCertificate.HostNameInCertificate.IsNull() {
			*hostNameInCertificate = r.Configuration.SslMethod.EncryptedVerifyCertificate.HostNameInCertificate.ValueString()
		} else {
			hostNameInCertificate = nil
		}
		name3 := new(shared.DestinationMssqlV2UpdateSchemasSslMethodName)
		if !r.Configuration.SslMethod.EncryptedVerifyCertificate.Name.IsUnknown() && !r.Configuration.SslMethod.EncryptedVerifyCertificate.Name.IsNull() {
			*name3 = shared.DestinationMssqlV2UpdateSchemasSslMethodName(r.Configuration.SslMethod.EncryptedVerifyCertificate.Name.ValueString())
		} else {
			name3 = nil
		}
		trustStoreName := new(string)
		if !r.Configuration.SslMethod.EncryptedVerifyCertificate.TrustStoreName.IsUnknown() && !r.Configuration.SslMethod.EncryptedVerifyCertificate.TrustStoreName.IsNull() {
			*trustStoreName = r.Configuration.SslMethod.EncryptedVerifyCertificate.TrustStoreName.ValueString()
		} else {
			trustStoreName = nil
		}
		trustStorePassword := new(string)
		if !r.Configuration.SslMethod.EncryptedVerifyCertificate.TrustStorePassword.IsUnknown() && !r.Configuration.SslMethod.EncryptedVerifyCertificate.TrustStorePassword.IsNull() {
			*trustStorePassword = r.Configuration.SslMethod.EncryptedVerifyCertificate.TrustStorePassword.ValueString()
		} else {
			trustStorePassword = nil
		}
		var additionalProperties4 interface{}
		if !r.Configuration.SslMethod.EncryptedVerifyCertificate.AdditionalProperties.IsUnknown() && !r.Configuration.SslMethod.EncryptedVerifyCertificate.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.SslMethod.EncryptedVerifyCertificate.AdditionalProperties.ValueString()), &additionalProperties4)
		}
		destinationMssqlV2UpdateEncryptedVerifyCertificate = &shared.DestinationMssqlV2UpdateEncryptedVerifyCertificate{
			HostNameInCertificate: hostNameInCertificate,
			Name:                  name3,
			TrustStoreName:        trustStoreName,
			TrustStorePassword:    trustStorePassword,
			AdditionalProperties:  additionalProperties4,
		}
	}
	if destinationMssqlV2UpdateEncryptedVerifyCertificate != nil {
		sslMethod = shared.DestinationMssqlV2UpdateSSLMethod{
			DestinationMssqlV2UpdateEncryptedVerifyCertificate: destinationMssqlV2UpdateEncryptedVerifyCertificate,
		}
	}
	var user string
	user = r.Configuration.User.ValueString()

	configuration := shared.DestinationMssqlV2Update{
		Database:      database,
		Host:          host,
		JdbcURLParams: jdbcURLParams,
		LoadType:      loadType,
		Password:      password,
		Port:          port,
		Schema:        schema,
		SslMethod:     sslMethod,
		User:          user,
	}
	out := shared.DestinationMssqlV2PutRequest{
		Name:          name,
		WorkspaceID:   workspaceID,
		Configuration: configuration,
	}
	return &out
}
