diff --git a/.changes/2.31.19.json b/.changes/2.31.19.json
new file mode 100644
index 000000000000..430d77bc7f39
--- /dev/null
+++ b/.changes/2.31.19.json
@@ -0,0 +1,42 @@
+{
+ "version": "2.31.19",
+ "date": "2025-04-09",
+ "entries": [
+ {
+ "type": "feature",
+ "category": "AWS Control Catalog",
+ "contributor": "",
+ "description": "The GetControl API now surfaces a control's Severity, CreateTime, and Identifier for a control's Implementation. The ListControls API now surfaces a control's Behavior, Severity, CreateTime, and Identifier for a control's Implementation."
+ },
+ {
+ "type": "feature",
+ "category": "AWS Glue",
+ "contributor": "",
+ "description": "The TableOptimizer APIs in AWS Glue now return the DpuHours field in each TableOptimizerRun, providing clients visibility to the DPU-hours used for billing in managed Apache Iceberg table compaction optimization."
+ },
+ {
+ "type": "feature",
+ "category": "AWS Ground Station",
+ "contributor": "",
+ "description": "Support tagging Agents and adjust input field validations"
+ },
+ {
+ "type": "feature",
+ "category": "AWS Transfer Family",
+ "contributor": "",
+ "description": "This launch includes 2 enhancements to SFTP connectors user-experience: 1) Customers can self-serve concurrent connections setting for their connectors, and 2) Customers can discover the public host key of remote servers using their SFTP connectors."
+ },
+ {
+ "type": "feature",
+ "category": "Amazon DynamoDB",
+ "contributor": "",
+ "description": "Documentation update for secondary indexes and Create_Table."
+ },
+ {
+ "type": "feature",
+ "category": "AWS SDK for Java v2",
+ "contributor": "",
+ "description": "Updated endpoint and partition metadata."
+ }
+ ]
+}
\ No newline at end of file
diff --git a/.changes/next-release/bugfix-AWSSDKforJavav2-e869e94.json b/.changes/next-release/bugfix-AWSSDKforJavav2-e869e94.json
new file mode 100644
index 000000000000..359e53fe8270
--- /dev/null
+++ b/.changes/next-release/bugfix-AWSSDKforJavav2-e869e94.json
@@ -0,0 +1,6 @@
+{
+ "type": "bugfix",
+ "category": "AWS SDK for Java v2",
+ "contributor": "",
+ "description": "Enhance non-streaming error unmarshalling to properly unmarshall exceptions to their expected types."
+}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c8ea8052fce1..93a1f1f940d1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,29 @@
#### 👋 _Looking for changelogs for older versions? You can find them in the [changelogs](./changelogs) directory._
+# __2.31.19__ __2025-04-09__
+## __AWS Control Catalog__
+ - ### Features
+ - The GetControl API now surfaces a control's Severity, CreateTime, and Identifier for a control's Implementation. The ListControls API now surfaces a control's Behavior, Severity, CreateTime, and Identifier for a control's Implementation.
+
+## __AWS Glue__
+ - ### Features
+ - The TableOptimizer APIs in AWS Glue now return the DpuHours field in each TableOptimizerRun, providing clients visibility to the DPU-hours used for billing in managed Apache Iceberg table compaction optimization.
+
+## __AWS Ground Station__
+ - ### Features
+ - Support tagging Agents and adjust input field validations
+
+## __AWS SDK for Java v2__
+ - ### Features
+ - Updated endpoint and partition metadata.
+
+## __AWS Transfer Family__
+ - ### Features
+ - This launch includes 2 enhancements to SFTP connectors user-experience: 1) Customers can self-serve concurrent connections setting for their connectors, and 2) Customers can discover the public host key of remote servers using their SFTP connectors.
+
+## __Amazon DynamoDB__
+ - ### Features
+ - Documentation update for secondary indexes and Create_Table.
+
# __2.31.18__ __2025-04-08__
## __AWS Cost Explorer Service__
- ### Features
diff --git a/README.md b/README.md
index 87f3abf45c5a..f7c4d635bb1b 100644
--- a/README.md
+++ b/README.md
@@ -51,7 +51,7 @@ To automatically manage module versions (currently all modules have the same ver
software.amazon.awssdk
bom
- 2.31.18
+ 2.31.19
pom
import
@@ -85,12 +85,12 @@ Alternatively you can add dependencies for the specific services you use only:
software.amazon.awssdk
ec2
- 2.31.18
+ 2.31.19
software.amazon.awssdk
s3
- 2.31.18
+ 2.31.19
```
@@ -102,7 +102,7 @@ You can import the whole SDK into your project (includes *ALL* services). Please
software.amazon.awssdk
aws-sdk-java
- 2.31.18
+ 2.31.19
```
diff --git a/archetypes/archetype-app-quickstart/pom.xml b/archetypes/archetype-app-quickstart/pom.xml
index d4ecbebd1775..ad6c13f98f6c 100644
--- a/archetypes/archetype-app-quickstart/pom.xml
+++ b/archetypes/archetype-app-quickstart/pom.xml
@@ -20,7 +20,7 @@
archetypes
software.amazon.awssdk
- 2.31.19-SNAPSHOT
+ 2.31.20-SNAPSHOT
4.0.0
diff --git a/archetypes/archetype-lambda/pom.xml b/archetypes/archetype-lambda/pom.xml
index 646c744f2fca..3672a4b9aea2 100644
--- a/archetypes/archetype-lambda/pom.xml
+++ b/archetypes/archetype-lambda/pom.xml
@@ -20,7 +20,7 @@
archetypes
software.amazon.awssdk
- 2.31.19-SNAPSHOT
+ 2.31.20-SNAPSHOT
4.0.0
archetype-lambda
diff --git a/archetypes/archetype-tools/pom.xml b/archetypes/archetype-tools/pom.xml
index 52150cac118d..97305574f184 100644
--- a/archetypes/archetype-tools/pom.xml
+++ b/archetypes/archetype-tools/pom.xml
@@ -20,7 +20,7 @@
archetypes
software.amazon.awssdk
- 2.31.19-SNAPSHOT
+ 2.31.20-SNAPSHOT
4.0.0
diff --git a/archetypes/pom.xml b/archetypes/pom.xml
index e09e2a845892..4344ba823e09 100644
--- a/archetypes/pom.xml
+++ b/archetypes/pom.xml
@@ -20,7 +20,7 @@
aws-sdk-java-pom
software.amazon.awssdk
- 2.31.19-SNAPSHOT
+ 2.31.20-SNAPSHOT
4.0.0
archetypes
diff --git a/aws-sdk-java/pom.xml b/aws-sdk-java/pom.xml
index 16218f37deaf..c550d431c802 100644
--- a/aws-sdk-java/pom.xml
+++ b/aws-sdk-java/pom.xml
@@ -17,7 +17,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.31.19-SNAPSHOT
+ 2.31.20-SNAPSHOT
../pom.xml
aws-sdk-java
diff --git a/bom-internal/pom.xml b/bom-internal/pom.xml
index 0cf21f5e9212..b01d28a45617 100644
--- a/bom-internal/pom.xml
+++ b/bom-internal/pom.xml
@@ -20,7 +20,7 @@
aws-sdk-java-pom
software.amazon.awssdk
- 2.31.19-SNAPSHOT
+ 2.31.20-SNAPSHOT
4.0.0
diff --git a/bom/pom.xml b/bom/pom.xml
index c0fce7688fd9..55255d8f1c4d 100644
--- a/bom/pom.xml
+++ b/bom/pom.xml
@@ -17,7 +17,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.31.19-SNAPSHOT
+ 2.31.20-SNAPSHOT
../pom.xml
bom
diff --git a/bundle-logging-bridge/pom.xml b/bundle-logging-bridge/pom.xml
index 294c010d1770..6df83199f5e7 100644
--- a/bundle-logging-bridge/pom.xml
+++ b/bundle-logging-bridge/pom.xml
@@ -21,7 +21,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.31.19-SNAPSHOT
+ 2.31.20-SNAPSHOT
bundle-logging-bridge
jar
diff --git a/bundle-sdk/pom.xml b/bundle-sdk/pom.xml
index 409d0fe22055..b18a0ebbd93f 100644
--- a/bundle-sdk/pom.xml
+++ b/bundle-sdk/pom.xml
@@ -21,7 +21,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.31.19-SNAPSHOT
+ 2.31.20-SNAPSHOT
bundle-sdk
jar
diff --git a/bundle/pom.xml b/bundle/pom.xml
index 2aab0eb2ace7..0232001045f8 100644
--- a/bundle/pom.xml
+++ b/bundle/pom.xml
@@ -21,7 +21,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.31.19-SNAPSHOT
+ 2.31.20-SNAPSHOT
bundle
jar
diff --git a/codegen-lite-maven-plugin/pom.xml b/codegen-lite-maven-plugin/pom.xml
index 3e49d5ac31b4..ff18061e377f 100644
--- a/codegen-lite-maven-plugin/pom.xml
+++ b/codegen-lite-maven-plugin/pom.xml
@@ -22,7 +22,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.31.19-SNAPSHOT
+ 2.31.20-SNAPSHOT
../pom.xml
codegen-lite-maven-plugin
diff --git a/codegen-lite/pom.xml b/codegen-lite/pom.xml
index 99bf7a84217f..d816cc29892a 100644
--- a/codegen-lite/pom.xml
+++ b/codegen-lite/pom.xml
@@ -21,7 +21,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.31.19-SNAPSHOT
+ 2.31.20-SNAPSHOT
codegen-lite
AWS Java SDK :: Code Generator Lite
diff --git a/codegen-maven-plugin/pom.xml b/codegen-maven-plugin/pom.xml
index 2e0adc46c1e5..3df15b8f39f0 100644
--- a/codegen-maven-plugin/pom.xml
+++ b/codegen-maven-plugin/pom.xml
@@ -22,7 +22,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.31.19-SNAPSHOT
+ 2.31.20-SNAPSHOT
../pom.xml
codegen-maven-plugin
diff --git a/codegen/pom.xml b/codegen/pom.xml
index f5401616dce5..e36be37bcb47 100644
--- a/codegen/pom.xml
+++ b/codegen/pom.xml
@@ -21,7 +21,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.31.19-SNAPSHOT
+ 2.31.20-SNAPSHOT
codegen
AWS Java SDK :: Code Generator
diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/JsonProtocolSpec.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/JsonProtocolSpec.java
index 9fa214efb8fe..16f0ef70a3bc 100644
--- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/JsonProtocolSpec.java
+++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/JsonProtocolSpec.java
@@ -39,6 +39,7 @@
import software.amazon.awssdk.codegen.model.intermediate.OperationModel;
import software.amazon.awssdk.codegen.model.intermediate.Protocol;
import software.amazon.awssdk.codegen.model.intermediate.ShapeModel;
+import software.amazon.awssdk.codegen.model.intermediate.ShapeType;
import software.amazon.awssdk.codegen.poet.PoetExtension;
import software.amazon.awssdk.codegen.poet.auth.scheme.AuthSchemeSpecUtils;
import software.amazon.awssdk.codegen.poet.client.traits.HttpChecksumRequiredTrait;
@@ -116,7 +117,6 @@ public MethodSpec initProtocolFactory(IntermediateModel model) {
methodSpec.addCode("$L", hasAwsQueryCompatible());
}
- registerModeledExceptions(model, poetExtensions).forEach(methodSpec::addCode);
methodSpec.addCode(";");
return methodSpec.build();
@@ -170,11 +170,40 @@ public CodeBlock responseHandler(IntermediateModel model, OperationModel opModel
public Optional errorResponseHandler(OperationModel opModel) {
String protocolFactory = protocolFactoryLiteral(model, opModel);
- return Optional.of(
- CodeBlock.builder()
- .add("\n\n$T<$T> errorResponseHandler = createErrorResponseHandler($L, operationMetadata);",
- HttpResponseHandler.class, AwsServiceException.class, protocolFactory)
- .build());
+ CodeBlock.Builder builder = CodeBlock.builder();
+ ParameterizedTypeName metadataMapperType = ParameterizedTypeName.get(
+ ClassName.get(Function.class),
+ ClassName.get(String.class),
+ ParameterizedTypeName.get(Optional.class, ExceptionMetadata.class));
+
+ builder.add("\n$T exceptionMetadataMapper = errorCode -> {\n", metadataMapperType);
+ builder.add("if (errorCode == null) {\n");
+ builder.add("return $T.empty();\n", Optional.class);
+ builder.add("}\n");
+ builder.add("switch (errorCode) {\n");
+ model.getShapes().values().stream()
+ .filter(shape -> shape.getShapeType() == ShapeType.Exception)
+ .forEach(exceptionShape -> {
+ String exceptionName = exceptionShape.getShapeName();
+ String errorCode = exceptionShape.getErrorCode();
+
+ builder.add("case $S:\n", errorCode);
+ builder.add("return $T.of($T.builder()\n", Optional.class, ExceptionMetadata.class)
+ .add(".errorCode($S)\n", errorCode);
+ builder.add(populateHttpStatusCode(exceptionShape, model));
+ builder.add(".exceptionBuilderSupplier($T::builder)\n",
+ poetExtensions.getModelClassFromShape(exceptionShape))
+ .add(".build());\n");
+ });
+
+ builder.add("default: return $T.empty();\n", Optional.class);
+ builder.add("}\n");
+ builder.add("};\n");
+
+ builder.add("$T<$T> errorResponseHandler = createErrorResponseHandler($L, operationMetadata, exceptionMetadataMapper);",
+ HttpResponseHandler.class, AwsServiceException.class, protocolFactory);
+
+ return Optional.of(builder.build());
}
@Override
@@ -411,24 +440,8 @@ public Optional createErrorResponseHandler() {
ClassName httpResponseHandler = ClassName.get(HttpResponseHandler.class);
ClassName sdkBaseException = ClassName.get(AwsServiceException.class);
TypeName responseHandlerOfException = ParameterizedTypeName.get(httpResponseHandler, sdkBaseException);
-
- return Optional.of(MethodSpec.methodBuilder("createErrorResponseHandler")
- .addParameter(BaseAwsJsonProtocolFactory.class, "protocolFactory")
- .addParameter(JsonOperationMetadata.class, "operationMetadata")
- .returns(responseHandlerOfException)
- .addModifiers(Modifier.PRIVATE)
- .addStatement("return protocolFactory.createErrorResponseHandler(operationMetadata)")
- .build());
- }
-
- @Override
- public Optional createEventstreamErrorResponseHandler() {
- ClassName httpResponseHandler = ClassName.get(HttpResponseHandler.class);
- ClassName sdkBaseException = ClassName.get(AwsServiceException.class);
- TypeName responseHandlerOfException = ParameterizedTypeName.get(httpResponseHandler, sdkBaseException);
ParameterizedTypeName mapperType = ParameterizedTypeName.get(ClassName.get(Function.class),
ClassName.get(String.class), ParameterizedTypeName.get(Optional.class, ExceptionMetadata.class));
-
return Optional.of(MethodSpec.methodBuilder("createErrorResponseHandler")
.addParameter(BaseAwsJsonProtocolFactory.class, "protocolFactory")
.addParameter(JsonOperationMetadata.class, "operationMetadata")
diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/QueryProtocolSpec.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/QueryProtocolSpec.java
index b6cca23e38cf..dfe2d40a2f21 100644
--- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/QueryProtocolSpec.java
+++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/QueryProtocolSpec.java
@@ -195,4 +195,4 @@ public CodeBlock asyncExecutionHandler(IntermediateModel intermediateModel, Oper
public Optional createErrorResponseHandler() {
return Optional.empty();
}
-}
+}
\ No newline at end of file
diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/XmlProtocolSpec.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/XmlProtocolSpec.java
index 1a081497f020..de69a870d9bd 100644
--- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/XmlProtocolSpec.java
+++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/XmlProtocolSpec.java
@@ -91,7 +91,7 @@ public CodeBlock responseHandler(IntermediateModel model,
return CodeBlock.builder()
.addStatement("\n\n$T responseHandler = protocolFactory.createCombinedResponseHandler($T::builder, "
+ "new $T().withHasStreamingSuccessResponse($L))",
- handlerType, responseType, XmlOperationMetadata.class, opModel.hasStreamingOutput())
+ handlerType, responseType, XmlOperationMetadata.class, opModel.hasStreamingOutput())
.build();
}
@@ -386,4 +386,4 @@ private CodeBlock whenCompleteBlock(OperationModel operationModel, String respon
return whenComplete.build();
}
-}
+}
\ No newline at end of file
diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-aws-json-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-aws-json-async-client-class.java
index 7298068aa6ad..e4a6f0f5d2ab 100644
--- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-aws-json-async-client-class.java
+++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-aws-json-async-client-class.java
@@ -128,7 +128,7 @@ final class DefaultJsonAsyncClient implements JsonAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultJsonAsyncClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
- .serviceProtocol(AwsServiceProtocol.AWS_JSON).build();
+ .serviceProtocol(AwsServiceProtocol.AWS_JSON).build();
private final AsyncClientHandler clientHandler;
@@ -178,32 +178,46 @@ public JsonUtilities utilities() {
public CompletableFuture aPostOperation(APostOperationRequest aPostOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest
- .overrideConfiguration().orElse(null));
+ .overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
- .isPayloadJson(true).build();
+ .isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
- operationMetadata, APostOperationResponse::builder);
-
+ operationMetadata, APostOperationResponse::builder);
+ Function> exceptionMetadataMapper = errorCode -> {
+ if (errorCode == null) {
+ return Optional.empty();
+ }
+ switch (errorCode) {
+ case "InvalidInputException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInputException").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "ServiceFaultException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("ServiceFaultException").httpStatusCode(500)
+ .exceptionBuilderSupplier(ServiceFaultException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata, exceptionMetadataMapper);
String hostPrefix = "{StringMember}-foo.";
HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember",
- "aPostOperationRequest");
+ "aPostOperationRequest");
String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember());
CompletableFuture executeFuture = clientHandler
- .execute(new ClientExecutionParams()
- .withOperationName("APostOperation").withProtocolMetadata(protocolMetadata)
- .withMarshaller(new APostOperationRequestMarshaller(protocolFactory))
- .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
- .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
- .hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest));
+ .execute(new ClientExecutionParams()
+ .withOperationName("APostOperation").withProtocolMetadata(protocolMetadata)
+ .withMarshaller(new APostOperationRequestMarshaller(protocolFactory))
+ .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
+ .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
+ .hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
@@ -242,32 +256,46 @@ public CompletableFuture aPostOperation(APostOperationRe
*/
@Override
public CompletableFuture aPostOperationWithOutput(
- APostOperationWithOutputRequest aPostOperationWithOutputRequest) {
+ APostOperationWithOutputRequest aPostOperationWithOutputRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest,
- this.clientConfiguration);
+ this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest
- .overrideConfiguration().orElse(null));
+ .overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
- .isPayloadJson(true).build();
+ .isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
- operationMetadata, APostOperationWithOutputResponse::builder);
-
+ operationMetadata, APostOperationWithOutputResponse::builder);
+ Function> exceptionMetadataMapper = errorCode -> {
+ if (errorCode == null) {
+ return Optional.empty();
+ }
+ switch (errorCode) {
+ case "InvalidInputException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInputException").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "ServiceFaultException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("ServiceFaultException").httpStatusCode(500)
+ .exceptionBuilderSupplier(ServiceFaultException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata, exceptionMetadataMapper);
CompletableFuture executeFuture = clientHandler
- .execute(new ClientExecutionParams()
- .withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata)
- .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))
- .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
- .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
- .withInput(aPostOperationWithOutputRequest));
+ .execute(new ClientExecutionParams()
+ .withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata)
+ .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))
+ .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
+ .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
+ .withInput(aPostOperationWithOutputRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
@@ -301,66 +329,81 @@ public CompletableFuture aPostOperationWithOut
*/
@Override
public CompletableFuture eventStreamOperation(EventStreamOperationRequest eventStreamOperationRequest,
- Publisher requestStream, EventStreamOperationResponseHandler asyncResponseHandler) {
+ Publisher requestStream, EventStreamOperationResponseHandler asyncResponseHandler) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationRequest,
- this.clientConfiguration);
+ this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationRequest
- .overrideConfiguration().orElse(null));
+ .overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
- .isPayloadJson(true).build();
+ .isPayloadJson(true).build();
HttpResponseHandler responseHandler = new AttachHttpMetadataResponseHandler(
- protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationResponse::builder));
+ protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationResponse::builder));
HttpResponseHandler voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata
- .builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder);
+ .builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder);
HttpResponseHandler extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler(
- JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(),
- EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder)
- .putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder)
- .putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder)
- .putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder)
- .defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build());
+ JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(),
+ EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder)
+ .putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder)
+ .putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder)
+ .putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder)
+ .defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build());
Function> eventstreamExceptionMetadataMapper = errorCode -> {
switch (errorCode) {
- default:
- return Optional.empty();
+ default:
+ return Optional.empty();
}
};
HttpResponseHandler errorEventResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata, eventstreamExceptionMetadataMapper);
+ operationMetadata, eventstreamExceptionMetadataMapper);
+ Function> exceptionMetadataMapper = errorCode -> {
+ if (errorCode == null) {
+ return Optional.empty();
+ }
+ switch (errorCode) {
+ case "InvalidInputException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInputException").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "ServiceFaultException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("ServiceFaultException").httpStatusCode(500)
+ .exceptionBuilderSupplier(ServiceFaultException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata, exceptionMetadataMapper);
EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder()
- .putMarshaller(DefaultInputEvent.class, new InputEventMarshaller(protocolFactory)).build();
+ .putMarshaller(DefaultInputEvent.class, new InputEventMarshaller(protocolFactory)).build();
SdkPublisher eventPublisher = SdkPublisher.adapt(requestStream);
Publisher adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map(
- AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer);
+ AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer);
CompletableFuture future = new CompletableFuture<>();
EventStreamAsyncResponseTransformer asyncResponseTransformer = EventStreamAsyncResponseTransformer
- . builder().eventStreamResponseHandler(asyncResponseHandler)
- .eventResponseHandler(eventResponseHandler).initialResponseHandler(responseHandler)
- .exceptionResponseHandler(errorEventResponseHandler).future(future).executor(executor)
- .serviceName(serviceName()).build();
+ . builder().eventStreamResponseHandler(asyncResponseHandler)
+ .eventResponseHandler(eventResponseHandler).initialResponseHandler(responseHandler)
+ .exceptionResponseHandler(errorEventResponseHandler).future(future).executor(executor)
+ .serviceName(serviceName()).build();
CompletableFuture executeFuture = clientHandler.execute(
- new ClientExecutionParams()
- .withOperationName("EventStreamOperation").withProtocolMetadata(protocolMetadata)
- .withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory))
- .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withFullDuplex(true)
- .withInitialRequestEvent(true).withResponseHandler(voidResponseHandler)
- .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
- .withMetricCollector(apiCallMetricCollector).withInput(eventStreamOperationRequest),
- asyncResponseTransformer);
+ new ClientExecutionParams()
+ .withOperationName("EventStreamOperation").withProtocolMetadata(protocolMetadata)
+ .withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory))
+ .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withFullDuplex(true)
+ .withInitialRequestEvent(true).withResponseHandler(voidResponseHandler)
+ .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
+ .withMetricCollector(apiCallMetricCollector).withInput(eventStreamOperationRequest),
+ asyncResponseTransformer);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
try {
@@ -375,7 +418,7 @@ public CompletableFuture eventStreamOperation(EventStreamOperationRequest
return CompletableFutureUtils.forwardExceptionTo(future, executeFuture);
} catch (Throwable t) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
- () -> asyncResponseHandler.exceptionOccurred(t));
+ () -> asyncResponseHandler.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
@@ -404,40 +447,54 @@ public CompletableFuture eventStreamOperation(EventStreamOperationRequest
*/
@Override
public CompletableFuture eventStreamOperationWithOnlyInput(
- EventStreamOperationWithOnlyInputRequest eventStreamOperationWithOnlyInputRequest,
- Publisher requestStream) {
+ EventStreamOperationWithOnlyInputRequest eventStreamOperationWithOnlyInputRequest,
+ Publisher requestStream) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyInputRequest,
- this.clientConfiguration);
+ this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
- eventStreamOperationWithOnlyInputRequest.overrideConfiguration().orElse(null));
+ eventStreamOperationWithOnlyInputRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyInput");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
- .isPayloadJson(true).build();
+ .isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
- .createResponseHandler(operationMetadata, EventStreamOperationWithOnlyInputResponse::builder);
-
+ .createResponseHandler(operationMetadata, EventStreamOperationWithOnlyInputResponse::builder);
+ Function> exceptionMetadataMapper = errorCode -> {
+ if (errorCode == null) {
+ return Optional.empty();
+ }
+ switch (errorCode) {
+ case "InvalidInputException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInputException").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "ServiceFaultException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("ServiceFaultException").httpStatusCode(500)
+ .exceptionBuilderSupplier(ServiceFaultException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata, exceptionMetadataMapper);
EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder()
- .putMarshaller(DefaultInputEventOne.class, new InputEventMarshaller(protocolFactory))
- .putMarshaller(DefaultInputEventTwo.class, new InputEventTwoMarshaller(protocolFactory)).build();
+ .putMarshaller(DefaultInputEventOne.class, new InputEventMarshaller(protocolFactory))
+ .putMarshaller(DefaultInputEventTwo.class, new InputEventTwoMarshaller(protocolFactory)).build();
SdkPublisher eventPublisher = SdkPublisher.adapt(requestStream);
Publisher adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map(
- AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer);
+ AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer);
CompletableFuture executeFuture = clientHandler
- .execute(new ClientExecutionParams()
- .withOperationName("EventStreamOperationWithOnlyInput").withProtocolMetadata(protocolMetadata)
- .withMarshaller(new EventStreamOperationWithOnlyInputRequestMarshaller(protocolFactory))
- .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withInitialRequestEvent(true)
- .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
- .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
- .withInput(eventStreamOperationWithOnlyInputRequest));
+ .execute(new ClientExecutionParams()
+ .withOperationName("EventStreamOperationWithOnlyInput").withProtocolMetadata(protocolMetadata)
+ .withMarshaller(new EventStreamOperationWithOnlyInputRequestMarshaller(protocolFactory))
+ .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withInitialRequestEvent(true)
+ .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
+ .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
+ .withInput(eventStreamOperationWithOnlyInputRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
@@ -472,60 +529,75 @@ public CompletableFuture eventStreamO
*/
@Override
public CompletableFuture eventStreamOperationWithOnlyOutput(
- EventStreamOperationWithOnlyOutputRequest eventStreamOperationWithOnlyOutputRequest,
- EventStreamOperationWithOnlyOutputResponseHandler asyncResponseHandler) {
+ EventStreamOperationWithOnlyOutputRequest eventStreamOperationWithOnlyOutputRequest,
+ EventStreamOperationWithOnlyOutputResponseHandler asyncResponseHandler) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyOutputRequest,
- this.clientConfiguration);
+ this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
- eventStreamOperationWithOnlyOutputRequest.overrideConfiguration().orElse(null));
+ eventStreamOperationWithOnlyOutputRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyOutput");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
- .isPayloadJson(true).build();
+ .isPayloadJson(true).build();
HttpResponseHandler responseHandler = new AttachHttpMetadataResponseHandler(
- protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationWithOnlyOutputResponse::builder));
+ protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationWithOnlyOutputResponse::builder));
HttpResponseHandler voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata
- .builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder);
+ .builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder);
HttpResponseHandler extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler(
- JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(),
- EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder)
- .putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder)
- .putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder)
- .putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder)
- .defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build());
+ JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(),
+ EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder)
+ .putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder)
+ .putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder)
+ .putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder)
+ .defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build());
Function> eventstreamExceptionMetadataMapper = errorCode -> {
switch (errorCode) {
- default:
- return Optional.empty();
+ default:
+ return Optional.empty();
}
};
HttpResponseHandler errorEventResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata, eventstreamExceptionMetadataMapper);
+ operationMetadata, eventstreamExceptionMetadataMapper);
+ Function> exceptionMetadataMapper = errorCode -> {
+ if (errorCode == null) {
+ return Optional.empty();
+ }
+ switch (errorCode) {
+ case "InvalidInputException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInputException").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "ServiceFaultException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("ServiceFaultException").httpStatusCode(500)
+ .exceptionBuilderSupplier(ServiceFaultException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata, exceptionMetadataMapper);
CompletableFuture future = new CompletableFuture<>();
EventStreamAsyncResponseTransformer asyncResponseTransformer = EventStreamAsyncResponseTransformer
- . builder()
- .eventStreamResponseHandler(asyncResponseHandler).eventResponseHandler(eventResponseHandler)
- .initialResponseHandler(responseHandler).exceptionResponseHandler(errorEventResponseHandler).future(future)
- .executor(executor).serviceName(serviceName()).build();
+ . builder()
+ .eventStreamResponseHandler(asyncResponseHandler).eventResponseHandler(eventResponseHandler)
+ .initialResponseHandler(responseHandler).exceptionResponseHandler(errorEventResponseHandler).future(future)
+ .executor(executor).serviceName(serviceName()).build();
CompletableFuture executeFuture = clientHandler.execute(
- new ClientExecutionParams()
- .withOperationName("EventStreamOperationWithOnlyOutput").withProtocolMetadata(protocolMetadata)
- .withMarshaller(new EventStreamOperationWithOnlyOutputRequestMarshaller(protocolFactory))
- .withResponseHandler(voidResponseHandler).withErrorResponseHandler(errorResponseHandler)
- .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
- .withInput(eventStreamOperationWithOnlyOutputRequest), asyncResponseTransformer);
+ new ClientExecutionParams()
+ .withOperationName("EventStreamOperationWithOnlyOutput").withProtocolMetadata(protocolMetadata)
+ .withMarshaller(new EventStreamOperationWithOnlyOutputRequestMarshaller(protocolFactory))
+ .withResponseHandler(voidResponseHandler).withErrorResponseHandler(errorResponseHandler)
+ .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
+ .withInput(eventStreamOperationWithOnlyOutputRequest), asyncResponseTransformer);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
try {
@@ -540,7 +612,7 @@ public CompletableFuture eventStreamOperationWithOnlyOutput(
return CompletableFutureUtils.forwardExceptionTo(future, executeFuture);
} catch (Throwable t) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
- () -> asyncResponseHandler.exceptionOccurred(t));
+ () -> asyncResponseHandler.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
@@ -572,32 +644,46 @@ public CompletableFuture eventStreamOperationWithOnlyOutput(
*/
@Override
public CompletableFuture getWithoutRequiredMembers(
- GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) {
+ GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getWithoutRequiredMembersRequest,
- this.clientConfiguration);
+ this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getWithoutRequiredMembersRequest
- .overrideConfiguration().orElse(null));
+ .overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetWithoutRequiredMembers");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
- .isPayloadJson(true).build();
+ .isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
- operationMetadata, GetWithoutRequiredMembersResponse::builder);
-
+ operationMetadata, GetWithoutRequiredMembersResponse::builder);
+ Function> exceptionMetadataMapper = errorCode -> {
+ if (errorCode == null) {
+ return Optional.empty();
+ }
+ switch (errorCode) {
+ case "InvalidInputException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInputException").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "ServiceFaultException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("ServiceFaultException").httpStatusCode(500)
+ .exceptionBuilderSupplier(ServiceFaultException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata, exceptionMetadataMapper);
CompletableFuture executeFuture = clientHandler
- .execute(new ClientExecutionParams()
- .withOperationName("GetWithoutRequiredMembers").withProtocolMetadata(protocolMetadata)
- .withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory))
- .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
- .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
- .withInput(getWithoutRequiredMembersRequest));
+ .execute(new ClientExecutionParams()
+ .withOperationName("GetWithoutRequiredMembers").withProtocolMetadata(protocolMetadata)
+ .withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory))
+ .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
+ .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
+ .withInput(getWithoutRequiredMembersRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
@@ -632,36 +718,50 @@ public CompletableFuture getWithoutRequiredMe
*/
@Override
public CompletableFuture operationWithChecksumRequired(
- OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) {
+ OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest,
- this.clientConfiguration);
+ this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
- operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null));
+ operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
- .isPayloadJson(true).build();
+ .isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
- operationMetadata, OperationWithChecksumRequiredResponse::builder);
-
+ operationMetadata, OperationWithChecksumRequiredResponse::builder);
+ Function> exceptionMetadataMapper = errorCode -> {
+ if (errorCode == null) {
+ return Optional.empty();
+ }
+ switch (errorCode) {
+ case "InvalidInputException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInputException").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "ServiceFaultException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("ServiceFaultException").httpStatusCode(500)
+ .exceptionBuilderSupplier(ServiceFaultException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata, exceptionMetadataMapper);
CompletableFuture executeFuture = clientHandler
- .execute(new ClientExecutionParams()
- .withOperationName("OperationWithChecksumRequired")
- .withProtocolMetadata(protocolMetadata)
- .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))
- .withResponseHandler(responseHandler)
- .withErrorResponseHandler(errorResponseHandler)
- .withRequestConfiguration(clientConfiguration)
- .withMetricCollector(apiCallMetricCollector)
- .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED,
- HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest));
+ .execute(new ClientExecutionParams()
+ .withOperationName("OperationWithChecksumRequired")
+ .withProtocolMetadata(protocolMetadata)
+ .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))
+ .withResponseHandler(responseHandler)
+ .withErrorResponseHandler(errorResponseHandler)
+ .withRequestConfiguration(clientConfiguration)
+ .withMetricCollector(apiCallMetricCollector)
+ .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED,
+ HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
@@ -695,32 +795,46 @@ public CompletableFuture operationWithChe
*/
@Override
public CompletableFuture operationWithNoneAuthType(
- OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) {
+ OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest,
- this.clientConfiguration);
+ this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest
- .overrideConfiguration().orElse(null));
+ .overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
- .isPayloadJson(true).build();
+ .isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
- operationMetadata, OperationWithNoneAuthTypeResponse::builder);
-
+ operationMetadata, OperationWithNoneAuthTypeResponse::builder);
+ Function> exceptionMetadataMapper = errorCode -> {
+ if (errorCode == null) {
+ return Optional.empty();
+ }
+ switch (errorCode) {
+ case "InvalidInputException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInputException").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "ServiceFaultException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("ServiceFaultException").httpStatusCode(500)
+ .exceptionBuilderSupplier(ServiceFaultException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata, exceptionMetadataMapper);
CompletableFuture executeFuture = clientHandler
- .execute(new ClientExecutionParams()
- .withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata)
- .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory))
- .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
- .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
- .withInput(operationWithNoneAuthTypeRequest));
+ .execute(new ClientExecutionParams()
+ .withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata)
+ .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory))
+ .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
+ .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
+ .withInput(operationWithNoneAuthTypeRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
@@ -755,37 +869,51 @@ public CompletableFuture operationWithNoneAut
*/
@Override
public CompletableFuture operationWithRequestCompression(
- OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) {
+ OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest,
- this.clientConfiguration);
+ this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
- operationWithRequestCompressionRequest.overrideConfiguration().orElse(null));
+ operationWithRequestCompressionRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
- .isPayloadJson(true).build();
+ .isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
- operationMetadata, OperationWithRequestCompressionResponse::builder);
-
+ operationMetadata, OperationWithRequestCompressionResponse::builder);
+ Function> exceptionMetadataMapper = errorCode -> {
+ if (errorCode == null) {
+ return Optional.empty();
+ }
+ switch (errorCode) {
+ case "InvalidInputException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInputException").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "ServiceFaultException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("ServiceFaultException").httpStatusCode(500)
+ .exceptionBuilderSupplier(ServiceFaultException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata, exceptionMetadataMapper);
CompletableFuture executeFuture = clientHandler
- .execute(new ClientExecutionParams()
- .withOperationName("OperationWithRequestCompression")
- .withProtocolMetadata(protocolMetadata)
- .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))
- .withResponseHandler(responseHandler)
- .withErrorResponseHandler(errorResponseHandler)
- .withRequestConfiguration(clientConfiguration)
- .withMetricCollector(apiCallMetricCollector)
- .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION,
- RequestCompression.builder().encodings("gzip").isStreaming(false).build())
- .withInput(operationWithRequestCompressionRequest));
+ .execute(new ClientExecutionParams()
+ .withOperationName("OperationWithRequestCompression")
+ .withProtocolMetadata(protocolMetadata)
+ .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))
+ .withResponseHandler(responseHandler)
+ .withErrorResponseHandler(errorResponseHandler)
+ .withRequestConfiguration(clientConfiguration)
+ .withMetricCollector(apiCallMetricCollector)
+ .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION,
+ RequestCompression.builder().encodings("gzip").isStreaming(false).build())
+ .withInput(operationWithRequestCompressionRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
@@ -820,32 +948,46 @@ public CompletableFuture operationWithR
*/
@Override
public CompletableFuture paginatedOperationWithResultKey(
- PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) {
+ PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithResultKeyRequest,
- this.clientConfiguration);
+ this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
- paginatedOperationWithResultKeyRequest.overrideConfiguration().orElse(null));
+ paginatedOperationWithResultKeyRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithResultKey");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
- .isPayloadJson(true).build();
+ .isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
- operationMetadata, PaginatedOperationWithResultKeyResponse::builder);
-
+ operationMetadata, PaginatedOperationWithResultKeyResponse::builder);
+ Function> exceptionMetadataMapper = errorCode -> {
+ if (errorCode == null) {
+ return Optional.empty();
+ }
+ switch (errorCode) {
+ case "InvalidInputException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInputException").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "ServiceFaultException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("ServiceFaultException").httpStatusCode(500)
+ .exceptionBuilderSupplier(ServiceFaultException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata, exceptionMetadataMapper);
CompletableFuture executeFuture = clientHandler
- .execute(new ClientExecutionParams()
- .withOperationName("PaginatedOperationWithResultKey").withProtocolMetadata(protocolMetadata)
- .withMarshaller(new PaginatedOperationWithResultKeyRequestMarshaller(protocolFactory))
- .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
- .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
- .withInput(paginatedOperationWithResultKeyRequest));
+ .execute(new ClientExecutionParams()
+ .withOperationName("PaginatedOperationWithResultKey").withProtocolMetadata(protocolMetadata)
+ .withMarshaller(new PaginatedOperationWithResultKeyRequestMarshaller(protocolFactory))
+ .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
+ .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
+ .withInput(paginatedOperationWithResultKeyRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
@@ -880,32 +1022,46 @@ public CompletableFuture paginatedOpera
*/
@Override
public CompletableFuture paginatedOperationWithoutResultKey(
- PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) {
+ PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithoutResultKeyRequest,
- this.clientConfiguration);
+ this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
- paginatedOperationWithoutResultKeyRequest.overrideConfiguration().orElse(null));
+ paginatedOperationWithoutResultKeyRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithoutResultKey");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
- .isPayloadJson(true).build();
+ .isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
- .createResponseHandler(operationMetadata, PaginatedOperationWithoutResultKeyResponse::builder);
-
+ .createResponseHandler(operationMetadata, PaginatedOperationWithoutResultKeyResponse::builder);
+ Function> exceptionMetadataMapper = errorCode -> {
+ if (errorCode == null) {
+ return Optional.empty();
+ }
+ switch (errorCode) {
+ case "InvalidInputException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInputException").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "ServiceFaultException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("ServiceFaultException").httpStatusCode(500)
+ .exceptionBuilderSupplier(ServiceFaultException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata, exceptionMetadataMapper);
CompletableFuture executeFuture = clientHandler
- .execute(new ClientExecutionParams()
- .withOperationName("PaginatedOperationWithoutResultKey").withProtocolMetadata(protocolMetadata)
- .withMarshaller(new PaginatedOperationWithoutResultKeyRequestMarshaller(protocolFactory))
- .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
- .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
- .withInput(paginatedOperationWithoutResultKeyRequest));
+ .execute(new ClientExecutionParams()
+ .withOperationName("PaginatedOperationWithoutResultKey").withProtocolMetadata(protocolMetadata)
+ .withMarshaller(new PaginatedOperationWithoutResultKeyRequestMarshaller(protocolFactory))
+ .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
+ .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
+ .withInput(paginatedOperationWithoutResultKeyRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
@@ -944,36 +1100,50 @@ public CompletableFuture paginatedOp
*/
@Override
public CompletableFuture streamingInputOperation(
- StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) {
+ StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest,
- this.clientConfiguration);
+ this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest
- .overrideConfiguration().orElse(null));
+ .overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
- .isPayloadJson(true).build();
+ .isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
- operationMetadata, StreamingInputOperationResponse::builder);
-
+ operationMetadata, StreamingInputOperationResponse::builder);
+ Function> exceptionMetadataMapper = errorCode -> {
+ if (errorCode == null) {
+ return Optional.empty();
+ }
+ switch (errorCode) {
+ case "InvalidInputException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInputException").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "ServiceFaultException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("ServiceFaultException").httpStatusCode(500)
+ .exceptionBuilderSupplier(ServiceFaultException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata, exceptionMetadataMapper);
CompletableFuture executeFuture = clientHandler
- .execute(new ClientExecutionParams()
- .withOperationName("StreamingInputOperation")
- .withProtocolMetadata(protocolMetadata)
- .withMarshaller(
- AsyncStreamingRequestMarshaller.builder()
- .delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory))
- .asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler)
- .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
- .withMetricCollector(apiCallMetricCollector).withAsyncRequestBody(requestBody)
- .withInput(streamingInputOperationRequest));
+ .execute(new ClientExecutionParams()
+ .withOperationName("StreamingInputOperation")
+ .withProtocolMetadata(protocolMetadata)
+ .withMarshaller(
+ AsyncStreamingRequestMarshaller.builder()
+ .delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory))
+ .asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler)
+ .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
+ .withMetricCollector(apiCallMetricCollector).withAsyncRequestBody(requestBody)
+ .withInput(streamingInputOperationRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
@@ -1017,49 +1187,63 @@ public CompletableFuture streamingInputOperatio
*/
@Override
public CompletableFuture streamingInputOutputOperation(
- StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, AsyncRequestBody requestBody,
- AsyncResponseTransformer asyncResponseTransformer) {
+ StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, AsyncRequestBody requestBody,
+ AsyncResponseTransformer asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOutputOperationRequest,
- this.clientConfiguration);
+ this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
- streamingInputOutputOperationRequest.overrideConfiguration().orElse(null));
+ streamingInputOutputOperationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOutputOperation");
Pair, CompletableFuture> pair = AsyncResponseTransformerUtils
- .wrapWithEndOfStreamFuture(asyncResponseTransformer);
+ .wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture endOfStreamFuture = pair.right();
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true)
- .isPayloadJson(false).build();
+ .isPayloadJson(false).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
- operationMetadata, StreamingInputOutputOperationResponse::builder);
-
+ operationMetadata, StreamingInputOutputOperationResponse::builder);
+ Function> exceptionMetadataMapper = errorCode -> {
+ if (errorCode == null) {
+ return Optional.empty();
+ }
+ switch (errorCode) {
+ case "InvalidInputException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInputException").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "ServiceFaultException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("ServiceFaultException").httpStatusCode(500)
+ .exceptionBuilderSupplier(ServiceFaultException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata, exceptionMetadataMapper);
CompletableFuture executeFuture = clientHandler.execute(
- new ClientExecutionParams()
- .withOperationName("StreamingInputOutputOperation")
- .withProtocolMetadata(protocolMetadata)
- .withMarshaller(
- AsyncStreamingRequestMarshaller
- .builder()
- .delegateMarshaller(
- new StreamingInputOutputOperationRequestMarshaller(protocolFactory))
- .asyncRequestBody(requestBody).transferEncoding(true).build())
- .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
- .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
- .withAsyncRequestBody(requestBody).withInput(streamingInputOutputOperationRequest),
- asyncResponseTransformer);
+ new ClientExecutionParams()
+ .withOperationName("StreamingInputOutputOperation")
+ .withProtocolMetadata(protocolMetadata)
+ .withMarshaller(
+ AsyncStreamingRequestMarshaller
+ .builder()
+ .delegateMarshaller(
+ new StreamingInputOutputOperationRequestMarshaller(protocolFactory))
+ .asyncRequestBody(requestBody).transferEncoding(true).build())
+ .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
+ .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
+ .withAsyncRequestBody(requestBody).withInput(streamingInputOutputOperationRequest),
+ asyncResponseTransformer);
AsyncResponseTransformer finalAsyncResponseTransformer = asyncResponseTransformer;
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
- () -> finalAsyncResponseTransformer.exceptionOccurred(e));
+ () -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
@@ -1070,7 +1254,7 @@ public CompletableFuture streamingInputOutputOperation(
} catch (Throwable t) {
AsyncResponseTransformer finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
- () -> finalAsyncResponseTransformer.exceptionOccurred(t));
+ () -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
@@ -1103,42 +1287,56 @@ public CompletableFuture streamingInputOutputOperation(
*/
@Override
public CompletableFuture streamingOutputOperation(
- StreamingOutputOperationRequest streamingOutputOperationRequest,
- AsyncResponseTransformer asyncResponseTransformer) {
+ StreamingOutputOperationRequest streamingOutputOperationRequest,
+ AsyncResponseTransformer asyncResponseTransformer) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest,
- this.clientConfiguration);
+ this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest
- .overrideConfiguration().orElse(null));
+ .overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation");
Pair, CompletableFuture> pair = AsyncResponseTransformerUtils
- .wrapWithEndOfStreamFuture(asyncResponseTransformer);
+ .wrapWithEndOfStreamFuture(asyncResponseTransformer);
asyncResponseTransformer = pair.left();
CompletableFuture endOfStreamFuture = pair.right();
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true)
- .isPayloadJson(false).build();
+ .isPayloadJson(false).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
- operationMetadata, StreamingOutputOperationResponse::builder);
-
+ operationMetadata, StreamingOutputOperationResponse::builder);
+ Function> exceptionMetadataMapper = errorCode -> {
+ if (errorCode == null) {
+ return Optional.empty();
+ }
+ switch (errorCode) {
+ case "InvalidInputException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInputException").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "ServiceFaultException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("ServiceFaultException").httpStatusCode(500)
+ .exceptionBuilderSupplier(ServiceFaultException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata, exceptionMetadataMapper);
CompletableFuture executeFuture = clientHandler.execute(
- new ClientExecutionParams()
- .withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata)
- .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory))
- .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
- .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
- .withInput(streamingOutputOperationRequest), asyncResponseTransformer);
+ new ClientExecutionParams()
+ .withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata)
+ .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory))
+ .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
+ .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
+ .withInput(streamingOutputOperationRequest), asyncResponseTransformer);
AsyncResponseTransformer finalAsyncResponseTransformer = asyncResponseTransformer;
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
- () -> finalAsyncResponseTransformer.exceptionOccurred(e));
+ () -> finalAsyncResponseTransformer.exceptionOccurred(e));
}
endOfStreamFuture.whenComplete((r2, e2) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
@@ -1149,7 +1347,7 @@ public CompletableFuture streamingOutputOperation(
} catch (Throwable t) {
AsyncResponseTransformer finalAsyncResponseTransformer = asyncResponseTransformer;
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
- () -> finalAsyncResponseTransformer.exceptionOccurred(t));
+ () -> finalAsyncResponseTransformer.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
@@ -1166,21 +1364,12 @@ public final String serviceName() {
}
private > T init(T builder) {
- return builder
- .clientConfiguration(clientConfiguration)
- .defaultServiceExceptionSupplier(JsonException::builder)
- .protocol(AwsJsonProtocol.AWS_JSON)
- .protocolVersion("1.1")
- .registerModeledException(
- ExceptionMetadata.builder().errorCode("InvalidInputException")
- .exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build())
- .registerModeledException(
- ExceptionMetadata.builder().errorCode("ServiceFaultException")
- .exceptionBuilderSupplier(ServiceFaultException::builder).httpStatusCode(500).build());
+ return builder.clientConfiguration(clientConfiguration).defaultServiceExceptionSupplier(JsonException::builder)
+ .protocol(AwsJsonProtocol.AWS_JSON).protocolVersion("1.1");
}
private static List resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
- RequestOverrideConfiguration requestOverrideConfiguration) {
+ RequestOverrideConfiguration requestOverrideConfiguration) {
List publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
@@ -1232,12 +1421,7 @@ private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request,
}
private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
- JsonOperationMetadata operationMetadata) {
- return protocolFactory.createErrorResponseHandler(operationMetadata);
- }
-
- private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
- JsonOperationMetadata operationMetadata, Function> exceptionMetadataMapper) {
+ JsonOperationMetadata operationMetadata, Function> exceptionMetadataMapper) {
return protocolFactory.createErrorResponseHandler(operationMetadata, exceptionMetadataMapper);
}
diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-cbor-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-cbor-async-client-class.java
index 8953d6a681c1..235d8c308f2e 100644
--- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-cbor-async-client-class.java
+++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-cbor-async-client-class.java
@@ -129,7 +129,7 @@ final class DefaultJsonAsyncClient implements JsonAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultJsonAsyncClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
- .serviceProtocol(AwsServiceProtocol.CBOR).build();
+ .serviceProtocol(AwsServiceProtocol.CBOR).build();
private final AsyncClientHandler clientHandler;
@@ -182,32 +182,46 @@ public JsonUtilities utilities() {
public CompletableFuture aPostOperation(APostOperationRequest aPostOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest
- .overrideConfiguration().orElse(null));
+ .overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
- .isPayloadJson(true).build();
+ .isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
- operationMetadata, APostOperationResponse::builder);
-
+ operationMetadata, APostOperationResponse::builder);
+ Function> exceptionMetadataMapper = errorCode -> {
+ if (errorCode == null) {
+ return Optional.empty();
+ }
+ switch (errorCode) {
+ case "InvalidInputException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInputException").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "ServiceFaultException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("ServiceFaultException").httpStatusCode(500)
+ .exceptionBuilderSupplier(ServiceFaultException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata, exceptionMetadataMapper);
String hostPrefix = "{StringMember}-foo.";
HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember",
- "aPostOperationRequest");
+ "aPostOperationRequest");
String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember());
CompletableFuture executeFuture = clientHandler
- .execute(new ClientExecutionParams()
- .withOperationName("APostOperation").withProtocolMetadata(protocolMetadata)
- .withMarshaller(new APostOperationRequestMarshaller(protocolFactory))
- .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
- .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
- .hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest));
+ .execute(new ClientExecutionParams()
+ .withOperationName("APostOperation").withProtocolMetadata(protocolMetadata)
+ .withMarshaller(new APostOperationRequestMarshaller(protocolFactory))
+ .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
+ .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
+ .hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
@@ -246,32 +260,46 @@ public CompletableFuture aPostOperation(APostOperationRe
*/
@Override
public CompletableFuture aPostOperationWithOutput(
- APostOperationWithOutputRequest aPostOperationWithOutputRequest) {
+ APostOperationWithOutputRequest aPostOperationWithOutputRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest,
- this.clientConfiguration);
+ this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest
- .overrideConfiguration().orElse(null));
+ .overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
- .isPayloadJson(true).build();
+ .isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
- operationMetadata, APostOperationWithOutputResponse::builder);
-
+ operationMetadata, APostOperationWithOutputResponse::builder);
+ Function> exceptionMetadataMapper = errorCode -> {
+ if (errorCode == null) {
+ return Optional.empty();
+ }
+ switch (errorCode) {
+ case "InvalidInputException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInputException").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "ServiceFaultException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("ServiceFaultException").httpStatusCode(500)
+ .exceptionBuilderSupplier(ServiceFaultException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata, exceptionMetadataMapper);
CompletableFuture executeFuture = clientHandler
- .execute(new ClientExecutionParams()
- .withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata)
- .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))
- .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
- .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
- .withInput(aPostOperationWithOutputRequest));
+ .execute(new ClientExecutionParams()
+ .withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata)
+ .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))
+ .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
+ .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
+ .withInput(aPostOperationWithOutputRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
@@ -305,66 +333,81 @@ public CompletableFuture aPostOperationWithOut
*/
@Override
public CompletableFuture eventStreamOperation(EventStreamOperationRequest eventStreamOperationRequest,
- Publisher requestStream, EventStreamOperationResponseHandler asyncResponseHandler) {
+ Publisher requestStream, EventStreamOperationResponseHandler asyncResponseHandler) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationRequest,
- this.clientConfiguration);
+ this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationRequest
- .overrideConfiguration().orElse(null));
+ .overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
- .isPayloadJson(true).build();
+ .isPayloadJson(true).build();
HttpResponseHandler responseHandler = new AttachHttpMetadataResponseHandler(
- protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationResponse::builder));
+ protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationResponse::builder));
HttpResponseHandler voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata
- .builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder);
+ .builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder);
HttpResponseHandler extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler(
- JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(),
- EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder)
- .putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder)
- .putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder)
- .putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder)
- .defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build());
+ JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(),
+ EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder)
+ .putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder)
+ .putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder)
+ .putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder)
+ .defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build());
Function> eventstreamExceptionMetadataMapper = errorCode -> {
switch (errorCode) {
- default:
- return Optional.empty();
+ default:
+ return Optional.empty();
}
};
HttpResponseHandler errorEventResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata, eventstreamExceptionMetadataMapper);
+ operationMetadata, eventstreamExceptionMetadataMapper);
+ Function> exceptionMetadataMapper = errorCode -> {
+ if (errorCode == null) {
+ return Optional.empty();
+ }
+ switch (errorCode) {
+ case "InvalidInputException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInputException").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "ServiceFaultException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("ServiceFaultException").httpStatusCode(500)
+ .exceptionBuilderSupplier(ServiceFaultException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata, exceptionMetadataMapper);
EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder()
- .putMarshaller(DefaultInputEvent.class, new InputEventMarshaller(protocolFactory)).build();
+ .putMarshaller(DefaultInputEvent.class, new InputEventMarshaller(protocolFactory)).build();
SdkPublisher eventPublisher = SdkPublisher.adapt(requestStream);
Publisher adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map(
- AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer);
+ AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer);
CompletableFuture future = new CompletableFuture<>();
EventStreamAsyncResponseTransformer asyncResponseTransformer = EventStreamAsyncResponseTransformer
- . builder().eventStreamResponseHandler(asyncResponseHandler)
- .eventResponseHandler(eventResponseHandler).initialResponseHandler(responseHandler)
- .exceptionResponseHandler(errorEventResponseHandler).future(future).executor(executor)
- .serviceName(serviceName()).build();
+ . builder().eventStreamResponseHandler(asyncResponseHandler)
+ .eventResponseHandler(eventResponseHandler).initialResponseHandler(responseHandler)
+ .exceptionResponseHandler(errorEventResponseHandler).future(future).executor(executor)
+ .serviceName(serviceName()).build();
CompletableFuture executeFuture = clientHandler.execute(
- new ClientExecutionParams()
- .withOperationName("EventStreamOperation").withProtocolMetadata(protocolMetadata)
- .withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory))
- .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withFullDuplex(true)
- .withInitialRequestEvent(true).withResponseHandler(voidResponseHandler)
- .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
- .withMetricCollector(apiCallMetricCollector).withInput(eventStreamOperationRequest),
- asyncResponseTransformer);
+ new ClientExecutionParams()
+ .withOperationName("EventStreamOperation").withProtocolMetadata(protocolMetadata)
+ .withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory))
+ .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withFullDuplex(true)
+ .withInitialRequestEvent(true).withResponseHandler(voidResponseHandler)
+ .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
+ .withMetricCollector(apiCallMetricCollector).withInput(eventStreamOperationRequest),
+ asyncResponseTransformer);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
try {
@@ -379,7 +422,7 @@ public CompletableFuture eventStreamOperation(EventStreamOperationRequest
return CompletableFutureUtils.forwardExceptionTo(future, executeFuture);
} catch (Throwable t) {
runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring",
- () -> asyncResponseHandler.exceptionOccurred(t));
+ () -> asyncResponseHandler.exceptionOccurred(t));
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
@@ -408,40 +451,54 @@ public CompletableFuture eventStreamOperation(EventStreamOperationRequest
*/
@Override
public CompletableFuture eventStreamOperationWithOnlyInput(
- EventStreamOperationWithOnlyInputRequest eventStreamOperationWithOnlyInputRequest,
- Publisher requestStream) {
+ EventStreamOperationWithOnlyInputRequest eventStreamOperationWithOnlyInputRequest,
+ Publisher requestStream) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyInputRequest,
- this.clientConfiguration);
+ this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
- eventStreamOperationWithOnlyInputRequest.overrideConfiguration().orElse(null));
+ eventStreamOperationWithOnlyInputRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyInput");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
- .isPayloadJson(true).build();
+ .isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
- .createResponseHandler(operationMetadata, EventStreamOperationWithOnlyInputResponse::builder);
-
+ .createResponseHandler(operationMetadata, EventStreamOperationWithOnlyInputResponse::builder);
+ Function> exceptionMetadataMapper = errorCode -> {
+ if (errorCode == null) {
+ return Optional.empty();
+ }
+ switch (errorCode) {
+ case "InvalidInputException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInputException").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "ServiceFaultException":
+ return Optional.of(ExceptionMetadata.builder().errorCode("ServiceFaultException").httpStatusCode(500)
+ .exceptionBuilderSupplier(ServiceFaultException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata, exceptionMetadataMapper);
EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder()
- .putMarshaller(DefaultInputEventOne.class, new InputEventMarshaller(protocolFactory))
- .putMarshaller(DefaultInputEventTwo.class, new InputEventTwoMarshaller(protocolFactory)).build();
+ .putMarshaller(DefaultInputEventOne.class, new InputEventMarshaller(protocolFactory))
+ .putMarshaller(DefaultInputEventTwo.class, new InputEventTwoMarshaller(protocolFactory)).build();
SdkPublisher eventPublisher = SdkPublisher.adapt(requestStream);
Publisher adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map(
- AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer);
+ AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer);
CompletableFuture executeFuture = clientHandler
- .execute(new ClientExecutionParams()
- .withOperationName("EventStreamOperationWithOnlyInput").withProtocolMetadata(protocolMetadata)
- .withMarshaller(new EventStreamOperationWithOnlyInputRequestMarshaller(protocolFactory))
- .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withInitialRequestEvent(true)
- .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
- .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
- .withInput(eventStreamOperationWithOnlyInputRequest));
+ .execute(new ClientExecutionParams()
+ .withOperationName("EventStreamOperationWithOnlyInput").withProtocolMetadata(protocolMetadata)
+ .withMarshaller(new EventStreamOperationWithOnlyInputRequestMarshaller(protocolFactory))
+ .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withInitialRequestEvent(true)
+ .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
+ .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
+ .withInput(eventStreamOperationWithOnlyInputRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
@@ -476,60 +533,75 @@ public CompletableFuture eventStreamO
*/
@Override
public CompletableFuture eventStreamOperationWithOnlyOutput(
- EventStreamOperationWithOnlyOutputRequest eventStreamOperationWithOnlyOutputRequest,
- EventStreamOperationWithOnlyOutputResponseHandler asyncResponseHandler) {
+ EventStreamOperationWithOnlyOutputRequest eventStreamOperationWithOnlyOutputRequest,
+ EventStreamOperationWithOnlyOutputResponseHandler asyncResponseHandler) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyOutputRequest,
- this.clientConfiguration);
+ this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
- eventStreamOperationWithOnlyOutputRequest.overrideConfiguration().orElse(null));
+ eventStreamOperationWithOnlyOutputRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
- .create("ApiCall");
+ .create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyOutput");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
- .isPayloadJson(true).build();
+ .isPayloadJson(true).build();
HttpResponseHandler responseHandler = new AttachHttpMetadataResponseHandler(
- protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationWithOnlyOutputResponse::builder));
+ protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationWithOnlyOutputResponse::builder));
HttpResponseHandler