// 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 *DestinationPostgresResourceModel) ToSharedDestinationPostgresCreateRequest() *shared.DestinationPostgresCreateRequest {
	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()

	disableTypeDedupe := new(bool)
	if !r.Configuration.DisableTypeDedupe.IsUnknown() && !r.Configuration.DisableTypeDedupe.IsNull() {
		*disableTypeDedupe = r.Configuration.DisableTypeDedupe.ValueBool()
	} else {
		disableTypeDedupe = nil
	}
	dropCascade := new(bool)
	if !r.Configuration.DropCascade.IsUnknown() && !r.Configuration.DropCascade.IsNull() {
		*dropCascade = r.Configuration.DropCascade.ValueBool()
	} else {
		dropCascade = nil
	}
	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
	}
	password := new(string)
	if !r.Configuration.Password.IsUnknown() && !r.Configuration.Password.IsNull() {
		*password = r.Configuration.Password.ValueString()
	} else {
		password = nil
	}
	port := new(int64)
	if !r.Configuration.Port.IsUnknown() && !r.Configuration.Port.IsNull() {
		*port = r.Configuration.Port.ValueInt64()
	} else {
		port = nil
	}
	rawDataSchema := new(string)
	if !r.Configuration.RawDataSchema.IsUnknown() && !r.Configuration.RawDataSchema.IsNull() {
		*rawDataSchema = r.Configuration.RawDataSchema.ValueString()
	} else {
		rawDataSchema = nil
	}
	schema := new(string)
	if !r.Configuration.Schema.IsUnknown() && !r.Configuration.Schema.IsNull() {
		*schema = r.Configuration.Schema.ValueString()
	} else {
		schema = nil
	}
	ssl := new(bool)
	if !r.Configuration.Ssl.IsUnknown() && !r.Configuration.Ssl.IsNull() {
		*ssl = r.Configuration.Ssl.ValueBool()
	} else {
		ssl = nil
	}
	var sslMode *shared.DestinationPostgresSSLModes
	if r.Configuration.SslMode != nil {
		var destinationPostgresDisable *shared.DestinationPostgresDisable
		if r.Configuration.SslMode.Disable != nil {
			destinationPostgresDisable = &shared.DestinationPostgresDisable{}
		}
		if destinationPostgresDisable != nil {
			sslMode = &shared.DestinationPostgresSSLModes{
				DestinationPostgresDisable: destinationPostgresDisable,
			}
		}
		var destinationPostgresAllow *shared.DestinationPostgresAllow
		if r.Configuration.SslMode.Allow != nil {
			destinationPostgresAllow = &shared.DestinationPostgresAllow{}
		}
		if destinationPostgresAllow != nil {
			sslMode = &shared.DestinationPostgresSSLModes{
				DestinationPostgresAllow: destinationPostgresAllow,
			}
		}
		var destinationPostgresPrefer *shared.DestinationPostgresPrefer
		if r.Configuration.SslMode.Prefer != nil {
			destinationPostgresPrefer = &shared.DestinationPostgresPrefer{}
		}
		if destinationPostgresPrefer != nil {
			sslMode = &shared.DestinationPostgresSSLModes{
				DestinationPostgresPrefer: destinationPostgresPrefer,
			}
		}
		var destinationPostgresRequire *shared.DestinationPostgresRequire
		if r.Configuration.SslMode.Require != nil {
			destinationPostgresRequire = &shared.DestinationPostgresRequire{}
		}
		if destinationPostgresRequire != nil {
			sslMode = &shared.DestinationPostgresSSLModes{
				DestinationPostgresRequire: destinationPostgresRequire,
			}
		}
		var destinationPostgresVerifyCa *shared.DestinationPostgresVerifyCa
		if r.Configuration.SslMode.VerifyCa != nil {
			var caCertificate string
			caCertificate = r.Configuration.SslMode.VerifyCa.CaCertificate.ValueString()

			clientKeyPassword := new(string)
			if !r.Configuration.SslMode.VerifyCa.ClientKeyPassword.IsUnknown() && !r.Configuration.SslMode.VerifyCa.ClientKeyPassword.IsNull() {
				*clientKeyPassword = r.Configuration.SslMode.VerifyCa.ClientKeyPassword.ValueString()
			} else {
				clientKeyPassword = nil
			}
			destinationPostgresVerifyCa = &shared.DestinationPostgresVerifyCa{
				CaCertificate:     caCertificate,
				ClientKeyPassword: clientKeyPassword,
			}
		}
		if destinationPostgresVerifyCa != nil {
			sslMode = &shared.DestinationPostgresSSLModes{
				DestinationPostgresVerifyCa: destinationPostgresVerifyCa,
			}
		}
		var destinationPostgresVerifyFull *shared.DestinationPostgresVerifyFull
		if r.Configuration.SslMode.VerifyFull != nil {
			var caCertificate1 string
			caCertificate1 = r.Configuration.SslMode.VerifyFull.CaCertificate.ValueString()

			var clientCertificate string
			clientCertificate = r.Configuration.SslMode.VerifyFull.ClientCertificate.ValueString()

			var clientKey string
			clientKey = r.Configuration.SslMode.VerifyFull.ClientKey.ValueString()

			clientKeyPassword1 := new(string)
			if !r.Configuration.SslMode.VerifyFull.ClientKeyPassword.IsUnknown() && !r.Configuration.SslMode.VerifyFull.ClientKeyPassword.IsNull() {
				*clientKeyPassword1 = r.Configuration.SslMode.VerifyFull.ClientKeyPassword.ValueString()
			} else {
				clientKeyPassword1 = nil
			}
			destinationPostgresVerifyFull = &shared.DestinationPostgresVerifyFull{
				CaCertificate:     caCertificate1,
				ClientCertificate: clientCertificate,
				ClientKey:         clientKey,
				ClientKeyPassword: clientKeyPassword1,
			}
		}
		if destinationPostgresVerifyFull != nil {
			sslMode = &shared.DestinationPostgresSSLModes{
				DestinationPostgresVerifyFull: destinationPostgresVerifyFull,
			}
		}
	}
	var tunnelMethod *shared.DestinationPostgresSSHTunnelMethod
	if r.Configuration.TunnelMethod != nil {
		var destinationPostgresNoTunnel *shared.DestinationPostgresNoTunnel
		if r.Configuration.TunnelMethod.NoTunnel != nil {
			destinationPostgresNoTunnel = &shared.DestinationPostgresNoTunnel{}
		}
		if destinationPostgresNoTunnel != nil {
			tunnelMethod = &shared.DestinationPostgresSSHTunnelMethod{
				DestinationPostgresNoTunnel: destinationPostgresNoTunnel,
			}
		}
		var destinationPostgresSSHKeyAuthentication *shared.DestinationPostgresSSHKeyAuthentication
		if r.Configuration.TunnelMethod.SSHKeyAuthentication != nil {
			var sshKey string
			sshKey = r.Configuration.TunnelMethod.SSHKeyAuthentication.SSHKey.ValueString()

			var tunnelHost string
			tunnelHost = r.Configuration.TunnelMethod.SSHKeyAuthentication.TunnelHost.ValueString()

			tunnelPort := new(int64)
			if !r.Configuration.TunnelMethod.SSHKeyAuthentication.TunnelPort.IsUnknown() && !r.Configuration.TunnelMethod.SSHKeyAuthentication.TunnelPort.IsNull() {
				*tunnelPort = r.Configuration.TunnelMethod.SSHKeyAuthentication.TunnelPort.ValueInt64()
			} else {
				tunnelPort = nil
			}
			var tunnelUser string
			tunnelUser = r.Configuration.TunnelMethod.SSHKeyAuthentication.TunnelUser.ValueString()

			destinationPostgresSSHKeyAuthentication = &shared.DestinationPostgresSSHKeyAuthentication{
				SSHKey:     sshKey,
				TunnelHost: tunnelHost,
				TunnelPort: tunnelPort,
				TunnelUser: tunnelUser,
			}
		}
		if destinationPostgresSSHKeyAuthentication != nil {
			tunnelMethod = &shared.DestinationPostgresSSHTunnelMethod{
				DestinationPostgresSSHKeyAuthentication: destinationPostgresSSHKeyAuthentication,
			}
		}
		var destinationPostgresPasswordAuthentication *shared.DestinationPostgresPasswordAuthentication
		if r.Configuration.TunnelMethod.PasswordAuthentication != nil {
			var tunnelHost1 string
			tunnelHost1 = r.Configuration.TunnelMethod.PasswordAuthentication.TunnelHost.ValueString()

			tunnelPort1 := new(int64)
			if !r.Configuration.TunnelMethod.PasswordAuthentication.TunnelPort.IsUnknown() && !r.Configuration.TunnelMethod.PasswordAuthentication.TunnelPort.IsNull() {
				*tunnelPort1 = r.Configuration.TunnelMethod.PasswordAuthentication.TunnelPort.ValueInt64()
			} else {
				tunnelPort1 = nil
			}
			var tunnelUser1 string
			tunnelUser1 = r.Configuration.TunnelMethod.PasswordAuthentication.TunnelUser.ValueString()

			var tunnelUserPassword string
			tunnelUserPassword = r.Configuration.TunnelMethod.PasswordAuthentication.TunnelUserPassword.ValueString()

			destinationPostgresPasswordAuthentication = &shared.DestinationPostgresPasswordAuthentication{
				TunnelHost:         tunnelHost1,
				TunnelPort:         tunnelPort1,
				TunnelUser:         tunnelUser1,
				TunnelUserPassword: tunnelUserPassword,
			}
		}
		if destinationPostgresPasswordAuthentication != nil {
			tunnelMethod = &shared.DestinationPostgresSSHTunnelMethod{
				DestinationPostgresPasswordAuthentication: destinationPostgresPasswordAuthentication,
			}
		}
	}
	unconstrainedNumber := new(bool)
	if !r.Configuration.UnconstrainedNumber.IsUnknown() && !r.Configuration.UnconstrainedNumber.IsNull() {
		*unconstrainedNumber = r.Configuration.UnconstrainedNumber.ValueBool()
	} else {
		unconstrainedNumber = nil
	}
	var username string
	username = r.Configuration.Username.ValueString()

	configuration := shared.DestinationPostgres{
		Database:            database,
		DisableTypeDedupe:   disableTypeDedupe,
		DropCascade:         dropCascade,
		Host:                host,
		JdbcURLParams:       jdbcURLParams,
		Password:            password,
		Port:                port,
		RawDataSchema:       rawDataSchema,
		Schema:              schema,
		Ssl:                 ssl,
		SslMode:             sslMode,
		TunnelMethod:        tunnelMethod,
		UnconstrainedNumber: unconstrainedNumber,
		Username:            username,
	}
	out := shared.DestinationPostgresCreateRequest{
		Name:          name,
		DefinitionID:  definitionID,
		WorkspaceID:   workspaceID,
		Configuration: configuration,
	}
	return &out
}

