commonMain.aws.sdk.kotlin.services.ssooidc.serde.CreateTokenWithIAMOperationSerializer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ssooidc-jvm Show documentation
Show all versions of ssooidc-jvm Show documentation
The AWS SDK for Kotlin client for SSO OIDC
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.ssooidc.serde
import aws.sdk.kotlin.services.ssooidc.model.CreateTokenWithIamRequest
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 CreateTokenWithIAMOperationSerializer: HttpSerializer.NonStreaming {
override fun serialize(context: ExecutionContext, input: CreateTokenWithIamRequest): HttpRequestBuilder {
val builder = HttpRequestBuilder()
builder.method = HttpMethod.POST
builder.url {
path.encoded = "/token"
parameters.decodedParameters {
add("aws_iam", "t")
}
}
val payload = serializeCreateTokenWithIAMOperationBody(context, input)
builder.body = HttpBody.fromBytes(payload)
if (builder.body !is HttpBody.Empty) {
builder.headers.setMissing("Content-Type", "application/json")
}
return builder
}
}
private fun serializeCreateTokenWithIAMOperationBody(context: ExecutionContext, input: CreateTokenWithIamRequest): ByteArray {
val serializer = JsonSerializer()
val ASSERTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("assertion"))
val CLIENTID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("clientId"))
val CODE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("code"))
val CODEVERIFIER_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("codeVerifier"))
val GRANTTYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("grantType"))
val REDIRECTURI_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("redirectUri"))
val REFRESHTOKEN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("refreshToken"))
val REQUESTEDTOKENTYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("requestedTokenType"))
val SCOPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("scope"))
val SUBJECTTOKEN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("subjectToken"))
val SUBJECTTOKENTYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("subjectTokenType"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(ASSERTION_DESCRIPTOR)
field(CLIENTID_DESCRIPTOR)
field(CODE_DESCRIPTOR)
field(CODEVERIFIER_DESCRIPTOR)
field(GRANTTYPE_DESCRIPTOR)
field(REDIRECTURI_DESCRIPTOR)
field(REFRESHTOKEN_DESCRIPTOR)
field(REQUESTEDTOKENTYPE_DESCRIPTOR)
field(SCOPE_DESCRIPTOR)
field(SUBJECTTOKEN_DESCRIPTOR)
field(SUBJECTTOKENTYPE_DESCRIPTOR)
}
serializer.serializeStruct(OBJ_DESCRIPTOR) {
input.assertion?.let { field(ASSERTION_DESCRIPTOR, it) }
input.clientId?.let { field(CLIENTID_DESCRIPTOR, it) }
input.code?.let { field(CODE_DESCRIPTOR, it) }
input.codeVerifier?.let { field(CODEVERIFIER_DESCRIPTOR, it) }
input.grantType?.let { field(GRANTTYPE_DESCRIPTOR, it) }
input.redirectUri?.let { field(REDIRECTURI_DESCRIPTOR, it) }
input.refreshToken?.let { field(REFRESHTOKEN_DESCRIPTOR, it) }
input.requestedTokenType?.let { field(REQUESTEDTOKENTYPE_DESCRIPTOR, it) }
if (input.scope != null) {
listField(SCOPE_DESCRIPTOR) {
for (el0 in input.scope) {
serializeString(el0)
}
}
}
input.subjectToken?.let { field(SUBJECTTOKEN_DESCRIPTOR, it) }
input.subjectTokenType?.let { field(SUBJECTTOKENTYPE_DESCRIPTOR, it) }
}
return serializer.toByteArray()
}