in aws-ssmincidents-responseplan/src/main/java/software/amazon/ssmincidents/responseplan/CreateHandler.java [20:53]
protected ProgressEvent<ResourceModel, CallbackContext> handleRequest(
final AmazonWebServicesClientProxy proxy,
final ResourceHandlerRequest<ResourceModel> request,
final CallbackContext callbackContext,
final ProxyClient<SsmIncidentsClient> proxyClient,
final Logger logger) {
this.logger = logger;
if (request.getDesiredResourceState().getArn() != null) {
throw new CfnInvalidRequestException("Attempting to set a ReadOnly Property.");
}
return ProgressEvent.progress(request.getDesiredResourceState(), callbackContext)
.then(progress ->
proxy.initiate("AWS-SSMIncidents-ResponsePlan::Create", proxyClient, progress.getResourceModel(),
progress.getCallbackContext())
.translateToServiceRequest(Translator::translateToCreateRequest)
.makeServiceCall((awsRequest, client) -> {
CreateResponsePlanResponse awsResponse = null;
try {
awsResponse = client
.injectCredentialsAndInvokeV2(awsRequest, proxyClient.client()::createResponsePlan);
} catch (final Exception e) {
e.printStackTrace();
throw Translator.handleException(e);
}
logger.log(String.format("%s successfully created.", ResourceModel.TYPE_NAME));
return awsResponse;
})
.done((createResponsePlanRequest, createResponsePlanResponse, client, model, context) -> ProgressEvent.defaultInProgressHandler(context, 0, updateModelWithArn(model, createResponsePlanResponse.arn())))
)
.then(progress -> new ReadHandler().handleRequest(proxy, request, callbackContext, proxyClient, logger));
}