// 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 *DestinationS3ResourceModel) ToSharedDestinationS3CreateRequest() *shared.DestinationS3CreateRequest {
	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()

	accessKeyID := new(string)
	if !r.Configuration.AccessKeyID.IsUnknown() && !r.Configuration.AccessKeyID.IsNull() {
		*accessKeyID = r.Configuration.AccessKeyID.ValueString()
	} else {
		accessKeyID = nil
	}
	fileNamePattern := new(string)
	if !r.Configuration.FileNamePattern.IsUnknown() && !r.Configuration.FileNamePattern.IsNull() {
		*fileNamePattern = r.Configuration.FileNamePattern.ValueString()
	} else {
		fileNamePattern = nil
	}
	var format shared.DestinationS3OutputFormat
	var destinationS3CSVCommaSeparatedValues *shared.DestinationS3CSVCommaSeparatedValues
	if r.Configuration.Format.CSVCommaSeparatedValues != nil {
		var compression *shared.DestinationS3Compression
		if r.Configuration.Format.CSVCommaSeparatedValues.Compression != nil {
			var destinationS3NoCompression *shared.DestinationS3NoCompression
			if r.Configuration.Format.CSVCommaSeparatedValues.Compression.NoCompression != nil {
				compressionType := new(shared.DestinationS3CompressionType)
				if !r.Configuration.Format.CSVCommaSeparatedValues.Compression.NoCompression.CompressionType.IsUnknown() && !r.Configuration.Format.CSVCommaSeparatedValues.Compression.NoCompression.CompressionType.IsNull() {
					*compressionType = shared.DestinationS3CompressionType(r.Configuration.Format.CSVCommaSeparatedValues.Compression.NoCompression.CompressionType.ValueString())
				} else {
					compressionType = nil
				}
				var additionalProperties interface{}
				if !r.Configuration.Format.CSVCommaSeparatedValues.Compression.NoCompression.AdditionalProperties.IsUnknown() && !r.Configuration.Format.CSVCommaSeparatedValues.Compression.NoCompression.AdditionalProperties.IsNull() {
					_ = json.Unmarshal([]byte(r.Configuration.Format.CSVCommaSeparatedValues.Compression.NoCompression.AdditionalProperties.ValueString()), &additionalProperties)
				}
				destinationS3NoCompression = &shared.DestinationS3NoCompression{
					CompressionType:      compressionType,
					AdditionalProperties: additionalProperties,
				}
			}
			if destinationS3NoCompression != nil {
				compression = &shared.DestinationS3Compression{
					DestinationS3NoCompression: destinationS3NoCompression,
				}
			}
			var destinationS3GZIP *shared.DestinationS3GZIP
			if r.Configuration.Format.CSVCommaSeparatedValues.Compression.Gzip != nil {
				compressionType1 := new(shared.DestinationS3SchemasCompressionType)
				if !r.Configuration.Format.CSVCommaSeparatedValues.Compression.Gzip.CompressionType.IsUnknown() && !r.Configuration.Format.CSVCommaSeparatedValues.Compression.Gzip.CompressionType.IsNull() {
					*compressionType1 = shared.DestinationS3SchemasCompressionType(r.Configuration.Format.CSVCommaSeparatedValues.Compression.Gzip.CompressionType.ValueString())
				} else {
					compressionType1 = nil
				}
				var additionalProperties1 interface{}
				if !r.Configuration.Format.CSVCommaSeparatedValues.Compression.Gzip.AdditionalProperties.IsUnknown() && !r.Configuration.Format.CSVCommaSeparatedValues.Compression.Gzip.AdditionalProperties.IsNull() {
					_ = json.Unmarshal([]byte(r.Configuration.Format.CSVCommaSeparatedValues.Compression.Gzip.AdditionalProperties.ValueString()), &additionalProperties1)
				}
				destinationS3GZIP = &shared.DestinationS3GZIP{
					CompressionType:      compressionType1,
					AdditionalProperties: additionalProperties1,
				}
			}
			if destinationS3GZIP != nil {
				compression = &shared.DestinationS3Compression{
					DestinationS3GZIP: destinationS3GZIP,
				}
			}
		}
		flattening := new(shared.DestinationS3Flattening)
		if !r.Configuration.Format.CSVCommaSeparatedValues.Flattening.IsUnknown() && !r.Configuration.Format.CSVCommaSeparatedValues.Flattening.IsNull() {
			*flattening = shared.DestinationS3Flattening(r.Configuration.Format.CSVCommaSeparatedValues.Flattening.ValueString())
		} else {
			flattening = nil
		}
		formatType := new(shared.DestinationS3FormatType)
		if !r.Configuration.Format.CSVCommaSeparatedValues.FormatType.IsUnknown() && !r.Configuration.Format.CSVCommaSeparatedValues.FormatType.IsNull() {
			*formatType = shared.DestinationS3FormatType(r.Configuration.Format.CSVCommaSeparatedValues.FormatType.ValueString())
		} else {
			formatType = nil
		}
		var additionalProperties2 interface{}
		if !r.Configuration.Format.CSVCommaSeparatedValues.AdditionalProperties.IsUnknown() && !r.Configuration.Format.CSVCommaSeparatedValues.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.Format.CSVCommaSeparatedValues.AdditionalProperties.ValueString()), &additionalProperties2)
		}
		destinationS3CSVCommaSeparatedValues = &shared.DestinationS3CSVCommaSeparatedValues{
			Compression:          compression,
			Flattening:           flattening,
			FormatType:           formatType,
			AdditionalProperties: additionalProperties2,
		}
	}
	if destinationS3CSVCommaSeparatedValues != nil {
		format = shared.DestinationS3OutputFormat{
			DestinationS3CSVCommaSeparatedValues: destinationS3CSVCommaSeparatedValues,
		}
	}
	var destinationS3JSONLinesNewlineDelimitedJSON *shared.DestinationS3JSONLinesNewlineDelimitedJSON
	if r.Configuration.Format.JSONLinesNewlineDelimitedJSON != nil {
		var compression1 *shared.DestinationS3SchemasCompression
		if r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression != nil {
			var destinationS3SchemasNoCompression *shared.DestinationS3SchemasNoCompression
			if r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.NoCompression != nil {
				compressionType2 := new(shared.DestinationS3SchemasFormatCompressionType)
				if !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.NoCompression.CompressionType.IsUnknown() && !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.NoCompression.CompressionType.IsNull() {
					*compressionType2 = shared.DestinationS3SchemasFormatCompressionType(r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.NoCompression.CompressionType.ValueString())
				} else {
					compressionType2 = nil
				}
				var additionalProperties3 interface{}
				if !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.NoCompression.AdditionalProperties.IsUnknown() && !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.NoCompression.AdditionalProperties.IsNull() {
					_ = json.Unmarshal([]byte(r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.NoCompression.AdditionalProperties.ValueString()), &additionalProperties3)
				}
				destinationS3SchemasNoCompression = &shared.DestinationS3SchemasNoCompression{
					CompressionType:      compressionType2,
					AdditionalProperties: additionalProperties3,
				}
			}
			if destinationS3SchemasNoCompression != nil {
				compression1 = &shared.DestinationS3SchemasCompression{
					DestinationS3SchemasNoCompression: destinationS3SchemasNoCompression,
				}
			}
			var destinationS3SchemasGZIP *shared.DestinationS3SchemasGZIP
			if r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.Gzip != nil {
				compressionType3 := new(shared.DestinationS3SchemasFormatOutputFormatCompressionType)
				if !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.Gzip.CompressionType.IsUnknown() && !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.Gzip.CompressionType.IsNull() {
					*compressionType3 = shared.DestinationS3SchemasFormatOutputFormatCompressionType(r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.Gzip.CompressionType.ValueString())
				} else {
					compressionType3 = nil
				}
				var additionalProperties4 interface{}
				if !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.Gzip.AdditionalProperties.IsUnknown() && !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.Gzip.AdditionalProperties.IsNull() {
					_ = json.Unmarshal([]byte(r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.Gzip.AdditionalProperties.ValueString()), &additionalProperties4)
				}
				destinationS3SchemasGZIP = &shared.DestinationS3SchemasGZIP{
					CompressionType:      compressionType3,
					AdditionalProperties: additionalProperties4,
				}
			}
			if destinationS3SchemasGZIP != nil {
				compression1 = &shared.DestinationS3SchemasCompression{
					DestinationS3SchemasGZIP: destinationS3SchemasGZIP,
				}
			}
		}
		flattening1 := new(shared.DestinationS3SchemasFlattening)
		if !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Flattening.IsUnknown() && !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Flattening.IsNull() {
			*flattening1 = shared.DestinationS3SchemasFlattening(r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Flattening.ValueString())
		} else {
			flattening1 = nil
		}
		formatType1 := new(shared.DestinationS3SchemasFormatType)
		if !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.FormatType.IsUnknown() && !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.FormatType.IsNull() {
			*formatType1 = shared.DestinationS3SchemasFormatType(r.Configuration.Format.JSONLinesNewlineDelimitedJSON.FormatType.ValueString())
		} else {
			formatType1 = nil
		}
		var additionalProperties5 interface{}
		if !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.AdditionalProperties.IsUnknown() && !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.Format.JSONLinesNewlineDelimitedJSON.AdditionalProperties.ValueString()), &additionalProperties5)
		}
		destinationS3JSONLinesNewlineDelimitedJSON = &shared.DestinationS3JSONLinesNewlineDelimitedJSON{
			Compression:          compression1,
			Flattening:           flattening1,
			FormatType:           formatType1,
			AdditionalProperties: additionalProperties5,
		}
	}
	if destinationS3JSONLinesNewlineDelimitedJSON != nil {
		format = shared.DestinationS3OutputFormat{
			DestinationS3JSONLinesNewlineDelimitedJSON: destinationS3JSONLinesNewlineDelimitedJSON,
		}
	}
	var destinationS3AvroApacheAvro *shared.DestinationS3AvroApacheAvro
	if r.Configuration.Format.AvroApacheAvro != nil {
		var compressionCodec shared.DestinationS3CompressionCodec
		var destinationS3SchemasFormatNoCompression *shared.DestinationS3SchemasFormatNoCompression
		if r.Configuration.Format.AvroApacheAvro.CompressionCodec.NoCompression != nil {
			codec := new(shared.DestinationS3Codec)
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.NoCompression.Codec.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.NoCompression.Codec.IsNull() {
				*codec = shared.DestinationS3Codec(r.Configuration.Format.AvroApacheAvro.CompressionCodec.NoCompression.Codec.ValueString())
			} else {
				codec = nil
			}
			var additionalProperties6 interface{}
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.NoCompression.AdditionalProperties.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.NoCompression.AdditionalProperties.IsNull() {
				_ = json.Unmarshal([]byte(r.Configuration.Format.AvroApacheAvro.CompressionCodec.NoCompression.AdditionalProperties.ValueString()), &additionalProperties6)
			}
			destinationS3SchemasFormatNoCompression = &shared.DestinationS3SchemasFormatNoCompression{
				Codec:                codec,
				AdditionalProperties: additionalProperties6,
			}
		}
		if destinationS3SchemasFormatNoCompression != nil {
			compressionCodec = shared.DestinationS3CompressionCodec{
				DestinationS3SchemasFormatNoCompression: destinationS3SchemasFormatNoCompression,
			}
		}
		var destinationS3Deflate *shared.DestinationS3Deflate
		if r.Configuration.Format.AvroApacheAvro.CompressionCodec.Deflate != nil {
			codec1 := new(shared.DestinationS3SchemasCodec)
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Deflate.Codec.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Deflate.Codec.IsNull() {
				*codec1 = shared.DestinationS3SchemasCodec(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Deflate.Codec.ValueString())
			} else {
				codec1 = nil
			}
			var compressionLevel int64
			compressionLevel = r.Configuration.Format.AvroApacheAvro.CompressionCodec.Deflate.CompressionLevel.ValueInt64()

			var additionalProperties7 interface{}
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Deflate.AdditionalProperties.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Deflate.AdditionalProperties.IsNull() {
				_ = json.Unmarshal([]byte(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Deflate.AdditionalProperties.ValueString()), &additionalProperties7)
			}
			destinationS3Deflate = &shared.DestinationS3Deflate{
				Codec:                codec1,
				CompressionLevel:     compressionLevel,
				AdditionalProperties: additionalProperties7,
			}
		}
		if destinationS3Deflate != nil {
			compressionCodec = shared.DestinationS3CompressionCodec{
				DestinationS3Deflate: destinationS3Deflate,
			}
		}
		var destinationS3Bzip2 *shared.DestinationS3Bzip2
		if r.Configuration.Format.AvroApacheAvro.CompressionCodec.Bzip2 != nil {
			codec2 := new(shared.DestinationS3SchemasFormatCodec)
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Bzip2.Codec.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Bzip2.Codec.IsNull() {
				*codec2 = shared.DestinationS3SchemasFormatCodec(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Bzip2.Codec.ValueString())
			} else {
				codec2 = nil
			}
			var additionalProperties8 interface{}
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Bzip2.AdditionalProperties.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Bzip2.AdditionalProperties.IsNull() {
				_ = json.Unmarshal([]byte(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Bzip2.AdditionalProperties.ValueString()), &additionalProperties8)
			}
			destinationS3Bzip2 = &shared.DestinationS3Bzip2{
				Codec:                codec2,
				AdditionalProperties: additionalProperties8,
			}
		}
		if destinationS3Bzip2 != nil {
			compressionCodec = shared.DestinationS3CompressionCodec{
				DestinationS3Bzip2: destinationS3Bzip2,
			}
		}
		var destinationS3Xz *shared.DestinationS3Xz
		if r.Configuration.Format.AvroApacheAvro.CompressionCodec.Xz != nil {
			codec3 := new(shared.DestinationS3SchemasFormatOutputFormatCodec)
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Xz.Codec.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Xz.Codec.IsNull() {
				*codec3 = shared.DestinationS3SchemasFormatOutputFormatCodec(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Xz.Codec.ValueString())
			} else {
				codec3 = nil
			}
			var compressionLevel1 int64
			compressionLevel1 = r.Configuration.Format.AvroApacheAvro.CompressionCodec.Xz.CompressionLevel.ValueInt64()

			var additionalProperties9 interface{}
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Xz.AdditionalProperties.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Xz.AdditionalProperties.IsNull() {
				_ = json.Unmarshal([]byte(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Xz.AdditionalProperties.ValueString()), &additionalProperties9)
			}
			destinationS3Xz = &shared.DestinationS3Xz{
				Codec:                codec3,
				CompressionLevel:     compressionLevel1,
				AdditionalProperties: additionalProperties9,
			}
		}
		if destinationS3Xz != nil {
			compressionCodec = shared.DestinationS3CompressionCodec{
				DestinationS3Xz: destinationS3Xz,
			}
		}
		var destinationS3Zstandard *shared.DestinationS3Zstandard
		if r.Configuration.Format.AvroApacheAvro.CompressionCodec.Zstandard != nil {
			codec4 := new(shared.DestinationS3SchemasFormatOutputFormat3Codec)
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Zstandard.Codec.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Zstandard.Codec.IsNull() {
				*codec4 = shared.DestinationS3SchemasFormatOutputFormat3Codec(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Zstandard.Codec.ValueString())
			} else {
				codec4 = nil
			}
			var compressionLevel2 int64
			compressionLevel2 = r.Configuration.Format.AvroApacheAvro.CompressionCodec.Zstandard.CompressionLevel.ValueInt64()

			var includeChecksum bool
			includeChecksum = r.Configuration.Format.AvroApacheAvro.CompressionCodec.Zstandard.IncludeChecksum.ValueBool()

			var additionalProperties10 interface{}
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Zstandard.AdditionalProperties.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Zstandard.AdditionalProperties.IsNull() {
				_ = json.Unmarshal([]byte(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Zstandard.AdditionalProperties.ValueString()), &additionalProperties10)
			}
			destinationS3Zstandard = &shared.DestinationS3Zstandard{
				Codec:                codec4,
				CompressionLevel:     compressionLevel2,
				IncludeChecksum:      includeChecksum,
				AdditionalProperties: additionalProperties10,
			}
		}
		if destinationS3Zstandard != nil {
			compressionCodec = shared.DestinationS3CompressionCodec{
				DestinationS3Zstandard: destinationS3Zstandard,
			}
		}
		var destinationS3Snappy *shared.DestinationS3Snappy
		if r.Configuration.Format.AvroApacheAvro.CompressionCodec.Snappy != nil {
			codec5 := new(shared.DestinationS3SchemasFormatOutputFormat3CompressionCodecCodec)
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Snappy.Codec.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Snappy.Codec.IsNull() {
				*codec5 = shared.DestinationS3SchemasFormatOutputFormat3CompressionCodecCodec(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Snappy.Codec.ValueString())
			} else {
				codec5 = nil
			}
			var additionalProperties11 interface{}
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Snappy.AdditionalProperties.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Snappy.AdditionalProperties.IsNull() {
				_ = json.Unmarshal([]byte(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Snappy.AdditionalProperties.ValueString()), &additionalProperties11)
			}
			destinationS3Snappy = &shared.DestinationS3Snappy{
				Codec:                codec5,
				AdditionalProperties: additionalProperties11,
			}
		}
		if destinationS3Snappy != nil {
			compressionCodec = shared.DestinationS3CompressionCodec{
				DestinationS3Snappy: destinationS3Snappy,
			}
		}
		formatType2 := new(shared.DestinationS3SchemasFormatFormatType)
		if !r.Configuration.Format.AvroApacheAvro.FormatType.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.FormatType.IsNull() {
			*formatType2 = shared.DestinationS3SchemasFormatFormatType(r.Configuration.Format.AvroApacheAvro.FormatType.ValueString())
		} else {
			formatType2 = nil
		}
		var additionalProperties12 interface{}
		if !r.Configuration.Format.AvroApacheAvro.AdditionalProperties.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.Format.AvroApacheAvro.AdditionalProperties.ValueString()), &additionalProperties12)
		}
		destinationS3AvroApacheAvro = &shared.DestinationS3AvroApacheAvro{
			CompressionCodec:     compressionCodec,
			FormatType:           formatType2,
			AdditionalProperties: additionalProperties12,
		}
	}
	if destinationS3AvroApacheAvro != nil {
		format = shared.DestinationS3OutputFormat{
			DestinationS3AvroApacheAvro: destinationS3AvroApacheAvro,
		}
	}
	var destinationS3ParquetColumnarStorage *shared.DestinationS3ParquetColumnarStorage
	if r.Configuration.Format.ParquetColumnarStorage != nil {
		blockSizeMb := new(int64)
		if !r.Configuration.Format.ParquetColumnarStorage.BlockSizeMb.IsUnknown() && !r.Configuration.Format.ParquetColumnarStorage.BlockSizeMb.IsNull() {
			*blockSizeMb = r.Configuration.Format.ParquetColumnarStorage.BlockSizeMb.ValueInt64()
		} else {
			blockSizeMb = nil
		}
		compressionCodec1 := new(shared.DestinationS3SchemasCompressionCodec)
		if !r.Configuration.Format.ParquetColumnarStorage.CompressionCodec.IsUnknown() && !r.Configuration.Format.ParquetColumnarStorage.CompressionCodec.IsNull() {
			*compressionCodec1 = shared.DestinationS3SchemasCompressionCodec(r.Configuration.Format.ParquetColumnarStorage.CompressionCodec.ValueString())
		} else {
			compressionCodec1 = nil
		}
		dictionaryEncoding := new(bool)
		if !r.Configuration.Format.ParquetColumnarStorage.DictionaryEncoding.IsUnknown() && !r.Configuration.Format.ParquetColumnarStorage.DictionaryEncoding.IsNull() {
			*dictionaryEncoding = r.Configuration.Format.ParquetColumnarStorage.DictionaryEncoding.ValueBool()
		} else {
			dictionaryEncoding = nil
		}
		dictionaryPageSizeKb := new(int64)
		if !r.Configuration.Format.ParquetColumnarStorage.DictionaryPageSizeKb.IsUnknown() && !r.Configuration.Format.ParquetColumnarStorage.DictionaryPageSizeKb.IsNull() {
			*dictionaryPageSizeKb = r.Configuration.Format.ParquetColumnarStorage.DictionaryPageSizeKb.ValueInt64()
		} else {
			dictionaryPageSizeKb = nil
		}
		formatType3 := new(shared.DestinationS3SchemasFormatOutputFormatFormatType)
		if !r.Configuration.Format.ParquetColumnarStorage.FormatType.IsUnknown() && !r.Configuration.Format.ParquetColumnarStorage.FormatType.IsNull() {
			*formatType3 = shared.DestinationS3SchemasFormatOutputFormatFormatType(r.Configuration.Format.ParquetColumnarStorage.FormatType.ValueString())
		} else {
			formatType3 = nil
		}
		maxPaddingSizeMb := new(int64)
		if !r.Configuration.Format.ParquetColumnarStorage.MaxPaddingSizeMb.IsUnknown() && !r.Configuration.Format.ParquetColumnarStorage.MaxPaddingSizeMb.IsNull() {
			*maxPaddingSizeMb = r.Configuration.Format.ParquetColumnarStorage.MaxPaddingSizeMb.ValueInt64()
		} else {
			maxPaddingSizeMb = nil
		}
		pageSizeKb := new(int64)
		if !r.Configuration.Format.ParquetColumnarStorage.PageSizeKb.IsUnknown() && !r.Configuration.Format.ParquetColumnarStorage.PageSizeKb.IsNull() {
			*pageSizeKb = r.Configuration.Format.ParquetColumnarStorage.PageSizeKb.ValueInt64()
		} else {
			pageSizeKb = nil
		}
		var additionalProperties13 interface{}
		if !r.Configuration.Format.ParquetColumnarStorage.AdditionalProperties.IsUnknown() && !r.Configuration.Format.ParquetColumnarStorage.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.Format.ParquetColumnarStorage.AdditionalProperties.ValueString()), &additionalProperties13)
		}
		destinationS3ParquetColumnarStorage = &shared.DestinationS3ParquetColumnarStorage{
			BlockSizeMb:          blockSizeMb,
			CompressionCodec:     compressionCodec1,
			DictionaryEncoding:   dictionaryEncoding,
			DictionaryPageSizeKb: dictionaryPageSizeKb,
			FormatType:           formatType3,
			MaxPaddingSizeMb:     maxPaddingSizeMb,
			PageSizeKb:           pageSizeKb,
			AdditionalProperties: additionalProperties13,
		}
	}
	if destinationS3ParquetColumnarStorage != nil {
		format = shared.DestinationS3OutputFormat{
			DestinationS3ParquetColumnarStorage: destinationS3ParquetColumnarStorage,
		}
	}
	roleArn := new(string)
	if !r.Configuration.RoleArn.IsUnknown() && !r.Configuration.RoleArn.IsNull() {
		*roleArn = r.Configuration.RoleArn.ValueString()
	} else {
		roleArn = nil
	}
	var s3BucketName string
	s3BucketName = r.Configuration.S3BucketName.ValueString()

	var s3BucketPath string
	s3BucketPath = r.Configuration.S3BucketPath.ValueString()

	s3BucketRegion := new(shared.DestinationS3S3BucketRegion)
	if !r.Configuration.S3BucketRegion.IsUnknown() && !r.Configuration.S3BucketRegion.IsNull() {
		*s3BucketRegion = shared.DestinationS3S3BucketRegion(r.Configuration.S3BucketRegion.ValueString())
	} else {
		s3BucketRegion = nil
	}
	s3Endpoint := new(string)
	if !r.Configuration.S3Endpoint.IsUnknown() && !r.Configuration.S3Endpoint.IsNull() {
		*s3Endpoint = r.Configuration.S3Endpoint.ValueString()
	} else {
		s3Endpoint = nil
	}
	s3PathFormat := new(string)
	if !r.Configuration.S3PathFormat.IsUnknown() && !r.Configuration.S3PathFormat.IsNull() {
		*s3PathFormat = r.Configuration.S3PathFormat.ValueString()
	} else {
		s3PathFormat = nil
	}
	secretAccessKey := new(string)
	if !r.Configuration.SecretAccessKey.IsUnknown() && !r.Configuration.SecretAccessKey.IsNull() {
		*secretAccessKey = r.Configuration.SecretAccessKey.ValueString()
	} else {
		secretAccessKey = nil
	}
	configuration := shared.DestinationS3{
		AccessKeyID:     accessKeyID,
		FileNamePattern: fileNamePattern,
		Format:          format,
		RoleArn:         roleArn,
		S3BucketName:    s3BucketName,
		S3BucketPath:    s3BucketPath,
		S3BucketRegion:  s3BucketRegion,
		S3Endpoint:      s3Endpoint,
		S3PathFormat:    s3PathFormat,
		SecretAccessKey: secretAccessKey,
	}
	out := shared.DestinationS3CreateRequest{
		Name:          name,
		DefinitionID:  definitionID,
		WorkspaceID:   workspaceID,
		Configuration: configuration,
	}
	return &out
}

