// 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 *DestinationDevNullResourceModel) ToSharedDestinationDevNullCreateRequest() *shared.DestinationDevNullCreateRequest {
	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 testDestination shared.TestDestination
	var logging *shared.Logging
	if r.Configuration.TestDestination.Logging != nil {
		var loggingConfig shared.LoggingConfiguration
		var firstNEntries *shared.FirstNEntries
		if r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries != nil {
			loggingType := new(shared.LoggingType)
			if !r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries.LoggingType.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries.LoggingType.IsNull() {
				*loggingType = shared.LoggingType(r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries.LoggingType.ValueString())
			} else {
				loggingType = nil
			}
			maxEntryCount := new(float64)
			if !r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries.MaxEntryCount.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries.MaxEntryCount.IsNull() {
				*maxEntryCount, _ = r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries.MaxEntryCount.ValueBigFloat().Float64()
			} else {
				maxEntryCount = nil
			}
			var additionalProperties interface{}
			if !r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries.AdditionalProperties.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries.AdditionalProperties.IsNull() {
				_ = json.Unmarshal([]byte(r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries.AdditionalProperties.ValueString()), &additionalProperties)
			}
			firstNEntries = &shared.FirstNEntries{
				LoggingType:          loggingType,
				MaxEntryCount:        maxEntryCount,
				AdditionalProperties: additionalProperties,
			}
		}
		if firstNEntries != nil {
			loggingConfig = shared.LoggingConfiguration{
				FirstNEntries: firstNEntries,
			}
		}
		var everyNThEntry *shared.EveryNThEntry
		if r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry != nil {
			loggingType1 := new(shared.DestinationDevNullLoggingType)
			if !r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.LoggingType.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.LoggingType.IsNull() {
				*loggingType1 = shared.DestinationDevNullLoggingType(r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.LoggingType.ValueString())
			} else {
				loggingType1 = nil
			}
			maxEntryCount1 := new(float64)
			if !r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.MaxEntryCount.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.MaxEntryCount.IsNull() {
				*maxEntryCount1, _ = r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.MaxEntryCount.ValueBigFloat().Float64()
			} else {
				maxEntryCount1 = nil
			}
			var nthEntryToLog int64
			nthEntryToLog = r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.NthEntryToLog.ValueInt64()

			var additionalProperties1 interface{}
			if !r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.AdditionalProperties.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.AdditionalProperties.IsNull() {
				_ = json.Unmarshal([]byte(r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.AdditionalProperties.ValueString()), &additionalProperties1)
			}
			everyNThEntry = &shared.EveryNThEntry{
				LoggingType:          loggingType1,
				MaxEntryCount:        maxEntryCount1,
				NthEntryToLog:        nthEntryToLog,
				AdditionalProperties: additionalProperties1,
			}
		}
		if everyNThEntry != nil {
			loggingConfig = shared.LoggingConfiguration{
				EveryNThEntry: everyNThEntry,
			}
		}
		var randomSampling *shared.RandomSampling
		if r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling != nil {
			loggingType2 := new(shared.DestinationDevNullSchemasLoggingType)
			if !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.LoggingType.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.LoggingType.IsNull() {
				*loggingType2 = shared.DestinationDevNullSchemasLoggingType(r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.LoggingType.ValueString())
			} else {
				loggingType2 = nil
			}
			maxEntryCount2 := new(float64)
			if !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.MaxEntryCount.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.MaxEntryCount.IsNull() {
				*maxEntryCount2, _ = r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.MaxEntryCount.ValueBigFloat().Float64()
			} else {
				maxEntryCount2 = nil
			}
			samplingRatio := new(float64)
			if !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.SamplingRatio.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.SamplingRatio.IsNull() {
				*samplingRatio, _ = r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.SamplingRatio.ValueBigFloat().Float64()
			} else {
				samplingRatio = nil
			}
			seed := new(float64)
			if !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.Seed.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.Seed.IsNull() {
				*seed, _ = r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.Seed.ValueBigFloat().Float64()
			} else {
				seed = nil
			}
			var additionalProperties2 interface{}
			if !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.AdditionalProperties.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.AdditionalProperties.IsNull() {
				_ = json.Unmarshal([]byte(r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.AdditionalProperties.ValueString()), &additionalProperties2)
			}
			randomSampling = &shared.RandomSampling{
				LoggingType:          loggingType2,
				MaxEntryCount:        maxEntryCount2,
				SamplingRatio:        samplingRatio,
				Seed:                 seed,
				AdditionalProperties: additionalProperties2,
			}
		}
		if randomSampling != nil {
			loggingConfig = shared.LoggingConfiguration{
				RandomSampling: randomSampling,
			}
		}
		testDestinationType := new(shared.TestDestinationType)
		if !r.Configuration.TestDestination.Logging.TestDestinationType.IsUnknown() && !r.Configuration.TestDestination.Logging.TestDestinationType.IsNull() {
			*testDestinationType = shared.TestDestinationType(r.Configuration.TestDestination.Logging.TestDestinationType.ValueString())
		} else {
			testDestinationType = nil
		}
		var additionalProperties3 interface{}
		if !r.Configuration.TestDestination.Logging.AdditionalProperties.IsUnknown() && !r.Configuration.TestDestination.Logging.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.TestDestination.Logging.AdditionalProperties.ValueString()), &additionalProperties3)
		}
		logging = &shared.Logging{
			LoggingConfig:        loggingConfig,
			TestDestinationType:  testDestinationType,
			AdditionalProperties: additionalProperties3,
		}
	}
	if logging != nil {
		testDestination = shared.TestDestination{
			Logging: logging,
		}
	}
	var silent *shared.Silent
	if r.Configuration.TestDestination.Silent != nil {
		testDestinationType1 := new(shared.DestinationDevNullTestDestinationType)
		if !r.Configuration.TestDestination.Silent.TestDestinationType.IsUnknown() && !r.Configuration.TestDestination.Silent.TestDestinationType.IsNull() {
			*testDestinationType1 = shared.DestinationDevNullTestDestinationType(r.Configuration.TestDestination.Silent.TestDestinationType.ValueString())
		} else {
			testDestinationType1 = nil
		}
		var additionalProperties4 interface{}
		if !r.Configuration.TestDestination.Silent.AdditionalProperties.IsUnknown() && !r.Configuration.TestDestination.Silent.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.TestDestination.Silent.AdditionalProperties.ValueString()), &additionalProperties4)
		}
		silent = &shared.Silent{
			TestDestinationType:  testDestinationType1,
			AdditionalProperties: additionalProperties4,
		}
	}
	if silent != nil {
		testDestination = shared.TestDestination{
			Silent: silent,
		}
	}
	var throttled *shared.Throttled
	if r.Configuration.TestDestination.Throttled != nil {
		var millisPerRecord int64
		millisPerRecord = r.Configuration.TestDestination.Throttled.MillisPerRecord.ValueInt64()

		testDestinationType2 := new(shared.DestinationDevNullSchemasTestDestinationType)
		if !r.Configuration.TestDestination.Throttled.TestDestinationType.IsUnknown() && !r.Configuration.TestDestination.Throttled.TestDestinationType.IsNull() {
			*testDestinationType2 = shared.DestinationDevNullSchemasTestDestinationType(r.Configuration.TestDestination.Throttled.TestDestinationType.ValueString())
		} else {
			testDestinationType2 = nil
		}
		var additionalProperties5 interface{}
		if !r.Configuration.TestDestination.Throttled.AdditionalProperties.IsUnknown() && !r.Configuration.TestDestination.Throttled.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.TestDestination.Throttled.AdditionalProperties.ValueString()), &additionalProperties5)
		}
		throttled = &shared.Throttled{
			MillisPerRecord:      millisPerRecord,
			TestDestinationType:  testDestinationType2,
			AdditionalProperties: additionalProperties5,
		}
	}
	if throttled != nil {
		testDestination = shared.TestDestination{
			Throttled: throttled,
		}
	}
	var failing *shared.Failing
	if r.Configuration.TestDestination.Failing != nil {
		var numMessages int64
		numMessages = r.Configuration.TestDestination.Failing.NumMessages.ValueInt64()

		testDestinationType3 := new(shared.DestinationDevNullSchemasTestDestinationTestDestinationType)
		if !r.Configuration.TestDestination.Failing.TestDestinationType.IsUnknown() && !r.Configuration.TestDestination.Failing.TestDestinationType.IsNull() {
			*testDestinationType3 = shared.DestinationDevNullSchemasTestDestinationTestDestinationType(r.Configuration.TestDestination.Failing.TestDestinationType.ValueString())
		} else {
			testDestinationType3 = nil
		}
		var additionalProperties6 interface{}
		if !r.Configuration.TestDestination.Failing.AdditionalProperties.IsUnknown() && !r.Configuration.TestDestination.Failing.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.TestDestination.Failing.AdditionalProperties.ValueString()), &additionalProperties6)
		}
		failing = &shared.Failing{
			NumMessages:          numMessages,
			TestDestinationType:  testDestinationType3,
			AdditionalProperties: additionalProperties6,
		}
	}
	if failing != nil {
		testDestination = shared.TestDestination{
			Failing: failing,
		}
	}
	configuration := shared.DestinationDevNull{
		TestDestination: testDestination,
	}
	out := shared.DestinationDevNullCreateRequest{
		Name:          name,
		DefinitionID:  definitionID,
		WorkspaceID:   workspaceID,
		Configuration: configuration,
	}
	return &out
}

