commonMain.aws.sdk.kotlin.hll.dynamodbmapper.operations.GetItem.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dynamodb-mapper-jvm Show documentation
Show all versions of dynamodb-mapper-jvm Show documentation
High level DynamoDbMapper client
// Code generated by dynamodb-mapper-ops-codegen. DO NOT EDIT!
package aws.sdk.kotlin.hll.dynamodbmapper.operations
import aws.sdk.kotlin.hll.dynamodbmapper.expressions.internal.ParameterizingExpressionVisitor
import aws.sdk.kotlin.hll.dynamodbmapper.internal.withWrappedClient
import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemSchema
import aws.sdk.kotlin.hll.dynamodbmapper.model.TableSpec
import aws.sdk.kotlin.hll.dynamodbmapper.model.toItem
import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.internal.HReqContextImpl
import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.internal.MapperContextImpl
import aws.sdk.kotlin.hll.dynamodbmapper.pipeline.internal.Operation
import aws.sdk.kotlin.services.dynamodb.model.ConsumedCapacity
import aws.sdk.kotlin.services.dynamodb.model.ReturnConsumedCapacity
import aws.smithy.kotlin.runtime.ExperimentalApi
import aws.sdk.kotlin.services.dynamodb.model.GetItemRequest as LowLevelGetItemRequest
import aws.sdk.kotlin.services.dynamodb.model.GetItemResponse as LowLevelGetItemResponse
@ExperimentalApi
public interface GetItemRequest {
@ExperimentalApi
public companion object { }
public val consistentRead: Boolean?
public val key: T?
public val returnConsumedCapacity: ReturnConsumedCapacity?
}
private data class GetItemRequestImpl(
override val consistentRead: Boolean?,
override val key: T?,
override val returnConsumedCapacity: ReturnConsumedCapacity?,
): GetItemRequest
/**
* A DSL-style builder for instances of [GetItemRequest]
*/
@ExperimentalApi
public class GetItemRequestBuilder {
public var consistentRead: Boolean? = null
public var key: T? = null
public var returnConsumedCapacity: ReturnConsumedCapacity? = null
public fun build(): GetItemRequest {
val consistentRead = consistentRead
val key = key
val returnConsumedCapacity = returnConsumedCapacity
return GetItemRequestImpl(
consistentRead,
key,
returnConsumedCapacity,
)
}
}
@ExperimentalApi
public fun GetItemRequest.toBuilder(): GetItemRequestBuilder = GetItemRequestBuilder().apply {
consistentRead = [email protected]
key = [email protected]
returnConsumedCapacity = [email protected]
}
@ExperimentalApi
public fun GetItemRequest.copy(block: GetItemRequestBuilder.() -> Unit): GetItemRequest =
toBuilder().apply(block).build()
@ExperimentalApi
public fun GetItemRequest(block: GetItemRequestBuilder.() -> Unit): GetItemRequest =
GetItemRequestBuilder().apply(block).build()
private fun GetItemRequest.convert(
tableName: String?,
schema: ItemSchema,
) = LowLevelGetItemRequest {
consistentRead = [email protected]
returnConsumedCapacity = [email protected]
[email protected]?.let { key = schema.converter.convertTo(it, schema.keyAttributeNames) }
this.tableName = tableName
val expressionVisitor = ParameterizingExpressionVisitor()
expressionAttributeNames = expressionVisitor.expressionAttributeNames()
}
@ExperimentalApi
public interface GetItemResponse {
@ExperimentalApi
public companion object { }
public val consumedCapacity: ConsumedCapacity?
public val item: T?
}
private data class GetItemResponseImpl(
override val consumedCapacity: ConsumedCapacity?,
override val item: T?,
): GetItemResponse
/**
* A DSL-style builder for instances of [GetItemResponse]
*/
@ExperimentalApi
public class GetItemResponseBuilder {
public var consumedCapacity: ConsumedCapacity? = null
public var item: T? = null
public fun build(): GetItemResponse {
val consumedCapacity = consumedCapacity
val item = item
return GetItemResponseImpl(
consumedCapacity,
item,
)
}
}
@ExperimentalApi
public fun GetItemResponse.toBuilder(): GetItemResponseBuilder = GetItemResponseBuilder().apply {
consumedCapacity = [email protected]
item = [email protected]
}
@ExperimentalApi
public fun GetItemResponse.copy(block: GetItemResponseBuilder.() -> Unit): GetItemResponse =
toBuilder().apply(block).build()
@ExperimentalApi
public fun GetItemResponse(block: GetItemResponseBuilder.() -> Unit): GetItemResponse =
GetItemResponseBuilder().apply(block).build()
private fun LowLevelGetItemResponse.convert(schema: ItemSchema) = GetItemResponse {
consumedCapacity = [email protected]
item = [email protected]?.toItem()?.let(schema.converter::convertFrom)
}
internal fun getItemOperation(spec: TableSpec) = Operation(
initialize = { highLevelReq: GetItemRequest -> HReqContextImpl(highLevelReq, spec.schema, MapperContextImpl(spec, "GetItem")) },
serialize = { highLevelReq, schema -> highLevelReq.convert(spec.tableName, schema) },
lowLevelInvoke = { lowLevelReq ->
spec.mapper.client.withWrappedClient { client ->
client.getItem(lowLevelReq)
}
},
deserialize = LowLevelGetItemResponse::convert,
interceptors = spec.mapper.config.interceptors,
)
© 2015 - 2024 Weber Informatics LLC | Privacy Policy