public ProgressEvent handleRequest()

in aws-ecr-replicationconfiguration/src/main/java/software/amazon/ecr/replicationconfiguration/UpdateHandler.java [18:51]


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

        final ResourceModel model = request.getDesiredResourceState();
        final EcrClient client = proxyClient.client();

        try {
            // Ensure resource exists on the ECR Registry.
            if (!hasExistingResource(describeRegistryResource(proxy, client))) {
                throw new ResourceNotFoundException(ResourceModel.TYPE_NAME, model.getRegistryId());
            }

            final PutReplicationConfigurationResponse response = proxy.injectCredentialsAndInvokeV2(
                    Translator.putReplicationConfiguration(model),
                    client::putReplicationConfiguration);
            logger.log(String.format("%s [%s] Update Successful", ResourceModel.TYPE_NAME, response.replicationConfiguration()));
        } catch (AwsServiceException e) {
            return ProgressEvent.<ResourceModel, CallbackContext>builder()
                    .resourceModel(model)
                    .status(OperationStatus.FAILED)
                    .errorCode(HandlerErrorCode.GeneralServiceException)
                    .message(e.getMessage())
                    .build();
        }

        return ProgressEvent.<ResourceModel, CallbackContext>builder()
                .resourceModel(model)
                .status(OperationStatus.SUCCESS)
                .build();
    }