diff --git a/.changes/2.29.5.json b/.changes/2.29.5.json
new file mode 100644
index 000000000000..6d61f3552c5a
--- /dev/null
+++ b/.changes/2.29.5.json
@@ -0,0 +1,60 @@
+{
+ "version": "2.29.5",
+ "date": "2024-10-31",
+ "entries": [
+ {
+ "type": "bugfix",
+ "category": "AWS SDK for Java v2",
+ "contributor": "",
+ "description": "Fix an issue where the SDK does not properly unmarshall an evenstream exception to the expected exception type."
+ },
+ {
+ "type": "feature",
+ "category": "AWS Batch",
+ "contributor": "",
+ "description": "Add `podNamespace` to `EksAttemptDetail` and `containerID` to `EksAttemptContainerDetail`."
+ },
+ {
+ "type": "feature",
+ "category": "AWS Glue",
+ "contributor": "",
+ "description": "Add schedule support for AWS Glue column statistics"
+ },
+ {
+ "type": "feature",
+ "category": "Amazon Prometheus Service",
+ "contributor": "",
+ "description": "Added support for UpdateScraper API, to enable updating collector configuration in-place"
+ },
+ {
+ "type": "feature",
+ "category": "Amazon SageMaker Service",
+ "contributor": "",
+ "description": "SageMaker HyperPod adds scale-down at instance level via BatchDeleteClusterNodes API and group level via UpdateCluster API. SageMaker Training exposes secondary job status in TrainingJobSummary from ListTrainingJobs API. SageMaker now supports G6, G6e, P5e instances for HyperPod and Training."
+ },
+ {
+ "type": "feature",
+ "category": "Amazon Simple Email Service",
+ "contributor": "",
+ "description": "This release enables customers to provide the email template content in the SESv2 SendEmail and SendBulkEmail APIs instead of the name or the ARN of a stored email template."
+ },
+ {
+ "type": "feature",
+ "category": "Auto Scaling",
+ "contributor": "",
+ "description": "Adds bake time for Auto Scaling group Instance Refresh"
+ },
+ {
+ "type": "feature",
+ "category": "Elastic Load Balancing",
+ "contributor": "",
+ "description": "Add UDP support for AWS PrivateLink and dual-stack Network Load Balancers"
+ },
+ {
+ "type": "feature",
+ "category": "AWS SDK for Java v2",
+ "contributor": "",
+ "description": "Updated endpoint and partition metadata."
+ }
+ ]
+}
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 285da69c9359..5dfe00ccdbe4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,40 @@
#### 👋 _Looking for changelogs for older versions? You can find them in the [changelogs](./changelogs) directory._
+# __2.29.5__ __2024-10-31__
+## __AWS Batch__
+ - ### Features
+ - Add `podNamespace` to `EksAttemptDetail` and `containerID` to `EksAttemptContainerDetail`.
+
+## __AWS Glue__
+ - ### Features
+ - Add schedule support for AWS Glue column statistics
+
+## __AWS SDK for Java v2__
+ - ### Features
+ - Updated endpoint and partition metadata.
+
+ - ### Bugfixes
+ - Fix an issue where the SDK does not properly unmarshall an evenstream exception to the expected exception type.
+
+## __Amazon Prometheus Service__
+ - ### Features
+ - Added support for UpdateScraper API, to enable updating collector configuration in-place
+
+## __Amazon SageMaker Service__
+ - ### Features
+ - SageMaker HyperPod adds scale-down at instance level via BatchDeleteClusterNodes API and group level via UpdateCluster API. SageMaker Training exposes secondary job status in TrainingJobSummary from ListTrainingJobs API. SageMaker now supports G6, G6e, P5e instances for HyperPod and Training.
+
+## __Amazon Simple Email Service__
+ - ### Features
+ - This release enables customers to provide the email template content in the SESv2 SendEmail and SendBulkEmail APIs instead of the name or the ARN of a stored email template.
+
+## __Auto Scaling__
+ - ### Features
+ - Adds bake time for Auto Scaling group Instance Refresh
+
+## __Elastic Load Balancing__
+ - ### Features
+ - Add UDP support for AWS PrivateLink and dual-stack Network Load Balancers
+
# __2.29.4__ __2024-10-30__
## __AWS AppSync__
- ### Features
diff --git a/README.md b/README.md
index 5f33a9ccad77..2d26b4757611 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.29.4
+ 2.29.5
pom
import
@@ -85,12 +85,12 @@ Alternatively you can add dependencies for the specific services you use only:
software.amazon.awssdk
ec2
- 2.29.4
+ 2.29.5
software.amazon.awssdk
s3
- 2.29.4
+ 2.29.5
```
@@ -102,7 +102,7 @@ You can import the whole SDK into your project (includes *ALL* services). Please
software.amazon.awssdk
aws-sdk-java
- 2.29.4
+ 2.29.5
```
diff --git a/archetypes/archetype-app-quickstart/pom.xml b/archetypes/archetype-app-quickstart/pom.xml
index 7986e7062ffc..66b9d83d2e7b 100644
--- a/archetypes/archetype-app-quickstart/pom.xml
+++ b/archetypes/archetype-app-quickstart/pom.xml
@@ -20,7 +20,7 @@
archetypes
software.amazon.awssdk
- 2.29.4
+ 2.29.5
4.0.0
diff --git a/archetypes/archetype-lambda/pom.xml b/archetypes/archetype-lambda/pom.xml
index c0a9b86dac08..64fdadce3143 100644
--- a/archetypes/archetype-lambda/pom.xml
+++ b/archetypes/archetype-lambda/pom.xml
@@ -20,7 +20,7 @@
archetypes
software.amazon.awssdk
- 2.29.4
+ 2.29.5
4.0.0
archetype-lambda
diff --git a/archetypes/archetype-tools/pom.xml b/archetypes/archetype-tools/pom.xml
index 431eb4245a8c..8f663a971bbe 100644
--- a/archetypes/archetype-tools/pom.xml
+++ b/archetypes/archetype-tools/pom.xml
@@ -20,7 +20,7 @@
archetypes
software.amazon.awssdk
- 2.29.4
+ 2.29.5
4.0.0
diff --git a/archetypes/pom.xml b/archetypes/pom.xml
index 42fb55f0b2b2..d2e343bc3801 100644
--- a/archetypes/pom.xml
+++ b/archetypes/pom.xml
@@ -20,7 +20,7 @@
aws-sdk-java-pom
software.amazon.awssdk
- 2.29.4
+ 2.29.5
4.0.0
archetypes
diff --git a/aws-sdk-java/pom.xml b/aws-sdk-java/pom.xml
index 4f805af2ce99..2c93023cbf33 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.29.4
+ 2.29.5
../pom.xml
aws-sdk-java
diff --git a/bom-internal/pom.xml b/bom-internal/pom.xml
index be692f7d4972..52f978c2ab97 100644
--- a/bom-internal/pom.xml
+++ b/bom-internal/pom.xml
@@ -20,7 +20,7 @@
aws-sdk-java-pom
software.amazon.awssdk
- 2.29.4
+ 2.29.5
4.0.0
diff --git a/bom/pom.xml b/bom/pom.xml
index 87a6034aa8a2..2ed795067490 100644
--- a/bom/pom.xml
+++ b/bom/pom.xml
@@ -17,7 +17,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.29.4
+ 2.29.5
../pom.xml
bom
diff --git a/bundle-logging-bridge/pom.xml b/bundle-logging-bridge/pom.xml
index de781f470693..2e95d1f64f62 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.29.4
+ 2.29.5
bundle-logging-bridge
jar
diff --git a/bundle-sdk/pom.xml b/bundle-sdk/pom.xml
index 969edfba0465..1a65ddb81475 100644
--- a/bundle-sdk/pom.xml
+++ b/bundle-sdk/pom.xml
@@ -21,7 +21,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.29.4
+ 2.29.5
bundle-sdk
jar
diff --git a/bundle/pom.xml b/bundle/pom.xml
index 0efed01d105e..1e96f7a11792 100644
--- a/bundle/pom.xml
+++ b/bundle/pom.xml
@@ -21,7 +21,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.29.4
+ 2.29.5
bundle
jar
diff --git a/codegen-lite-maven-plugin/pom.xml b/codegen-lite-maven-plugin/pom.xml
index e5956dfe44a4..3dacc5ac6e87 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.29.4
+ 2.29.5
../pom.xml
codegen-lite-maven-plugin
diff --git a/codegen-lite/pom.xml b/codegen-lite/pom.xml
index d0f2a9e859b3..6241e5811b7a 100644
--- a/codegen-lite/pom.xml
+++ b/codegen-lite/pom.xml
@@ -21,7 +21,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.29.4
+ 2.29.5
codegen-lite
AWS Java SDK :: Code Generator Lite
diff --git a/codegen-maven-plugin/pom.xml b/codegen-maven-plugin/pom.xml
index edfdb02ab187..6687ce1ef2aa 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.29.4
+ 2.29.5
../pom.xml
codegen-maven-plugin
diff --git a/codegen/pom.xml b/codegen/pom.xml
index 8202b0a03649..d0044f7e4d39 100644
--- a/codegen/pom.xml
+++ b/codegen/pom.xml
@@ -21,7 +21,7 @@
software.amazon.awssdk
aws-sdk-java-pom
- 2.29.4
+ 2.29.5
codegen
AWS Java SDK :: Code Generator
diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/OperationContextParam.java b/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/OperationContextParam.java
index c41926736d81..f2ca29b73652 100644
--- a/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/OperationContextParam.java
+++ b/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/OperationContextParam.java
@@ -18,13 +18,13 @@
import com.fasterxml.jackson.core.TreeNode;
public class OperationContextParam {
- private TreeNode value;
+ private TreeNode path;
- public TreeNode getValue() {
- return value;
+ public TreeNode getPath() {
+ return path;
}
- public void setValue(TreeNode value) {
- this.value = value;
+ public void setPath(TreeNode path) {
+ this.path = path;
}
}
diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java
index 070dfb293404..aaa729662c17 100644
--- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java
+++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java
@@ -182,6 +182,7 @@ protected void addAdditionalMethods(TypeSpec.Builder type) {
type.addMethod(ClientClassUtils.updateRetryStrategyClientConfigurationMethod());
type.addMethod(updateSdkClientConfigurationMethod(configurationUtils.serviceClientConfigurationBuilderClassName()));
protocolSpec.createErrorResponseHandler().ifPresent(type::addMethod);
+ protocolSpec.createEventstreamErrorResponseHandler().ifPresent(type::addMethod);
}
@Override
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 7907593c19b7..9fa214efb8fe 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
@@ -27,6 +27,7 @@
import com.squareup.javapoet.WildcardTypeName;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
+import java.util.function.Function;
import javax.lang.model.element.Modifier;
import software.amazon.awssdk.awscore.eventstream.EventStreamAsyncResponseTransformer;
import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionPojoSupplier;
@@ -55,6 +56,7 @@
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.protocol.VoidSdkResponse;
import software.amazon.awssdk.protocols.cbor.AwsCborProtocolFactory;
+import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
@@ -238,7 +240,7 @@ public CodeBlock asyncExecutionHandler(IntermediateModel intermediateModel, Oper
.add(".eventStreamResponseHandler(asyncResponseHandler)\n")
.add(".eventResponseHandler(eventResponseHandler)\n")
.add(".initialResponseHandler(responseHandler)\n")
- .add(".exceptionResponseHandler(errorResponseHandler)\n")
+ .add(".exceptionResponseHandler(errorEventResponseHandler)\n")
.add(".future(future)\n")
.add(".executor(executor)\n")
.add(".serviceName(serviceName())\n")
@@ -419,6 +421,25 @@ public Optional createErrorResponseHandler() {
.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")
+ .addParameter(mapperType, "exceptionMetadataMapper")
+ .returns(responseHandlerOfException)
+ .addModifiers(Modifier.PRIVATE)
+ .addStatement("return protocolFactory.createErrorResponseHandler(operationMetadata, "
+ + "exceptionMetadataMapper)")
+ .build());
+ }
+
private String protocolEnumName(software.amazon.awssdk.codegen.model.intermediate.Protocol protocol) {
switch (protocol) {
case CBOR:
@@ -480,6 +501,37 @@ private void responseHandlersForEventStreaming(OperationModel opModel, TypeName
});
builder.add(".defaultSdkPojoSupplier(() -> new $T($T.UNKNOWN))\n"
+ ".build());\n", SdkPojoBuilder.class, eventStreamBaseClass);
+
+ ParameterizedTypeName metadataMapperType = ParameterizedTypeName.get(
+ ClassName.get(Function.class),
+ ClassName.get(String.class),
+ ParameterizedTypeName.get(Optional.class, ExceptionMetadata.class));
+
+ builder.add("\n");
+ builder.add("$T eventstreamExceptionMetadataMapper = errorCode -> {\n", metadataMapperType);
+ builder.add("switch (errorCode) {\n");
+ EventStreamUtils.getErrorMembers(eventStream).forEach(m -> {
+ String errorCode = m.getC2jName();
+ builder.add("case $S:\n", errorCode);
+ builder.add("return $T.of($T.builder()", Optional.class, ExceptionMetadata.class);
+ builder.add(".errorCode($S)", m.getShape().getErrorCode());
+ builder.add(populateHttpStatusCode(m.getShape(), model));
+ builder.add(".exceptionBuilderSupplier($T::builder).build());\n",
+ poetExtensions.getModelClassFromShape(m.getShape()));
+ });
+ builder.add("default: return $T.empty();", Optional.class);
+ builder.add("}\n");
+ builder.add("};\n");
+
+ ParameterizedTypeName errorResponseHandlerType = ParameterizedTypeName.get(HttpResponseHandler.class,
+ AwsServiceException.class);
+
+ builder.add("\n");
+ builder.addStatement("$T errorEventResponseHandler = createErrorResponseHandler($N, operationMetadata, "
+ + "eventstreamExceptionMetadataMapper)",
+ errorResponseHandlerType,
+ protocolFactoryLiteral(model, opModel));
+
}
private String protocolFactoryLiteral(IntermediateModel model, OperationModel opModel) {
diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/ProtocolSpec.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/ProtocolSpec.java
index 443a483887eb..74df3666fd0f 100644
--- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/ProtocolSpec.java
+++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/specs/ProtocolSpec.java
@@ -66,6 +66,10 @@ default Class extends SyncClientHandler> getClientHandlerClass() {
Optional createErrorResponseHandler();
+ default Optional createEventstreamErrorResponseHandler() {
+ return Optional.empty();
+ }
+
default List additionalMethods() {
return new ArrayList<>();
}
diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/eventstream/EventStreamUtils.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/eventstream/EventStreamUtils.java
index 44267cd394fe..0d9b8a34e39d 100644
--- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/eventstream/EventStreamUtils.java
+++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/eventstream/EventStreamUtils.java
@@ -126,6 +126,16 @@ public static Stream getEventMembers(ShapeModel eventStreamShape) {
.filter(m -> m.getShape() != null && m.getShape().isEvent());
}
+ public static Stream getErrorMembers(ShapeModel eventStreamShape) {
+ if (eventStreamShape == null || eventStreamShape.getMembers() == null) {
+ return Stream.empty();
+ }
+
+ return eventStreamShape.getMembers()
+ .stream()
+ .filter(m -> m.getShape() != null && !m.getShape().isEvent());
+ }
+
/**
* Returns the all operations that contain the given event stream shape. The event stream can be in operation
* request or response shape.
diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/rules/EndpointResolverInterceptorSpec.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/rules/EndpointResolverInterceptorSpec.java
index 77c214e384d6..77ad7c724dee 100644
--- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/rules/EndpointResolverInterceptorSpec.java
+++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/rules/EndpointResolverInterceptorSpec.java
@@ -558,10 +558,10 @@ private MethodSpec setOperationContextParamsMethod(OperationModel opModel) {
b.addStatement("$1T input = new $1T(request)", poetExtension.jmesPathRuntimeClass().nestedClass("Value"));
opModel.getOperationContextParams().forEach((key, value) -> {
- if (Objects.requireNonNull(value.getValue().asToken()) == JsonToken.VALUE_STRING) {
+ if (Objects.requireNonNull(value.getPath().asToken()) == JsonToken.VALUE_STRING) {
String setterName = endpointRulesSpecUtils.paramMethodName(key);
- String jmesPathString = ((JrsString) value.getValue()).getValue();
+ String jmesPathString = ((JrsString) value.getPath()).getValue();
CodeBlock addParam = CodeBlock.builder()
.add("params.$N(", setterName)
.add(jmesPathGenerator.interpret(jmesPathString, "input"))
@@ -572,7 +572,7 @@ private MethodSpec setOperationContextParamsMethod(OperationModel opModel) {
b.addStatement(addParam);
} else {
throw new RuntimeException("Invalid operation context parameter path for " + opModel.getOperationName() +
- ". Expected VALUE_STRING, but got " + value.getValue().asToken());
+ ". Expected VALUE_STRING, but got " + value.getPath().asToken());
}
});
diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/query/customization-with-duplicate-operationcontextparams.config b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/query/customization-with-duplicate-operationcontextparams.config
index 2c2e44b21feb..cfa4792d334e 100644
--- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/query/customization-with-duplicate-operationcontextparams.config
+++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/query/customization-with-duplicate-operationcontextparams.config
@@ -4,7 +4,7 @@
"operationName": "OperationWithOperationContextParam",
"operationContextParamsMap": {
"customEndpointArray": {
- "value": "ListMember.StringList[*].LeafString"
+ "path": "ListMember.StringList[*].LeafString"
}
}
}
diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/query/customization-with-incorrectName-operationcontextparams.config b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/query/customization-with-incorrectName-operationcontextparams.config
index d4904b1df742..5a689bc6892b 100644
--- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/query/customization-with-incorrectName-operationcontextparams.config
+++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/query/customization-with-incorrectName-operationcontextparams.config
@@ -4,7 +4,7 @@
"operationName": "RandomOperationName",
"operationContextParamsMap": {
"customEndpointArray": {
- "value": "ListMember.StringList[*].LeafString"
+ "path": "ListMember.StringList[*].LeafString"
}
}
}
diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/query/customization.config b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/query/customization.config
index 02f2e6840aea..908e483057be 100644
--- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/query/customization.config
+++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/query/customization.config
@@ -17,7 +17,7 @@
"operationName": "OperationWithCustomizedOperationContextParam",
"operationContextParamsMap": {
"customEndpointArray": {
- "value": "ListMember.StringList[*].LeafString"
+ "path": "ListMember.StringList[*].LeafString"
}
}
}
diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/query/service-2.json b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/query/service-2.json
index 40df42ff90e0..8d2bbdcbdab4 100644
--- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/query/service-2.json
+++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/query/service-2.json
@@ -38,7 +38,7 @@
"requestUri": "/"
},
"operationContextParams":{
- "customEndpointArray":{"value":"ListMember.StringList[*].LeafString"}
+ "customEndpointArray":{"path":"ListMember.StringList[*].LeafString"}
},
"input":{"shape":"WithOperationContextParam"}
},
diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/rest-json/service-2.json b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/rest-json/service-2.json
index a144431455dd..82620e0da9bf 100644
--- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/rest-json/service-2.json
+++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/rest-json/service-2.json
@@ -471,6 +471,12 @@
// Legacy generation uses shape name == event name
"eventThree": {
"shape": "LegacyEventThree"
+ },
+ "errorOne": {
+ "shape": "InvalidInputException"
+ },
+ "errorTwo": {
+ "shape": "InvalidInputException"
}
},
"eventstream": true
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 2bb3074aa08c..7298068aa6ad 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
@@ -5,9 +5,11 @@
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
+import java.util.function.Function;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -126,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;
@@ -176,32 +178,32 @@ 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);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata);
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()));
});
@@ -240,32 +242,32 @@ 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);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata);
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()));
});
@@ -299,56 +301,66 @@ 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();
+ }
+ };
+
+ HttpResponseHandler errorEventResponseHandler = createErrorResponseHandler(protocolFactory,
+ operationMetadata, eventstreamExceptionMetadataMapper);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata);
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(errorResponseHandler).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 {
@@ -363,7 +375,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);
}
@@ -392,40 +404,40 @@ 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);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata);
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()));
});
@@ -460,50 +472,60 @@ 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();
+ }
+ };
+
+ HttpResponseHandler errorEventResponseHandler = createErrorResponseHandler(protocolFactory,
+ operationMetadata, eventstreamExceptionMetadataMapper);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata);
CompletableFuture future = new CompletableFuture<>();
EventStreamAsyncResponseTransformer asyncResponseTransformer = EventStreamAsyncResponseTransformer
- . builder()
- .eventStreamResponseHandler(asyncResponseHandler).eventResponseHandler(eventResponseHandler)
- .initialResponseHandler(responseHandler).exceptionResponseHandler(errorResponseHandler).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 {
@@ -518,7 +540,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);
}
@@ -550,32 +572,32 @@ 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);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata);
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()));
});
@@ -610,36 +632,36 @@ 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);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata);
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()));
});
@@ -673,32 +695,32 @@ 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);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata);
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()));
});
@@ -733,37 +755,37 @@ 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);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata);
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()));
});
@@ -798,32 +820,32 @@ 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);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata);
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()));
});
@@ -858,32 +880,32 @@ 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);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata);
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()));
});
@@ -922,36 +944,36 @@ 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);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata);
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()));
});
@@ -995,49 +1017,49 @@ 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);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata);
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()));
@@ -1048,7 +1070,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);
}
@@ -1081,42 +1103,42 @@ 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);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata);
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()));
@@ -1127,7 +1149,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);
}
@@ -1145,20 +1167,20 @@ 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());
+ .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());
}
private static List resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
- RequestOverrideConfiguration requestOverrideConfiguration) {
+ RequestOverrideConfiguration requestOverrideConfiguration) {
List publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
@@ -1210,10 +1232,15 @@ private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request,
}
private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
- JsonOperationMetadata operationMetadata) {
+ JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
+ private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
+ JsonOperationMetadata operationMetadata, Function> exceptionMetadataMapper) {
+ return protocolFactory.createErrorResponseHandler(operationMetadata, exceptionMetadataMapper);
+ }
+
@Override
public void close() {
clientHandler.close();
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 cd713cf630a0..8953d6a681c1 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
@@ -5,9 +5,11 @@
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
+import java.util.function.Function;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -330,6 +332,16 @@ public CompletableFuture eventStreamOperation(EventStreamOperationRequest
.putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder)
.defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build());
+ Function> eventstreamExceptionMetadataMapper = errorCode -> {
+ switch (errorCode) {
+ default:
+ return Optional.empty();
+ }
+ };
+
+ HttpResponseHandler errorEventResponseHandler = createErrorResponseHandler(protocolFactory,
+ operationMetadata, eventstreamExceptionMetadataMapper);
+
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder()
@@ -341,8 +353,8 @@ public CompletableFuture eventStreamOperation(EventStreamOperationRequest
EventStreamAsyncResponseTransformer asyncResponseTransformer = EventStreamAsyncResponseTransformer
. builder().eventStreamResponseHandler(asyncResponseHandler)
.eventResponseHandler(eventResponseHandler).initialResponseHandler(responseHandler)
- .exceptionResponseHandler(errorResponseHandler).future(future).executor(executor).serviceName(serviceName())
- .build();
+ .exceptionResponseHandler(errorEventResponseHandler).future(future).executor(executor)
+ .serviceName(serviceName()).build();
CompletableFuture executeFuture = clientHandler.execute(
new ClientExecutionParams()
@@ -492,13 +504,23 @@ public CompletableFuture eventStreamOperationWithOnlyOutput(
.putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder)
.defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build());
+ Function> eventstreamExceptionMetadataMapper = errorCode -> {
+ switch (errorCode) {
+ default:
+ return Optional.empty();
+ }
+ };
+
+ HttpResponseHandler errorEventResponseHandler = createErrorResponseHandler(protocolFactory,
+ operationMetadata, eventstreamExceptionMetadataMapper);
+
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture future = new CompletableFuture<>();
EventStreamAsyncResponseTransformer asyncResponseTransformer = EventStreamAsyncResponseTransformer
. builder()
.eventStreamResponseHandler(asyncResponseHandler).eventResponseHandler(eventResponseHandler)
- .initialResponseHandler(responseHandler).exceptionResponseHandler(errorResponseHandler).future(future)
+ .initialResponseHandler(responseHandler).exceptionResponseHandler(errorEventResponseHandler).future(future)
.executor(executor).serviceName(serviceName()).build();
CompletableFuture executeFuture = clientHandler.execute(
@@ -1218,6 +1240,11 @@ private HttpResponseHandler createErrorResponseHandler(Base
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
+ private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
+ JsonOperationMetadata operationMetadata, Function> exceptionMetadataMapper) {
+ return protocolFactory.createErrorResponseHandler(operationMetadata, exceptionMetadataMapper);
+ }
+
@Override
public void close() {
clientHandler.close();
diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-json-async-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-json-async-client-class.java
index aa5c4ef710ce..5958db5e6167 100644
--- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-json-async-client-class.java
+++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-json-async-client-class.java
@@ -5,10 +5,12 @@
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Consumer;
+import java.util.function.Function;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -136,7 +138,7 @@ final class DefaultJsonAsyncClient implements JsonAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultJsonAsyncClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
- .serviceProtocol(AwsServiceProtocol.REST_JSON).build();
+ .serviceProtocol(AwsServiceProtocol.REST_JSON).build();
private final AsyncClientHandler clientHandler;
@@ -189,32 +191,32 @@ 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);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata);
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()));
});
@@ -252,32 +254,32 @@ 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);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata);
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()));
});
@@ -311,32 +313,32 @@ public CompletableFuture aPostOperationWithOut
*/
@Override
public CompletableFuture bearerAuthOperation(
- BearerAuthOperationRequest bearerAuthOperationRequest) {
+ BearerAuthOperationRequest bearerAuthOperationRequest) {
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest,
- this.clientConfiguration);
+ this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest
- .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, "BearerAuthOperation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
- .isPayloadJson(true).build();
+ .isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
- operationMetadata, BearerAuthOperationResponse::builder);
+ operationMetadata, BearerAuthOperationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata);
CompletableFuture executeFuture = clientHandler
- .execute(new ClientExecutionParams()
- .withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata)
- .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory))
- .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
- .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
- .credentialType(CredentialType.TOKEN).withInput(bearerAuthOperationRequest));
+ .execute(new ClientExecutionParams()
+ .withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata)
+ .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory))
+ .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
+ .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
+ .credentialType(CredentialType.TOKEN).withInput(bearerAuthOperationRequest));
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
@@ -370,59 +372,75 @@ public CompletableFuture bearerAuthOperation(
*/
@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) {
+ case "errorOne":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInput").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ case "errorTwo":
+ return Optional.of(ExceptionMetadata.builder().errorCode("InvalidInput").httpStatusCode(400)
+ .exceptionBuilderSupplier(InvalidInputException::builder).build());
+ default:
+ return Optional.empty();
+ }
+ };
+
+ HttpResponseHandler errorEventResponseHandler = createErrorResponseHandler(protocolFactory,
+ operationMetadata, eventstreamExceptionMetadataMapper);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
- operationMetadata);
+ operationMetadata);
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(errorResponseHandler).future(future).executor(executor).serviceName(serviceName())
- .build();
+ . builder().eventStreamResponseHandler(asyncResponseHandler)
+ .eventResponseHandler(eventResponseHandler).initialResponseHandler(responseHandler)
+ .exceptionResponseHandler(errorEventResponseHandler).future(future).executor(executor)
+ .serviceName(serviceName()).build();
RestEventStreamAsyncResponseTransformer restAsyncResponseTransformer = RestEventStreamAsyncResponseTransformer
- . builder()
- .eventStreamAsyncResponseTransformer(asyncResponseTransformer)
- .eventStreamResponseHandler(asyncResponseHandler).build();
+ . builder()
+ .eventStreamAsyncResponseTransformer(asyncResponseTransformer)
+ .eventStreamResponseHandler(asyncResponseHandler).build();
CompletableFuture executeFuture = clientHandler.execute(
- new ClientExecutionParams()
- .withOperationName("EventStreamOperation").withProtocolMetadata(protocolMetadata)
- .withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory))
- .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withFullDuplex(true)
- .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
- .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
- .withInput(eventStreamOperationRequest), restAsyncResponseTransformer);
+ new ClientExecutionParams()
+ .withOperationName("EventStreamOperation").withProtocolMetadata(protocolMetadata)
+ .withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory))
+ .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withFullDuplex(true)
+ .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
+ .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector)
+ .withInput(eventStreamOperationRequest), restAsyncResponseTransformer);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
if (e != null) {
try {
@@ -437,7 +455,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);
}
@@ -466,39 +484,39 @@ public CompletableFuture eventStreamOperation(EventStreamOperationRequest
*/
@Override
public CompletableFuture