Doc AWS SDK Examples GitHub リポジトリには、他にも SDK の例があります。 AWS
翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
AWS SDK を使用して新しい AMI 無料トライアル契約を作成する
次のコード例は、新しい AMI 無料トライアル契約を作成する方法を示しています。
- Java
-
- SDK for Java 2.x
-
注記
GitHub には、その他のリソースもあります。AWS Marketplace API リファレンスコードライブラリ
リポジトリで完全な例を見つけて、設定と実行の方法を確認してください。 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.CreateAgreementRequestRequest; import software.amazon.awssdk.services.marketplaceagreement.model.CreateAgreementRequestResponse; import software.amazon.awssdk.services.marketplaceagreement.model.Intent; import software.amazon.awssdk.services.marketplaceagreement.model.RequestedTerm; import utils.AgreementApiUtils; /** * Demonstrates how to create an AMI Free Trial agreement * using the AWS Marketplace Agreement Service APIs. * * <p>Scenario: A buyer subscribes to an AMI product that offers a free trial period. * The free trial includes a FreeTrialPricingTerm alongside a UsageBasedPricingTerm. * * <p>Before running this sample, replace the placeholder constants below with values from * your AWS Marketplace offer: * <ul> * <li>{@code AGREEMENT_PROPOSAL_IDENTIFIER} — the agreementProposalId from the offer.</li> * <li>Term IDs (starting with {@code term-}) — found in the offer's term list.</li> * </ul> */ public class NewAmiFreeTrial { // The agreementProposalId from the offer. private static final String AGREEMENT_PROPOSAL_IDENTIFIER = "<your-agreement-proposal-identifier>"; // Term ID for the FreeTrialPricingTerm in your offer. private static final String FREE_TRIAL_PRICING_TERM_ID = "<your-free-trial-pricing-term-id>"; // Term ID for the UsageBasedPricingTerm in your offer (applies after the trial ends). private static final String USAGE_BASED_PRICING_TERM_ID = "<your-usage-based-pricing-term-id>"; // Term ID for the SupportTerm in your offer. private static final String SUPPORT_TERM_ID = "<your-support-term-id>"; // Term ID for the LegalTerm in your offer. private static final String LEGAL_TERM_ID = "<your-legal-term-id>"; public static void main(String[] args) { createAndAcceptAmiFreeTrialAgreementRequest(); } /** * Creates an AMI Free Trial agreement. * The FreeTrialPricingTerm grants access at no cost for the trial period. * The UsageBasedPricingTerm defines the charges that apply once the trial ends. */ private static void createAndAcceptAmiFreeTrialAgreementRequest() { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); RequestedTerm freeTrialPricingTerm = RequestedTerm.builder() .id(FREE_TRIAL_PRICING_TERM_ID) .build(); RequestedTerm usageBasedPricingTerm = RequestedTerm.builder() .id(USAGE_BASED_PRICING_TERM_ID) .build(); RequestedTerm supportTerm = RequestedTerm.builder() .id(SUPPORT_TERM_ID) .build(); RequestedTerm legalTerm = RequestedTerm.builder() .id(LEGAL_TERM_ID) .build(); CreateAgreementRequestRequest createAgreementRequestRequest = CreateAgreementRequestRequest.builder() .clientToken(AgreementApiUtils.generateClientToken()) .intent(Intent.NEW) .requestedTerms(freeTrialPricingTerm, usageBasedPricingTerm, supportTerm, legalTerm) .agreementProposalIdentifier(AGREEMENT_PROPOSAL_IDENTIFIER) .build(); CreateAgreementRequestResponse createAgreementRequestResponse = marketplaceAgreementClient.createAgreementRequest(createAgreementRequestRequest); System.out.println("Agreement request created. AgreementRequestId: " + createAgreementRequestResponse.agreementRequestId()); AcceptAgreementRequestRequest acceptAgreementRequestRequest = AcceptAgreementRequestRequest.builder() .agreementRequestId(createAgreementRequestResponse.agreementRequestId()) .build(); AcceptAgreementRequestResponse acceptAgreementRequestResponse = marketplaceAgreementClient.acceptAgreementRequest(acceptAgreementRequestRequest); System.out.println("Agreement request with freeTrialPricingTerm accepted. AgreementId: " + acceptAgreementRequestResponse.agreementId()); } }-
API の詳細については、AWS SDK for Java 2.x 「 API リファレンス」の「CreateAgreementRequest」を参照してください。
-
- JavaScript
-
- SDK for JavaScript (v3)
-
注記
GitHub には、その他のリソースもあります。AWS Marketplace API リファレンスコードライブラリ
リポジトリで完全な例を見つけて、設定と実行の方法を確認してください。 const { MarketplaceAgreementClient, CreateAgreementRequestCommand, AcceptAgreementRequestCommand, } = require("@aws-sdk/client-marketplace-agreement"); const { generateClientToken } = require("./utils/AgreementApiUtils"); /** * Demonstrates how to create an AMI Free Trial agreement * using the AWS Marketplace Agreement Service APIs. * * Scenario: A buyer subscribes to an AMI product that offers a free trial period. * The free trial includes a FreeTrialPricingTerm alongside a UsageBasedPricingTerm. * * Before running this sample, replace the placeholder constants below with values from * your AWS Marketplace offer: * - AGREEMENT_PROPOSAL_IDENTIFIER — the agreementProposalId from the offer. * - Term IDs (starting with "term-") — found in the offer's term list. */ // The agreementProposalId from the offer. const AGREEMENT_PROPOSAL_IDENTIFIER = "<your-agreement-proposal-identifier>"; // Term ID for the FreeTrialPricingTerm in your offer. const FREE_TRIAL_PRICING_TERM_ID = "<your-free-trial-pricing-term-id>"; // Term ID for the UsageBasedPricingTerm in your offer (applies after the trial ends). const USAGE_BASED_PRICING_TERM_ID = "<your-usage-based-pricing-term-id>"; // Term ID for the SupportTerm in your offer. const SUPPORT_TERM_ID = "<your-support-term-id>"; // Term ID for the LegalTerm in your offer. const LEGAL_TERM_ID = "<your-legal-term-id>"; /** * Creates an AMI Free Trial agreement. * The FreeTrialPricingTerm grants access at no cost for the trial period. * The UsageBasedPricingTerm defines the charges that apply once the trial ends. */ async function createAndAcceptAmiFreeTrialAgreementRequest() { const client = new MarketplaceAgreementClient(); const freeTrialPricingTerm = { id: FREE_TRIAL_PRICING_TERM_ID }; const usageBasedPricingTerm = { id: USAGE_BASED_PRICING_TERM_ID }; const supportTerm = { id: SUPPORT_TERM_ID }; const legalTerm = { id: LEGAL_TERM_ID }; const createAgreementRequestResponse = await client.send( new CreateAgreementRequestCommand({ clientToken: generateClientToken(), intent: "NEW", requestedTerms: [freeTrialPricingTerm, usageBasedPricingTerm, supportTerm, legalTerm], agreementProposalIdentifier: AGREEMENT_PROPOSAL_IDENTIFIER, }) ); console.log("Agreement request created. AgreementRequestId: " + createAgreementRequestResponse.agreementRequestId); const acceptAgreementRequestResponse = await client.send( new AcceptAgreementRequestCommand({ agreementRequestId: createAgreementRequestResponse.agreementRequestId, }) ); console.log("Agreement request with freeTrialPricingTerm accepted. AgreementId: " + acceptAgreementRequestResponse.agreementId); } createAndAcceptAmiFreeTrialAgreementRequest();-
API の詳細については、AWS SDK for JavaScript 「 API リファレンス」の「CreateAgreementRequest」を参照してください。
-
- Python
-
- SDK for Python (Boto3)
-
注記
GitHub には、その他のリソースもあります。AWS Marketplace API リファレンスコードライブラリ
リポジトリで完全な例を見つけて、設定と実行の方法を確認してください。 """ Demonstrates how to create an AMI Free Trial agreement using the AWS Marketplace Agreement Service APIs. Scenario: A buyer subscribes to an AMI product that offers a free trial period. The free trial includes a FreeTrialPricingTerm alongside a UsageBasedPricingTerm. Before running this sample, replace the placeholder constants below with values from your AWS Marketplace offer: - AGREEMENT_PROPOSAL_IDENTIFIER — the agreementProposalId from the offer. - Term IDs (starting with term-) — found in the offer's term list. """ import boto3 from utils.agreement_api_utils import generate_client_token class NewAmiFreeTrial: # The agreementProposalId from the offer. AGREEMENT_PROPOSAL_IDENTIFIER = "<your-agreement-proposal-identifier>" # Term ID for the FreeTrialPricingTerm in your offer. FREE_TRIAL_PRICING_TERM_ID = "<your-free-trial-pricing-term-id>" # Term ID for the UsageBasedPricingTerm in your offer (applies after the trial ends). USAGE_BASED_PRICING_TERM_ID = "<your-usage-based-pricing-term-id>" # Term ID for the SupportTerm in your offer. SUPPORT_TERM_ID = "<your-support-term-id>" # Term ID for the LegalTerm in your offer. LEGAL_TERM_ID = "<your-legal-term-id>" @staticmethod def create_and_accept_ami_free_trial_agreement_request(): """ Create an AMI Free Trial agreement. The FreeTrialPricingTerm grants access at no cost for the trial period. The UsageBasedPricingTerm defines the charges that apply once the trial ends. """ client = boto3.client("marketplace-agreement") create_response = client.create_agreement_request( clientToken=generate_client_token(), intent="NEW", requestedTerms=[ {"id": NewAmiFreeTrial.FREE_TRIAL_PRICING_TERM_ID}, {"id": NewAmiFreeTrial.USAGE_BASED_PRICING_TERM_ID}, {"id": NewAmiFreeTrial.SUPPORT_TERM_ID}, {"id": NewAmiFreeTrial.LEGAL_TERM_ID}, ], agreementProposalIdentifier=NewAmiFreeTrial.AGREEMENT_PROPOSAL_IDENTIFIER, ) agreement_request_id = create_response["agreementRequestId"] print("Agreement request created. AgreementRequestId: " + agreement_request_id) accept_response = client.accept_agreement_request( agreementRequestId=agreement_request_id ) print( "Agreement request with freeTrialPricingTerm accepted. AgreementId: " + accept_response["agreementId"] ) if __name__ == "__main__": NewAmiFreeTrial.create_and_accept_ami_free_trial_agreement_request()-
API の詳細については、 AWS SDK for Python (Boto3) API リファレンスの「CreateAgreementRequest」を参照してください。
-
使用料金モデルの AMI ConfigurableUpfrontPricingTerm を修正する
前払いで新しい SaaS 契約を作成する