commonMain.aws.sdk.kotlin.services.backup.serde.StartRestoreJobOperationSerializer.kt Maven / Gradle / Ivy
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.backup.serde
import aws.sdk.kotlin.services.backup.model.StartRestoreJobRequest
import aws.smithy.kotlin.runtime.http.HttpBody
import aws.smithy.kotlin.runtime.http.HttpMethod
import aws.smithy.kotlin.runtime.http.operation.HttpSerializer
import aws.smithy.kotlin.runtime.http.request.HttpRequestBuilder
import aws.smithy.kotlin.runtime.http.request.url
import aws.smithy.kotlin.runtime.operation.ExecutionContext
import aws.smithy.kotlin.runtime.serde.SdkFieldDescriptor
import aws.smithy.kotlin.runtime.serde.SdkObjectDescriptor
import aws.smithy.kotlin.runtime.serde.SerialKind
import aws.smithy.kotlin.runtime.serde.asSdkSerializable
import aws.smithy.kotlin.runtime.serde.deserializeList
import aws.smithy.kotlin.runtime.serde.deserializeMap
import aws.smithy.kotlin.runtime.serde.deserializeStruct
import aws.smithy.kotlin.runtime.serde.field
import aws.smithy.kotlin.runtime.serde.json.JsonDeserializer
import aws.smithy.kotlin.runtime.serde.json.JsonSerialName
import aws.smithy.kotlin.runtime.serde.json.JsonSerializer
import aws.smithy.kotlin.runtime.serde.serializeList
import aws.smithy.kotlin.runtime.serde.serializeMap
import aws.smithy.kotlin.runtime.serde.serializeStruct
internal class StartRestoreJobOperationSerializer: HttpSerializer.NonStreaming {
override fun serialize(context: ExecutionContext, input: StartRestoreJobRequest): HttpRequestBuilder {
val builder = HttpRequestBuilder()
builder.method = HttpMethod.PUT
builder.url {
path.encoded = "/restore-jobs"
}
val payload = serializeStartRestoreJobOperationBody(context, input)
builder.body = HttpBody.fromBytes(payload)
if (builder.body !is HttpBody.Empty) {
builder.headers.setMissing("Content-Type", "application/json")
}
return builder
}
}
private fun serializeStartRestoreJobOperationBody(context: ExecutionContext, input: StartRestoreJobRequest): ByteArray {
val serializer = JsonSerializer()
val COPYSOURCETAGSTORESTOREDRESOURCE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Boolean, JsonSerialName("CopySourceTagsToRestoredResource"))
val IAMROLEARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("IamRoleArn"))
val IDEMPOTENCYTOKEN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("IdempotencyToken"))
val METADATA_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Map, JsonSerialName("Metadata"))
val RECOVERYPOINTARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("RecoveryPointArn"))
val RESOURCETYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("ResourceType"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(COPYSOURCETAGSTORESTOREDRESOURCE_DESCRIPTOR)
field(IAMROLEARN_DESCRIPTOR)
field(IDEMPOTENCYTOKEN_DESCRIPTOR)
field(METADATA_DESCRIPTOR)
field(RECOVERYPOINTARN_DESCRIPTOR)
field(RESOURCETYPE_DESCRIPTOR)
}
serializer.serializeStruct(OBJ_DESCRIPTOR) {
input.copySourceTagsToRestoredResource?.let { field(COPYSOURCETAGSTORESTOREDRESOURCE_DESCRIPTOR, it) }
input.iamRoleArn?.let { field(IAMROLEARN_DESCRIPTOR, it) }
input.idempotencyToken?.let { field(IDEMPOTENCYTOKEN_DESCRIPTOR, it) }
if (input.metadata != null) {
mapField(METADATA_DESCRIPTOR) {
input.metadata.forEach { (key, value) ->
entry(key, value)
}
}
}
input.recoveryPointArn?.let { field(RECOVERYPOINTARN_DESCRIPTOR, it) }
input.resourceType?.let { field(RESOURCETYPE_DESCRIPTOR, it) }
}
return serializer.toByteArray()
}