View a markdown version of this page

AWS SDK를 사용하여 선결제로 새 SaaS 계약 생성 - AWS SDK 코드 예제

Doc AWS SDK 예제 GitHub 리포지토리에서 더 많은 SDK 예제를 사용할 수 있습니다. AWS

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

AWS SDK를 사용하여 선결제로 새 SaaS 계약 생성

다음 코드 예제에서는 선결제와 함께 새 SaaS 계약 계약을 생성하는 방법을 보여줍니다.

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.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.Intent; import software.amazon.awssdk.services.marketplaceagreement.model.RequestedTerm; import software.amazon.awssdk.services.marketplaceagreement.model.RequestedTermConfiguration; import software.amazon.awssdk.services.marketplaceagreement.model.TaxConfiguration; import utils.AgreementApiUtils; /** * Demonstrates how to create a SaaS agreement with CONTRACT pricing model with upfront payment * using the AWS Marketplace Agreement Service APIs. * * <p>Scenario: A buyer subscribes to a SaaS product using a ConfigurableUpfrontPricingTerm, * selecting an agreement duration and specifying quantities for multiple dimensions. * Tax estimation is enabled at the time of agreement creation. * * <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> * <li>{@code SELECTOR_VALUE} — duration for the agreement (e.g., {@code P12M} for 12 months).</li> * <li>{@code DIMENSION_1_KEY}, {@code DIMENSION_2_KEY} — dimension keys defined in the offer.</li> * <li>{@code DIMENSION_1_VALUE}, {@code DIMENSION_2_VALUE} — quantities for each dimension.</li> * </ul> */ public class NewSaaSContractWithUpfrontPayment { // The agreementProposalId from the offer. private static final String AGREEMENT_PROPOSAL_IDENTIFIER = "<your-agreement-proposal-identifier>"; // Term ID for the ConfigurableUpfrontPricingTerm in your offer. private static final String CONFIGURABLE_UPFRONT_PRICING_TERM_ID = "<your-configurable-upfront-pricing-term-id>"; // Duration for the agreement (e.g., "P12M" for 12 months). private static final String SELECTOR_VALUE = "<your-selector-value>"; // First dimension key and quantity defined in your offer. private static final String DIMENSION_1_KEY = "<your-dimension-1-key>"; private static final int DIMENSION_1_VALUE = 10; // Second dimension key and quantity defined in your offer. private static final String DIMENSION_2_KEY = "<your-dimension-2-key>"; private static final int DIMENSION_2_VALUE = 20; // Term ID for the LegalTerm in your offer. private static final String LEGAL_TERM_ID = "<your-legal-term-id>"; // Tax estimation setting: "ENABLED" to include estimated taxes in the agreement. private static final String TAX_ESTIMATION = "ENABLED"; public static void main(String[] args) { createSaaSContractAgreement(); } /** * Creates a SaaS agreement with CONTRACT pricing model with configurable upfront pricing * for multiple dimensions and tax estimation. */ private static void createSaaSContractAgreement() { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); 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(), Dimension.builder() .dimensionKey(DIMENSION_2_KEY) .dimensionValue(DIMENSION_2_VALUE) .build()) .build())) .build(); RequestedTerm legalTerm = RequestedTerm.builder() .id(LEGAL_TERM_ID) .build(); CreateAgreementRequestRequest createAgreementRequestRequest = CreateAgreementRequestRequest.builder() .clientToken(AgreementApiUtils.generateClientToken()) .intent(Intent.NEW) .requestedTerms(configurableUpfrontPricingTerm, legalTerm) .taxConfiguration(TaxConfiguration.builder().taxEstimation(TAX_ESTIMATION).build()) .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("SaaS agreement request with CONTRACT pricing model accepted. AgreementId: " + acceptAgreementRequestResponse.agreementId()); } }
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 a SaaS agreement with CONTRACT pricing model with upfront payment * using the AWS Marketplace Agreement Service APIs. * * Scenario: A buyer subscribes to a SaaS product using a ConfigurableUpfrontPricingTerm, * selecting an agreement duration and specifying quantities for multiple dimensions. * Tax estimation is enabled at the time of agreement creation. * * 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. * - SELECTOR_VALUE — duration for the agreement (e.g., "P12M" for 12 months). * - DIMENSION_1_KEY, DIMENSION_2_KEY — dimension keys defined in the offer. * - DIMENSION_1_VALUE, DIMENSION_2_VALUE — quantities for each dimension. */ // The agreementProposalId from the offer. const AGREEMENT_PROPOSAL_IDENTIFIER = "<your-agreement-proposal-identifier>"; // Term ID for the ConfigurableUpfrontPricingTerm in your offer. const CONFIGURABLE_UPFRONT_PRICING_TERM_ID = "<your-configurable-upfront-pricing-term-id>"; // Duration for the agreement (e.g., "P12M" for 12 months). const SELECTOR_VALUE = "<your-selector-value>"; // First dimension key and quantity defined in your offer. const DIMENSION_1_KEY = "<your-dimension-1-key>"; const DIMENSION_1_VALUE = 10; // Second dimension key and quantity defined in your offer. const DIMENSION_2_KEY = "<your-dimension-2-key>"; const DIMENSION_2_VALUE = 20; // Term ID for the LegalTerm in your offer. const LEGAL_TERM_ID = "<your-legal-term-id>"; // Tax estimation setting: "ENABLED" to include estimated taxes in the agreement. const TAX_ESTIMATION = "ENABLED"; /** * Creates a SaaS agreement with CONTRACT pricing model with configurable upfront pricing * for multiple dimensions and tax estimation. */ async function createSaaSContractAgreement() { const client = new MarketplaceAgreementClient(); const configurableUpfrontPricingTerm = { id: CONFIGURABLE_UPFRONT_PRICING_TERM_ID, configuration: { configurableUpfrontPricingTermConfiguration: { selectorValue: SELECTOR_VALUE, dimensions: [ { dimensionKey: DIMENSION_1_KEY, dimensionValue: DIMENSION_1_VALUE }, { dimensionKey: DIMENSION_2_KEY, dimensionValue: DIMENSION_2_VALUE }, ], }, }, }; const legalTerm = { id: LEGAL_TERM_ID }; const createAgreementRequestResponse = await client.send( new CreateAgreementRequestCommand({ clientToken: generateClientToken(), intent: "NEW", requestedTerms: [configurableUpfrontPricingTerm, legalTerm], taxConfiguration: { taxEstimation: TAX_ESTIMATION }, agreementProposalIdentifier: AGREEMENT_PROPOSAL_IDENTIFIER, }) ); console.log("Agreement request created. AgreementRequestId: " + createAgreementRequestResponse.agreementRequestId); const acceptAgreementRequestResponse = await client.send( new AcceptAgreementRequestCommand({ agreementRequestId: createAgreementRequestResponse.agreementRequestId, }) ); console.log("SaaS agreement request with CONTRACT pricing model accepted. AgreementId: " + acceptAgreementRequestResponse.agreementId); } createSaaSContractAgreement();
Python
SDK for Python(Boto3)
참고

GitHub에 더 많은 내용이 있습니다. AWS Marketplace API 참조 코드 라이브러리 리포지토리에서 전체 예제를 확인하고 설정 및 실행하는 방법을 알아보세요.

""" Demonstrates how to create a SaaS agreement with CONTRACT pricing model with upfront payment using the AWS Marketplace Agreement Service APIs. Scenario: A buyer subscribes to a SaaS product using a ConfigurableUpfrontPricingTerm, selecting an agreement duration and specifying quantities for multiple dimensions. Tax estimation is enabled at the time of agreement creation. 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. - SELECTOR_VALUE — duration for the agreement (e.g., P12M for 12 months). - DIMENSION_1_KEY, DIMENSION_2_KEY — dimension keys defined in the offer. - DIMENSION_1_VALUE, DIMENSION_2_VALUE — quantities for each dimension. """ import boto3 from utils.agreement_api_utils import generate_client_token class NewSaaSContractWithUpfrontPayment: # The agreementProposalId from the offer. AGREEMENT_PROPOSAL_IDENTIFIER = "<your-agreement-proposal-identifier>" # Term ID for the ConfigurableUpfrontPricingTerm in your offer. CONFIGURABLE_UPFRONT_PRICING_TERM_ID = "<your-configurable-upfront-pricing-term-id>" # Duration for the agreement (e.g., "P12M" for 12 months). SELECTOR_VALUE = "<your-selector-value>" # First dimension key and quantity defined in your offer. DIMENSION_1_KEY = "<your-dimension-1-key>" DIMENSION_1_VALUE = 10 # Second dimension key and quantity defined in your offer. DIMENSION_2_KEY = "<your-dimension-2-key>" DIMENSION_2_VALUE = 20 # Term ID for the LegalTerm in your offer. LEGAL_TERM_ID = "<your-legal-term-id>" # Tax estimation setting: "ENABLED" to include estimated taxes in the agreement. TAX_ESTIMATION = "ENABLED" @staticmethod def create_saas_contract_agreement(): """ Create a SaaS agreement with CONTRACT pricing model with configurable upfront pricing for multiple dimensions and tax estimation. """ client = boto3.client("marketplace-agreement") configurable_upfront_pricing_term = { "id": NewSaaSContractWithUpfrontPayment.CONFIGURABLE_UPFRONT_PRICING_TERM_ID, "configuration": { "configurableUpfrontPricingTermConfiguration": { "selectorValue": NewSaaSContractWithUpfrontPayment.SELECTOR_VALUE, "dimensions": [ { "dimensionKey": NewSaaSContractWithUpfrontPayment.DIMENSION_1_KEY, "dimensionValue": NewSaaSContractWithUpfrontPayment.DIMENSION_1_VALUE, }, { "dimensionKey": NewSaaSContractWithUpfrontPayment.DIMENSION_2_KEY, "dimensionValue": NewSaaSContractWithUpfrontPayment.DIMENSION_2_VALUE, }, ], } }, } legal_term = {"id": NewSaaSContractWithUpfrontPayment.LEGAL_TERM_ID} create_response = client.create_agreement_request( clientToken=generate_client_token(), intent="NEW", requestedTerms=[configurable_upfront_pricing_term, legal_term], taxConfiguration={"taxEstimation": NewSaaSContractWithUpfrontPayment.TAX_ESTIMATION}, agreementProposalIdentifier=NewSaaSContractWithUpfrontPayment.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( "SaaS agreement request with CONTRACT pricing model accepted. AgreementId: " + accept_response["agreementId"] ) if __name__ == "__main__": NewSaaSContractWithUpfrontPayment.create_saas_contract_agreement()