Sono disponibili altri esempi per SDK AWS nel repository GitHub della documentazione degli esempi per SDK AWS
Ottenere informazioni su un accordo con un SDK AWS
Gli esempi di codice seguenti mostrano come ottenere le informazioni su un accordo.
- Java
-
- SDK per Java 2.x
-
Nota
Ulteriori informazioni su GitHub. Trova l’esempio completo e scopri come eseguire la configurazione e l’esecuzione nel repository di esempi di codice dell’API Marketplace AWS
. // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package com.example.awsmarketplace.agreementapi; import static com.example.awsmarketplace.utils.ReferenceCodesConstants.*; import com.example.awsmarketplace.utils.ReferenceCodesUtils; import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; import software.amazon.awssdk.http.apache.ApacheHttpClient; import software.amazon.awssdk.services.marketplaceagreement.MarketplaceAgreementClient; import software.amazon.awssdk.services.marketplaceagreement.model.DescribeAgreementRequest; import software.amazon.awssdk.services.marketplaceagreement.model.DescribeAgreementResponse; public class DescribeAgreement { public static void main(String[] args) { String agreementId = args.length > 0 ? args[0] : AGREEMENT_ID; DescribeAgreementResponse describeAgreementResponse = getResponse(agreementId); ReferenceCodesUtils.formatOutput(describeAgreementResponse); } public static DescribeAgreementResponse getResponse(String agreementId) { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); DescribeAgreementRequest describeAgreementRequest = DescribeAgreementRequest.builder() .agreementId(agreementId) .build(); DescribeAgreementResponse describeAgreementResponse = marketplaceAgreementClient.describeAgreement(describeAgreementRequest); return describeAgreementResponse; } }-
Per informazioni dettagliate sull’API, consulta DescribeAgreement nella documentazione di riferimento dell’API AWS SDK for Java 2.x.
-
- Python
-
- SDK per Python (Boto3)
-
Nota
Ulteriori informazioni su GitHub. Trova l’esempio completo e scopri come eseguire la configurazione e l’esecuzione nel repository di esempi di codice dell’API Marketplace AWS
. # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 """ Purpose Shows how to use the AWS SDK for Python (Boto3) to get agreement information AG-07 """ import argparse import logging import boto3 import utils.helpers as helper from botocore.exceptions import ClientError mp_client = boto3.client("marketplace-agreement") logger = logging.getLogger(__name__) def get_agreement_information(agreement_id): try: response = mp_client.describe_agreement(agreementId=agreement_id) except ClientError as e: if e.response["Error"]["Code"] == "ResourceNotFoundException": logger.error("Agreement with ID %s not found.", agreement_id) raise e else: logger.error("Unexpected error: %s", e) raise e return response if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--agreement-id", "-aid", help="Provide agreement ID to describe agreement status", required=True, ) args = parser.parse_args() response = get_agreement_information(agreement_id=args.agreement_id) helper.pretty_print_datetime(response)-
Per informazioni dettagliate sull’API, consulta DescribeAgreement nella documentazione di riferimento dell’API AWS SDK per Python (Boto3).
-