func (r *DestinationDevNullResourceModel) 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 *DestinationDevNullResourceModel) ToSharedDestinationDevNullPutRequest() *shared.DestinationDevNullPutRequest {
	var name string
	name = r.Name.ValueString()

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

	var testDestination shared.DestinationDevNullUpdateTestDestination
	var destinationDevNullUpdateLogging *shared.DestinationDevNullUpdateLogging
	if r.Configuration.TestDestination.Logging != nil {
		var loggingConfig shared.DestinationDevNullUpdateLoggingConfiguration
		var destinationDevNullUpdateFirstNEntries *shared.DestinationDevNullUpdateFirstNEntries
		if r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries != nil {
			loggingType := new(shared.DestinationDevNullUpdateLoggingType)
			if !r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries.LoggingType.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries.LoggingType.IsNull() {
				*loggingType = shared.DestinationDevNullUpdateLoggingType(r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries.LoggingType.ValueString())
			} else {
				loggingType = nil
			}
			maxEntryCount := new(float64)
			if !r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries.MaxEntryCount.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries.MaxEntryCount.IsNull() {
				*maxEntryCount, _ = r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries.MaxEntryCount.ValueBigFloat().Float64()
			} else {
				maxEntryCount = nil
			}
			var additionalProperties interface{}
			if !r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries.AdditionalProperties.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries.AdditionalProperties.IsNull() {
				_ = json.Unmarshal([]byte(r.Configuration.TestDestination.Logging.LoggingConfig.FirstNEntries.AdditionalProperties.ValueString()), &additionalProperties)
			}
			destinationDevNullUpdateFirstNEntries = &shared.DestinationDevNullUpdateFirstNEntries{
				LoggingType:          loggingType,
				MaxEntryCount:        maxEntryCount,
				AdditionalProperties: additionalProperties,
			}
		}
		if destinationDevNullUpdateFirstNEntries != nil {
			loggingConfig = shared.DestinationDevNullUpdateLoggingConfiguration{
				DestinationDevNullUpdateFirstNEntries: destinationDevNullUpdateFirstNEntries,
			}
		}
		var destinationDevNullUpdateEveryNThEntry *shared.DestinationDevNullUpdateEveryNThEntry
		if r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry != nil {
			loggingType1 := new(shared.DestinationDevNullUpdateSchemasLoggingType)
			if !r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.LoggingType.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.LoggingType.IsNull() {
				*loggingType1 = shared.DestinationDevNullUpdateSchemasLoggingType(r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.LoggingType.ValueString())
			} else {
				loggingType1 = nil
			}
			maxEntryCount1 := new(float64)
			if !r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.MaxEntryCount.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.MaxEntryCount.IsNull() {
				*maxEntryCount1, _ = r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.MaxEntryCount.ValueBigFloat().Float64()
			} else {
				maxEntryCount1 = nil
			}
			var nthEntryToLog int64
			nthEntryToLog = r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.NthEntryToLog.ValueInt64()

			var additionalProperties1 interface{}
			if !r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.AdditionalProperties.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.AdditionalProperties.IsNull() {
				_ = json.Unmarshal([]byte(r.Configuration.TestDestination.Logging.LoggingConfig.EveryNThEntry.AdditionalProperties.ValueString()), &additionalProperties1)
			}
			destinationDevNullUpdateEveryNThEntry = &shared.DestinationDevNullUpdateEveryNThEntry{
				LoggingType:          loggingType1,
				MaxEntryCount:        maxEntryCount1,
				NthEntryToLog:        nthEntryToLog,
				AdditionalProperties: additionalProperties1,
			}
		}
		if destinationDevNullUpdateEveryNThEntry != nil {
			loggingConfig = shared.DestinationDevNullUpdateLoggingConfiguration{
				DestinationDevNullUpdateEveryNThEntry: destinationDevNullUpdateEveryNThEntry,
			}
		}
		var destinationDevNullUpdateRandomSampling *shared.DestinationDevNullUpdateRandomSampling
		if r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling != nil {
			loggingType2 := new(shared.DestinationDevNullUpdateSchemasTestDestinationLoggingType)
			if !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.LoggingType.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.LoggingType.IsNull() {
				*loggingType2 = shared.DestinationDevNullUpdateSchemasTestDestinationLoggingType(r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.LoggingType.ValueString())
			} else {
				loggingType2 = nil
			}
			maxEntryCount2 := new(float64)
			if !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.MaxEntryCount.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.MaxEntryCount.IsNull() {
				*maxEntryCount2, _ = r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.MaxEntryCount.ValueBigFloat().Float64()
			} else {
				maxEntryCount2 = nil
			}
			samplingRatio := new(float64)
			if !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.SamplingRatio.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.SamplingRatio.IsNull() {
				*samplingRatio, _ = r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.SamplingRatio.ValueBigFloat().Float64()
			} else {
				samplingRatio = nil
			}
			seed := new(float64)
			if !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.Seed.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.Seed.IsNull() {
				*seed, _ = r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.Seed.ValueBigFloat().Float64()
			} else {
				seed = nil
			}
			var additionalProperties2 interface{}
			if !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.AdditionalProperties.IsUnknown() && !r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.AdditionalProperties.IsNull() {
				_ = json.Unmarshal([]byte(r.Configuration.TestDestination.Logging.LoggingConfig.RandomSampling.AdditionalProperties.ValueString()), &additionalProperties2)
			}
			destinationDevNullUpdateRandomSampling = &shared.DestinationDevNullUpdateRandomSampling{
				LoggingType:          loggingType2,
				MaxEntryCount:        maxEntryCount2,
				SamplingRatio:        samplingRatio,
				Seed:                 seed,
				AdditionalProperties: additionalProperties2,
			}
		}
		if destinationDevNullUpdateRandomSampling != nil {
			loggingConfig = shared.DestinationDevNullUpdateLoggingConfiguration{
				DestinationDevNullUpdateRandomSampling: destinationDevNullUpdateRandomSampling,
			}
		}
		testDestinationType := new(shared.DestinationDevNullUpdateTestDestinationType)
		if !r.Configuration.TestDestination.Logging.TestDestinationType.IsUnknown() && !r.Configuration.TestDestination.Logging.TestDestinationType.IsNull() {
			*testDestinationType = shared.DestinationDevNullUpdateTestDestinationType(r.Configuration.TestDestination.Logging.TestDestinationType.ValueString())
		} else {
			testDestinationType = nil
		}
		var additionalProperties3 interface{}
		if !r.Configuration.TestDestination.Logging.AdditionalProperties.IsUnknown() && !r.Configuration.TestDestination.Logging.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.TestDestination.Logging.AdditionalProperties.ValueString()), &additionalProperties3)
		}
		destinationDevNullUpdateLogging = &shared.DestinationDevNullUpdateLogging{
			LoggingConfig:        loggingConfig,
			TestDestinationType:  testDestinationType,
			AdditionalProperties: additionalProperties3,
		}
	}
	if destinationDevNullUpdateLogging != nil {
		testDestination = shared.DestinationDevNullUpdateTestDestination{
			DestinationDevNullUpdateLogging: destinationDevNullUpdateLogging,
		}
	}
	var destinationDevNullUpdateSilent *shared.DestinationDevNullUpdateSilent
	if r.Configuration.TestDestination.Silent != nil {
		testDestinationType1 := new(shared.DestinationDevNullUpdateSchemasTestDestinationType)
		if !r.Configuration.TestDestination.Silent.TestDestinationType.IsUnknown() && !r.Configuration.TestDestination.Silent.TestDestinationType.IsNull() {
			*testDestinationType1 = shared.DestinationDevNullUpdateSchemasTestDestinationType(r.Configuration.TestDestination.Silent.TestDestinationType.ValueString())
		} else {
			testDestinationType1 = nil
		}
		var additionalProperties4 interface{}
		if !r.Configuration.TestDestination.Silent.AdditionalProperties.IsUnknown() && !r.Configuration.TestDestination.Silent.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.TestDestination.Silent.AdditionalProperties.ValueString()), &additionalProperties4)
		}
		destinationDevNullUpdateSilent = &shared.DestinationDevNullUpdateSilent{
			TestDestinationType:  testDestinationType1,
			AdditionalProperties: additionalProperties4,
		}
	}
	if destinationDevNullUpdateSilent != nil {
		testDestination = shared.DestinationDevNullUpdateTestDestination{
			DestinationDevNullUpdateSilent: destinationDevNullUpdateSilent,
		}
	}
	var destinationDevNullUpdateThrottled *shared.DestinationDevNullUpdateThrottled
	if r.Configuration.TestDestination.Throttled != nil {
		var millisPerRecord int64
		millisPerRecord = r.Configuration.TestDestination.Throttled.MillisPerRecord.ValueInt64()

		testDestinationType2 := new(shared.DestinationDevNullUpdateSchemasTestDestinationTestDestinationType)
		if !r.Configuration.TestDestination.Throttled.TestDestinationType.IsUnknown() && !r.Configuration.TestDestination.Throttled.TestDestinationType.IsNull() {
			*testDestinationType2 = shared.DestinationDevNullUpdateSchemasTestDestinationTestDestinationType(r.Configuration.TestDestination.Throttled.TestDestinationType.ValueString())
		} else {
			testDestinationType2 = nil
		}
		var additionalProperties5 interface{}
		if !r.Configuration.TestDestination.Throttled.AdditionalProperties.IsUnknown() && !r.Configuration.TestDestination.Throttled.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.TestDestination.Throttled.AdditionalProperties.ValueString()), &additionalProperties5)
		}
		destinationDevNullUpdateThrottled = &shared.DestinationDevNullUpdateThrottled{
			MillisPerRecord:      millisPerRecord,
			TestDestinationType:  testDestinationType2,
			AdditionalProperties: additionalProperties5,
		}
	}
	if destinationDevNullUpdateThrottled != nil {
		testDestination = shared.DestinationDevNullUpdateTestDestination{
			DestinationDevNullUpdateThrottled: destinationDevNullUpdateThrottled,
		}
	}
	var destinationDevNullUpdateFailing *shared.DestinationDevNullUpdateFailing
	if r.Configuration.TestDestination.Failing != nil {
		var numMessages int64
		numMessages = r.Configuration.TestDestination.Failing.NumMessages.ValueInt64()

		testDestinationType3 := new(shared.DestinationDevNullUpdateSchemasTestDestinationTestDestinationTestDestinationType)
		if !r.Configuration.TestDestination.Failing.TestDestinationType.IsUnknown() && !r.Configuration.TestDestination.Failing.TestDestinationType.IsNull() {
			*testDestinationType3 = shared.DestinationDevNullUpdateSchemasTestDestinationTestDestinationTestDestinationType(r.Configuration.TestDestination.Failing.TestDestinationType.ValueString())
		} else {
			testDestinationType3 = nil
		}
		var additionalProperties6 interface{}
		if !r.Configuration.TestDestination.Failing.AdditionalProperties.IsUnknown() && !r.Configuration.TestDestination.Failing.AdditionalProperties.IsNull() {
			_ = json.Unmarshal([]byte(r.Configuration.TestDestination.Failing.AdditionalProperties.ValueString()), &additionalProperties6)
		}
		destinationDevNullUpdateFailing = &shared.DestinationDevNullUpdateFailing{
			NumMessages:          numMessages,
			TestDestinationType:  testDestinationType3,
			AdditionalProperties: additionalProperties6,
		}
	}
	if destinationDevNullUpdateFailing != nil {
		testDestination = shared.DestinationDevNullUpdateTestDestination{
			DestinationDevNullUpdateFailing: destinationDevNullUpdateFailing,
		}
	}
	configuration := shared.DestinationDevNullUpdate{
		TestDestination: testDestination,
	}
	out := shared.DestinationDevNullPutRequest{
		Name:          name,
		WorkspaceID:   workspaceID,
		Configuration: configuration,
	}
	return &out
}
