// 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 *SourceNetsuiteEnterpriseResourceModel) ToSharedSourceNetsuiteEnterpriseCreateRequest() *shared.SourceNetsuiteEnterpriseCreateRequest {
	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 accountID string
	accountID = r.Configuration.AccountID.ValueString()

	var authenticationMethod shared.SourceNetsuiteEnterpriseAuthenticationMethod
	var sourceNetsuiteEnterprisePasswordAuthentication *shared.SourceNetsuiteEnterprisePasswordAuthentication
	if r.Configuration.AuthenticationMethod.PasswordAuthentication != nil {
		authenticationMethod1 := new(shared.SourceNetsuiteEnterpriseSchemasAuthenticationMethodAuthenticationMethod)
		if !r.Configuration.AuthenticationMethod.PasswordAuthentication.AuthenticationMethod.IsUnknown() && !r.Configuration.AuthenticationMethod.PasswordAuthentication.AuthenticationMethod.IsNull() {
			*authenticationMethod1 = shared.SourceNetsuiteEnterpriseSchemasAuthenticationMethodAuthenticationMethod(r.Configuration.AuthenticationMethod.PasswordAuthentication.AuthenticationMethod.ValueString())
		} else {
			authenticationMethod1 = nil
		}
		var password string
		password = r.Configuration.AuthenticationMethod.PasswordAuthentication.Password.ValueString()

		var additionalProperties interface{}
		if !r.Configuration.AuthenticationMethod.PasswordAuthentication.AdditionalProperties.IsUnknown() && !r.Configuration.AuthenticationMethod.PasswordAuthentication.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.AuthenticationMethod.PasswordAuthentication.AdditionalProperties.ValueString()), &additionalProperties)
		}
		sourceNetsuiteEnterprisePasswordAuthentication = &shared.SourceNetsuiteEnterprisePasswordAuthentication{
			AuthenticationMethod: authenticationMethod1,
			Password:             password,
			AdditionalProperties: additionalProperties,
		}
	}
	if sourceNetsuiteEnterprisePasswordAuthentication != nil {
		authenticationMethod = shared.SourceNetsuiteEnterpriseAuthenticationMethod{
			SourceNetsuiteEnterprisePasswordAuthentication: sourceNetsuiteEnterprisePasswordAuthentication,
		}
	}
	var tokenBasedAuthentication *shared.TokenBasedAuthentication
	if r.Configuration.AuthenticationMethod.TokenBasedAuthentication != nil {
		authenticationMethod2 := new(shared.SourceNetsuiteEnterpriseSchemasAuthenticationMethod)
		if !r.Configuration.AuthenticationMethod.TokenBasedAuthentication.AuthenticationMethod.IsUnknown() && !r.Configuration.AuthenticationMethod.TokenBasedAuthentication.AuthenticationMethod.IsNull() {
			*authenticationMethod2 = shared.SourceNetsuiteEnterpriseSchemasAuthenticationMethod(r.Configuration.AuthenticationMethod.TokenBasedAuthentication.AuthenticationMethod.ValueString())
		} else {
			authenticationMethod2 = nil
		}
		var clientID string
		clientID = r.Configuration.AuthenticationMethod.TokenBasedAuthentication.ClientID.ValueString()

		var clientSecret string
		clientSecret = r.Configuration.AuthenticationMethod.TokenBasedAuthentication.ClientSecret.ValueString()

		var tokenID string
		tokenID = r.Configuration.AuthenticationMethod.TokenBasedAuthentication.TokenID.ValueString()

		var tokenSecret string
		tokenSecret = r.Configuration.AuthenticationMethod.TokenBasedAuthentication.TokenSecret.ValueString()

		var additionalProperties1 interface{}
		if !r.Configuration.AuthenticationMethod.TokenBasedAuthentication.AdditionalProperties.IsUnknown() && !r.Configuration.AuthenticationMethod.TokenBasedAuthentication.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.AuthenticationMethod.TokenBasedAuthentication.AdditionalProperties.ValueString()), &additionalProperties1)
		}
		tokenBasedAuthentication = &shared.TokenBasedAuthentication{
			AuthenticationMethod: authenticationMethod2,
			ClientID:             clientID,
			ClientSecret:         clientSecret,
			TokenID:              tokenID,
			TokenSecret:          tokenSecret,
			AdditionalProperties: additionalProperties1,
		}
	}
	if tokenBasedAuthentication != nil {
		authenticationMethod = shared.SourceNetsuiteEnterpriseAuthenticationMethod{
			TokenBasedAuthentication: tokenBasedAuthentication,
		}
	}
	checkPrivileges := new(bool)
	if !r.Configuration.CheckPrivileges.IsUnknown() && !r.Configuration.CheckPrivileges.IsNull() {
		*checkPrivileges = r.Configuration.CheckPrivileges.ValueBool()
	} else {
		checkPrivileges = nil
	}
	checkpointTargetIntervalSeconds := new(int64)
	if !r.Configuration.CheckpointTargetIntervalSeconds.IsUnknown() && !r.Configuration.CheckpointTargetIntervalSeconds.IsNull() {
		*checkpointTargetIntervalSeconds = r.Configuration.CheckpointTargetIntervalSeconds.ValueInt64()
	} else {
		checkpointTargetIntervalSeconds = nil
	}
	concurrency := new(int64)
	if !r.Configuration.Concurrency.IsUnknown() && !r.Configuration.Concurrency.IsNull() {
		*concurrency = r.Configuration.Concurrency.ValueInt64()
	} else {
		concurrency = nil
	}
	var cursor shared.SourceNetsuiteEnterpriseUpdateMethod
	var sourceNetsuiteEnterpriseScanChangesWithUserDefinedCursor *shared.SourceNetsuiteEnterpriseScanChangesWithUserDefinedCursor
	if r.Configuration.Cursor.ScanChangesWithUserDefinedCursor != nil {
		cursorMethod := new(shared.CursorMethod)
		if !r.Configuration.Cursor.ScanChangesWithUserDefinedCursor.CursorMethod.IsUnknown() && !r.Configuration.Cursor.ScanChangesWithUserDefinedCursor.CursorMethod.IsNull() {
			*cursorMethod = shared.CursorMethod(r.Configuration.Cursor.ScanChangesWithUserDefinedCursor.CursorMethod.ValueString())
		} else {
			cursorMethod = nil
		}
		var additionalProperties2 interface{}
		if !r.Configuration.Cursor.ScanChangesWithUserDefinedCursor.AdditionalProperties.IsUnknown() && !r.Configuration.Cursor.ScanChangesWithUserDefinedCursor.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.Cursor.ScanChangesWithUserDefinedCursor.AdditionalProperties.ValueString()), &additionalProperties2)
		}
		sourceNetsuiteEnterpriseScanChangesWithUserDefinedCursor = &shared.SourceNetsuiteEnterpriseScanChangesWithUserDefinedCursor{
			CursorMethod:         cursorMethod,
			AdditionalProperties: additionalProperties2,
		}
	}
	if sourceNetsuiteEnterpriseScanChangesWithUserDefinedCursor != nil {
		cursor = shared.SourceNetsuiteEnterpriseUpdateMethod{
			SourceNetsuiteEnterpriseScanChangesWithUserDefinedCursor: sourceNetsuiteEnterpriseScanChangesWithUserDefinedCursor,
		}
	}
	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
	}
	port := new(int64)
	if !r.Configuration.Port.IsUnknown() && !r.Configuration.Port.IsNull() {
		*port = r.Configuration.Port.ValueInt64()
	} else {
		port = nil
	}
	var roleID string
	roleID = r.Configuration.RoleID.ValueString()

	var tunnelMethod shared.SourceNetsuiteEnterpriseSSHTunnelMethod
	var sourceNetsuiteEnterpriseNoTunnel *shared.SourceNetsuiteEnterpriseNoTunnel
	if r.Configuration.TunnelMethod.NoTunnel != nil {
		tunnelMethod1 := new(shared.SourceNetsuiteEnterpriseTunnelMethod)
		if !r.Configuration.TunnelMethod.NoTunnel.TunnelMethod.IsUnknown() && !r.Configuration.TunnelMethod.NoTunnel.TunnelMethod.IsNull() {
			*tunnelMethod1 = shared.SourceNetsuiteEnterpriseTunnelMethod(r.Configuration.TunnelMethod.NoTunnel.TunnelMethod.ValueString())
		} else {
			tunnelMethod1 = nil
		}
		var additionalProperties3 interface{}
		if !r.Configuration.TunnelMethod.NoTunnel.AdditionalProperties.IsUnknown() && !r.Configuration.TunnelMethod.NoTunnel.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.TunnelMethod.NoTunnel.AdditionalProperties.ValueString()), &additionalProperties3)
		}
		sourceNetsuiteEnterpriseNoTunnel = &shared.SourceNetsuiteEnterpriseNoTunnel{
			TunnelMethod:         tunnelMethod1,
			AdditionalProperties: additionalProperties3,
		}
	}
	if sourceNetsuiteEnterpriseNoTunnel != nil {
		tunnelMethod = shared.SourceNetsuiteEnterpriseSSHTunnelMethod{
			SourceNetsuiteEnterpriseNoTunnel: sourceNetsuiteEnterpriseNoTunnel,
		}
	}
	var sourceNetsuiteEnterpriseSSHKeyAuthentication *shared.SourceNetsuiteEnterpriseSSHKeyAuthentication
	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()

		tunnelMethod2 := new(shared.SourceNetsuiteEnterpriseSchemasTunnelMethod)
		if !r.Configuration.TunnelMethod.SSHKeyAuthentication.TunnelMethod.IsUnknown() && !r.Configuration.TunnelMethod.SSHKeyAuthentication.TunnelMethod.IsNull() {
			*tunnelMethod2 = shared.SourceNetsuiteEnterpriseSchemasTunnelMethod(r.Configuration.TunnelMethod.SSHKeyAuthentication.TunnelMethod.ValueString())
		} else {
			tunnelMethod2 = nil
		}
		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()

		var additionalProperties4 interface{}
		if !r.Configuration.TunnelMethod.SSHKeyAuthentication.AdditionalProperties.IsUnknown() && !r.Configuration.TunnelMethod.SSHKeyAuthentication.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.TunnelMethod.SSHKeyAuthentication.AdditionalProperties.ValueString()), &additionalProperties4)
		}
		sourceNetsuiteEnterpriseSSHKeyAuthentication = &shared.SourceNetsuiteEnterpriseSSHKeyAuthentication{
			SSHKey:               sshKey,
			TunnelHost:           tunnelHost,
			TunnelMethod:         tunnelMethod2,
			TunnelPort:           tunnelPort,
			TunnelUser:           tunnelUser,
			AdditionalProperties: additionalProperties4,
		}
	}
	if sourceNetsuiteEnterpriseSSHKeyAuthentication != nil {
		tunnelMethod = shared.SourceNetsuiteEnterpriseSSHTunnelMethod{
			SourceNetsuiteEnterpriseSSHKeyAuthentication: sourceNetsuiteEnterpriseSSHKeyAuthentication,
		}
	}
	var sourceNetsuiteEnterpriseSchemasPasswordAuthentication *shared.SourceNetsuiteEnterpriseSchemasPasswordAuthentication
	if r.Configuration.TunnelMethod.PasswordAuthentication != nil {
		var tunnelHost1 string
		tunnelHost1 = r.Configuration.TunnelMethod.PasswordAuthentication.TunnelHost.ValueString()

		tunnelMethod3 := new(shared.SourceNetsuiteEnterpriseSchemasTunnelMethodTunnelMethod)
		if !r.Configuration.TunnelMethod.PasswordAuthentication.TunnelMethod.IsUnknown() && !r.Configuration.TunnelMethod.PasswordAuthentication.TunnelMethod.IsNull() {
			*tunnelMethod3 = shared.SourceNetsuiteEnterpriseSchemasTunnelMethodTunnelMethod(r.Configuration.TunnelMethod.PasswordAuthentication.TunnelMethod.ValueString())
		} else {
			tunnelMethod3 = nil
		}
		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()

		var additionalProperties5 interface{}
		if !r.Configuration.TunnelMethod.PasswordAuthentication.AdditionalProperties.IsUnknown() && !r.Configuration.TunnelMethod.PasswordAuthentication.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.TunnelMethod.PasswordAuthentication.AdditionalProperties.ValueString()), &additionalProperties5)
		}
		sourceNetsuiteEnterpriseSchemasPasswordAuthentication = &shared.SourceNetsuiteEnterpriseSchemasPasswordAuthentication{
			TunnelHost:           tunnelHost1,
			TunnelMethod:         tunnelMethod3,
			TunnelPort:           tunnelPort1,
			TunnelUser:           tunnelUser1,
			TunnelUserPassword:   tunnelUserPassword,
			AdditionalProperties: additionalProperties5,
		}
	}
	if sourceNetsuiteEnterpriseSchemasPasswordAuthentication != nil {
		tunnelMethod = shared.SourceNetsuiteEnterpriseSSHTunnelMethod{
			SourceNetsuiteEnterpriseSchemasPasswordAuthentication: sourceNetsuiteEnterpriseSchemasPasswordAuthentication,
		}
	}
	var username string
	username = r.Configuration.Username.ValueString()

	configuration := shared.SourceNetsuiteEnterprise{
		AccountID:                       accountID,
		AuthenticationMethod:            authenticationMethod,
		CheckPrivileges:                 checkPrivileges,
		CheckpointTargetIntervalSeconds: checkpointTargetIntervalSeconds,
		Concurrency:                     concurrency,
		Cursor:                          cursor,
		Host:                            host,
		JdbcURLParams:                   jdbcURLParams,
		Port:                            port,
		RoleID:                          roleID,
		TunnelMethod:                    tunnelMethod,
		Username:                        username,
	}
	secretID := new(string)
	if !r.SecretID.IsUnknown() && !r.SecretID.IsNull() {
		*secretID = r.SecretID.ValueString()
	} else {
		secretID = nil
	}
	out := shared.SourceNetsuiteEnterpriseCreateRequest{
		Name:          name,
		DefinitionID:  definitionID,
		WorkspaceID:   workspaceID,
		Configuration: configuration,
		SecretID:      secretID,
	}
	return &out
}

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