func (r *DestinationS3ResourceModel) 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 *DestinationS3ResourceModel) ToSharedDestinationS3PutRequest() *shared.DestinationS3PutRequest {
	var name string
	name = r.Name.ValueString()

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

	accessKeyID := new(string)
	if !r.Configuration.AccessKeyID.IsUnknown() && !r.Configuration.AccessKeyID.IsNull() {
		*accessKeyID = r.Configuration.AccessKeyID.ValueString()
	} else {
		accessKeyID = nil
	}
	fileNamePattern := new(string)
	if !r.Configuration.FileNamePattern.IsUnknown() && !r.Configuration.FileNamePattern.IsNull() {
		*fileNamePattern = r.Configuration.FileNamePattern.ValueString()
	} else {
		fileNamePattern = nil
	}
	var format shared.DestinationS3UpdateOutputFormat
	var destinationS3UpdateCSVCommaSeparatedValues *shared.DestinationS3UpdateCSVCommaSeparatedValues
	if r.Configuration.Format.CSVCommaSeparatedValues != nil {
		var compression *shared.DestinationS3UpdateCompression
		if r.Configuration.Format.CSVCommaSeparatedValues.Compression != nil {
			var destinationS3UpdateNoCompression *shared.DestinationS3UpdateNoCompression
			if r.Configuration.Format.CSVCommaSeparatedValues.Compression.NoCompression != nil {
				compressionType := new(shared.DestinationS3UpdateCompressionType)
				if !r.Configuration.Format.CSVCommaSeparatedValues.Compression.NoCompression.CompressionType.IsUnknown() && !r.Configuration.Format.CSVCommaSeparatedValues.Compression.NoCompression.CompressionType.IsNull() {
					*compressionType = shared.DestinationS3UpdateCompressionType(r.Configuration.Format.CSVCommaSeparatedValues.Compression.NoCompression.CompressionType.ValueString())
				} else {
					compressionType = nil
				}
				var additionalProperties interface{}
				if !r.Configuration.Format.CSVCommaSeparatedValues.Compression.NoCompression.AdditionalProperties.IsUnknown() && !r.Configuration.Format.CSVCommaSeparatedValues.Compression.NoCompression.AdditionalProperties.IsNull() {
					_ = json.Unmarshal([]byte(r.Configuration.Format.CSVCommaSeparatedValues.Compression.NoCompression.AdditionalProperties.ValueString()), &additionalProperties)
				}
				destinationS3UpdateNoCompression = &shared.DestinationS3UpdateNoCompression{
					CompressionType:      compressionType,
					AdditionalProperties: additionalProperties,
				}
			}
			if destinationS3UpdateNoCompression != nil {
				compression = &shared.DestinationS3UpdateCompression{
					DestinationS3UpdateNoCompression: destinationS3UpdateNoCompression,
				}
			}
			var destinationS3UpdateGZIP *shared.DestinationS3UpdateGZIP
			if r.Configuration.Format.CSVCommaSeparatedValues.Compression.Gzip != nil {
				compressionType1 := new(shared.DestinationS3UpdateSchemasCompressionType)
				if !r.Configuration.Format.CSVCommaSeparatedValues.Compression.Gzip.CompressionType.IsUnknown() && !r.Configuration.Format.CSVCommaSeparatedValues.Compression.Gzip.CompressionType.IsNull() {
					*compressionType1 = shared.DestinationS3UpdateSchemasCompressionType(r.Configuration.Format.CSVCommaSeparatedValues.Compression.Gzip.CompressionType.ValueString())
				} else {
					compressionType1 = nil
				}
				var additionalProperties1 interface{}
				if !r.Configuration.Format.CSVCommaSeparatedValues.Compression.Gzip.AdditionalProperties.IsUnknown() && !r.Configuration.Format.CSVCommaSeparatedValues.Compression.Gzip.AdditionalProperties.IsNull() {
					_ = json.Unmarshal([]byte(r.Configuration.Format.CSVCommaSeparatedValues.Compression.Gzip.AdditionalProperties.ValueString()), &additionalProperties1)
				}
				destinationS3UpdateGZIP = &shared.DestinationS3UpdateGZIP{
					CompressionType:      compressionType1,
					AdditionalProperties: additionalProperties1,
				}
			}
			if destinationS3UpdateGZIP != nil {
				compression = &shared.DestinationS3UpdateCompression{
					DestinationS3UpdateGZIP: destinationS3UpdateGZIP,
				}
			}
		}
		flattening := new(shared.DestinationS3UpdateFlattening)
		if !r.Configuration.Format.CSVCommaSeparatedValues.Flattening.IsUnknown() && !r.Configuration.Format.CSVCommaSeparatedValues.Flattening.IsNull() {
			*flattening = shared.DestinationS3UpdateFlattening(r.Configuration.Format.CSVCommaSeparatedValues.Flattening.ValueString())
		} else {
			flattening = nil
		}
		formatType := new(shared.DestinationS3UpdateFormatType)
		if !r.Configuration.Format.CSVCommaSeparatedValues.FormatType.IsUnknown() && !r.Configuration.Format.CSVCommaSeparatedValues.FormatType.IsNull() {
			*formatType = shared.DestinationS3UpdateFormatType(r.Configuration.Format.CSVCommaSeparatedValues.FormatType.ValueString())
		} else {
			formatType = nil
		}
		var additionalProperties2 interface{}
		if !r.Configuration.Format.CSVCommaSeparatedValues.AdditionalProperties.IsUnknown() && !r.Configuration.Format.CSVCommaSeparatedValues.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.Format.CSVCommaSeparatedValues.AdditionalProperties.ValueString()), &additionalProperties2)
		}
		destinationS3UpdateCSVCommaSeparatedValues = &shared.DestinationS3UpdateCSVCommaSeparatedValues{
			Compression:          compression,
			Flattening:           flattening,
			FormatType:           formatType,
			AdditionalProperties: additionalProperties2,
		}
	}
	if destinationS3UpdateCSVCommaSeparatedValues != nil {
		format = shared.DestinationS3UpdateOutputFormat{
			DestinationS3UpdateCSVCommaSeparatedValues: destinationS3UpdateCSVCommaSeparatedValues,
		}
	}
	var destinationS3UpdateJSONLinesNewlineDelimitedJSON *shared.DestinationS3UpdateJSONLinesNewlineDelimitedJSON
	if r.Configuration.Format.JSONLinesNewlineDelimitedJSON != nil {
		var compression1 *shared.DestinationS3UpdateSchemasCompression
		if r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression != nil {
			var destinationS3UpdateSchemasNoCompression *shared.DestinationS3UpdateSchemasNoCompression
			if r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.NoCompression != nil {
				compressionType2 := new(shared.DestinationS3UpdateSchemasFormatCompressionType)
				if !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.NoCompression.CompressionType.IsUnknown() && !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.NoCompression.CompressionType.IsNull() {
					*compressionType2 = shared.DestinationS3UpdateSchemasFormatCompressionType(r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.NoCompression.CompressionType.ValueString())
				} else {
					compressionType2 = nil
				}
				var additionalProperties3 interface{}
				if !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.NoCompression.AdditionalProperties.IsUnknown() && !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.NoCompression.AdditionalProperties.IsNull() {
					_ = json.Unmarshal([]byte(r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.NoCompression.AdditionalProperties.ValueString()), &additionalProperties3)
				}
				destinationS3UpdateSchemasNoCompression = &shared.DestinationS3UpdateSchemasNoCompression{
					CompressionType:      compressionType2,
					AdditionalProperties: additionalProperties3,
				}
			}
			if destinationS3UpdateSchemasNoCompression != nil {
				compression1 = &shared.DestinationS3UpdateSchemasCompression{
					DestinationS3UpdateSchemasNoCompression: destinationS3UpdateSchemasNoCompression,
				}
			}
			var destinationS3UpdateSchemasGZIP *shared.DestinationS3UpdateSchemasGZIP
			if r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.Gzip != nil {
				compressionType3 := new(shared.DestinationS3UpdateSchemasFormatOutputFormatCompressionType)
				if !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.Gzip.CompressionType.IsUnknown() && !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.Gzip.CompressionType.IsNull() {
					*compressionType3 = shared.DestinationS3UpdateSchemasFormatOutputFormatCompressionType(r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.Gzip.CompressionType.ValueString())
				} else {
					compressionType3 = nil
				}
				var additionalProperties4 interface{}
				if !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.Gzip.AdditionalProperties.IsUnknown() && !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.Gzip.AdditionalProperties.IsNull() {
					_ = json.Unmarshal([]byte(r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Compression.Gzip.AdditionalProperties.ValueString()), &additionalProperties4)
				}
				destinationS3UpdateSchemasGZIP = &shared.DestinationS3UpdateSchemasGZIP{
					CompressionType:      compressionType3,
					AdditionalProperties: additionalProperties4,
				}
			}
			if destinationS3UpdateSchemasGZIP != nil {
				compression1 = &shared.DestinationS3UpdateSchemasCompression{
					DestinationS3UpdateSchemasGZIP: destinationS3UpdateSchemasGZIP,
				}
			}
		}
		flattening1 := new(shared.DestinationS3UpdateSchemasFlattening)
		if !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Flattening.IsUnknown() && !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Flattening.IsNull() {
			*flattening1 = shared.DestinationS3UpdateSchemasFlattening(r.Configuration.Format.JSONLinesNewlineDelimitedJSON.Flattening.ValueString())
		} else {
			flattening1 = nil
		}
		formatType1 := new(shared.DestinationS3UpdateSchemasFormatType)
		if !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.FormatType.IsUnknown() && !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.FormatType.IsNull() {
			*formatType1 = shared.DestinationS3UpdateSchemasFormatType(r.Configuration.Format.JSONLinesNewlineDelimitedJSON.FormatType.ValueString())
		} else {
			formatType1 = nil
		}
		var additionalProperties5 interface{}
		if !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.AdditionalProperties.IsUnknown() && !r.Configuration.Format.JSONLinesNewlineDelimitedJSON.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.Format.JSONLinesNewlineDelimitedJSON.AdditionalProperties.ValueString()), &additionalProperties5)
		}
		destinationS3UpdateJSONLinesNewlineDelimitedJSON = &shared.DestinationS3UpdateJSONLinesNewlineDelimitedJSON{
			Compression:          compression1,
			Flattening:           flattening1,
			FormatType:           formatType1,
			AdditionalProperties: additionalProperties5,
		}
	}
	if destinationS3UpdateJSONLinesNewlineDelimitedJSON != nil {
		format = shared.DestinationS3UpdateOutputFormat{
			DestinationS3UpdateJSONLinesNewlineDelimitedJSON: destinationS3UpdateJSONLinesNewlineDelimitedJSON,
		}
	}
	var destinationS3UpdateAvroApacheAvro *shared.DestinationS3UpdateAvroApacheAvro
	if r.Configuration.Format.AvroApacheAvro != nil {
		var compressionCodec shared.DestinationS3UpdateCompressionCodec
		var destinationS3UpdateSchemasFormatNoCompression *shared.DestinationS3UpdateSchemasFormatNoCompression
		if r.Configuration.Format.AvroApacheAvro.CompressionCodec.NoCompression != nil {
			codec := new(shared.DestinationS3UpdateCodec)
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.NoCompression.Codec.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.NoCompression.Codec.IsNull() {
				*codec = shared.DestinationS3UpdateCodec(r.Configuration.Format.AvroApacheAvro.CompressionCodec.NoCompression.Codec.ValueString())
			} else {
				codec = nil
			}
			var additionalProperties6 interface{}
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.NoCompression.AdditionalProperties.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.NoCompression.AdditionalProperties.IsNull() {
				_ = json.Unmarshal([]byte(r.Configuration.Format.AvroApacheAvro.CompressionCodec.NoCompression.AdditionalProperties.ValueString()), &additionalProperties6)
			}
			destinationS3UpdateSchemasFormatNoCompression = &shared.DestinationS3UpdateSchemasFormatNoCompression{
				Codec:                codec,
				AdditionalProperties: additionalProperties6,
			}
		}
		if destinationS3UpdateSchemasFormatNoCompression != nil {
			compressionCodec = shared.DestinationS3UpdateCompressionCodec{
				DestinationS3UpdateSchemasFormatNoCompression: destinationS3UpdateSchemasFormatNoCompression,
			}
		}
		var destinationS3UpdateDeflate *shared.DestinationS3UpdateDeflate
		if r.Configuration.Format.AvroApacheAvro.CompressionCodec.Deflate != nil {
			codec1 := new(shared.DestinationS3UpdateSchemasCodec)
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Deflate.Codec.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Deflate.Codec.IsNull() {
				*codec1 = shared.DestinationS3UpdateSchemasCodec(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Deflate.Codec.ValueString())
			} else {
				codec1 = nil
			}
			var compressionLevel int64
			compressionLevel = r.Configuration.Format.AvroApacheAvro.CompressionCodec.Deflate.CompressionLevel.ValueInt64()

			var additionalProperties7 interface{}
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Deflate.AdditionalProperties.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Deflate.AdditionalProperties.IsNull() {
				_ = json.Unmarshal([]byte(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Deflate.AdditionalProperties.ValueString()), &additionalProperties7)
			}
			destinationS3UpdateDeflate = &shared.DestinationS3UpdateDeflate{
				Codec:                codec1,
				CompressionLevel:     compressionLevel,
				AdditionalProperties: additionalProperties7,
			}
		}
		if destinationS3UpdateDeflate != nil {
			compressionCodec = shared.DestinationS3UpdateCompressionCodec{
				DestinationS3UpdateDeflate: destinationS3UpdateDeflate,
			}
		}
		var destinationS3UpdateBzip2 *shared.DestinationS3UpdateBzip2
		if r.Configuration.Format.AvroApacheAvro.CompressionCodec.Bzip2 != nil {
			codec2 := new(shared.DestinationS3UpdateSchemasFormatCodec)
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Bzip2.Codec.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Bzip2.Codec.IsNull() {
				*codec2 = shared.DestinationS3UpdateSchemasFormatCodec(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Bzip2.Codec.ValueString())
			} else {
				codec2 = nil
			}
			var additionalProperties8 interface{}
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Bzip2.AdditionalProperties.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Bzip2.AdditionalProperties.IsNull() {
				_ = json.Unmarshal([]byte(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Bzip2.AdditionalProperties.ValueString()), &additionalProperties8)
			}
			destinationS3UpdateBzip2 = &shared.DestinationS3UpdateBzip2{
				Codec:                codec2,
				AdditionalProperties: additionalProperties8,
			}
		}
		if destinationS3UpdateBzip2 != nil {
			compressionCodec = shared.DestinationS3UpdateCompressionCodec{
				DestinationS3UpdateBzip2: destinationS3UpdateBzip2,
			}
		}
		var destinationS3UpdateXz *shared.DestinationS3UpdateXz
		if r.Configuration.Format.AvroApacheAvro.CompressionCodec.Xz != nil {
			codec3 := new(shared.DestinationS3UpdateSchemasFormatOutputFormatCodec)
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Xz.Codec.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Xz.Codec.IsNull() {
				*codec3 = shared.DestinationS3UpdateSchemasFormatOutputFormatCodec(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Xz.Codec.ValueString())
			} else {
				codec3 = nil
			}
			var compressionLevel1 int64
			compressionLevel1 = r.Configuration.Format.AvroApacheAvro.CompressionCodec.Xz.CompressionLevel.ValueInt64()

			var additionalProperties9 interface{}
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Xz.AdditionalProperties.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Xz.AdditionalProperties.IsNull() {
				_ = json.Unmarshal([]byte(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Xz.AdditionalProperties.ValueString()), &additionalProperties9)
			}
			destinationS3UpdateXz = &shared.DestinationS3UpdateXz{
				Codec:                codec3,
				CompressionLevel:     compressionLevel1,
				AdditionalProperties: additionalProperties9,
			}
		}
		if destinationS3UpdateXz != nil {
			compressionCodec = shared.DestinationS3UpdateCompressionCodec{
				DestinationS3UpdateXz: destinationS3UpdateXz,
			}
		}
		var destinationS3UpdateZstandard *shared.DestinationS3UpdateZstandard
		if r.Configuration.Format.AvroApacheAvro.CompressionCodec.Zstandard != nil {
			codec4 := new(shared.DestinationS3UpdateSchemasFormatOutputFormat3Codec)
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Zstandard.Codec.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Zstandard.Codec.IsNull() {
				*codec4 = shared.DestinationS3UpdateSchemasFormatOutputFormat3Codec(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Zstandard.Codec.ValueString())
			} else {
				codec4 = nil
			}
			var compressionLevel2 int64
			compressionLevel2 = r.Configuration.Format.AvroApacheAvro.CompressionCodec.Zstandard.CompressionLevel.ValueInt64()

			var includeChecksum bool
			includeChecksum = r.Configuration.Format.AvroApacheAvro.CompressionCodec.Zstandard.IncludeChecksum.ValueBool()

			var additionalProperties10 interface{}
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Zstandard.AdditionalProperties.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Zstandard.AdditionalProperties.IsNull() {
				_ = json.Unmarshal([]byte(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Zstandard.AdditionalProperties.ValueString()), &additionalProperties10)
			}
			destinationS3UpdateZstandard = &shared.DestinationS3UpdateZstandard{
				Codec:                codec4,
				CompressionLevel:     compressionLevel2,
				IncludeChecksum:      includeChecksum,
				AdditionalProperties: additionalProperties10,
			}
		}
		if destinationS3UpdateZstandard != nil {
			compressionCodec = shared.DestinationS3UpdateCompressionCodec{
				DestinationS3UpdateZstandard: destinationS3UpdateZstandard,
			}
		}
		var destinationS3UpdateSnappy *shared.DestinationS3UpdateSnappy
		if r.Configuration.Format.AvroApacheAvro.CompressionCodec.Snappy != nil {
			codec5 := new(shared.DestinationS3UpdateSchemasFormatOutputFormat3CompressionCodecCodec)
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Snappy.Codec.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Snappy.Codec.IsNull() {
				*codec5 = shared.DestinationS3UpdateSchemasFormatOutputFormat3CompressionCodecCodec(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Snappy.Codec.ValueString())
			} else {
				codec5 = nil
			}
			var additionalProperties11 interface{}
			if !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Snappy.AdditionalProperties.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.CompressionCodec.Snappy.AdditionalProperties.IsNull() {
				_ = json.Unmarshal([]byte(r.Configuration.Format.AvroApacheAvro.CompressionCodec.Snappy.AdditionalProperties.ValueString()), &additionalProperties11)
			}
			destinationS3UpdateSnappy = &shared.DestinationS3UpdateSnappy{
				Codec:                codec5,
				AdditionalProperties: additionalProperties11,
			}
		}
		if destinationS3UpdateSnappy != nil {
			compressionCodec = shared.DestinationS3UpdateCompressionCodec{
				DestinationS3UpdateSnappy: destinationS3UpdateSnappy,
			}
		}
		formatType2 := new(shared.DestinationS3UpdateSchemasFormatFormatType)
		if !r.Configuration.Format.AvroApacheAvro.FormatType.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.FormatType.IsNull() {
			*formatType2 = shared.DestinationS3UpdateSchemasFormatFormatType(r.Configuration.Format.AvroApacheAvro.FormatType.ValueString())
		} else {
			formatType2 = nil
		}
		var additionalProperties12 interface{}
		if !r.Configuration.Format.AvroApacheAvro.AdditionalProperties.IsUnknown() && !r.Configuration.Format.AvroApacheAvro.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.Format.AvroApacheAvro.AdditionalProperties.ValueString()), &additionalProperties12)
		}
		destinationS3UpdateAvroApacheAvro = &shared.DestinationS3UpdateAvroApacheAvro{
			CompressionCodec:     compressionCodec,
			FormatType:           formatType2,
			AdditionalProperties: additionalProperties12,
		}
	}
	if destinationS3UpdateAvroApacheAvro != nil {
		format = shared.DestinationS3UpdateOutputFormat{
			DestinationS3UpdateAvroApacheAvro: destinationS3UpdateAvroApacheAvro,
		}
	}
	var destinationS3UpdateParquetColumnarStorage *shared.DestinationS3UpdateParquetColumnarStorage
	if r.Configuration.Format.ParquetColumnarStorage != nil {
		blockSizeMb := new(int64)
		if !r.Configuration.Format.ParquetColumnarStorage.BlockSizeMb.IsUnknown() && !r.Configuration.Format.ParquetColumnarStorage.BlockSizeMb.IsNull() {
			*blockSizeMb = r.Configuration.Format.ParquetColumnarStorage.BlockSizeMb.ValueInt64()
		} else {
			blockSizeMb = nil
		}
		compressionCodec1 := new(shared.DestinationS3UpdateSchemasCompressionCodec)
		if !r.Configuration.Format.ParquetColumnarStorage.CompressionCodec.IsUnknown() && !r.Configuration.Format.ParquetColumnarStorage.CompressionCodec.IsNull() {
			*compressionCodec1 = shared.DestinationS3UpdateSchemasCompressionCodec(r.Configuration.Format.ParquetColumnarStorage.CompressionCodec.ValueString())
		} else {
			compressionCodec1 = nil
		}
		dictionaryEncoding := new(bool)
		if !r.Configuration.Format.ParquetColumnarStorage.DictionaryEncoding.IsUnknown() && !r.Configuration.Format.ParquetColumnarStorage.DictionaryEncoding.IsNull() {
			*dictionaryEncoding = r.Configuration.Format.ParquetColumnarStorage.DictionaryEncoding.ValueBool()
		} else {
			dictionaryEncoding = nil
		}
		dictionaryPageSizeKb := new(int64)
		if !r.Configuration.Format.ParquetColumnarStorage.DictionaryPageSizeKb.IsUnknown() && !r.Configuration.Format.ParquetColumnarStorage.DictionaryPageSizeKb.IsNull() {
			*dictionaryPageSizeKb = r.Configuration.Format.ParquetColumnarStorage.DictionaryPageSizeKb.ValueInt64()
		} else {
			dictionaryPageSizeKb = nil
		}
		formatType3 := new(shared.DestinationS3UpdateSchemasFormatOutputFormatFormatType)
		if !r.Configuration.Format.ParquetColumnarStorage.FormatType.IsUnknown() && !r.Configuration.Format.ParquetColumnarStorage.FormatType.IsNull() {
			*formatType3 = shared.DestinationS3UpdateSchemasFormatOutputFormatFormatType(r.Configuration.Format.ParquetColumnarStorage.FormatType.ValueString())
		} else {
			formatType3 = nil
		}
		maxPaddingSizeMb := new(int64)
		if !r.Configuration.Format.ParquetColumnarStorage.MaxPaddingSizeMb.IsUnknown() && !r.Configuration.Format.ParquetColumnarStorage.MaxPaddingSizeMb.IsNull() {
			*maxPaddingSizeMb = r.Configuration.Format.ParquetColumnarStorage.MaxPaddingSizeMb.ValueInt64()
		} else {
			maxPaddingSizeMb = nil
		}
		pageSizeKb := new(int64)
		if !r.Configuration.Format.ParquetColumnarStorage.PageSizeKb.IsUnknown() && !r.Configuration.Format.ParquetColumnarStorage.PageSizeKb.IsNull() {
			*pageSizeKb = r.Configuration.Format.ParquetColumnarStorage.PageSizeKb.ValueInt64()
		} else {
			pageSizeKb = nil
		}
		var additionalProperties13 interface{}
		if !r.Configuration.Format.ParquetColumnarStorage.AdditionalProperties.IsUnknown() && !r.Configuration.Format.ParquetColumnarStorage.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.Format.ParquetColumnarStorage.AdditionalProperties.ValueString()), &additionalProperties13)
		}
		destinationS3UpdateParquetColumnarStorage = &shared.DestinationS3UpdateParquetColumnarStorage{
			BlockSizeMb:          blockSizeMb,
			CompressionCodec:     compressionCodec1,
			DictionaryEncoding:   dictionaryEncoding,
			DictionaryPageSizeKb: dictionaryPageSizeKb,
			FormatType:           formatType3,
			MaxPaddingSizeMb:     maxPaddingSizeMb,
			PageSizeKb:           pageSizeKb,
			AdditionalProperties: additionalProperties13,
		}
	}
	if destinationS3UpdateParquetColumnarStorage != nil {
		format = shared.DestinationS3UpdateOutputFormat{
			DestinationS3UpdateParquetColumnarStorage: destinationS3UpdateParquetColumnarStorage,
		}
	}
	roleArn := new(string)
	if !r.Configuration.RoleArn.IsUnknown() && !r.Configuration.RoleArn.IsNull() {
		*roleArn = r.Configuration.RoleArn.ValueString()
	} else {
		roleArn = nil
	}
	var s3BucketName string
	s3BucketName = r.Configuration.S3BucketName.ValueString()

	var s3BucketPath string
	s3BucketPath = r.Configuration.S3BucketPath.ValueString()

	s3BucketRegion := new(shared.DestinationS3UpdateS3BucketRegion)
	if !r.Configuration.S3BucketRegion.IsUnknown() && !r.Configuration.S3BucketRegion.IsNull() {
		*s3BucketRegion = shared.DestinationS3UpdateS3BucketRegion(r.Configuration.S3BucketRegion.ValueString())
	} else {
		s3BucketRegion = nil
	}
	s3Endpoint := new(string)
	if !r.Configuration.S3Endpoint.IsUnknown() && !r.Configuration.S3Endpoint.IsNull() {
		*s3Endpoint = r.Configuration.S3Endpoint.ValueString()
	} else {
		s3Endpoint = nil
	}
	s3PathFormat := new(string)
	if !r.Configuration.S3PathFormat.IsUnknown() && !r.Configuration.S3PathFormat.IsNull() {
		*s3PathFormat = r.Configuration.S3PathFormat.ValueString()
	} else {
		s3PathFormat = nil
	}
	secretAccessKey := new(string)
	if !r.Configuration.SecretAccessKey.IsUnknown() && !r.Configuration.SecretAccessKey.IsNull() {
		*secretAccessKey = r.Configuration.SecretAccessKey.ValueString()
	} else {
		secretAccessKey = nil
	}
	configuration := shared.DestinationS3Update{
		AccessKeyID:     accessKeyID,
		FileNamePattern: fileNamePattern,
		Format:          format,
		RoleArn:         roleArn,
		S3BucketName:    s3BucketName,
		S3BucketPath:    s3BucketPath,
		S3BucketRegion:  s3BucketRegion,
		S3Endpoint:      s3Endpoint,
		S3PathFormat:    s3PathFormat,
		SecretAccessKey: secretAccessKey,
	}
	out := shared.DestinationS3PutRequest{
		Name:          name,
		WorkspaceID:   workspaceID,
		Configuration: configuration,
	}
	return &out
}
