Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/awslabs/aws-sdk-kotlin into…
Browse files Browse the repository at this point in the history
… multi-auth
  • Loading branch information
0marperez committed Mar 6, 2024
2 parents 442b0aa + 805e7d5 commit aef9252
Show file tree
Hide file tree
Showing 68 changed files with 6,247 additions and 1,238 deletions.
5 changes: 0 additions & 5 deletions .changes/8e7992a3-5add-4fc4-987f-c8bd0c6ef405.json

This file was deleted.

75 changes: 75 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,80 @@
# Changelog

## [1.0.71] - 03/05/2024

### Features
* (**organizations**) This release contains an endpoint addition
* (**sesv2**) Adds support for providing custom headers within SendEmail and SendBulkEmail for SESv2.

### Documentation
* (**apigateway**) Documentation updates for Amazon API Gateway
* (**chatbot**) Minor update to documentation.

## [1.0.70] - 03/04/2024

### Features
* (**cloudformation**) Add DetailedStatus field to DescribeStackEvents and DescribeStacks APIs
* (**fsx**) Added support for creating FSx for NetApp ONTAP file systems with up to 12 HA pairs, delivering up to 72 GB/s of read throughput and 12 GB/s of write throughput.
* (**organizations**) Documentation update for AWS Organizations

## [1.0.69] - 03/01/2024

### Documentation
* (**accessanalyzer**) Fixed a typo in description field.
* (**autoscaling**) With this release, Amazon EC2 Auto Scaling groups, EC2 Fleet, and Spot Fleet improve the default price protection behavior of attribute-based instance type selection of Spot Instances, to consistently select from a wide range of instance types.
* (**ec2**) With this release, Amazon EC2 Auto Scaling groups, EC2 Fleet, and Spot Fleet improve the default price protection behavior of attribute-based instance type selection of Spot Instances, to consistently select from a wide range of instance types.

## [1.0.68] - 02/29/2024

### Features
* (**docdbelastic**) Launched Elastic Clusters Readable Secondaries, Start/Stop, Configurable Shard Instance count, Automatic Backups and Snapshot Copying
* (**eks**) Added support for new AL2023 AMIs to the supported AMITypes.
* (**lexmodelsv2**) This release makes AMAZON.QnAIntent generally available in Amazon Lex. This generative AI feature leverages large language models available through Amazon Bedrock to automate frequently asked questions (FAQ) experience for end-users.
* (**migrationhuborchestrator**) Adds new CreateTemplate, UpdateTemplate and DeleteTemplate APIs.
* (**quicksight**) TooltipTarget for Combo chart visuals; ColumnConfiguration limit increase to 2000; Documentation Update
* (**sagemaker**) Adds support for ModelDataSource in Model Packages to support unzipped models. Adds support to specify SourceUri for models which allows registration of models without mandating a container for hosting. Using SourceUri, customers can decouple the model from hosting information during registration.
* (**securitylake**) Add capability to update the Data Lake's MetaStoreManager Role in order to perform required data lake updates to use Iceberg table format in their data lake or update the role for any other reason.
* Add support for S3 Express One Zone