func (r *DestinationPostgresResourceModel) 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 *DestinationPostgresResourceModel) ToSharedDestinationPostgresPutRequest() *shared.DestinationPostgresPutRequest {
	var name string
	name = r.Name.ValueString()

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

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

	disableTypeDedupe := new(bool)
	if !r.Configuration.DisableTypeDedupe.IsUnknown() && !r.Configuration.DisableTypeDedupe.IsNull() {
		*disableTypeDedupe = r.Configuration.DisableTypeDedupe.ValueBool()
	} else {
		disableTypeDedupe = nil
	}
	dropCascade := new(bool)
	if !r.Configuration.DropCascade.IsUnknown() && !r.Configuration.DropCascade.IsNull() {
		*dropCascade = r.Configuration.DropCascade.ValueBool()
	} else {
		dropCascade = nil
	}
	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
	}
	password := new(string)
	if !r.Configuration.Password.IsUnknown() && !r.Configuration.Password.IsNull() {
		*password = r.Configuration.Password.ValueString()
	} else {
		password = nil
	}
	port := new(int64)
	if !r.Configuration.Port.IsUnknown() && !r.Configuration.Port.IsNull() {
		*port = r.Configuration.Port.ValueInt64()
	} else {
		port = nil
	}
	rawDataSchema := new(string)
	if !r.Configuration.RawDataSchema.IsUnknown() && !r.Configuration.RawDataSchema.IsNull() {
		*rawDataSchema = r.Configuration.RawDataSchema.ValueString()
	} else {
		rawDataSchema = nil
	}
	schema := new(string)
	if !r.Configuration.Schema.IsUnknown() && !r.Configuration.Schema.IsNull() {
		*schema = r.Configuration.Schema.ValueString()
	} else {
		schema = nil
	}
	ssl := new(bool)
	if !r.Configuration.Ssl.IsUnknown() && !r.Configuration.Ssl.IsNull() {
		*ssl = r.Configuration.Ssl.ValueBool()
	} else {
		ssl = nil
	}
	var sslMode *shared.DestinationPostgresUpdateSSLModes
	if r.Configuration.SslMode != nil {
		var destinationPostgresUpdateDisable *shared.DestinationPostgresUpdateDisable
		if r.Configuration.SslMode.Disable != nil {
			destinationPostgresUpdateDisable = &shared.DestinationPostgresUpdateDisable{}
		}
		if destinationPostgresUpdateDisable != nil {
			sslMode = &shared.DestinationPostgresUpdateSSLModes{
				DestinationPostgresUpdateDisable: destinationPostgresUpdateDisable,
			}
		}
		var destinationPostgresUpdateAllow *shared.DestinationPostgresUpdateAllow
		if r.Configuration.SslMode.Allow != nil {
			destinationPostgresUpdateAllow = &shared.DestinationPostgresUpdateAllow{}
		}
		if destinationPostgresUpdateAllow != nil {
			sslMode = &shared.DestinationPostgresUpdateSSLModes{
				DestinationPostgresUpdateAllow: destinationPostgresUpdateAllow,
			}
		}
		var destinationPostgresUpdatePrefer *shared.DestinationPostgresUpdatePrefer
		if r.Configuration.SslMode.Prefer != nil {
			destinationPostgresUpdatePrefer = &shared.DestinationPostgresUpdatePrefer{}
		}
		if destinationPostgresUpdatePrefer != nil {
			sslMode = &shared.DestinationPostgresUpdateSSLModes{
				DestinationPostgresUpdatePrefer: destinationPostgresUpdatePrefer,
			}
		}
		var destinationPostgresUpdateRequire *shared.DestinationPostgresUpdateRequire
		if r.Configuration.SslMode.Require != nil {
			destinationPostgresUpdateRequire = &shared.DestinationPostgresUpdateRequire{}
		}
		if destinationPostgresUpdateRequire != nil {
			sslMode = &shared.DestinationPostgresUpdateSSLModes{
				DestinationPostgresUpdateRequire: destinationPostgresUpdateRequire,
			}
		}
		var destinationPostgresUpdateVerifyCa *shared.DestinationPostgresUpdateVerifyCa
		if r.Configuration.SslMode.VerifyCa != nil {
			var caCertificate string
			caCertificate = r.Configuration.SslMode.VerifyCa.CaCertificate.ValueString()

			clientKeyPassword := new(string)
			if !r.Configuration.SslMode.VerifyCa.ClientKeyPassword.IsUnknown() && !r.Configuration.SslMode.VerifyCa.ClientKeyPassword.IsNull() {
				*clientKeyPassword = r.Configuration.SslMode.VerifyCa.ClientKeyPassword.ValueString()
			} else {
				clientKeyPassword = nil
			}
			destinationPostgresUpdateVerifyCa = &shared.DestinationPostgresUpdateVerifyCa{
				CaCertificate:     caCertificate,
				ClientKeyPassword: clientKeyPassword,
			}
		}
		if destinationPostgresUpdateVerifyCa != nil {
			sslMode = &shared.DestinationPostgresUpdateSSLModes{
				DestinationPostgresUpdateVerifyCa: destinationPostgresUpdateVerifyCa,
			}
		}
		var destinationPostgresUpdateVerifyFull *shared.DestinationPostgresUpdateVerifyFull
		if r.Configuration.SslMode.VerifyFull != nil {
			var caCertificate1 string
			caCertificate1 = r.Configuration.SslMode.VerifyFull.CaCertificate.ValueString()

			var clientCertificate string
			clientCertificate = r.Configuration.SslMode.VerifyFull.ClientCertificate.ValueString()

			var clientKey string
			clientKey = r.Configuration.SslMode.VerifyFull.ClientKey.ValueString()

			clientKeyPassword1 := new(string)
			if !r.Configuration.SslMode.VerifyFull.ClientKeyPassword.IsUnknown() && !r.Configuration.SslMode.VerifyFull.ClientKeyPassword.IsNull() {
				*clientKeyPassword1 = r.Configuration.SslMode.VerifyFull.ClientKeyPassword.ValueString()
			} else {
				clientKeyPassword1 = nil
			}
			destinationPostgresUpdateVerifyFull = &shared.DestinationPostgresUpdateVerifyFull{
				CaCertificate:     caCertificate1,
				ClientCertificate: clientCertificate,
				ClientKey:         clientKey,
				ClientKeyPassword: clientKeyPassword1,
			}
		}
		if destinationPostgresUpdateVerifyFull != nil {
			sslMode = &shared.DestinationPostgresUpdateSSLModes{
				DestinationPostgresUpdateVerifyFull: destinationPostgresUpdateVerifyFull,
			}
		}
	}
	var tunnelMethod *shared.DestinationPostgresUpdateSSHTunnelMethod
	if r.Configuration.TunnelMethod != nil {
		var destinationPostgresUpdateNoTunnel *shared.DestinationPostgresUpdateNoTunnel
		if r.Configuration.TunnelMethod.NoTunnel != nil {
			destinationPostgresUpdateNoTunnel = &shared.DestinationPostgresUpdateNoTunnel{}
		}
		if destinationPostgresUpdateNoTunnel != nil {
			tunnelMethod = &shared.DestinationPostgresUpdateSSHTunnelMethod{
				DestinationPostgresUpdateNoTunnel: destinationPostgresUpdateNoTunnel,
			}
		}
		var destinationPostgresUpdateSSHKeyAuthentication *shared.DestinationPostgresUpdateSSHKeyAuthentication
		if r.Configuration.TunnelMethod.SSHKeyAuthentication != nil {
			var sshKey string
			sshKey = r.Configuration.TunnelMethod.SSHKeyAuthentication.SSHKey.ValueString()

			var tunnelHost string
			tunnelHost = r.Configuration.TunnelMethod.SSHKeyAuthentication.TunnelHost.ValueString()

			tunnelPort := new(int64)
			if !r.Configuration.TunnelMethod.SSHKeyAuthentication.TunnelPort.IsUnknown() && !r.Configuration.TunnelMethod.SSHKeyAuthentication.TunnelPort.IsNull() {
				*tunnelPort = r.Configuration.TunnelMethod.SSHKeyAuthentication.TunnelPort.ValueInt64()
			} else {
				tunnelPort = nil
			}
			var tunnelUser string
			tunnelUser = r.Configuration.TunnelMethod.SSHKeyAuthentication.TunnelUser.ValueString()

			destinationPostgresUpdateSSHKeyAuthentication = &shared.DestinationPostgresUpdateSSHKeyAuthentication{
				SSHKey:     sshKey,
				TunnelHost: tunnelHost,
				TunnelPort: tunnelPort,
				TunnelUser: tunnelUser,
			}
		}
		if destinationPostgresUpdateSSHKeyAuthentication != nil {
			tunnelMethod = &shared.DestinationPostgresUpdateSSHTunnelMethod{
				DestinationPostgresUpdateSSHKeyAuthentication: destinationPostgresUpdateSSHKeyAuthentication,
			}
		}
		var destinationPostgresUpdatePasswordAuthentication *shared.DestinationPostgresUpdatePasswordAuthentication
		if r.Configuration.TunnelMethod.PasswordAuthentication != nil {
			var tunnelHost1 string
			tunnelHost1 = r.Configuration.TunnelMethod.PasswordAuthentication.TunnelHost.ValueString()

			tunnelPort1 := new(int64)
			if !r.Configuration.TunnelMethod.PasswordAuthentication.TunnelPort.IsUnknown() && !r.Configuration.TunnelMethod.PasswordAuthentication.TunnelPort.IsNull() {
				*tunnelPort1 = r.Configuration.TunnelMethod.PasswordAuthentication.TunnelPort.ValueInt64()
			} else {
				tunnelPort1 = nil
			}
			var tunnelUser1 string
			tunnelUser1 = r.Configuration.TunnelMethod.PasswordAuthentication.TunnelUser.ValueString()

			var tunnelUserPassword string
			tunnelUserPassword = r.Configuration.TunnelMethod.PasswordAuthentication.TunnelUserPassword.ValueString()

			destinationPostgresUpdatePasswordAuthentication = &shared.DestinationPostgresUpdatePasswordAuthentication{
				TunnelHost:         tunnelHost1,
				TunnelPort:         tunnelPort1,
				TunnelUser:         tunnelUser1,
				TunnelUserPassword: tunnelUserPassword,
			}
		}
		if destinationPostgresUpdatePasswordAuthentication != nil {
			tunnelMethod = &shared.DestinationPostgresUpdateSSHTunnelMethod{
				DestinationPostgresUpdatePasswordAuthentication: destinationPostgresUpdatePasswordAuthentication,
			}
		}
	}
	unconstrainedNumber := new(bool)
	if !r.Configuration.UnconstrainedNumber.IsUnknown() && !r.Configuration.UnconstrainedNumber.IsNull() {
		*unconstrainedNumber = r.Configuration.UnconstrainedNumber.ValueBool()
	} else {
		unconstrainedNumber = nil
	}
	var username string
	username = r.Configuration.Username.ValueString()

	configuration := shared.DestinationPostgresUpdate{
		Database:            database,
		DisableTypeDedupe:   disableTypeDedupe,
		DropCascade:         dropCascade,
		Host:                host,
		JdbcURLParams:       jdbcURLParams,
		Password:            password,
		Port:                port,
		RawDataSchema:       rawDataSchema,
		Schema:              schema,
		Ssl:                 ssl,
		SslMode:             sslMode,
		TunnelMethod:        tunnelMethod,
		UnconstrainedNumber: unconstrainedNumber,
		Username:            username,
	}
	out := shared.DestinationPostgresPutRequest{
		Name:          name,
		WorkspaceID:   workspaceID,
		Configuration: configuration,
	}
	return &out
}
