D'autres exemples de AWS SDK sont disponibles dans le référentiel AWS Doc SDK Examples
Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.
Remplacez un terme de tarification basé sur l'utilisation de l'AMI, mais conservez le terme existant ConfigurableUpfrontPricingTerm en utilisant un AWS Kit SDK
Les exemples de code suivants montrent comment remplacer un terme de tarification basé sur l'utilisation d'une AMI tout en conservant le terme existant. ConfigurableUpfrontPricingTerm
- Java
-
- SDK pour Java 2.x
-
Note
Il y en a plus à ce sujet GitHub. Trouvez l’exemple complet et découvrez comment le configurer et l’exécuter dans le référentiel Bibliothèque des codes de la référence des API d’AWS Marketplace
. package com.example.awsmarketplace.agreementapi.buyer; 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.AcceptAgreementRequestRequest; import software.amazon.awssdk.services.marketplaceagreement.model.AcceptAgreementRequestResponse; import software.amazon.awssdk.services.marketplaceagreement.model.ConfigurableUpfrontPricingTermConfiguration; import software.amazon.awssdk.services.marketplaceagreement.model.CreateAgreementRequestRequest; import software.amazon.awssdk.services.marketplaceagreement.model.CreateAgreementRequestResponse; import software.amazon.awssdk.services.marketplaceagreement.model.Dimension; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementEntitlementsResponse; import software.amazon.awssdk.services.marketplaceagreement.model.Intent; import software.amazon.awssdk.services.marketplaceagreement.model.RequestedTerm; import software.amazon.awssdk.services.marketplaceagreement.model.RequestedTermConfiguration; import utils.AgreementApiUtils; /** * Demonstrates how to replace an AMI agreement with usageBasedPricingTerm with a new offer while * the agreement with ConfigurableUpfrontPricingTerm (CUPT) is still active, using the AWS Marketplace Agreement Service APIs. * * <p>Scenario: An AMI product with USAGE pricing requires two agreements: * <ol> * <li>An agreement with <b>usageBasedPricingTerm</b> — accepted first to establish the base agreement.</li> * <li>An agreement with <b>configurableUpfrontPricingTerm (CUPT)</b> — accepted after the usageBasedPricingTerm agreement entitlements are active.</li> * </ol> * <p> This sample shows how to replace only the agreement with usageBasedPricingTerm with a * new offer without touching the existing agreement with configurableUpfrontPricingTerm (CUPT). * * <p>Flow: * <ol> * <li>Create and accept the initial agreement request with usageBasedPricingTerm.</li> * <li>Create and accept the agreement request with configurableUpfrontPricingTerm (CUPT) (after usageBasedPricingTerm agreement entitlements are active).</li> * <li>Replace the agreement with usageBasedPricingTerm with a new offer using Intent.REPLACE.</li> * </ol> * * <p>Before running this sample, replace the placeholder constants below with values from * your AWS Marketplace offers: * <ul> * <li>{@code AGREEMENT_PROPOSAL_IDENTIFIER} — the agreementProposalId from the initial offer.</li> * <li>{@code NEW_AGREEMENT_PROPOSAL_IDENTIFIER} — the agreementProposalId from the new offer to replace to.</li> * <li>Term IDs (starting with {@code term-}) — found in each offer's term list.</li> * <li>{@code SELECTOR_VALUE} — duration for the agreement (e.g., {@code P365D}).</li> * <li>{@code DIMENSION_1_KEY} — dimension key defined in the CUPT term.</li> * </ul> */ public class ReplaceAmiUsageBasedPricingTermButNotCupt { // The agreementProposalId from the initial offer. private static final String AGREEMENT_PROPOSAL_IDENTIFIER = "<your-agreement-proposal-identifier>"; // Term ID for the ConfigurableUpfrontPricingTerm in the initial offer. private static final String CONFIGURABLE_UPFRONT_PRICING_TERM_ID = "<your-configurable-upfront-pricing-term-id>"; // Duration for the agreement (e.g., "P365D" for 365 days). private static final String SELECTOR_VALUE = "<your-selector-value>"; // Dimension key defined in the CUPT term. private static final String DIMENSION_1_KEY = "<your-dimension-key>"; // Quantity for the dimension. private static final int DIMENSION_1_VALUE = 1; // Term ID for the UsageBasedPricingTerm in the initial offer. private static final String USAGE_TERM_ID = "<your-usage-term-id>"; // Term ID for the LegalTerm in the initial offer. private static final String LEGAL_TERM_ID = "<your-legal-term-id>"; // Term ID for the ValidityTerm in the initial offer. private static final String VALIDITY_TERM_ID = "<your-validity-term-id>"; // The agreementProposalId from the new offer to replace to. private static final String NEW_AGREEMENT_PROPOSAL_IDENTIFIER = "<your-new-agreement-proposal-identifier>"; // Term ID for the UsageBasedPricingTerm in the new offer. private static final String NEW_USAGE_TERM_ID = "<your-new-usage-term-id>"; // Term ID for the LegalTerm in the new offer. private static final String NEW_LEGAL_TERM_ID = "<your-new-legal-term-id>"; // Term ID for the ValidityTerm in the new offer. private static final String NEW_VALIDITY_TERM_ID = "<your-new-validity-term-id>"; public static void main(String[] args) { replaceAmiUsageWhenCuptExists(); } /** * Full end-to-end flow: * 1. Create and accept an agreement request with usageBasedPricingTerm, then wait for entitlements. * 2. Create and accept an agreement request with CUPT, then wait for entitlements. * 3. Replace the agreement with usageBasedPricingTerm with a new offer (agreement with CUPT is unaffected). */ private static void replaceAmiUsageWhenCuptExists() { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); RequestedTerm usageTerm = RequestedTerm.builder().id(USAGE_TERM_ID).build(); RequestedTerm legalTerm = RequestedTerm.builder().id(LEGAL_TERM_ID).build(); RequestedTerm validityTerm = RequestedTerm.builder().id(VALIDITY_TERM_ID).build(); // --- Step 1: Agreement with UBPT --- CreateAgreementRequestRequest createAgreementRequestRequest = CreateAgreementRequestRequest.builder() .clientToken(AgreementApiUtils.generateClientToken()) .intent(Intent.NEW) .requestedTerms(usageTerm, legalTerm, validityTerm) .agreementProposalIdentifier(AGREEMENT_PROPOSAL_IDENTIFIER) .build(); CreateAgreementRequestResponse createAgreementRequestResponse = marketplaceAgreementClient.createAgreementRequest(createAgreementRequestRequest); System.out.println("Agreement request with UBPT created. AgreementRequestId: " + createAgreementRequestResponse.agreementRequestId()); AcceptAgreementRequestRequest acceptAgreementRequestRequest = AcceptAgreementRequestRequest.builder() .agreementRequestId(createAgreementRequestResponse.agreementRequestId()) .build(); AcceptAgreementRequestResponse acceptAgreementRequestResponse = marketplaceAgreementClient.acceptAgreementRequest(acceptAgreementRequestRequest); final String usageAgreementId = acceptAgreementRequestResponse.agreementId(); System.out.println("Agreement request with UBPT accepted. AgreementId: " + usageAgreementId); // Wait for UBPT agreement entitlements to become active before creating the agreement with CUPT. System.out.println("Waiting for UBPT agreement entitlements to become active..."); GetAgreementEntitlementsResponse entitlementsResponse = AgreementApiUtils.pollUntilEntitlementsAvailable( marketplaceAgreementClient, usageAgreementId); System.out.println("UBPT agreement entitlements are now active."); AgreementApiUtils.formatOutput(entitlementsResponse); // --- Step 2: Agreement with configurableUpfrontPricingTerm (CUPT) --- RequestedTerm configurableUpfrontPricingTerm = RequestedTerm.builder() .id(CONFIGURABLE_UPFRONT_PRICING_TERM_ID) .configuration(RequestedTermConfiguration.fromConfigurableUpfrontPricingTermConfiguration( ConfigurableUpfrontPricingTermConfiguration.builder() .selectorValue(SELECTOR_VALUE) .dimensions(Dimension.builder() .dimensionKey(DIMENSION_1_KEY) .dimensionValue(DIMENSION_1_VALUE) .build()) .build())) .build(); CreateAgreementRequestRequest carRequest = CreateAgreementRequestRequest.builder() .clientToken(AgreementApiUtils.generateClientToken()) .intent(Intent.NEW) .requestedTerms(configurableUpfrontPricingTerm, legalTerm, validityTerm) .agreementProposalIdentifier(AGREEMENT_PROPOSAL_IDENTIFIER) .build(); CreateAgreementRequestResponse carResponse = marketplaceAgreementClient.createAgreementRequest(carRequest); System.out.println("Agreement request with CUPT created. AgreementRequestId: " + carResponse.agreementRequestId()); AcceptAgreementRequestRequest aarRequest = AcceptAgreementRequestRequest.builder() .agreementRequestId(carResponse.agreementRequestId()) .build(); AcceptAgreementRequestResponse aarResponse = marketplaceAgreementClient.acceptAgreementRequest(aarRequest); final String cuptAgreementId = aarResponse.agreementId(); System.out.println("Agreement request with CUPT accepted. AgreementId: " + cuptAgreementId); // Wait for CUPT agreement entitlements to become active before replacing usage. System.out.println("Waiting for CUPT agreement entitlements to become active..."); GetAgreementEntitlementsResponse cuptEntitlementsResponse = AgreementApiUtils.pollUntilEntitlementsAvailable( marketplaceAgreementClient, cuptAgreementId); System.out.println("CUPT agreement entitlements are now active."); AgreementApiUtils.formatOutput(cuptEntitlementsResponse); // --- Step 3: Replace Agreement with usageBasedPricingTerm with a new offer --- RequestedTerm newUsageTerm = RequestedTerm.builder().id(NEW_USAGE_TERM_ID).build(); RequestedTerm newLegalTerm = RequestedTerm.builder().id(NEW_LEGAL_TERM_ID).build(); RequestedTerm newValidityTerm = RequestedTerm.builder().id(NEW_VALIDITY_TERM_ID).build(); // Use Intent.REPLACE and sourceAgreementIdentifier pointing to the usageBasedPricingTerm agreement only. // The agreement with configurableUpfrontPricingTerm (CUPT) is NOT affected by this replacement. CreateAgreementRequestRequest carReplaceRequest = CreateAgreementRequestRequest.builder() .clientToken(AgreementApiUtils.generateClientToken()) .intent(Intent.REPLACE) .requestedTerms(newUsageTerm, newLegalTerm, newValidityTerm) .agreementProposalIdentifier(NEW_AGREEMENT_PROPOSAL_IDENTIFIER) .sourceAgreementIdentifier(usageAgreementId) .build(); CreateAgreementRequestResponse carReplaceResponse = marketplaceAgreementClient.createAgreementRequest(carReplaceRequest); System.out.println("Replace agreement request created. AgreementRequestId: " + carReplaceResponse.agreementRequestId()); AcceptAgreementRequestRequest aarReplaceRequest = AcceptAgreementRequestRequest.builder() .agreementRequestId(carReplaceResponse.agreementRequestId()) .build(); AcceptAgreementRequestResponse aarReplaceResponse = marketplaceAgreementClient.acceptAgreementRequest(aarReplaceRequest); System.out.println("Agreement with UBPT replaced. New AgreementId: " + aarReplaceResponse.agreementId()); } }-
Pour plus de détails sur l'API, voir CreateAgreementRequestla section Référence des AWS SDK for Java 2.x API.
-
- JavaScript
-
- SDK pour JavaScript (v3)
-
Note
Il y en a plus à ce sujet GitHub. Trouvez l’exemple complet et découvrez comment le configurer et l’exécuter dans le référentiel Bibliothèque des codes de la référence des API d’AWS Marketplace
. const { MarketplaceAgreementClient, CreateAgreementRequestCommand, AcceptAgreementRequestCommand, } = require("@aws-sdk/client-marketplace-agreement"); const { generateClientToken, formatOutput, pollUntilEntitlementsAvailable } = require("./utils/AgreementApiUtils"); /** * Demonstrates how to replace an AMI agreement with usageBasedPricingTerm with a new offer while * the agreement with ConfigurableUpfrontPricingTerm (CUPT) is still active, using the AWS Marketplace Agreement Service APIs. * * Scenario: An AMI product with USAGE pricing requires two agreements: * 1. An agreement with usageBasedPricingTerm — accepted first to establish the base agreement. * 2. An agreement with configurableUpfrontPricingTerm (CUPT) — accepted after the usageBasedPricingTerm agreement entitlements are active. * * This sample shows how to replace only the agreement with usageBasedPricingTerm with a * new offer without touching the existing agreement with configurableUpfrontPricingTerm (CUPT). * * Flow: * 1. Create and accept the initial agreement request with usageBasedPricingTerm. * 2. Create and accept the agreement request with configurableUpfrontPricingTerm (CUPT) (after usageBasedPricingTerm agreement entitlements are active). * 3. Replace the agreement with usageBasedPricingTerm with a new offer using Intent.REPLACE. * * Before running this sample, replace the placeholder constants below with values from * your AWS Marketplace offers: * - AGREEMENT_PROPOSAL_IDENTIFIER — the agreementProposalId from the initial offer. * - NEW_AGREEMENT_PROPOSAL_IDENTIFIER — the agreementProposalId from the new offer to replace to. * - Term IDs (starting with "term-") — found in each offer's term list. * - SELECTOR_VALUE — duration for the agreement (e.g., "P365D"). * - DIMENSION_1_KEY — dimension key defined in the CUPT term. */ // The agreementProposalId from the initial offer. const AGREEMENT_PROPOSAL_IDENTIFIER = "<your-agreement-proposal-identifier>"; // Term ID for the ConfigurableUpfrontPricingTerm in the initial offer. const CONFIGURABLE_UPFRONT_PRICING_TERM_ID = "<your-configurable-upfront-pricing-term-id>"; // Duration for the agreement (e.g., "P365D" for 365 days). const SELECTOR_VALUE = "<your-selector-value>"; // Dimension key defined in the CUPT term. const DIMENSION_1_KEY = "<your-dimension-key>"; // Quantity for the dimension. const DIMENSION_1_VALUE = 1; // Term ID for the UsageBasedPricingTerm in the initial offer. const USAGE_TERM_ID = "<your-usage-term-id>"; // Term ID for the LegalTerm in the initial offer. const LEGAL_TERM_ID = "<your-legal-term-id>"; // Term ID for the ValidityTerm in the initial offer. const VALIDITY_TERM_ID = "<your-validity-term-id>"; // The agreementProposalId from the new offer to replace to. const NEW_AGREEMENT_PROPOSAL_IDENTIFIER = "<your-new-agreement-proposal-identifier>"; // Term ID for the UsageBasedPricingTerm in the new offer. const NEW_USAGE_TERM_ID = "<your-new-usage-term-id>"; // Term ID for the LegalTerm in the new offer. const NEW_LEGAL_TERM_ID = "<your-new-legal-term-id>"; // Term ID for the ValidityTerm in the new offer. const NEW_VALIDITY_TERM_ID = "<your-new-validity-term-id>"; /** * Full end-to-end flow: * 1. Create and accept an agreement request with usageBasedPricingTerm, then wait for entitlements. * 2. Create and accept an agreement request with CUPT, then wait for entitlements. * 3. Replace the agreement with usageBasedPricingTerm with a new offer (agreement with CUPT is unaffected). */ async function replaceAmiUsageWhenCuptExists() { const client = new MarketplaceAgreementClient(); const usageTerm = { id: USAGE_TERM_ID }; const legalTerm = { id: LEGAL_TERM_ID }; const validityTerm = { id: VALIDITY_TERM_ID }; // --- Step 1: Agreement with UBPT --- const createAgreementRequestResponse = await client.send( new CreateAgreementRequestCommand({ clientToken: generateClientToken(), intent: "NEW", requestedTerms: [usageTerm, legalTerm, validityTerm], agreementProposalIdentifier: AGREEMENT_PROPOSAL_IDENTIFIER, }) ); console.log("Agreement request with UBPT created. AgreementRequestId: " + createAgreementRequestResponse.agreementRequestId); const acceptAgreementRequestResponse = await client.send( new AcceptAgreementRequestCommand({ agreementRequestId: createAgreementRequestResponse.agreementRequestId, }) ); const usageAgreementId = acceptAgreementRequestResponse.agreementId; console.log("Agreement request with UBPT accepted. AgreementId: " + usageAgreementId); // Wait for UBPT agreement entitlements to become active before creating the agreement with CUPT. console.log("Waiting for UBPT agreement entitlements to become active..."); const entitlementsResponse = await pollUntilEntitlementsAvailable(client, usageAgreementId); console.log("UBPT agreement entitlements are now active."); formatOutput(entitlementsResponse); // --- Step 2: Agreement with configurableUpfrontPricingTerm (CUPT) --- const configurableUpfrontPricingTerm = { id: CONFIGURABLE_UPFRONT_PRICING_TERM_ID, configuration: { configurableUpfrontPricingTermConfiguration: { selectorValue: SELECTOR_VALUE, dimensions: [ { dimensionKey: DIMENSION_1_KEY, dimensionValue: DIMENSION_1_VALUE }, ], }, }, }; const carResponse = await client.send( new CreateAgreementRequestCommand({ clientToken: generateClientToken(), intent: "NEW", requestedTerms: [configurableUpfrontPricingTerm, legalTerm, validityTerm], agreementProposalIdentifier: AGREEMENT_PROPOSAL_IDENTIFIER, }) ); console.log("Agreement request with CUPT created. AgreementRequestId: " + carResponse.agreementRequestId); const aarResponse = await client.send( new AcceptAgreementRequestCommand({ agreementRequestId: carResponse.agreementRequestId, }) ); const cuptAgreementId = aarResponse.agreementId; console.log("Agreement request with CUPT accepted. AgreementId: " + cuptAgreementId); // Wait for CUPT agreement entitlements to become active before replacing usage. console.log("Waiting for CUPT agreement entitlements to become active..."); const cuptEntitlementsResponse = await pollUntilEntitlementsAvailable(client, cuptAgreementId); console.log("CUPT agreement entitlements are now active."); formatOutput(cuptEntitlementsResponse); // --- Step 3: Replace Agreement with usageBasedPricingTerm with a new offer --- const newUsageTerm = { id: NEW_USAGE_TERM_ID }; const newLegalTerm = { id: NEW_LEGAL_TERM_ID }; const newValidityTerm = { id: NEW_VALIDITY_TERM_ID }; // Use Intent.REPLACE and sourceAgreementIdentifier pointing to the usageBasedPricingTerm agreement only. // The agreement with configurableUpfrontPricingTerm (CUPT) is NOT affected by this replacement. const carReplaceResponse = await client.send( new CreateAgreementRequestCommand({ clientToken: generateClientToken(), intent: "REPLACE", requestedTerms: [newUsageTerm, newLegalTerm, newValidityTerm], agreementProposalIdentifier: NEW_AGREEMENT_PROPOSAL_IDENTIFIER, sourceAgreementIdentifier: usageAgreementId, }) ); console.log("Replace agreement request created. AgreementRequestId: " + carReplaceResponse.agreementRequestId); const aarReplaceResponse = await client.send( new AcceptAgreementRequestCommand({ agreementRequestId: carReplaceResponse.agreementRequestId, }) ); console.log("Agreement with UBPT replaced. New AgreementId: " + aarReplaceResponse.agreementId); } replaceAmiUsageWhenCuptExists();-
Pour plus de détails sur l'API, voir CreateAgreementRequestla section Référence des AWS SDK pour JavaScript API.
-
- Python
-
- Kit SDK for Python (Boto3)
-
Note
Il y en a plus à ce sujet GitHub. Trouvez l’exemple complet et découvrez comment le configurer et l’exécuter dans le référentiel Bibliothèque des codes de la référence des API d’AWS Marketplace
. """ Demonstrates how to replace an AMI agreement with usageBasedPricingTerm with a new offer while the agreement with ConfigurableUpfrontPricingTerm (CUPT) is still active, using the AWS Marketplace Agreement Service APIs. Scenario: An AMI product with USAGE pricing requires two agreements: 1. An agreement with usageBasedPricingTerm — accepted first to establish the base agreement. 2. An agreement with configurableUpfrontPricingTerm (CUPT) — accepted after the usageBasedPricingTerm agreement entitlements are active. This sample shows how to replace only the agreement with usageBasedPricingTerm with a new offer without touching the existing agreement with configurableUpfrontPricingTerm (CUPT). Flow: 1. Create and accept the initial agreement request with usageBasedPricingTerm. 2. Create and accept the agreement request with configurableUpfrontPricingTerm (CUPT) (after usageBasedPricingTerm agreement entitlements are active). 3. Replace the agreement with usageBasedPricingTerm with a new offer using Intent.REPLACE. Before running this sample, replace the placeholder constants below with values from your AWS Marketplace offers: - AGREEMENT_PROPOSAL_IDENTIFIER — the agreementProposalId from the initial offer. - NEW_AGREEMENT_PROPOSAL_IDENTIFIER — the agreementProposalId from the new offer to replace to. - Term IDs (starting with term-) — found in each offer's term list. - SELECTOR_VALUE — duration for the agreement (e.g., P365D). - DIMENSION_1_KEY — dimension key defined in the CUPT term. """ import boto3 from utils.agreement_api_utils import ( format_output, generate_client_token, poll_until_entitlements_available, ) class ReplaceAmiUsageBasedPricingTermButNotCupt: # The agreementProposalId from the initial offer. AGREEMENT_PROPOSAL_IDENTIFIER = "<your-agreement-proposal-identifier>" # Term ID for the ConfigurableUpfrontPricingTerm in the initial offer. CONFIGURABLE_UPFRONT_PRICING_TERM_ID = "<your-configurable-upfront-pricing-term-id>" # Duration for the agreement (e.g., "P365D" for 365 days). SELECTOR_VALUE = "<your-selector-value>" # Dimension key defined in the CUPT term. DIMENSION_1_KEY = "<your-dimension-key>" # Quantity for the dimension. DIMENSION_1_VALUE = 1 # Term ID for the UsageBasedPricingTerm in the initial offer. USAGE_TERM_ID = "<your-usage-term-id>" # Term ID for the LegalTerm in the initial offer. LEGAL_TERM_ID = "<your-legal-term-id>" # Term ID for the ValidityTerm in the initial offer. VALIDITY_TERM_ID = "<your-validity-term-id>" # The agreementProposalId from the new offer to replace to. NEW_AGREEMENT_PROPOSAL_IDENTIFIER = "<your-new-agreement-proposal-identifier>" # Term ID for the UsageBasedPricingTerm in the new offer. NEW_USAGE_TERM_ID = "<your-new-usage-term-id>" # Term ID for the LegalTerm in the new offer. NEW_LEGAL_TERM_ID = "<your-new-legal-term-id>" # Term ID for the ValidityTerm in the new offer. NEW_VALIDITY_TERM_ID = "<your-new-validity-term-id>" @staticmethod def replace_ami_usage_when_cupt_exists(): """ Full end-to-end flow: 1. Create and accept an agreement request with usageBasedPricingTerm, then wait for entitlements. 2. Create and accept an agreement request with CUPT, then wait for entitlements. 3. Replace the agreement with usageBasedPricingTerm with a new offer (agreement with CUPT is unaffected). """ client = boto3.client("marketplace-agreement") cls = ReplaceAmiUsageBasedPricingTermButNotCupt usage_term = {"id": cls.USAGE_TERM_ID} legal_term = {"id": cls.LEGAL_TERM_ID} validity_term = {"id": cls.VALIDITY_TERM_ID} # --- Step 1: Agreement with UBPT --- create_response = client.create_agreement_request( clientToken=generate_client_token(), intent="NEW", requestedTerms=[usage_term, legal_term, validity_term], agreementProposalIdentifier=cls.AGREEMENT_PROPOSAL_IDENTIFIER, ) agreement_request_id = create_response["agreementRequestId"] print("Agreement request with UBPT created. AgreementRequestId: " + agreement_request_id) accept_response = client.accept_agreement_request( agreementRequestId=agreement_request_id ) usage_agreement_id = accept_response["agreementId"] print("Agreement request with UBPT accepted. AgreementId: " + usage_agreement_id) # Wait for UBPT agreement entitlements to become active before creating the agreement with CUPT. print("Waiting for UBPT agreement entitlements to become active...") entitlements_response = poll_until_entitlements_available(client, usage_agreement_id) print("UBPT agreement entitlements are now active.") format_output(entitlements_response) # --- Step 2: Agreement with configurableUpfrontPricingTerm (CUPT) --- configurable_upfront_pricing_term = { "id": cls.CONFIGURABLE_UPFRONT_PRICING_TERM_ID, "configuration": { "configurableUpfrontPricingTermConfiguration": { "selectorValue": cls.SELECTOR_VALUE, "dimensions": [ { "dimensionKey": cls.DIMENSION_1_KEY, "dimensionValue": cls.DIMENSION_1_VALUE, }, ], } }, } car_response = client.create_agreement_request( clientToken=generate_client_token(), intent="NEW", requestedTerms=[configurable_upfront_pricing_term, legal_term, validity_term], agreementProposalIdentifier=cls.AGREEMENT_PROPOSAL_IDENTIFIER, ) print("Agreement request with CUPT created. AgreementRequestId: " + car_response["agreementRequestId"]) aar_response = client.accept_agreement_request( agreementRequestId=car_response["agreementRequestId"] ) cupt_agreement_id = aar_response["agreementId"] print("Agreement request with CUPT accepted. AgreementId: " + cupt_agreement_id) # Wait for CUPT agreement entitlements to become active before replacing usage. print("Waiting for CUPT agreement entitlements to become active...") cupt_entitlements_response = poll_until_entitlements_available(client, cupt_agreement_id) print("CUPT agreement entitlements are now active.") format_output(cupt_entitlements_response) # --- Step 3: Replace Agreement with usageBasedPricingTerm with a new offer --- new_usage_term = {"id": cls.NEW_USAGE_TERM_ID} new_legal_term = {"id": cls.NEW_LEGAL_TERM_ID} new_validity_term = {"id": cls.NEW_VALIDITY_TERM_ID} # Use Intent.REPLACE and sourceAgreementIdentifier pointing to the usageBasedPricingTerm agreement only. # The agreement with configurableUpfrontPricingTerm (CUPT) is NOT affected by this replacement. car_replace_response = client.create_agreement_request( clientToken=generate_client_token(), intent="REPLACE", requestedTerms=[new_usage_term, new_legal_term, new_validity_term], agreementProposalIdentifier=cls.NEW_AGREEMENT_PROPOSAL_IDENTIFIER, sourceAgreementIdentifier=usage_agreement_id, ) print("Replace agreement request created. AgreementRequestId: " + car_replace_response["agreementRequestId"]) aar_replace_response = client.accept_agreement_request( agreementRequestId=car_replace_response["agreementRequestId"] ) print("Agreement with UBPT replaced. New AgreementId: " + aar_replace_response["agreementId"]) if __name__ == "__main__": ReplaceAmiUsageBasedPricingTermButNotCupt.replace_ami_usage_when_cupt_exists()-
Pour plus de détails sur l'API, consultez CreateAgreementRequestle AWS manuel de référence de l'API SDK for Python (Boto3).
-