// 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 *SourceFileResourceModel) ToSharedSourceFileCreateRequest() *shared.SourceFileCreateRequest {
	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 datasetName string
	datasetName = r.Configuration.DatasetName.ValueString()

	format := new(shared.FileFormat)
	if !r.Configuration.Format.IsUnknown() && !r.Configuration.Format.IsNull() {
		*format = shared.FileFormat(r.Configuration.Format.ValueString())
	} else {
		format = nil
	}
	var provider shared.StorageProvider
	var httpsPublicWeb *shared.HTTPSPublicWeb
	if r.Configuration.Provider.HTTPSPublicWeb != nil {
		userAgent := new(bool)
		if !r.Configuration.Provider.HTTPSPublicWeb.UserAgent.IsUnknown() && !r.Configuration.Provider.HTTPSPublicWeb.UserAgent.IsNull() {
			*userAgent = r.Configuration.Provider.HTTPSPublicWeb.UserAgent.ValueBool()
		} else {
			userAgent = nil
		}
		httpsPublicWeb = &shared.HTTPSPublicWeb{
			UserAgent: userAgent,
		}
	}
	if httpsPublicWeb != nil {
		provider = shared.StorageProvider{
			HTTPSPublicWeb: httpsPublicWeb,
		}
	}
	var gcsGoogleCloudStorage *shared.GCSGoogleCloudStorage
	if r.Configuration.Provider.GCSGoogleCloudStorage != nil {
		serviceAccountJSON := new(string)
		if !r.Configuration.Provider.GCSGoogleCloudStorage.ServiceAccountJSON.IsUnknown() && !r.Configuration.Provider.GCSGoogleCloudStorage.ServiceAccountJSON.IsNull() {
			*serviceAccountJSON = r.Configuration.Provider.GCSGoogleCloudStorage.ServiceAccountJSON.ValueString()
		} else {
			serviceAccountJSON = nil
		}
		gcsGoogleCloudStorage = &shared.GCSGoogleCloudStorage{
			ServiceAccountJSON: serviceAccountJSON,
		}
	}
	if gcsGoogleCloudStorage != nil {
		provider = shared.StorageProvider{
			GCSGoogleCloudStorage: gcsGoogleCloudStorage,
		}
	}
	var s3AmazonWebServices *shared.S3AmazonWebServices
	if r.Configuration.Provider.S3AmazonWebServices != nil {
		awsAccessKeyID := new(string)
		if !r.Configuration.Provider.S3AmazonWebServices.AwsAccessKeyID.IsUnknown() && !r.Configuration.Provider.S3AmazonWebServices.AwsAccessKeyID.IsNull() {
			*awsAccessKeyID = r.Configuration.Provider.S3AmazonWebServices.AwsAccessKeyID.ValueString()
		} else {
			awsAccessKeyID = nil
		}
		awsSecretAccessKey := new(string)
		if !r.Configuration.Provider.S3AmazonWebServices.AwsSecretAccessKey.IsUnknown() && !r.Configuration.Provider.S3AmazonWebServices.AwsSecretAccessKey.IsNull() {
			*awsSecretAccessKey = r.Configuration.Provider.S3AmazonWebServices.AwsSecretAccessKey.ValueString()
		} else {
			awsSecretAccessKey = nil
		}
		s3AmazonWebServices = &shared.S3AmazonWebServices{
			AwsAccessKeyID:     awsAccessKeyID,
			AwsSecretAccessKey: awsSecretAccessKey,
		}
	}
	if s3AmazonWebServices != nil {
		provider = shared.StorageProvider{
			S3AmazonWebServices: s3AmazonWebServices,
		}
	}
	var azBlobAzureBlobStorage *shared.AzBlobAzureBlobStorage
	if r.Configuration.Provider.AzBlobAzureBlobStorage != nil {
		sasToken := new(string)
		if !r.Configuration.Provider.AzBlobAzureBlobStorage.SasToken.IsUnknown() && !r.Configuration.Provider.AzBlobAzureBlobStorage.SasToken.IsNull() {
			*sasToken = r.Configuration.Provider.AzBlobAzureBlobStorage.SasToken.ValueString()
		} else {
			sasToken = nil
		}
		sharedKey := new(string)
		if !r.Configuration.Provider.AzBlobAzureBlobStorage.SharedKey.IsUnknown() && !r.Configuration.Provider.AzBlobAzureBlobStorage.SharedKey.IsNull() {
			*sharedKey = r.Configuration.Provider.AzBlobAzureBlobStorage.SharedKey.ValueString()
		} else {
			sharedKey = nil
		}
		var storageAccount string
		storageAccount = r.Configuration.Provider.AzBlobAzureBlobStorage.StorageAccount.ValueString()

		azBlobAzureBlobStorage = &shared.AzBlobAzureBlobStorage{
			SasToken:       sasToken,
			SharedKey:      sharedKey,
			StorageAccount: storageAccount,
		}
	}
	if azBlobAzureBlobStorage != nil {
		provider = shared.StorageProvider{
			AzBlobAzureBlobStorage: azBlobAzureBlobStorage,
		}
	}
	var sshSecureShell *shared.SSHSecureShell
	if r.Configuration.Provider.SSHSecureShell != nil {
		var host string
		host = r.Configuration.Provider.SSHSecureShell.Host.ValueString()

		password := new(string)
		if !r.Configuration.Provider.SSHSecureShell.Password.IsUnknown() && !r.Configuration.Provider.SSHSecureShell.Password.IsNull() {
			*password = r.Configuration.Provider.SSHSecureShell.Password.ValueString()
		} else {
			password = nil
		}
		port := new(string)
		if !r.Configuration.Provider.SSHSecureShell.Port.IsUnknown() && !r.Configuration.Provider.SSHSecureShell.Port.IsNull() {
			*port = r.Configuration.Provider.SSHSecureShell.Port.ValueString()
		} else {
			port = nil
		}
		var user string
		user = r.Configuration.Provider.SSHSecureShell.User.ValueString()

		sshSecureShell = &shared.SSHSecureShell{
			Host:     host,
			Password: password,
			Port:     port,
			User:     user,
		}
	}
	if sshSecureShell != nil {
		provider = shared.StorageProvider{
			SSHSecureShell: sshSecureShell,
		}
	}
	var scpSecureCopyProtocol *shared.SCPSecureCopyProtocol
	if r.Configuration.Provider.SCPSecureCopyProtocol != nil {
		var host1 string
		host1 = r.Configuration.Provider.SCPSecureCopyProtocol.Host.ValueString()

		password1 := new(string)
		if !r.Configuration.Provider.SCPSecureCopyProtocol.Password.IsUnknown() && !r.Configuration.Provider.SCPSecureCopyProtocol.Password.IsNull() {
			*password1 = r.Configuration.Provider.SCPSecureCopyProtocol.Password.ValueString()
		} else {
			password1 = nil
		}
		port1 := new(string)
		if !r.Configuration.Provider.SCPSecureCopyProtocol.Port.IsUnknown() && !r.Configuration.Provider.SCPSecureCopyProtocol.Port.IsNull() {
			*port1 = r.Configuration.Provider.SCPSecureCopyProtocol.Port.ValueString()
		} else {
			port1 = nil
		}
		var user1 string
		user1 = r.Configuration.Provider.SCPSecureCopyProtocol.User.ValueString()

		scpSecureCopyProtocol = &shared.SCPSecureCopyProtocol{
			Host:     host1,
			Password: password1,
			Port:     port1,
			User:     user1,
		}
	}
	if scpSecureCopyProtocol != nil {
		provider = shared.StorageProvider{
			SCPSecureCopyProtocol: scpSecureCopyProtocol,
		}
	}
	var sftpSecureFileTransferProtocol *shared.SFTPSecureFileTransferProtocol
	if r.Configuration.Provider.SFTPSecureFileTransferProtocol != nil {
		var host2 string
		host2 = r.Configuration.Provider.SFTPSecureFileTransferProtocol.Host.ValueString()

		password2 := new(string)
		if !r.Configuration.Provider.SFTPSecureFileTransferProtocol.Password.IsUnknown() && !r.Configuration.Provider.SFTPSecureFileTransferProtocol.Password.IsNull() {
			*password2 = r.Configuration.Provider.SFTPSecureFileTransferProtocol.Password.ValueString()
		} else {
			password2 = nil
		}
		port2 := new(string)
		if !r.Configuration.Provider.SFTPSecureFileTransferProtocol.Port.IsUnknown() && !r.Configuration.Provider.SFTPSecureFileTransferProtocol.Port.IsNull() {
			*port2 = r.Configuration.Provider.SFTPSecureFileTransferProtocol.Port.ValueString()
		} else {
			port2 = nil
		}
		var user2 string
		user2 = r.Configuration.Provider.SFTPSecureFileTransferProtocol.User.ValueString()

		sftpSecureFileTransferProtocol = &shared.SFTPSecureFileTransferProtocol{
			Host:     host2,
			Password: password2,
			Port:     port2,
			User:     user2,
		}
	}
	if sftpSecureFileTransferProtocol != nil {
		provider = shared.StorageProvider{
			SFTPSecureFileTransferProtocol: sftpSecureFileTransferProtocol,
		}
	}
	var localFilesystemLimited *shared.LocalFilesystemLimited
	if r.Configuration.Provider.LocalFilesystemLimited != nil {
		localFilesystemLimited = &shared.LocalFilesystemLimited{}
	}
	if localFilesystemLimited != nil {
		provider = shared.StorageProvider{
			LocalFilesystemLimited: localFilesystemLimited,
		}
	}
	readerOptions := new(string)
	if !r.Configuration.ReaderOptions.IsUnknown() && !r.Configuration.ReaderOptions.IsNull() {
		*readerOptions = r.Configuration.ReaderOptions.ValueString()
	} else {
		readerOptions = nil
	}
	var url string
	url = r.Configuration.URL.ValueString()

	configuration := shared.SourceFile{
		DatasetName:   datasetName,
		Format:        format,
		Provider:      provider,
		ReaderOptions: readerOptions,
		URL:           url,
	}
	secretID := new(string)
	if !r.SecretID.IsUnknown() && !r.SecretID.IsNull() {
		*secretID = r.SecretID.ValueString()
	} else {
		secretID = nil
	}
	out := shared.SourceFileCreateRequest{
		Name:          name,
		DefinitionID:  definitionID,
		WorkspaceID:   workspaceID,
		Configuration: configuration,
		SecretID:      secretID,
	}
	return &out
}

