AWS code-library documentation change
Summary
Complete overhaul of AWS Marketplace Agreement code examples. Removed all existing examples and replaced with 20 new examples covering agreement cancellation/payment processing, SaaS/AMI agreement amendments, free trials, financial operations, and purchase order management. Added detailed scenarios for each example and updated API references.
Security assessment
The changes involve comprehensive content replacement without any references to security vulnerabilities, patches, or security-specific features. All modifications are functional updates demonstrating API usage patterns for marketplace agreements.
Diff
diff --git a/code-library/latest/ug/python_3_marketplace-agreement_code_examples.md b/code-library/latest/ug/python_3_marketplace-agreement_code_examples.md index 455b7f5e6..df27333ab 100644 --- a//code-library/latest/ug/python_3_marketplace-agreement_code_examples.md +++ b//code-library/latest/ug/python_3_marketplace-agreement_code_examples.md @@ -26 +26 @@ Each example includes a link to the complete source code, where you can find ins -The following code example shows how to get all agreement IDs. +The following code example shows how to accept an agreement cancellation request initiated by the seller. @@ -36,7 +36,2 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - # 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 all agreement ids - AG-09 - """ + import sys + import os @@ -44 +39 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - import logging + sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) @@ -47,7 +41,0 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - from botocore.exceptions import ClientError - - mp_client = boto3.client("marketplace-agreement") - - logger = logging.getLogger(__name__) - - MAX_PAGE_RESULTS = 10 @@ -56,3 +44 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - def get_agreements(): - AgreementSummaryList = [] - agreement_id_list = [] + class AcceptAgreementCancellationRequest: @@ -60,12 +46,2 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - try: - agreements = mp_client.search_agreements( - catalog="AWSMarketplace", - maxResults=MAX_PAGE_RESULTS, - filters=[ - {"name": "PartyType", "values": ["Proposer"]}, - {"name": "AgreementType", "values": ["PurchaseAgreement"]}, - ], - ) - except ClientError as e: - logger.error("Could not complete search_agreements request.") - raise + AGREEMENT_ID = "<AGREEMENT ID HERE>" + AGREEMENT_CANCELLATION_REQUEST_ID = "<AGREEMENT CANCELLATION REQUEST ID HERE>" @@ -73 +49,3 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - AgreementSummaryList.extend(agreements["agreementViewSummaries"]) + @staticmethod + def accept_agreement_cancellation_request(): + client = boto3.client("marketplace-agreement") @@ -75,10 +53,3 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - while "nextToken" in agreements and agreements["nextToken"] is not None: - try: - agreements = mp_client.search_agreements( - catalog="AWSMarketplace", - maxResults=MAX_PAGE_RESULTS, - nextToken=agreements["nextToken"], - filters=[ - {"name": "PartyType", "values": ["Proposer"]}, - {"name": "AgreementType", "values": ["PurchaseAgreement"]}, - ], + response = client.accept_agreement_cancellation_request( + agreementId=AcceptAgreementCancellationRequest.AGREEMENT_ID, + agreementCancellationRequestId=AcceptAgreementCancellationRequest.AGREEMENT_CANCELLATION_REQUEST_ID, @@ -86,5 +56,0 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - except ClientError as e: - logger.error("Could not complete search_agreements request.") - raise - - AgreementSummaryList.extend(agreements["agreementViewSummaries"]) @@ -92,4 +58,7 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - for agreement in AgreementSummaryList: - agreement_id_list.append(agreement["agreementId"]) - - return agreement_id_list + print("Agreement ID: " + response["agreementId"]) + print("Cancellation Request ID: " + response["agreementCancellationRequestId"]) + print("Status: " + str(response.get("status", ""))) + print("Description: " + str(response.get("description", ""))) + print("Reason Code: " + str(response.get("reasonCode", ""))) + print("Created At: " + str(response.get("createdAt", ""))) + print("Updated At: " + str(response.get("updatedAt", ""))) @@ -99,3 +68 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - agreement_id_list = get_agreements() - - print(agreement_id_list) + AcceptAgreementCancellationRequest.accept_agreement_cancellation_request() @@ -105 +72 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - * For API details, see [SearchAgreements](https://docs.aws.amazon.com/goto/boto3/marketplace-agreement-2020-03-01/SearchAgreements) in _AWS SDK for Python (Boto3) API Reference_. + * For API details, see [AcceptAgreementCancellationRequest](https://docs.aws.amazon.com/goto/boto3/marketplace-agreement-2020-03-01/AcceptAgreementCancellationRequest) in _AWS SDK for Python (Boto3) API Reference_. @@ -110 +77 @@ There's more on GitHub. Find the complete example and learn how to set up and ru -The following code example shows how to get all agreements. +The following code example shows how to accept an agreement payment request initiated by the seller. @@ -120,7 +87,2 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - # 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 all agreements - AG-01 - """ + import sys + import os @@ -128 +90 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - import logging + sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) @@ -131,16 +92,0 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - import utils.helpers as helper - from botocore.exceptions import ClientError - - mp_client = boto3.client("marketplace-agreement") - - logger = logging.getLogger(__name__) - - MAX_PAGE_RESULTS = 10 - - party_type_list = ["Proposer"] - agreement_type_list = ["PurchaseAgreement"] - - filter_list = [ - {"name": "PartyType", "values": party_type_list}, - {"name": "AgreementType", "values": agreement_type_list}, - ] @@ -148 +93,0 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - agreement_results_list = [] @@ -149,0 +95 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + class AcceptAgreementPaymentRequest: @@ -151,10 +97,3 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - def get_agreements(filter_list=filter_list): - try: - agreements = mp_client.search_agreements( - catalog="AWSMarketplace", - maxResults=MAX_PAGE_RESULTS, - filters=filter_list, - ) - except ClientError as e: - logger.error("Could not complete search_agreements request.") - raise e + AGREEMENT_ID = "<AGREEMENT ID HERE>" + PAYMENT_REQUEST_ID = "<PAYMENT REQUEST ID HERE>" + PURCHASE_ORDER_REFERENCE = "<PURCHASE ORDER REFERENCE HERE>" @@ -162 +101,3 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - agreement_results_list.extend(agreements["agreementViewSummaries"]) + @staticmethod + def accept_agreement_payment_request(): + client = boto3.client("marketplace-agreement") @@ -164,7 +105,4 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - while "nextToken" in agreements and agreements["nextToken"] is not None: - try: - agreements = mp_client.search_agreements( - catalog="AWSMarketplace", - maxResults=MAX_PAGE_RESULTS, - nextToken=agreements["nextToken"], - filters=filter_list, + response = client.accept_agreement_payment_request( + agreementId=AcceptAgreementPaymentRequest.AGREEMENT_ID, + paymentRequestId=AcceptAgreementPaymentRequest.PAYMENT_REQUEST_ID, + purchaseOrderReference=AcceptAgreementPaymentRequest.PURCHASE_ORDER_REFERENCE, @@ -172,3 +109,0 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - except ClientError as e: - logger.error("Could not complete search_agreements request.") - raise e @@ -176,3 +111,8 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - agreement_results_list.extend(agreements["agreementViewSummaries"]) - - return agreement_results_list + print("Payment Request ID: " + response["paymentRequestId"]) + print("Agreement ID: " + response["agreementId"]) + print("Status: " + str(response.get("status", ""))) + print("Name: " + str(response.get("name", ""))) + print("Charge Amount: " + str(response.get("chargeAmount", ""))) + print("Currency Code: " + str(response.get("currencyCode", ""))) + print("Created At: " + str(response.get("createdAt", ""))) + print("Updated At: " + str(response.get("updatedAt", ""))) @@ -182,2 +122 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - agreements_list = get_agreements(filter_list) - helper.pretty_print_datetime(agreements_list) + AcceptAgreementPaymentRequest.accept_agreement_payment_request() @@ -187 +126 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - * For API details, see [SearchAgreements](https://docs.aws.amazon.com/goto/boto3/marketplace-agreement-2020-03-01/SearchAgreements) in _AWS SDK for Python (Boto3) API Reference_. + * For API details, see [AcceptAgreementPaymentRequest](https://docs.aws.amazon.com/goto/boto3/marketplace-agreement-2020-03-01/AcceptAgreementPaymentRequest) in _AWS SDK for Python (Boto3) API Reference_. @@ -192 +131 @@ There's more on GitHub. Find the complete example and learn how to set up and ru -The following code example shows how to get customer ID from an agreement. +The following code example shows how to amend a SaaS contract agreement to add or update its renewal term. @@ -202,2 +140,0 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - # SPDX-License-Identifier: Apache-2.0 @@ -205,4 +142,13 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - Purpose - Shows how to use the AWS SDK for Python (Boto3) to get customer AWS account id - from a given agreement - AG-08 + Demonstrates how to create a SaaS agreement with CONTRACT pricing model and then turn on + the auto-renewal setting using the AWS Marketplace Agreement Service APIs. + + Scenario: A buyer subscribes to a SaaS product using a public offer that supports + auto-renewal. After acceptance, the buyer decides to amend the agreement to enable