commonMain.aws.sdk.kotlin.services.ssooidc.serde.CreateTokenOperationSerializer.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.CreateTokenRequest
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 CreateTokenOperationSerializer: HttpSerializer.NonStreaming {
override fun serialize(context: ExecutionContext, input: CreateTokenRequest): HttpRequestBuilder {
val builder = HttpRequestBuilder()
builder.method = HttpMethod.POST
builder.url {
path.encoded = "/token"
}
val payload = serializeCreateTokenOperationBody(context, input)
builder.body = HttpBody.fromBytes(payload)
if (builder.body !is HttpBody.Empty) {
builder.headers.setMissing("Content-Type", "application/json")
}
return builder
}
}
private fun serializeCreateTokenOperationBody(context: ExecutionContext, input: CreateTokenRequest): ByteArray {
val serializer = JsonSerializer()
val CLIENTID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("clientId"))
val CLIENTSECRET_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("clientSecret"))
val CODE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("code"))
val CODEVERIFIER_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("codeVerifier"))
val DEVICECODE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("deviceCode"))
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 SCOPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("scope"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(CLIENTID_DESCRIPTOR)
field(CLIENTSECRET_DESCRIPTOR)
field(CODE_DESCRIPTOR)
field(CODEVERIFIER_DESCRIPTOR)
field(DEVICECODE_DESCRIPTOR)
field(GRANTTYPE_DESCRIPTOR)
field(REDIRECTURI_DESCRIPTOR)
field(REFRESHTOKEN_DESCRIPTOR)
field(SCOPE_DESCRIPTOR)
}
serializer.serializeStruct(OBJ_DESCRIPTOR) {
input.clientId?.let { field(CLIENTID_DESCRIPTOR, it) }
input.clientSecret?.let { field(CLIENTSECRET_DESCRIPTOR, it) }
input.code?.let { field(CODE_DESCRIPTOR, it) }
input.codeVerifier?.let { field(CODEVERIFIER_DESCRIPTOR, it) }
input.deviceCode?.let { field(DEVICECODE_DESCRIPTOR, it) }
input.grantType?.let { field(GRANTTYPE_DESCRIPTOR, it) }
input.redirectUri?.let { field(REDIRECTURI_DESCRIPTOR, it) }
input.refreshToken?.let { field(REFRESHTOKEN_DESCRIPTOR, it) }
if (input.scope != null) {
listField(SCOPE_DESCRIPTOR) {
for (el0 in input.scope) {
serializeString(el0)
}
}
}
}
return serializer.toByteArray()
}