### Fixes
* Fix an issue where sections were not properly divided when parsing the config file
* [#1220](https://github.com/awslabs/aws-sdk-kotlin/issues/1220) Refactor XML deserialization to handle flat collections

## [1.0.67] - 02/28/2024

### Features
* (**batch**) This release adds Batch support for configuration of multicontainer jobs in ECS, Fargate, and EKS. This support is available for all types of jobs, including both array jobs and multi-node parallel jobs.
* (**bedrockagentruntime**) This release adds support to override search strategy performed by the Retrieve and RetrieveAndGenerate APIs for Amazon Bedrock Agents
* (**costexplorer**) This release introduces the new API 'GetApproximateUsageRecords', which retrieves estimated usage records for hourly granularity or resource-level data at daily granularity.
* (**ec2**) This release increases the range of MaxResults for GetNetworkInsightsAccessScopeAnalysisFindings to 1,000.
* (**iot**) This release reduces the maximum results returned per query invocation from 500 to 100 for the SearchIndex API. This change has no implications as long as the API is invoked until the nextToken is NULL.
* (**wafv2**) AWS WAF now supports configurable time windows for request aggregation with rate-based rules. Customers can now select time windows of 1 minute, 2 minutes or 10 minutes, in addition to the previously supported 5 minutes.

## [1.0.66] - 02/27/2024

### Features
* (**amplifyuibuilder**) We have added the ability to tag resources after they are created

## [1.0.65] - 02/26/2024

### Features
* (**drs**) Added volume status to DescribeSourceServer replicated volumes.
* (**kafkaconnect**) Adds support for tagging, with new TagResource, UntagResource and ListTagsForResource APIs to manage tags and updates to existing APIs to allow tag on create. This release also adds support for the new DeleteWorkerConfiguration API.
* (**rds**) This release adds support for gp3 data volumes for Multi-AZ DB Clusters.

### Documentation
* (**apigateway**) Documentation updates for Amazon API Gateway.

## [1.0.64] - 02/23/2024

### Features
* (**rds**) Add pattern and length based validations for DBShardGroupIdentifier

### Documentation
* (**appsync**) Documentation only updates for AppSync
* (**qldb**) Clarify possible values for KmsKeyArn and EncryptionDescription.
* (**rum**) Doc-only update for new RUM metrics that were added

## [1.0.63] - 02/22/2024

### Features
Expand Down
1 change: 1 addition & 0 deletions aws-runtime/aws-http/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ kotlin {
api(project(":aws-runtime:aws-endpoint"))
api(libs.smithy.kotlin.aws.signing.common)
api(libs.smithy.kotlin.http.client)
api(libs.smithy.kotlin.http.auth.aws)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import software.amazon.smithy.aws.traits.HttpChecksumTrait
import software.amazon.smithy.kotlin.codegen.KotlinSettings
import software.amazon.smithy.kotlin.codegen.core.KotlinWriter
import software.amazon.smithy.kotlin.codegen.core.RuntimeTypes
import software.amazon.smithy.kotlin.codegen.core.defaultName
import software.amazon.smithy.kotlin.codegen.core.withBlock
import software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration
import software.amazon.smithy.kotlin.codegen.model.*
Expand Down Expand Up @@ -43,22 +42,22 @@ class FlexibleChecksumsRequest : KotlinIntegration {
}

override fun render(ctx: ProtocolGenerator.GenerationContext, op: OperationShape, writer: KotlinWriter) {
val inputSymbol = ctx.symbolProvider.toSymbol(ctx.model.expectShape(op.inputShape))
val interceptorSymbol = RuntimeTypes.HttpClient.Interceptors.FlexibleChecksumsRequestInterceptor
val inputSymbol = ctx.symbolProvider.toSymbol(ctx.model.expectShape(op.inputShape))

val httpChecksumTrait = op.getTrait<HttpChecksumTrait>()!!

val requestAlgorithmMember = ctx.model.expectShape<StructureShape>(op.input.get())
.members()
.first { it.memberName == httpChecksumTrait.requestAlgorithmMember.get() }

writer.withBlock(
"op.interceptors.add(#T<#T> {",
"})",
interceptorSymbol,
inputSymbol,
) {
writer.write("it.#L?.value", requestAlgorithmMember.defaultName())
val requestAlgorithmMemberName = ctx.symbolProvider.toMemberName(requestAlgorithmMember)

writer.withBlock("op.interceptors.add(#T<#T>() {", "})", interceptorSymbol, inputSymbol) {
writer.write("input.#L?.value", requestAlgorithmMemberName)
}
writer.withBlock("input.#L?.let {", "}", requestAlgorithmMemberName) {
writer.write("op.context[#T.ChecksumAlgorithm] = it.value", RuntimeTypes.HttpClient.Operation.HttpOperationContext)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,32 @@ import software.amazon.smithy.kotlin.codegen.model.expectShape
import software.amazon.smithy.kotlin.codegen.model.hasTrait
import software.amazon.smithy.kotlin.codegen.model.traits.UnwrappedXmlOutput
import software.amazon.smithy.model.Model
import software.amazon.smithy.model.shapes.OperationShape
import software.amazon.smithy.model.shapes.ServiceShape
import software.amazon.smithy.model.shapes.StructureShape
import software.amazon.smithy.model.transform.ModelTransformer

/**
* Applies the [UnwrappedXmlOutput] custom-made [annotation trait](https://smithy.io/2.0/spec/model.html?highlight=annotation#annotation-traits) to structures
* whose operation is annotated with `S3UnwrappedXmlOutput` trait to mark when special unwrapped xml output deserialization is required.
* Applies the custom [UnwrappedXmlOutput]
* [annotation trait](https://smithy.io/2.0/spec/model.html?highlight=annotation#annotation-traits) to operations
* annotated with `S3UnwrappedXmlOutput` trait to mark when special unwrapped xml output deserialization is required.
*/
class UnwrappedXmlOutputIntegration : KotlinIntegration {
override fun enabledForService(model: Model, settings: KotlinSettings): Boolean =
model.expectShape<ServiceShape>(settings.service).isS3

override fun preprocessModel(model: Model, settings: KotlinSettings): Model {
val unwrappedStructures = model
val unwrappedOperations = model
.operationShapes
.filter { it.hasTrait<S3UnwrappedXmlOutputTrait>() }
.map { it.outputShape }
.map { it.id }
.toSet()

return ModelTransformer
.create()
.mapShapes(model) { shape ->
when {
shape.id in unwrappedStructures ->
(shape as StructureShape).toBuilder().addTrait(UnwrappedXmlOutput()).build()
shape.id in unwrappedOperations ->
(shape as OperationShape).toBuilder().addTrait(UnwrappedXmlOutput()).build()
else -> shape
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package aws.sdk.kotlin.codegen.customization.s3.express

import SigV4S3ExpressAuthTrait
import aws.sdk.kotlin.codegen.customization.s3.isS3
import software.amazon.smithy.aws.traits.HttpChecksumTrait
import software.amazon.smithy.kotlin.codegen.KotlinSettings
import software.amazon.smithy.kotlin.codegen.core.*
import software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration
import software.amazon.smithy.kotlin.codegen.lang.KotlinTypes
import software.amazon.smithy.kotlin.codegen.model.*
import software.amazon.smithy.kotlin.codegen.rendering.protocol.ProtocolGenerator
import software.amazon.smithy.kotlin.codegen.rendering.protocol.ProtocolMiddleware
import software.amazon.smithy.kotlin.codegen.rendering.util.ConfigProperty
import software.amazon.smithy.kotlin.codegen.rendering.util.ConfigPropertyType
import software.amazon.smithy.kotlin.codegen.utils.dq
import software.amazon.smithy.kotlin.codegen.utils.getOrNull
import software.amazon.smithy.model.Model
import software.amazon.smithy.model.shapes.*
import software.amazon.smithy.model.traits.*
import software.amazon.smithy.model.transform.ModelTransformer

/**
* An integration which handles codegen for S3 Express, such as:
* 1. Configure auth scheme by applying a synthetic shape and trait
* 2. Add ExpressClient and Bucket to execution context
* 3. Override checksums to use CRC32 instead of MD5
* 4. Disable all checksums for s3:UploadPart
*/
class S3ExpressIntegration : KotlinIntegration {
companion object {
val DisableExpressSessionAuth: ConfigProperty = ConfigProperty {
name = "disableS3ExpressSessionAuth"
useSymbolWithNullableBuilder(KotlinTypes.Boolean, "false")
documentation = """
Flag to disable S3 Express One Zone's bucket-level session authentication method.
""".trimIndent()
}

val ExpressCredentialsProvider: ConfigProperty = ConfigProperty {
name = "expressCredentialsProvider"
symbol = RuntimeTypes.Auth.Credentials.AwsCredentials.CredentialsProvider
documentation = """
Credentials provider to be used for making requests to S3 Express.
""".trimIndent()

propertyType = ConfigPropertyType.Custom(
render = { _, writer ->
writer.write(
"public val #1L: #2T = builder.#1L ?: #3T()",
name,
symbol,
buildSymbol {
name = "DefaultS3ExpressCredentialsProvider"
namespace = "aws.sdk.kotlin.services.s3.express"
},
)
},
renderBuilder = { prop, writer ->
prop.documentation?.let(writer::dokka)
writer.write("public var #L: #T? = null", name, symbol)
},
)
}
}

override fun enabledForService(model: Model, settings: KotlinSettings) =
model.expectShape<ServiceShape>(settings.service).isS3

/**
* Add a synthetic SigV4 S3 Express auth trait and shape
*/
override fun preprocessModel(model: Model, settings: KotlinSettings): Model {
val transformer = ModelTransformer.create()

// AuthIndex.getAuthSchemes looks for shapes with an AuthDefinitionTrait, so need to make one for SigV4 S3Express
val authDefinitionTrait = AuthDefinitionTrait.builder().addTrait(SigV4S3ExpressAuthTrait.ID).build()
val sigV4S3ExpressAuthShape = StructureShape.builder()
.addTrait(authDefinitionTrait)
.id(SigV4S3ExpressAuthTrait.ID)
.build()

val serviceShape = settings.getService(model)
val serviceShapeBuilder = serviceShape.toBuilder()

serviceShapeBuilder.addTrait(SigV4S3ExpressAuthTrait())

val authTrait = AuthTrait(serviceShape.expectTrait(AuthTrait::class.java).valueSet + mutableSetOf(SigV4S3ExpressAuthTrait.ID))
serviceShapeBuilder.addTrait(authTrait)

// Add the new shape and update the service shape's AuthTrait
return transformer.replaceShapes(model, listOf(sigV4S3ExpressAuthShape, serviceShapeBuilder.build()))
}

override fun customizeMiddleware(ctx: ProtocolGenerator.GenerationContext, resolved: List<ProtocolMiddleware>) =
resolved + listOf(
AddClientToExecutionContext,
AddBucketToExecutionContext,
UseCrc32Checksum,
UploadPartDisableChecksum,
)

private val S3AttributesSymbol = buildSymbol {
name = "S3Attributes"
namespace = "aws.sdk.kotlin.services.s3"
}

private val AddClientToExecutionContext = object : ProtocolMiddleware {
override val name: String = "AddClientToExecutionContext"

override fun isEnabledFor(ctx: ProtocolGenerator.GenerationContext, op: OperationShape): Boolean =
ctx.model.expectShape<ServiceShape>(ctx.settings.service).isS3

override fun render(ctx: ProtocolGenerator.GenerationContext, op: OperationShape, writer: KotlinWriter) {
writer.write("op.context[#T.ExpressClient] = this", S3AttributesSymbol)
}
}

private val AddBucketToExecutionContext = object : ProtocolMiddleware {
override val name: String = "AddBucketToExecutionContext"

override fun isEnabledFor(ctx: ProtocolGenerator.GenerationContext, op: OperationShape): Boolean =
ctx.model.expectShape<StructureShape>(op.input.get())
.members()
.any { it.memberName == "Bucket" }

override fun render(ctx: ProtocolGenerator.GenerationContext, op: OperationShape, writer: KotlinWriter) {
writer.write("input.bucket?.let { op.context[#T.Bucket] = it }", S3AttributesSymbol)
}
}

/**
* For any operations that require a checksum, set CRC32 if the user has not already configured a checksum.
*/
private val UseCrc32Checksum = object : ProtocolMiddleware {
override val name: String = "UseCrc32Checksum"

override val order: Byte = -1 // Render before flexible checksums

override fun isEnabledFor(ctx: ProtocolGenerator.GenerationContext, op: OperationShape): Boolean = !op.isS3UploadPart &&
(op.hasTrait<HttpChecksumRequiredTrait>() || (op.hasTrait<HttpChecksumTrait>() && op.expectTrait<HttpChecksumTrait>().isRequestChecksumRequired))

override fun render(ctx: ProtocolGenerator.GenerationContext, op: OperationShape, writer: KotlinWriter) {
val interceptorSymbol = buildSymbol {
namespace = "aws.sdk.kotlin.services.s3.express"
name = "S3ExpressCrc32ChecksumInterceptor"
}

val httpChecksumTrait = op.getTrait<HttpChecksumTrait>()

val checksumAlgorithmMember = ctx.model.expectShape<StructureShape>(op.input.get())
.members()
.firstOrNull { it.memberName == httpChecksumTrait?.requestAlgorithmMember?.getOrNull() }

// S3 models a header name x-amz-sdk-checksum-algorithm representing the name of the checksum algorithm used
val checksumHeaderName = checksumAlgorithmMember?.getTrait<HttpHeaderTrait>()?.value

writer.write("op.interceptors.add(#T(${checksumHeaderName?.dq() ?: ""}))", interceptorSymbol)
}
}

/**
* Disable all checksums for s3:UploadPart
*/
private val UploadPartDisableChecksum = object : ProtocolMiddleware {
override val name: String = "UploadPartDisableChecksum"

override fun isEnabledFor(ctx: ProtocolGenerator.GenerationContext, op: OperationShape): Boolean =
op.isS3UploadPart

override fun render(ctx: ProtocolGenerator.GenerationContext, op: OperationShape, writer: KotlinWriter) {
val interceptorSymbol = buildSymbol {
namespace = "aws.sdk.kotlin.services.s3.express"
name = "S3ExpressDisableChecksumInterceptor"
}
writer.addImport(interceptorSymbol)
writer.write("op.interceptors.add(#T())", interceptorSymbol)
}
}

private val OperationShape.isS3UploadPart: Boolean get() = id.name == "UploadPart"

override fun additionalServiceConfigProps(ctx: CodegenContext): List<ConfigProperty> = listOf(
DisableExpressSessionAuth,
ExpressCredentialsProvider,
)
}
Loading

0 comments on commit aef9252

Please sign in to comment.