private GetGrantResponse readResource()

in aws-licensemanager-grant/src/main/java/software/amazon/licensemanager/grant/ReadHandler.java [51:74]


    private GetGrantResponse readResource(
            final GetGrantRequest getGrantRequest,
            final ProxyClient<LicenseManagerClient> proxyClient,
            final ResourceModel model) {
        GetGrantResponse getGrantResponse = null;
        try {
            getGrantResponse = proxyClient.injectCredentialsAndInvokeV2(getGrantRequest, proxyClient.client()::getGrant);
            model.setGrantArn(getGrantResponse.grant().grantArn());
        } catch (ValidationException | InvalidParameterValueException e) {
            logger.log("Resource reading failed");
            throw new CfnNotFoundException(model.getGrantArn(), ResourceModel.TYPE_NAME);
        } catch (final AwsServiceException e) {
            logger.log("Resource reading failed");
            throw new CfnGeneralServiceException(ResourceModel.TYPE_NAME + e.getMessage(), e);
        }

        if (DELETED.equals(getGrantResponse.grant().grantStatus().toString())
                || PENDING_DELETE.equals(getGrantResponse.grant().grantStatus().toString())) {
            throw new CfnNotFoundException(model.getGrantArn(), ResourceModel.TYPE_NAME);
        }

        logger.log(String.format("%s has successfully been read.", ResourceModel.TYPE_NAME));
        return getGrantResponse;
    }