Search in sources :

Example 1 with GetDeploymentConfigurationResponse

use of software.amazon.awssdk.services.greengrassv2data.model.GetDeploymentConfigurationResponse in project aws-greengrass-nucleus by aws-greengrass.

the class DeploymentDocumentDownloader method getDeploymentConfiguration.

private GetDeploymentConfigurationResponse getDeploymentConfiguration(String deploymentId) throws RetryableDeploymentDocumentDownloadException {
    String thingName = Coerce.toString(deviceConfiguration.getThingName());
    GetDeploymentConfigurationRequest getDeploymentConfigurationRequest = GetDeploymentConfigurationRequest.builder().deploymentId(deploymentId).coreDeviceThingName(thingName).build();
    GetDeploymentConfigurationResponse deploymentConfiguration;
    try {
        logger.atInfo().kv("DeploymentId", deploymentId).kv("ThingName", thingName).log("Calling Greengrass cloud to get full deployment configuration.");
        deploymentConfiguration = greengrassServiceClientFactory.getGreengrassV2DataClient().getDeploymentConfiguration(getDeploymentConfigurationRequest);
    } catch (AwsServiceException e) {
        throw new RetryableDeploymentDocumentDownloadException("Greengrass Cloud Service returned an error when getting full deployment configuration.", e);
    } catch (SdkClientException e) {
        throw new RetryableDeploymentDocumentDownloadException("Failed to contact Greengrass cloud or unable to parse response.", e);
    }
    return deploymentConfiguration;
}
Also used : RetryableDeploymentDocumentDownloadException(com.aws.greengrass.deployment.exceptions.RetryableDeploymentDocumentDownloadException) SdkClientException(software.amazon.awssdk.core.exception.SdkClientException) GetDeploymentConfigurationRequest(software.amazon.awssdk.services.greengrassv2data.model.GetDeploymentConfigurationRequest) GetDeploymentConfigurationResponse(software.amazon.awssdk.services.greengrassv2data.model.GetDeploymentConfigurationResponse) AwsServiceException(software.amazon.awssdk.awscore.exception.AwsServiceException)

Example 2 with GetDeploymentConfigurationResponse

use of software.amazon.awssdk.services.greengrassv2data.model.GetDeploymentConfigurationResponse in project aws-greengrass-nucleus by aws-greengrass.

the class DeploymentDocumentDownloader method downloadDeploymentDocument.

protected String downloadDeploymentDocument(String deploymentId) throws DeploymentTaskFailureException, RetryableDeploymentDocumentDownloadException {
    // 1. Get url, digest, and algorithm by calling gg data plane
    GetDeploymentConfigurationResponse response = getDeploymentConfiguration(deploymentId);
    String preSignedUrl = response.preSignedUrl();
    String algorithm = response.integrityCheck().algorithm();
    String digest = response.integrityCheck().digest();
    validate(preSignedUrl, algorithm, digest);
    // 2. Download configuration and check integrity.
    String configurationInString = downloadFromUrl(deploymentId, preSignedUrl);
    checkIntegrity(algorithm, digest, configurationInString);
    return configurationInString;
}
Also used : GetDeploymentConfigurationResponse(software.amazon.awssdk.services.greengrassv2data.model.GetDeploymentConfigurationResponse)

Aggregations

GetDeploymentConfigurationResponse (software.amazon.awssdk.services.greengrassv2data.model.GetDeploymentConfigurationResponse)2 RetryableDeploymentDocumentDownloadException (com.aws.greengrass.deployment.exceptions.RetryableDeploymentDocumentDownloadException)1 AwsServiceException (software.amazon.awssdk.awscore.exception.AwsServiceException)1 SdkClientException (software.amazon.awssdk.core.exception.SdkClientException)1 GetDeploymentConfigurationRequest (software.amazon.awssdk.services.greengrassv2data.model.GetDeploymentConfigurationRequest)1