func (r *SourceNetsuiteEnterpriseResourceModel) ToSharedSourceNetsuiteEnterprisePutRequest() *shared.SourceNetsuiteEnterprisePutRequest {
	var name string
	name = r.Name.ValueString()

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

	var accountID string
	accountID = r.Configuration.AccountID.ValueString()

	var authenticationMethod shared.SourceNetsuiteEnterpriseUpdateAuthenticationMethod
	var sourceNetsuiteEnterpriseUpdatePasswordAuthentication *shared.SourceNetsuiteEnterpriseUpdatePasswordAuthentication
	if r.Configuration.AuthenticationMethod.PasswordAuthentication != nil {
		authenticationMethod1 := new(shared.SourceNetsuiteEnterpriseUpdateSchemasAuthenticationMethodAuthenticationMethod)
		if !r.Configuration.AuthenticationMethod.PasswordAuthentication.AuthenticationMethod.IsUnknown() && !r.Configuration.AuthenticationMethod.PasswordAuthentication.AuthenticationMethod.IsNull() {
			*authenticationMethod1 = shared.SourceNetsuiteEnterpriseUpdateSchemasAuthenticationMethodAuthenticationMethod(r.Configuration.AuthenticationMethod.PasswordAuthentication.AuthenticationMethod.ValueString())
		} else {
			authenticationMethod1 = nil
		}
		var password string
		password = r.Configuration.AuthenticationMethod.PasswordAuthentication.Password.ValueString()

		var additionalProperties interface{}
		if !r.Configuration.AuthenticationMethod.PasswordAuthentication.AdditionalProperties.IsUnknown() && !r.Configuration.AuthenticationMethod.PasswordAuthentication.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.AuthenticationMethod.PasswordAuthentication.AdditionalProperties.ValueString()), &additionalProperties)
		}
		sourceNetsuiteEnterpriseUpdatePasswordAuthentication = &shared.SourceNetsuiteEnterpriseUpdatePasswordAuthentication{
			AuthenticationMethod: authenticationMethod1,
			Password:             password,
			AdditionalProperties: additionalProperties,
		}
	}
	if sourceNetsuiteEnterpriseUpdatePasswordAuthentication != nil {
		authenticationMethod = shared.SourceNetsuiteEnterpriseUpdateAuthenticationMethod{
			SourceNetsuiteEnterpriseUpdatePasswordAuthentication: sourceNetsuiteEnterpriseUpdatePasswordAuthentication,
		}
	}
	var sourceNetsuiteEnterpriseUpdateTokenBasedAuthentication *shared.SourceNetsuiteEnterpriseUpdateTokenBasedAuthentication
	if r.Configuration.AuthenticationMethod.TokenBasedAuthentication != nil {
		authenticationMethod2 := new(shared.SourceNetsuiteEnterpriseUpdateSchemasAuthenticationMethod)
		if !r.Configuration.AuthenticationMethod.TokenBasedAuthentication.AuthenticationMethod.IsUnknown() && !r.Configuration.AuthenticationMethod.TokenBasedAuthentication.AuthenticationMethod.IsNull() {
			*authenticationMethod2 = shared.SourceNetsuiteEnterpriseUpdateSchemasAuthenticationMethod(r.Configuration.AuthenticationMethod.TokenBasedAuthentication.AuthenticationMethod.ValueString())
		} else {
			authenticationMethod2 = nil
		}
		var clientID string
		clientID = r.Configuration.AuthenticationMethod.TokenBasedAuthentication.ClientID.ValueString()

		var clientSecret string
		clientSecret = r.Configuration.AuthenticationMethod.TokenBasedAuthentication.ClientSecret.ValueString()

		var tokenID string
		tokenID = r.Configuration.AuthenticationMethod.TokenBasedAuthentication.TokenID.ValueString()

		var tokenSecret string
		tokenSecret = r.Configuration.AuthenticationMethod.TokenBasedAuthentication.TokenSecret.ValueString()

		var additionalProperties1 interface{}
		if !r.Configuration.AuthenticationMethod.TokenBasedAuthentication.AdditionalProperties.IsUnknown() && !r.Configuration.AuthenticationMethod.TokenBasedAuthentication.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.AuthenticationMethod.TokenBasedAuthentication.AdditionalProperties.ValueString()), &additionalProperties1)
		}
		sourceNetsuiteEnterpriseUpdateTokenBasedAuthentication = &shared.SourceNetsuiteEnterpriseUpdateTokenBasedAuthentication{
			AuthenticationMethod: authenticationMethod2,
			ClientID:             clientID,
			ClientSecret:         clientSecret,
			TokenID:              tokenID,
			TokenSecret:          tokenSecret,
			AdditionalProperties: additionalProperties1,
		}
	}
	if sourceNetsuiteEnterpriseUpdateTokenBasedAuthentication != nil {
		authenticationMethod = shared.SourceNetsuiteEnterpriseUpdateAuthenticationMethod{
			SourceNetsuiteEnterpriseUpdateTokenBasedAuthentication: sourceNetsuiteEnterpriseUpdateTokenBasedAuthentication,
		}
	}
	checkPrivileges := new(bool)
	if !r.Configuration.CheckPrivileges.IsUnknown() && !r.Configuration.CheckPrivileges.IsNull() {
		*checkPrivileges = r.Configuration.CheckPrivileges.ValueBool()
	} else {
		checkPrivileges = nil
	}
	checkpointTargetIntervalSeconds := new(int64)
	if !r.Configuration.CheckpointTargetIntervalSeconds.IsUnknown() && !r.Configuration.CheckpointTargetIntervalSeconds.IsNull() {
		*checkpointTargetIntervalSeconds = r.Configuration.CheckpointTargetIntervalSeconds.ValueInt64()
	} else {
		checkpointTargetIntervalSeconds = nil
	}
	concurrency := new(int64)
	if !r.Configuration.Concurrency.IsUnknown() && !r.Configuration.Concurrency.IsNull() {
		*concurrency = r.Configuration.Concurrency.ValueInt64()
	} else {
		concurrency = nil
	}
	var cursor shared.SourceNetsuiteEnterpriseUpdateUpdateMethod
	var sourceNetsuiteEnterpriseUpdateScanChangesWithUserDefinedCursor *shared.SourceNetsuiteEnterpriseUpdateScanChangesWithUserDefinedCursor
	if r.Configuration.Cursor.ScanChangesWithUserDefinedCursor != nil {
		cursorMethod := new(shared.SourceNetsuiteEnterpriseUpdateCursorMethod)
		if !r.Configuration.Cursor.ScanChangesWithUserDefinedCursor.CursorMethod.IsUnknown() && !r.Configuration.Cursor.ScanChangesWithUserDefinedCursor.CursorMethod.IsNull() {
			*cursorMethod = shared.SourceNetsuiteEnterpriseUpdateCursorMethod(r.Configuration.Cursor.ScanChangesWithUserDefinedCursor.CursorMethod.ValueString())
		} else {
			cursorMethod = nil
		}
		var additionalProperties2 interface{}
		if !r.Configuration.Cursor.ScanChangesWithUserDefinedCursor.AdditionalProperties.IsUnknown() && !r.Configuration.Cursor.ScanChangesWithUserDefinedCursor.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.Cursor.ScanChangesWithUserDefinedCursor.AdditionalProperties.ValueString()), &additionalProperties2)
		}
		sourceNetsuiteEnterpriseUpdateScanChangesWithUserDefinedCursor = &shared.SourceNetsuiteEnterpriseUpdateScanChangesWithUserDefinedCursor{
			CursorMethod:         cursorMethod,
			AdditionalProperties: additionalProperties2,
		}
	}
	if sourceNetsuiteEnterpriseUpdateScanChangesWithUserDefinedCursor != nil {
		cursor = shared.SourceNetsuiteEnterpriseUpdateUpdateMethod{
			SourceNetsuiteEnterpriseUpdateScanChangesWithUserDefinedCursor: sourceNetsuiteEnterpriseUpdateScanChangesWithUserDefinedCursor,
		}
	}
	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
	}
	port := new(int64)
	if !r.Configuration.Port.IsUnknown() && !r.Configuration.Port.IsNull() {
		*port = r.Configuration.Port.ValueInt64()
	} else {
		port = nil
	}
	var roleID string
	roleID = r.Configuration.RoleID.ValueString()

	var tunnelMethod shared.SourceNetsuiteEnterpriseUpdateSSHTunnelMethod
	var sourceNetsuiteEnterpriseUpdateNoTunnel *shared.SourceNetsuiteEnterpriseUpdateNoTunnel
	if r.Configuration.TunnelMethod.NoTunnel != nil {
		tunnelMethod1 := new(shared.SourceNetsuiteEnterpriseUpdateTunnelMethod)
		if !r.Configuration.TunnelMethod.NoTunnel.TunnelMethod.IsUnknown() && !r.Configuration.TunnelMethod.NoTunnel.TunnelMethod.IsNull() {
			*tunnelMethod1 = shared.SourceNetsuiteEnterpriseUpdateTunnelMethod(r.Configuration.TunnelMethod.NoTunnel.TunnelMethod.ValueString())
		} else {
			tunnelMethod1 = nil
		}
		var additionalProperties3 interface{}
		if !r.Configuration.TunnelMethod.NoTunnel.AdditionalProperties.IsUnknown() && !r.Configuration.TunnelMethod.NoTunnel.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.TunnelMethod.NoTunnel.AdditionalProperties.ValueString()), &additionalProperties3)
		}
		sourceNetsuiteEnterpriseUpdateNoTunnel = &shared.SourceNetsuiteEnterpriseUpdateNoTunnel{
			TunnelMethod:         tunnelMethod1,
			AdditionalProperties: additionalProperties3,
		}
	}
	if sourceNetsuiteEnterpriseUpdateNoTunnel != nil {
		tunnelMethod = shared.SourceNetsuiteEnterpriseUpdateSSHTunnelMethod{
			SourceNetsuiteEnterpriseUpdateNoTunnel: sourceNetsuiteEnterpriseUpdateNoTunnel,
		}
	}
	var sourceNetsuiteEnterpriseUpdateSSHKeyAuthentication *shared.SourceNetsuiteEnterpriseUpdateSSHKeyAuthentication
	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()

		tunnelMethod2 := new(shared.SourceNetsuiteEnterpriseUpdateSchemasTunnelMethod)
		if !r.Configuration.TunnelMethod.SSHKeyAuthentication.TunnelMethod.IsUnknown() && !r.Configuration.TunnelMethod.SSHKeyAuthentication.TunnelMethod.IsNull() {
			*tunnelMethod2 = shared.SourceNetsuiteEnterpriseUpdateSchemasTunnelMethod(r.Configuration.TunnelMethod.SSHKeyAuthentication.TunnelMethod.ValueString())
		} else {
			tunnelMethod2 = nil
		}
		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()

		var additionalProperties4 interface{}
		if !r.Configuration.TunnelMethod.SSHKeyAuthentication.AdditionalProperties.IsUnknown() && !r.Configuration.TunnelMethod.SSHKeyAuthentication.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.TunnelMethod.SSHKeyAuthentication.AdditionalProperties.ValueString()), &additionalProperties4)
		}
		sourceNetsuiteEnterpriseUpdateSSHKeyAuthentication = &shared.SourceNetsuiteEnterpriseUpdateSSHKeyAuthentication{
			SSHKey:               sshKey,
			TunnelHost:           tunnelHost,
			TunnelMethod:         tunnelMethod2,
			TunnelPort:           tunnelPort,
			TunnelUser:           tunnelUser,
			AdditionalProperties: additionalProperties4,
		}
	}
	if sourceNetsuiteEnterpriseUpdateSSHKeyAuthentication != nil {
		tunnelMethod = shared.SourceNetsuiteEnterpriseUpdateSSHTunnelMethod{
			SourceNetsuiteEnterpriseUpdateSSHKeyAuthentication: sourceNetsuiteEnterpriseUpdateSSHKeyAuthentication,
		}
	}
	var sourceNetsuiteEnterpriseUpdateSchemasPasswordAuthentication *shared.SourceNetsuiteEnterpriseUpdateSchemasPasswordAuthentication
	if r.Configuration.TunnelMethod.PasswordAuthentication != nil {
		var tunnelHost1 string
		tunnelHost1 = r.Configuration.TunnelMethod.PasswordAuthentication.TunnelHost.ValueString()

		tunnelMethod3 := new(shared.SourceNetsuiteEnterpriseUpdateSchemasTunnelMethodTunnelMethod)
		if !r.Configuration.TunnelMethod.PasswordAuthentication.TunnelMethod.IsUnknown() && !r.Configuration.TunnelMethod.PasswordAuthentication.TunnelMethod.IsNull() {
			*tunnelMethod3 = shared.SourceNetsuiteEnterpriseUpdateSchemasTunnelMethodTunnelMethod(r.Configuration.TunnelMethod.PasswordAuthentication.TunnelMethod.ValueString())
		} else {
			tunnelMethod3 = nil
		}
		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()

		var additionalProperties5 interface{}
		if !r.Configuration.TunnelMethod.PasswordAuthentication.AdditionalProperties.IsUnknown() && !r.Configuration.TunnelMethod.PasswordAuthentication.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.TunnelMethod.PasswordAuthentication.AdditionalProperties.ValueString()), &additionalProperties5)
		}
		sourceNetsuiteEnterpriseUpdateSchemasPasswordAuthentication = &shared.SourceNetsuiteEnterpriseUpdateSchemasPasswordAuthentication{
			TunnelHost:           tunnelHost1,
			TunnelMethod:         tunnelMethod3,
			TunnelPort:           tunnelPort1,
			TunnelUser:           tunnelUser1,
			TunnelUserPassword:   tunnelUserPassword,
			AdditionalProperties: additionalProperties5,
		}
	}
	if sourceNetsuiteEnterpriseUpdateSchemasPasswordAuthentication != nil {
		tunnelMethod = shared.SourceNetsuiteEnterpriseUpdateSSHTunnelMethod{
			SourceNetsuiteEnterpriseUpdateSchemasPasswordAuthentication: sourceNetsuiteEnterpriseUpdateSchemasPasswordAuthentication,
		}
	}
	var username string
	username = r.Configuration.Username.ValueString()

	configuration := shared.SourceNetsuiteEnterpriseUpdate{
		AccountID:                       accountID,
		AuthenticationMethod:            authenticationMethod,
		CheckPrivileges:                 checkPrivileges,
		CheckpointTargetIntervalSeconds: checkpointTargetIntervalSeconds,
		Concurrency:                     concurrency,
		Cursor:                          cursor,
		Host:                            host,
		JdbcURLParams:                   jdbcURLParams,
		Port:                            port,
		RoleID:                          roleID,
		TunnelMethod:                    tunnelMethod,
		Username:                        username,
	}
	out := shared.SourceNetsuiteEnterprisePutRequest{
		Name:          name,
		WorkspaceID:   workspaceID,
		Configuration: configuration,
	}
	return &out
}