func (r *SourceFileResourceModel) 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 *SourceFileResourceModel) ToSharedSourceFilePutRequest() *shared.SourceFilePutRequest {
	var name string
	name = r.Name.ValueString()

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

	var datasetName string
	datasetName = r.Configuration.DatasetName.ValueString()

	format := new(shared.SourceFileUpdateFileFormat)
	if !r.Configuration.Format.IsUnknown() && !r.Configuration.Format.IsNull() {
		*format = shared.SourceFileUpdateFileFormat(r.Configuration.Format.ValueString())
	} else {
		format = nil
	}
	var provider shared.SourceFileUpdateStorageProvider
	var sourceFileUpdateHTTPSPublicWeb *shared.SourceFileUpdateHTTPSPublicWeb
	if r.Configuration.Provider.HTTPSPublicWeb != nil {
		userAgent := new(bool)
		if !r.Configuration.Provider.HTTPSPublicWeb.UserAgent.IsUnknown() && !r.Configuration.Provider.HTTPSPublicWeb.UserAgent.IsNull() {
			*userAgent = r.Configuration.Provider.HTTPSPublicWeb.UserAgent.ValueBool()
		} else {
			userAgent = nil
		}
		sourceFileUpdateHTTPSPublicWeb = &shared.SourceFileUpdateHTTPSPublicWeb{
			UserAgent: userAgent,
		}
	}
	if sourceFileUpdateHTTPSPublicWeb != nil {
		provider = shared.SourceFileUpdateStorageProvider{
			SourceFileUpdateHTTPSPublicWeb: sourceFileUpdateHTTPSPublicWeb,
		}
	}
	var sourceFileUpdateGCSGoogleCloudStorage *shared.SourceFileUpdateGCSGoogleCloudStorage
	if r.Configuration.Provider.GCSGoogleCloudStorage != nil {
		serviceAccountJSON := new(string)
		if !r.Configuration.Provider.GCSGoogleCloudStorage.ServiceAccountJSON.IsUnknown() && !r.Configuration.Provider.GCSGoogleCloudStorage.ServiceAccountJSON.IsNull() {
			*serviceAccountJSON = r.Configuration.Provider.GCSGoogleCloudStorage.ServiceAccountJSON.ValueString()
		} else {
			serviceAccountJSON = nil
		}
		sourceFileUpdateGCSGoogleCloudStorage = &shared.SourceFileUpdateGCSGoogleCloudStorage{
			ServiceAccountJSON: serviceAccountJSON,
		}
	}
	if sourceFileUpdateGCSGoogleCloudStorage != nil {
		provider = shared.SourceFileUpdateStorageProvider{
			SourceFileUpdateGCSGoogleCloudStorage: sourceFileUpdateGCSGoogleCloudStorage,
		}
	}
	var sourceFileUpdateS3AmazonWebServices *shared.SourceFileUpdateS3AmazonWebServices
	if r.Configuration.Provider.S3AmazonWebServices != nil {
		awsAccessKeyID := new(string)
		if !r.Configuration.Provider.S3AmazonWebServices.AwsAccessKeyID.IsUnknown() && !r.Configuration.Provider.S3AmazonWebServices.AwsAccessKeyID.IsNull() {
			*awsAccessKeyID = r.Configuration.Provider.S3AmazonWebServices.AwsAccessKeyID.ValueString()
		} else {
			awsAccessKeyID = nil
		}
		awsSecretAccessKey := new(string)
		if !r.Configuration.Provider.S3AmazonWebServices.AwsSecretAccessKey.IsUnknown() && !r.Configuration.Provider.S3AmazonWebServices.AwsSecretAccessKey.IsNull() {
			*awsSecretAccessKey = r.Configuration.Provider.S3AmazonWebServices.AwsSecretAccessKey.ValueString()
		} else {
			awsSecretAccessKey = nil
		}
		sourceFileUpdateS3AmazonWebServices = &shared.SourceFileUpdateS3AmazonWebServices{
			AwsAccessKeyID:     awsAccessKeyID,
			AwsSecretAccessKey: awsSecretAccessKey,
		}
	}
	if sourceFileUpdateS3AmazonWebServices != nil {
		provider = shared.SourceFileUpdateStorageProvider{
			SourceFileUpdateS3AmazonWebServices: sourceFileUpdateS3AmazonWebServices,
		}
	}
	var sourceFileUpdateAzBlobAzureBlobStorage *shared.SourceFileUpdateAzBlobAzureBlobStorage
	if r.Configuration.Provider.AzBlobAzureBlobStorage != nil {
		sasToken := new(string)
		if !r.Configuration.Provider.AzBlobAzureBlobStorage.SasToken.IsUnknown() && !r.Configuration.Provider.AzBlobAzureBlobStorage.SasToken.IsNull() {
			*sasToken = r.Configuration.Provider.AzBlobAzureBlobStorage.SasToken.ValueString()
		} else {
			sasToken = nil
		}
		sharedKey := new(string)
		if !r.Configuration.Provider.AzBlobAzureBlobStorage.SharedKey.IsUnknown() && !r.Configuration.Provider.AzBlobAzureBlobStorage.SharedKey.IsNull() {
			*sharedKey = r.Configuration.Provider.AzBlobAzureBlobStorage.SharedKey.ValueString()
		} else {
			sharedKey = nil
		}
		var storageAccount string
		storageAccount = r.Configuration.Provider.AzBlobAzureBlobStorage.StorageAccount.ValueString()

		sourceFileUpdateAzBlobAzureBlobStorage = &shared.SourceFileUpdateAzBlobAzureBlobStorage{
			SasToken:       sasToken,
			SharedKey:      sharedKey,
			StorageAccount: storageAccount,
		}
	}
	if sourceFileUpdateAzBlobAzureBlobStorage != nil {
		provider = shared.SourceFileUpdateStorageProvider{
			SourceFileUpdateAzBlobAzureBlobStorage: sourceFileUpdateAzBlobAzureBlobStorage,
		}
	}
	var sourceFileUpdateSSHSecureShell *shared.SourceFileUpdateSSHSecureShell
	if r.Configuration.Provider.SSHSecureShell != nil {
		var host string
		host = r.Configuration.Provider.SSHSecureShell.Host.ValueString()

		password := new(string)
		if !r.Configuration.Provider.SSHSecureShell.Password.IsUnknown() && !r.Configuration.Provider.SSHSecureShell.Password.IsNull() {
			*password = r.Configuration.Provider.SSHSecureShell.Password.ValueString()
		} else {
			password = nil
		}
		port := new(string)
		if !r.Configuration.Provider.SSHSecureShell.Port.IsUnknown() && !r.Configuration.Provider.SSHSecureShell.Port.IsNull() {
			*port = r.Configuration.Provider.SSHSecureShell.Port.ValueString()
		} else {
			port = nil
		}
		var user string
		user = r.Configuration.Provider.SSHSecureShell.User.ValueString()

		sourceFileUpdateSSHSecureShell = &shared.SourceFileUpdateSSHSecureShell{
			Host:     host,
			Password: password,
			Port:     port,
			User:     user,
		}
	}
	if sourceFileUpdateSSHSecureShell != nil {
		provider = shared.SourceFileUpdateStorageProvider{
			SourceFileUpdateSSHSecureShell: sourceFileUpdateSSHSecureShell,
		}
	}
	var sourceFileUpdateSCPSecureCopyProtocol *shared.SourceFileUpdateSCPSecureCopyProtocol
	if r.Configuration.Provider.SCPSecureCopyProtocol != nil {
		var host1 string
		host1 = r.Configuration.Provider.SCPSecureCopyProtocol.Host.ValueString()

		password1 := new(string)
		if !r.Configuration.Provider.SCPSecureCopyProtocol.Password.IsUnknown() && !r.Configuration.Provider.SCPSecureCopyProtocol.Password.IsNull() {
			*password1 = r.Configuration.Provider.SCPSecureCopyProtocol.Password.ValueString()
		} else {
			password1 = nil
		}
		port1 := new(string)
		if !r.Configuration.Provider.SCPSecureCopyProtocol.Port.IsUnknown() && !r.Configuration.Provider.SCPSecureCopyProtocol.Port.IsNull() {
			*port1 = r.Configuration.Provider.SCPSecureCopyProtocol.Port.ValueString()
		} else {
			port1 = nil
		}
		var user1 string
		user1 = r.Configuration.Provider.SCPSecureCopyProtocol.User.ValueString()

		sourceFileUpdateSCPSecureCopyProtocol = &shared.SourceFileUpdateSCPSecureCopyProtocol{
			Host:     host1,
			Password: password1,
			Port:     port1,
			User:     user1,
		}
	}
	if sourceFileUpdateSCPSecureCopyProtocol != nil {
		provider = shared.SourceFileUpdateStorageProvider{
			SourceFileUpdateSCPSecureCopyProtocol: sourceFileUpdateSCPSecureCopyProtocol,
		}
	}
	var sourceFileUpdateSFTPSecureFileTransferProtocol *shared.SourceFileUpdateSFTPSecureFileTransferProtocol
	if r.Configuration.Provider.SFTPSecureFileTransferProtocol != nil {
		var host2 string
		host2 = r.Configuration.Provider.SFTPSecureFileTransferProtocol.Host.ValueString()

		password2 := new(string)
		if !r.Configuration.Provider.SFTPSecureFileTransferProtocol.Password.IsUnknown() && !r.Configuration.Provider.SFTPSecureFileTransferProtocol.Password.IsNull() {
			*password2 = r.Configuration.Provider.SFTPSecureFileTransferProtocol.Password.ValueString()
		} else {
			password2 = nil
		}
		port2 := new(string)
		if !r.Configuration.Provider.SFTPSecureFileTransferProtocol.Port.IsUnknown() && !r.Configuration.Provider.SFTPSecureFileTransferProtocol.Port.IsNull() {
			*port2 = r.Configuration.Provider.SFTPSecureFileTransferProtocol.Port.ValueString()
		} else {
			port2 = nil
		}
		var user2 string
		user2 = r.Configuration.Provider.SFTPSecureFileTransferProtocol.User.ValueString()

		sourceFileUpdateSFTPSecureFileTransferProtocol = &shared.SourceFileUpdateSFTPSecureFileTransferProtocol{
			Host:     host2,
			Password: password2,
			Port:     port2,
			User:     user2,
		}
	}
	if sourceFileUpdateSFTPSecureFileTransferProtocol != nil {
		provider = shared.SourceFileUpdateStorageProvider{
			SourceFileUpdateSFTPSecureFileTransferProtocol: sourceFileUpdateSFTPSecureFileTransferProtocol,
		}
	}
	var sourceFileUpdateLocalFilesystemLimited *shared.SourceFileUpdateLocalFilesystemLimited
	if r.Configuration.Provider.LocalFilesystemLimited != nil {
		sourceFileUpdateLocalFilesystemLimited = &shared.SourceFileUpdateLocalFilesystemLimited{}
	}
	if sourceFileUpdateLocalFilesystemLimited != nil {
		provider = shared.SourceFileUpdateStorageProvider{
			SourceFileUpdateLocalFilesystemLimited: sourceFileUpdateLocalFilesystemLimited,
		}
	}
	readerOptions := new(string)
	if !r.Configuration.ReaderOptions.IsUnknown() && !r.Configuration.ReaderOptions.IsNull() {
		*readerOptions = r.Configuration.ReaderOptions.ValueString()
	} else {
		readerOptions = nil
	}
	var url string
	url = r.Configuration.URL.ValueString()

	configuration := shared.SourceFileUpdate{
		DatasetName:   datasetName,
		Format:        format,
		Provider:      provider,
		ReaderOptions: readerOptions,
		URL:           url,
	}
	out := shared.SourceFilePutRequest{
		Name:          name,
		WorkspaceID:   workspaceID,
		Configuration: configuration,
	}
	return &out
}
