81
81
import software .amazon .awssdk .services .json .model .PaginatedOperationWithResultKeyResponse ;
82
82
import software .amazon .awssdk .services .json .model .PaginatedOperationWithoutResultKeyRequest ;
83
83
import software .amazon .awssdk .services .json .model .PaginatedOperationWithoutResultKeyResponse ;
84
+ import software .amazon .awssdk .services .json .model .ServiceFaultException ;
84
85
import software .amazon .awssdk .services .json .model .StreamingInputOperationRequest ;
85
86
import software .amazon .awssdk .services .json .model .StreamingInputOperationResponse ;
86
87
import software .amazon .awssdk .services .json .model .StreamingInputOutputOperationRequest ;
@@ -216,6 +217,7 @@ public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRe
216
217
* <ul>
217
218
* <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
218
219
* for an input parameter.</li>
220
+ * <li>ServiceFaultException</li>
219
221
* <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
220
222
* Can be used for catch all scenarios.</li>
221
223
* <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
@@ -641,31 +643,31 @@ public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChe
641
643
*/
642
644
@ Override
643
645
public CompletableFuture <OperationWithNoneAuthTypeResponse > operationWithNoneAuthType (
644
- OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest ) {
646
+ OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest ) {
645
647
List <MetricPublisher > metricPublishers = resolveMetricPublishers (clientConfiguration , operationWithNoneAuthTypeRequest
646
- .overrideConfiguration ().orElse (null ));
648
+ .overrideConfiguration ().orElse (null ));
647
649
MetricCollector apiCallMetricCollector = metricPublishers .isEmpty () ? NoOpMetricCollector .create () : MetricCollector
648
- .create ("ApiCall" );
650
+ .create ("ApiCall" );
649
651
try {
650
652
apiCallMetricCollector .reportMetric (CoreMetric .SERVICE_ID , "Json Service" );
651
653
apiCallMetricCollector .reportMetric (CoreMetric .OPERATION_NAME , "OperationWithNoneAuthType" );
652
654
JsonOperationMetadata operationMetadata = JsonOperationMetadata .builder ().hasStreamingSuccessResponse (false )
653
- .isPayloadJson (true ).build ();
655
+ .isPayloadJson (true ).build ();
654
656
655
657
HttpResponseHandler <OperationWithNoneAuthTypeResponse > responseHandler = protocolFactory .createResponseHandler (
656
- operationMetadata , OperationWithNoneAuthTypeResponse ::builder );
658
+ operationMetadata , OperationWithNoneAuthTypeResponse ::builder );
657
659
658
660
HttpResponseHandler <AwsServiceException > errorResponseHandler = createErrorResponseHandler (protocolFactory ,
659
- operationMetadata );
661
+ operationMetadata );
660
662
661
663
CompletableFuture <OperationWithNoneAuthTypeResponse > executeFuture = clientHandler
662
- .execute (new ClientExecutionParams <OperationWithNoneAuthTypeRequest , OperationWithNoneAuthTypeResponse >()
663
- .withOperationName ("OperationWithNoneAuthType" )
664
- .withMarshaller (new OperationWithNoneAuthTypeRequestMarshaller (protocolFactory ))
665
- .withResponseHandler (responseHandler ).withErrorResponseHandler (errorResponseHandler )
666
- .withMetricCollector (apiCallMetricCollector )
667
- .putExecutionAttribute (SdkInternalExecutionAttribute .IS_NONE_AUTH_TYPE_REQUEST , false )
668
- .withInput (operationWithNoneAuthTypeRequest ));
664
+ .execute (new ClientExecutionParams <OperationWithNoneAuthTypeRequest , OperationWithNoneAuthTypeResponse >()
665
+ .withOperationName ("OperationWithNoneAuthType" )
666
+ .withMarshaller (new OperationWithNoneAuthTypeRequestMarshaller (protocolFactory ))
667
+ .withResponseHandler (responseHandler ).withErrorResponseHandler (errorResponseHandler )
668
+ .withMetricCollector (apiCallMetricCollector )
669
+ .putExecutionAttribute (SdkInternalExecutionAttribute .IS_NONE_AUTH_TYPE_REQUEST , false )
670
+ .withInput (operationWithNoneAuthTypeRequest ));
669
671
CompletableFuture <OperationWithNoneAuthTypeResponse > whenCompleted = executeFuture .whenComplete ((r , e ) -> {
670
672
metricPublishers .forEach (p -> p .publish (apiCallMetricCollector .collect ()));
671
673
});
@@ -755,7 +757,7 @@ public CompletableFuture<PaginatedOperationWithResultKeyResponse> paginatedOpera
755
757
* The following are few ways to use the response class:
756
758
* </p>
757
759
* 1) Using the subscribe helper method
758
- *
760
+ *
759
761
* <pre>
760
762
* {@code
761
763
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyPublisher publisher = client.paginatedOperationWithResultKeyPaginator(request);
@@ -765,19 +767,19 @@ public CompletableFuture<PaginatedOperationWithResultKeyResponse> paginatedOpera
765
767
* </pre>
766
768
*
767
769
* 2) Using a custom subscriber
768
- *
770
+ *
769
771
* <pre>
770
772
* {@code
771
773
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyPublisher publisher = client.paginatedOperationWithResultKeyPaginator(request);
772
774
* publisher.subscribe(new Subscriber<software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse>() {
773
- *
775
+ *
774
776
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
775
- *
776
- *
777
+ *
778
+ *
777
779
* public void onNext(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse response) { //... };
778
780
* });}
779
781
* </pre>
780
- *
782
+ *
781
783
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
782
784
* <p>
783
785
* <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the
@@ -888,7 +890,7 @@ public CompletableFuture<PaginatedOperationWithoutResultKeyResponse> paginatedOp
888
890
* The following are few ways to use the response class:
889
891
* </p>
890
892
* 1) Using the subscribe helper method
891
- *
893
+ *
892
894
* <pre>
893
895
* {@code
894
896
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyPublisher publisher = client.paginatedOperationWithoutResultKeyPaginator(request);
@@ -898,19 +900,19 @@ public CompletableFuture<PaginatedOperationWithoutResultKeyResponse> paginatedOp
898
900
* </pre>
899
901
*
900
902
* 2) Using a custom subscriber
901
- *
903
+ *
902
904
* <pre>
903
905
* {@code
904
906
* software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyPublisher publisher = client.paginatedOperationWithoutResultKeyPaginator(request);
905
907
* publisher.subscribe(new Subscriber<software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse>() {
906
- *
908
+ *
907
909
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
908
- *
909
- *
910
+ *
911
+ *
910
912
* public void onNext(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse response) { //... };
911
913
* });}
912
914
* </pre>
913
- *
915
+ *
914
916
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
915
917
* <p>
916
918
* <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the
@@ -1050,8 +1052,8 @@ public <ReturnT> CompletableFuture<ReturnT> streamingInputOutputOperation(
1050
1052
try {
1051
1053
apiCallMetricCollector .reportMetric (CoreMetric .SERVICE_ID , "Json Service" );
1052
1054
apiCallMetricCollector .reportMetric (CoreMetric .OPERATION_NAME , "StreamingInputOutputOperation" );
1053
- Pair <AsyncResponseTransformer <StreamingInputOutputOperationResponse , ReturnT >, CompletableFuture <Void >> pair =
1054
- AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture (asyncResponseTransformer );
1055
+ Pair <AsyncResponseTransformer <StreamingInputOutputOperationResponse , ReturnT >, CompletableFuture <Void >> pair = AsyncResponseTransformerUtils
1056
+ .wrapWithEndOfStreamFuture (asyncResponseTransformer );
1055
1057
asyncResponseTransformer = pair .left ();
1056
1058
CompletableFuture <Void > endOfStreamFuture = pair .right ();
1057
1059
streamingInputOutputOperationRequest = applySignerOverride (streamingInputOutputOperationRequest ,
@@ -1092,7 +1094,7 @@ public <ReturnT> CompletableFuture<ReturnT> streamingInputOutputOperation(
1092
1094
} catch (Throwable t ) {
1093
1095
AsyncResponseTransformer <StreamingInputOutputOperationResponse , ReturnT > finalAsyncResponseTransformer = asyncResponseTransformer ;
1094
1096
runAndLogError (log , "Exception thrown in exceptionOccurred callback, ignoring" ,
1095
- () -> finalAsyncResponseTransformer .exceptionOccurred (t ));
1097
+ () -> finalAsyncResponseTransformer .exceptionOccurred (t ));
1096
1098
metricPublishers .forEach (p -> p .publish (apiCallMetricCollector .collect ()));
1097
1099
return CompletableFutureUtils .failedFuture (t );
1098
1100
}
@@ -1133,8 +1135,8 @@ public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation(
1133
1135
try {
1134
1136
apiCallMetricCollector .reportMetric (CoreMetric .SERVICE_ID , "Json Service" );
1135
1137
apiCallMetricCollector .reportMetric (CoreMetric .OPERATION_NAME , "StreamingOutputOperation" );
1136
- Pair <AsyncResponseTransformer <StreamingOutputOperationResponse , ReturnT >, CompletableFuture <Void >> pair =
1137
- AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture (asyncResponseTransformer );
1138
+ Pair <AsyncResponseTransformer <StreamingOutputOperationResponse , ReturnT >, CompletableFuture <Void >> pair = AsyncResponseTransformerUtils
1139
+ .wrapWithEndOfStreamFuture (asyncResponseTransformer );
1138
1140
asyncResponseTransformer = pair .left ();
1139
1141
CompletableFuture <Void > endOfStreamFuture = pair .right ();
1140
1142
JsonOperationMetadata operationMetadata = JsonOperationMetadata .builder ().hasStreamingSuccessResponse (true )
@@ -1168,7 +1170,7 @@ public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation(
1168
1170
} catch (Throwable t ) {
1169
1171
AsyncResponseTransformer <StreamingOutputOperationResponse , ReturnT > finalAsyncResponseTransformer = asyncResponseTransformer ;
1170
1172
runAndLogError (log , "Exception thrown in exceptionOccurred callback, ignoring" ,
1171
- () -> finalAsyncResponseTransformer .exceptionOccurred (t ));
1173
+ () -> finalAsyncResponseTransformer .exceptionOccurred (t ));
1172
1174
metricPublishers .forEach (p -> p .publish (apiCallMetricCollector .collect ()));
1173
1175
return CompletableFutureUtils .failedFuture (t );
1174
1176
}
@@ -1186,8 +1188,11 @@ private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) {
1186
1188
.protocol (AwsJsonProtocol .AWS_JSON )
1187
1189
.protocolVersion ("1.1" )
1188
1190
.registerModeledException (
1189
- ExceptionMetadata .builder ().errorCode ("InvalidInput" )
1190
- .exceptionBuilderSupplier (InvalidInputException ::builder ).httpStatusCode (400 ).build ());
1191
+ ExceptionMetadata .builder ().errorCode ("InvalidInputException" )
1192
+ .exceptionBuilderSupplier (InvalidInputException ::builder ).httpStatusCode (400 ).build ())
1193
+ .registerModeledException (
1194
+ ExceptionMetadata .builder ().errorCode ("ServiceFaultException" )
1195
+ .exceptionBuilderSupplier (ServiceFaultException ::builder ).httpStatusCode (500 ).build ());
1191
1196
}
1192
1197
1193
1198
private static List <MetricPublisher > resolveMetricPublishers (SdkClientConfiguration clientConfiguration ,
0 commit comments