public ProgressEvent handleRequest()

in aws-batch-schedulingpolicy/src/main/java/software/amazon/batch/schedulingpolicy/ReadHandler.java [32:68]


    public ProgressEvent<ResourceModel, CallbackContext> handleRequest(
        final AmazonWebServicesClientProxy proxy,
        final ResourceHandlerRequest<ResourceModel> request,
        final CallbackContext callbackContext,
        final Logger logger) {

        logger.log("Read handler for SchedulingPolicy invoked.");

        if (this.client == null) {
            this.client = ClientBuilder.getClient();
        }

        final ResourceModel model = request.getDesiredResourceState();
        logger.log("SchedulingPolicy model for delete request: " + model.toString());

        try {
            final DescribeSchedulingPoliciesResponse response =
                    proxy.injectCredentialsAndInvokeV2(Translator.toDescribeSchedulingPoliciesRequest(
                            Collections.singletonList(model.getArn())),
                    this.client::describeSchedulingPolicies);

            if (response.schedulingPolicies().size() != 0) {
                SchedulingPolicyDetail schedulingPolicyDetail = response.schedulingPolicies().get(0);
                logger.log("Read scheduling policy final result: " + schedulingPolicyDetail.toString());

                return ProgressEvent.<ResourceModel, CallbackContext>builder()
                        .resourceModel(Translator.toModelSchedulingPolicy(schedulingPolicyDetail))
                        .status(OperationStatus.SUCCESS)
                        .build();
            }
        } catch (final BatchException e) {
            Exceptions.handleBatchExceptions(request, callbackContext, e);
        }

        return ProgressEvent.failed(request.getDesiredResourceState(), callbackContext,  HandlerErrorCode.NotFound,
                String.format("Resource %s not found.", model.getArn()));
    }