public ProgressEvent handleRequest()

in aws-ssm-maintenancewindow/src/main/java/software/amazon/ssm/maintenancewindow/UpdateHandler.java [60:107]


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

        logger.log(String.format("Processing UpdateHandler request %s", request));

        final ResourceModel model = request.getDesiredResourceState();

        final ProgressEvent<ResourceModel, CallbackContext> progressEvent = new ProgressEvent<>();
        progressEvent.setResourceModel(request.getPreviousResourceState());
        progressEvent.setStatus(OperationStatus.FAILED);

        final String windowId = model.getWindowId();

        if (StringUtils.isNullOrEmpty(windowId)) {
            progressEvent.setErrorCode(HandlerErrorCode.InvalidRequest);
            progressEvent.setMessage("WindowId must be present to update the existing maintenance window.");
            return progressEvent;
        }

        final UpdateMaintenanceWindowRequest updateMaintenanceWindowRequest =
                updateMaintenanceWindowTranslator.resourceModelToRequest(model);

        try {
            final UpdateMaintenanceWindowResponse response =
                    proxy.injectCredentialsAndInvokeV2(updateMaintenanceWindowRequest, SSM_CLIENT::updateMaintenanceWindow);

            final ResourceModel updatedModel =
                    updateMaintenanceWindowToResourceModelTranslator.updateMaintenanceWindowResponseToResourceModel(response);

            updateTags(request.getDesiredResourceTags(), request.getSystemTags(), windowId, proxy);
            progressEvent.setResourceModel(updatedModel);

            progressEvent.setStatus(OperationStatus.SUCCESS);

        } catch (final Exception e) {
            final BaseHandlerException cfnException = exceptionTranslator
                    .translateFromServiceException(e, updateMaintenanceWindowRequest);

            logger.log(cfnException.getCause().getMessage());

            throw cfnException;
        }

        return progressEvent;
    }