Weitere AWS SDK Beispiele sind im Repo AWS Doc SDK Examples
Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.
AWS Marketplace APIBeispiele für Vereinbarungen, die SDK für Java 2.x verwendet werden
Die folgenden Codebeispiele zeigen Ihnen, wie Sie mithilfe von AWS SDK for Java 2.x with AWS Marketplace Agreement Aktionen ausführen und allgemeine Szenarien implementierenAPI.
Jedes Beispiel enthält einen Link zum vollständigen Quellcode, in dem Sie Anweisungen zum Einrichten und Ausführen des Codes im Kontext finden.
Themen
Vereinbarungen
Das folgende Codebeispiel zeigt, wie Sie alle Vereinbarungen abrufen könnenIDs.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package com.example.awsmarketplace.agreementapi; 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.AgreementViewSummary; import software.amazon.awssdk.services.marketplaceagreement.model.Filter; import software.amazon.awssdk.services.marketplaceagreement.model.SearchAgreementsRequest; import software.amazon.awssdk.services.marketplaceagreement.model.SearchAgreementsResponse; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import static com.example.awsmarketplace.utils.ReferenceCodesConstants.*; import com.example.awsmarketplace.utils.ReferenceCodesUtils; public class GetAllAgreementsIds { /* * Get all purchase agreements ids with party type = proposer; * Depend on the number of agreements in your account, this code may take some time to finish. */ public static void main(String[] args) { List<String> agreementIds = getAllAgreementIds(); ReferenceCodesUtils.formatOutput(agreementIds); } public static List<String> getAllAgreementIds() { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); // get all filters Filter partyType = Filter.builder().name(PARTY_TYPE_FILTER_NAME) .values(PARTY_TYPE_FILTER_VALUE_PROPOSER).build(); Filter agreementType = Filter.builder().name(AGREEMENT_TYPE_FILTER_NAME) .values(AGREEMENT_TYPE_FILTER_VALUE_PURCHASEAGREEMENT).build(); List<Filter> searchFilters = new ArrayList<Filter>(); searchFilters.addAll(Arrays.asList(partyType, agreementType)); // Save all results in a list array List<AgreementViewSummary> agreementSummaryList = new ArrayList<AgreementViewSummary>(); SearchAgreementsRequest searchAgreementsRequest = SearchAgreementsRequest.builder() .catalog(AWS_MP_CATALOG) .filters(searchFilters) .build(); SearchAgreementsResponse searchAgreementsResponse = marketplaceAgreementClient.searchAgreements(searchAgreementsRequest); agreementSummaryList.addAll(searchAgreementsResponse.agreementViewSummaries()); while (searchAgreementsResponse.nextToken() != null && searchAgreementsResponse.nextToken().length() > 0) { searchAgreementsRequest = SearchAgreementsRequest.builder() .catalog(AWS_MP_CATALOG) .nextToken(searchAgreementsResponse.nextToken()) .filters(searchFilters) .build(); searchAgreementsResponse = marketplaceAgreementClient.searchAgreements(searchAgreementsRequest); agreementSummaryList.addAll(searchAgreementsResponse.agreementViewSummaries()); } List<String> agreementIds = new ArrayList<String>(); for (AgreementViewSummary summary : agreementSummaryList) { agreementIds.add(summary.agreementId()); } return agreementIds; } }
-
APIEinzelheiten finden Sie SearchAgreementsunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie alle Vereinbarungen abrufen können.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package com.example.awsmarketplace.agreementapi; 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.AgreementViewSummary; import software.amazon.awssdk.services.marketplaceagreement.model.Filter; import software.amazon.awssdk.services.marketplaceagreement.model.SearchAgreementsRequest; import software.amazon.awssdk.services.marketplaceagreement.model.SearchAgreementsResponse; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import static com.example.awsmarketplace.utils.ReferenceCodesConstants.*; import com.example.awsmarketplace.utils.ReferenceCodesUtils; public class GetAllAgreements { /* * Get all purchase agreements with party type = proposer; * Depend on the number of agreements in your account, this code may take some time to finish. */ public static void main(String[] args) { List<AgreementViewSummary> agreementSummaryList = getAllAgreements(); ReferenceCodesUtils.formatOutput(agreementSummaryList); } public static List<AgreementViewSummary> getAllAgreements() { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); // get all filters Filter partyType = Filter.builder().name(PARTY_TYPE_FILTER_NAME) .values(PARTY_TYPE_FILTER_VALUE_PROPOSER).build(); Filter agreementType = Filter.builder().name(AGREEMENT_TYPE_FILTER_NAME) .values(AGREEMENT_TYPE_FILTER_VALUE_PURCHASEAGREEMENT).build(); List<Filter> searchFilters = new ArrayList<Filter>(); searchFilters.addAll(Arrays.asList(partyType, agreementType)); // Save all results in a list array List<AgreementViewSummary> agreementSummaryList = new ArrayList<AgreementViewSummary>(); SearchAgreementsRequest searchAgreementsRequest = SearchAgreementsRequest.builder() .catalog(AWS_MP_CATALOG) .filters(searchFilters) .build(); SearchAgreementsResponse searchAgreementsResponse = marketplaceAgreementClient.searchAgreements(searchAgreementsRequest); agreementSummaryList.addAll(searchAgreementsResponse.agreementViewSummaries()); while (searchAgreementsResponse.nextToken() != null && searchAgreementsResponse.nextToken().length() > 0) { searchAgreementsRequest = SearchAgreementsRequest.builder() .catalog(AWS_MP_CATALOG) .nextToken(searchAgreementsResponse.nextToken()) .filters(searchFilters).build(); searchAgreementsResponse = marketplaceAgreementClient.searchAgreements(searchAgreementsRequest); agreementSummaryList.addAll(searchAgreementsResponse.agreementViewSummaries()); } return agreementSummaryList; } }
-
APIEinzelheiten finden Sie SearchAgreementsunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie die Kundennummer aus einer Vereinbarung abrufen können.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // 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 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 GetAgreementCustomerInfo { /* * Obtain metadata about the customer who created the agreement, such as the customer's AWS Account ID */ public static void main(String[] args) { String agreementId = args.length > 0 ? args[0] : AGREEMENT_ID; DescribeAgreementResponse describeAgreementResponse = getDescribeAgreementResponse(agreementId); System.out.println("Customer's AWS Account ID is " + describeAgreementResponse.acceptor().accountId()); } public static DescribeAgreementResponse getDescribeAgreementResponse(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; } }
-
APIEinzelheiten finden Sie DescribeAgreementunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie finanzielle Details aus einer Vereinbarung abgerufen werden.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // 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 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 GetAgreementFinancialDetails { /* * Obtain financial details, such as Total Contract Value of the agreement from a given agreement */ public static void main(String[] args) { String agreementId = args.length > 0 ? args[0] : AGREEMENT_ID; String totalContractValue = getTotalContractValue(agreementId); System.out.println("Total Contract Value is " + totalContractValue); } public static String getTotalContractValue(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); String totalContractValue = "N/A"; if ( describeAgreementResponse.estimatedCharges() != null ) { totalContractValue = describeAgreementResponse.estimatedCharges().agreementValue() + " " + describeAgreementResponse.estimatedCharges().currencyCode(); } return totalContractValue; } }
-
APIEinzelheiten finden Sie DescribeAgreementunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie Details zur kostenlosen Testversion aus einer Vereinbarung abrufen können.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package com.example.awsmarketplace.agreementapi; 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.AcceptedTerm; import software.amazon.awssdk.services.marketplaceagreement.model.FreeTrialPricingTerm; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsRequest; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsResponse; import static com.example.awsmarketplace.utils.ReferenceCodesConstants.AGREEMENT_ID; import java.util.ArrayList; import java.util.List; import com.example.awsmarketplace.utils.ReferenceCodesUtils; public class GetAgreementTermsFreeTrialDetails { /* * Obtain the details from an agreement of a free trial I have provided to the customer */ public static void main(String[] args) { String agreementId = args.length > 0 ? args[0] : AGREEMENT_ID; List<FreeTrialPricingTerm> freeTrialPricingTerms = getFreeTrialPricingTerms(agreementId); ReferenceCodesUtils.formatOutput(freeTrialPricingTerms); } public static List<FreeTrialPricingTerm> getFreeTrialPricingTerms(String agreementId) { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); GetAgreementTermsRequest getAgreementTermsRequest = GetAgreementTermsRequest.builder().agreementId(agreementId) .build(); GetAgreementTermsResponse getAgreementTermsResponse = marketplaceAgreementClient.getAgreementTerms(getAgreementTermsRequest); List<FreeTrialPricingTerm> freeTrialPricingTerms = new ArrayList<FreeTrialPricingTerm>(); for (AcceptedTerm acceptedTerm : getAgreementTermsResponse.acceptedTerms()) { if (acceptedTerm.freeTrialPricingTerm() != null) { freeTrialPricingTerms.add(acceptedTerm.freeTrialPricingTerm()); } } return freeTrialPricingTerms; } }
-
APIEinzelheiten finden Sie DescribeAgreementunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie Informationen zu einer Vereinbarung abrufen.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // 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; } }
-
APIEinzelheiten finden Sie DescribeAgreementunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie Produkt- und Angebotsdetails aus einer Vereinbarung abrufen.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package com.example.awsmarketplace.agreementapi; 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; import software.amazon.awssdk.services.marketplaceagreement.model.Resource; import java.util.ArrayList; import java.util.List; import static com.example.awsmarketplace.utils.ReferenceCodesConstants.*; import com.example.awsmarketplace.utils.ReferenceCodesUtils; import software.amazon.awssdk.services.marketplacecatalog.MarketplaceCatalogClient; import software.amazon.awssdk.services.marketplacecatalog.model.DescribeEntityRequest; import software.amazon.awssdk.services.marketplacecatalog.model.DescribeEntityResponse; public class GetProductAndOfferDetailFromAgreement { public static void main(String[] args) { // call Agreement API to get offer and product information for the agreement String agreementId = args.length > 0 ? args[0] : AGREEMENT_ID; List<DescribeEntityResponse> entityResponseList = getEntities(agreementId); for (DescribeEntityResponse response : entityResponseList) { ReferenceCodesUtils.formatOutput(response); } } public static List<DescribeEntityResponse> getEntities(String agreementId) { List<DescribeEntityResponse> entityResponseList = new ArrayList<DescribeEntityResponse> (); MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); DescribeAgreementRequest describeAgreementRequest = DescribeAgreementRequest.builder() .agreementId(agreementId) .build(); DescribeAgreementResponse describeAgreementResponse = marketplaceAgreementClient.describeAgreement(describeAgreementRequest); // get offer id for the given agreement String offerId = describeAgreementResponse.proposalSummary().offerId(); // get all the product ids for this agreement List<String> productIds = new ArrayList<String>(); for (Resource resource : describeAgreementResponse.proposalSummary().resources()) { productIds.add(resource.id()); } // call Catalog API to get the details of the offer and products MarketplaceCatalogClient marketplaceCatalogClient = MarketplaceCatalogClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); DescribeEntityRequest describeEntityRequest = DescribeEntityRequest.builder() .catalog(AWS_MP_CATALOG) .entityId(offerId).build(); DescribeEntityResponse describeEntityResponse = marketplaceCatalogClient.describeEntity(describeEntityRequest); entityResponseList.add(describeEntityResponse); for (String productId : productIds) { describeEntityRequest = DescribeEntityRequest.builder() .catalog(AWS_MP_CATALOG) .entityId(productId).build(); describeEntityResponse = marketplaceCatalogClient.describeEntity(describeEntityRequest); System.out.println("Print details for product " + productId); entityResponseList.add(describeEntityResponse); } return entityResponseList; } }
-
APIEinzelheiten finden Sie DescribeAgreementunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie eine Vereinbarung abschließen können. EULA
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package com.example.awsmarketplace.agreementapi; 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.DocumentItem; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsRequest; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsResponse; import java.util.ArrayList; import java.util.List; import static com.example.awsmarketplace.utils.ReferenceCodesConstants.AGREEMENT_ID; import com.example.awsmarketplace.utils.ReferenceCodesUtils; public class GetAgreementTermsEula { /* * Obtain the EULA I have entered into with my customer via the agreement */ public static void main(String[] args) { String agreementId = args.length > 0 ? args[0] : AGREEMENT_ID; List<DocumentItem> legalEulaArray = getLegalEula(agreementId); ReferenceCodesUtils.formatOutput(legalEulaArray); } public static List<DocumentItem> getLegalEula(String agreementId) { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); GetAgreementTermsRequest getAgreementTermsRequest = GetAgreementTermsRequest.builder().agreementId(agreementId) .build(); GetAgreementTermsResponse getAgreementTermsResponse = marketplaceAgreementClient.getAgreementTerms(getAgreementTermsRequest); List<DocumentItem> legalEulaArray = new ArrayList<>(); getAgreementTermsResponse.acceptedTerms().stream() .filter(acceptedTerm -> acceptedTerm.legalTerm() != null && acceptedTerm.legalTerm().hasDocuments()) .flatMap(acceptedTerm -> acceptedTerm.legalTerm().documents().stream()) .filter(docItem -> docItem.type() != null) .forEach(legalEulaArray::add); return legalEulaArray; } }
-
APIEinzelheiten finden Sie GetAgreementTermsunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie die Bedingungen für die auto Verlängerung einer Vereinbarung abrufen können.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // 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 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.AcceptedTerm; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsRequest; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsResponse; public class GetAgreementAutoRenewal { /* * Obtain the auto-renewal status of the agreement */ public static void main(String[] args) { String agreementId = args.length > 0 ? args[0] : AGREEMENT_ID; String autoRenewal = getAutoRenewal(agreementId); System.out.println("Auto-Renewal status is " + autoRenewal); } public static String getAutoRenewal(String agreementId) { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); GetAgreementTermsRequest getAgreementTermsRequest = GetAgreementTermsRequest.builder() .agreementId(agreementId) .build(); GetAgreementTermsResponse getAgreementTermsResponse = marketplaceAgreementClient.getAgreementTerms(getAgreementTermsRequest); String autoRenewal = "No Auto Renewal"; for (AcceptedTerm acceptedTerm : getAgreementTermsResponse.acceptedTerms()) { if (acceptedTerm.renewalTerm() != null && acceptedTerm.renewalTerm().configuration() != null && acceptedTerm.renewalTerm().configuration().enableAutoRenew() != null) { autoRenewal = String.valueOf(acceptedTerm.renewalTerm().configuration().enableAutoRenew().booleanValue()); break; } } return autoRenewal; } }
-
APIEinzelheiten finden Sie GetAgreementTermsunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie die im Rahmen einer Vereinbarung erworbenen Dimensionen erhalten.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package com.example.awsmarketplace.agreementapi; 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.AcceptedTerm; import software.amazon.awssdk.services.marketplaceagreement.model.Dimension; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsRequest; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsResponse; import java.util.ArrayList; import java.util.List; import static com.example.awsmarketplace.utils.ReferenceCodesConstants.AGREEMENT_ID; import com.example.awsmarketplace.utils.ReferenceCodesUtils; public class GetAgreementTermsDimensionPurchased { /* * Obtain the dimensions the buyer has purchased from me via the agreement */ public static void main(String[] args) { String agreementId = args.length > 0 ? args[0] : AGREEMENT_ID; List<String> dimensionKeys = getDimensionKeys(agreementId); ReferenceCodesUtils.formatOutput(dimensionKeys); } public static List<String> getDimensionKeys(String agreementId) { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); GetAgreementTermsRequest getAgreementTermsRequest = GetAgreementTermsRequest.builder().agreementId(agreementId) .build(); GetAgreementTermsResponse getAgreementTermsResponse = marketplaceAgreementClient.getAgreementTerms(getAgreementTermsRequest); List<String> dimensionKeys = new ArrayList<String>(); for (AcceptedTerm acceptedTerm : getAgreementTermsResponse.acceptedTerms()) { if (acceptedTerm.configurableUpfrontPricingTerm() != null) { if (acceptedTerm.configurableUpfrontPricingTerm().configuration().selectorValue() != null) { List<Dimension> dimensions = acceptedTerm.configurableUpfrontPricingTerm().configuration().dimensions(); for (Dimension dimension : dimensions) { dimensionKeys.add(dimension.dimensionKey()); } } } } return dimensionKeys; } }
-
APIEinzelheiten finden Sie GetAgreementTermsunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie die Instanzen jeder Dimension abrufen, die in einer Vereinbarung erworben wurden.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package com.example.awsmarketplace.agreementapi; 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.AcceptedTerm; import software.amazon.awssdk.services.marketplaceagreement.model.Dimension; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsRequest; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsResponse; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.example.awsmarketplace.utils.ReferenceCodesConstants.AGREEMENT_ID; import com.example.awsmarketplace.utils.ReferenceCodesUtils; public class GetAgreementTermsDimensionInstances { /* * get instances of each dimension that buyer has purchased in the agreement */ public static void main(String[] args) { String agreementId = args.length > 0 ? args[0] : AGREEMENT_ID; Map<String, List<Dimension>> dimensionMap = getDimensions(agreementId); ReferenceCodesUtils.formatOutput(dimensionMap); } public static Map<String, List<Dimension>> getDimensions(String agreementId) { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); GetAgreementTermsRequest getAgreementTermsRequest = GetAgreementTermsRequest.builder().agreementId(agreementId) .build(); GetAgreementTermsResponse getAgreementTermsResponse = marketplaceAgreementClient.getAgreementTerms(getAgreementTermsRequest); Map<String, List<Dimension>> dimensionMap = new HashMap<String, List<Dimension>>(); for (AcceptedTerm acceptedTerm : getAgreementTermsResponse.acceptedTerms()) { List<Dimension> dimensionsList = new ArrayList<Dimension>(); if (acceptedTerm.configurableUpfrontPricingTerm() != null) { String selectorValue = ""; if (acceptedTerm.configurableUpfrontPricingTerm().configuration() != null) { if (acceptedTerm.configurableUpfrontPricingTerm().configuration().selectorValue() != null) { selectorValue = acceptedTerm.configurableUpfrontPricingTerm().configuration().selectorValue(); } if (acceptedTerm.configurableUpfrontPricingTerm().configuration().hasDimensions()) { dimensionsList = acceptedTerm.configurableUpfrontPricingTerm().configuration().dimensions(); } } if (selectorValue.length() > 0) { dimensionMap.put(selectorValue, dimensionsList); } } } return dimensionMap; } }
-
APIEinzelheiten finden Sie GetAgreementTermsunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie den Zahlungsplan einer Vereinbarung abrufen können.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package com.example.awsmarketplace.agreementapi; 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.AcceptedTerm; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsRequest; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsResponse; import software.amazon.awssdk.services.marketplaceagreement.model.PaymentScheduleTerm; import software.amazon.awssdk.services.marketplaceagreement.model.ScheduleItem; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.example.awsmarketplace.utils.ReferenceCodesConstants.*; import com.example.awsmarketplace.utils.ReferenceCodesUtils; public class GetAgreementTermsPaymentSchedule { /* * Obtain the payment schedule I have agreed to with the agreement, including the invoice date and invoice amount */ public static void main(String[] args) { String agreementId = args.length > 0 ? args[0] : AGREEMENT_ID; List<Map<String, Object>> paymentScheduleArray = getPaymentSchedules(agreementId); ReferenceCodesUtils.formatOutput(paymentScheduleArray); } public static List<Map<String, Object>> getPaymentSchedules(String agreementId) { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); GetAgreementTermsRequest getAgreementTermsRequest = GetAgreementTermsRequest.builder().agreementId(agreementId) .build(); GetAgreementTermsResponse getAgreementTermsResponse = marketplaceAgreementClient.getAgreementTerms(getAgreementTermsRequest); List<Map<String, Object>> paymentScheduleArray = new ArrayList<>(); String currencyCode = ""; for (AcceptedTerm acceptedTerm : getAgreementTermsResponse.acceptedTerms()) { if (acceptedTerm.paymentScheduleTerm() != null) { PaymentScheduleTerm paymentScheduleTerm = acceptedTerm.paymentScheduleTerm(); if (paymentScheduleTerm.currencyCode() != null) { currencyCode = paymentScheduleTerm.currencyCode(); } if (paymentScheduleTerm.hasSchedule()) { for (ScheduleItem schedule : paymentScheduleTerm.schedule()) { if (schedule.chargeDate() != null) { String chargeDate = schedule.chargeDate().toString(); String chargeAmount = schedule.chargeAmount(); Map<String, Object> scheduleMap = new HashMap<>(); scheduleMap.put(ATTRIBUTE_CURRENCY_CODE, currencyCode); scheduleMap.put(ATTRIBUTE_CHARGE_DATE, chargeDate); scheduleMap.put(ATTRIBUTE_CHARGE_AMOUNT, chargeAmount); paymentScheduleArray.add(scheduleMap); } } } } } return paymentScheduleArray; } }
-
APIEinzelheiten finden Sie GetAgreementTermsunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie die Preise pro Dimension in einer Vereinbarung ermitteln.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package com.example.awsmarketplace.agreementapi; 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.AcceptedTerm; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsRequest; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsResponse; import java.util.ArrayList; import java.util.List; import static com.example.awsmarketplace.utils.ReferenceCodesConstants.AGREEMENT_ID; import com.example.awsmarketplace.utils.ReferenceCodesUtils; public class GetAgreementTermsPricingEachDimension { /* * Obtain pricing per each dimension in the agreement */ public static void main(String[] args) { String agreementId = args.length > 0 ? args[0] : AGREEMENT_ID; List<Object> dimensions = getDimensions(agreementId); ReferenceCodesUtils.formatOutput(dimensions); } public static List<Object> getDimensions(String agreementId) { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); GetAgreementTermsRequest getAgreementTermsRequest = GetAgreementTermsRequest.builder().agreementId(agreementId) .build(); GetAgreementTermsResponse getAgreementTermsResponse = marketplaceAgreementClient.getAgreementTerms(getAgreementTermsRequest); List<Object> dimensions = new ArrayList<Object>(); for (AcceptedTerm acceptedTerm : getAgreementTermsResponse.acceptedTerms()) { List<Object> rateInfo = new ArrayList<Object>(); if (acceptedTerm.configurableUpfrontPricingTerm() != null) { if (acceptedTerm.configurableUpfrontPricingTerm().type() != null) { rateInfo.add(acceptedTerm.configurableUpfrontPricingTerm().type()); } if (acceptedTerm.configurableUpfrontPricingTerm().currencyCode() != null) { rateInfo.add(acceptedTerm.configurableUpfrontPricingTerm().currencyCode()); } if (acceptedTerm.configurableUpfrontPricingTerm().hasRateCards()) { rateInfo.add(acceptedTerm.configurableUpfrontPricingTerm().rateCards()); } dimensions.add(rateInfo); } } return dimensions; } }
-
APIEinzelheiten finden Sie GetAgreementTermsunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie den Preistyp einer Vereinbarung ermitteln.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package com.example.awsmarketplace.agreementapi; 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.AcceptedTerm; import software.amazon.awssdk.services.marketplaceagreement.model.AgreementViewSummary; import software.amazon.awssdk.services.marketplaceagreement.model.Filter; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsRequest; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsResponse; import software.amazon.awssdk.services.marketplaceagreement.model.SearchAgreementsRequest; import software.amazon.awssdk.services.marketplaceagreement.model.SearchAgreementsResponse; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import org.apache.commons.lang3.tuple.Triple; import software.amazon.awssdk.services.marketplacecatalog.MarketplaceCatalogClient; import software.amazon.awssdk.services.marketplacecatalog.model.DescribeEntityRequest; import software.amazon.awssdk.services.marketplacecatalog.model.DescribeEntityResponse; import static com.example.awsmarketplace.utils.ReferenceCodesConstants.*; import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; /* * Obtain the pricing type of the agreement (contract, FPS, metered, free etc.) */ public class GetAgreementPricingType { private static final String FILTER_NAME = "OfferId"; private static final String FILTER_VALUE = OFFER_ID; // Product types private static final String SAAS_PRODUCT = "SaaSProduct"; private static final String AMI_PRODUCT = "AmiProduct"; private static final String ML_PRODUCT = "MachineLearningProduct"; private static final String CONTAINER_PRODUCT = "ContainerProduct"; private static final String DATA_PRODUCT = "DataProduct"; private static final String PROSERVICE_PRODUCT = "ProfessionalServicesProduct"; private static final String AIQ_PRODUCT = "AiqProduct"; // Pricing types private static final String CCP = "CCP"; private static final String ANNUAL = "Annual"; private static final String CONTRACT = "Contract"; private static final String SFT = "SaaS Free Trial"; private static final String HMA = "Hourly and Monthly Agreements"; private static final String HOURLY = "Hourly"; private static final String MONTHLY = "Monthly"; private static final String AFPS = "Annual FPS"; private static final String CFPS = "Contract FPS"; private static final String CCPFPS = "CCP with FPS"; private static final String BYOL = "BYOL"; private static final String FREE = "Free"; private static final String FTH = "Free Trials and Hourly"; // Agreement term pricing types private static final Set<String> LEGAL = Set.of("LegalTerm"); private static final Set<String> CONFIGURABLE_UPFRONT = Set.of("ConfigurableUpfrontPricingTerm"); private static final Set<String> USAGE_BASED = Set.of("UsageBasedPricingTerm"); private static final Set<String> CONFIGURABLE_UPFRONT_AND_USAGE_BASED = Set.of("ConfigurableUpfrontPricingTerm", "UsageBasedPricingTerm"); private static final Set<String> FREE_TRIAL = Set.of("FreeTrialPricingTerm"); private static final Set<String> RECURRING_PAYMENT = Set.of("RecurringPaymentTerm"); private static final Set<String> USAGE_BASED_AND_RECURRING_PAYMENT = Set.of("UsageBasedPricingTerm", "RecurringPaymentTerm"); private static final Set<String> FIXED_UPFRONT_AND_PAYMENT_SCHEDULE = Set.of("FixedUpfrontPricingTerm", "PaymentScheduleTerm"); private static final Set<String> FIXED_UPFRONT_AND_PAYMENT_SCHEDULE_AND_USAGE_BASED = Set.of("FixedUpfrontPricingTerm", "PaymentScheduleTerm", "UsageBasedPricingTerm"); private static final Set<String> BYOL_PRICING = Set.of("ByolPricingTerm"); private static final Set<String> FREE_TRIAL_AND_USAGE_BASED = Set.of("FreeTrialPricingTerm", "UsageBasedPricingTerm"); private static final List<Set<String>> ALL_AGREEMENT_TERM_TYPES_COMBINATION = Arrays.asList(LEGAL, CONFIGURABLE_UPFRONT, USAGE_BASED, CONFIGURABLE_UPFRONT_AND_USAGE_BASED, FREE_TRIAL, RECURRING_PAYMENT, USAGE_BASED_AND_RECURRING_PAYMENT, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE_AND_USAGE_BASED, BYOL_PRICING, FREE_TRIAL_AND_USAGE_BASED); private static MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); private static MarketplaceCatalogClient marketplaceCatalogClient = MarketplaceCatalogClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); /* * Get agreement Pricing Type given product type, agreement term types and offer types if needed */ public static String getPricingType(String productType, Set<String> agreementTermType, Set<String> offerType) { Map<Triple<String, Set<String>, Set<String>>, String> pricingTypes = new HashMap<>(); pricingTypes.put(Triple.of(SAAS_PRODUCT, CONFIGURABLE_UPFRONT_AND_USAGE_BASED, new HashSet<>()), CCP); pricingTypes.put(Triple.of(DATA_PRODUCT, CONFIGURABLE_UPFRONT_AND_USAGE_BASED, new HashSet<>()), CCP); pricingTypes.put(Triple.of(CONTAINER_PRODUCT, CONFIGURABLE_UPFRONT, CONFIGURABLE_UPFRONT_AND_USAGE_BASED), ANNUAL); pricingTypes.put(Triple.of(AMI_PRODUCT, CONFIGURABLE_UPFRONT, CONFIGURABLE_UPFRONT_AND_USAGE_BASED), ANNUAL); pricingTypes.put(Triple.of(ML_PRODUCT, CONFIGURABLE_UPFRONT, CONFIGURABLE_UPFRONT_AND_USAGE_BASED), ANNUAL); pricingTypes.put(Triple.of(CONTAINER_PRODUCT, CONFIGURABLE_UPFRONT, CONFIGURABLE_UPFRONT), CONTRACT); pricingTypes.put(Triple.of(AMI_PRODUCT, CONFIGURABLE_UPFRONT, CONFIGURABLE_UPFRONT), CONTRACT); pricingTypes.put(Triple.of(SAAS_PRODUCT, CONFIGURABLE_UPFRONT, new HashSet<>()), CONTRACT); pricingTypes.put(Triple.of(DATA_PRODUCT, CONFIGURABLE_UPFRONT, new HashSet<>()), CONTRACT); pricingTypes.put(Triple.of(AIQ_PRODUCT, CONFIGURABLE_UPFRONT, new HashSet<>()), CONTRACT); pricingTypes.put(Triple.of(PROSERVICE_PRODUCT, CONFIGURABLE_UPFRONT, new HashSet<>()), CONTRACT); pricingTypes.put(Triple.of(SAAS_PRODUCT, FREE_TRIAL, new HashSet<>()), SFT); pricingTypes.put(Triple.of(AMI_PRODUCT, USAGE_BASED_AND_RECURRING_PAYMENT, new HashSet<>()), HMA); pricingTypes.put(Triple.of(SAAS_PRODUCT, USAGE_BASED, new HashSet<>()), HOURLY); pricingTypes.put(Triple.of(AMI_PRODUCT, USAGE_BASED, new HashSet<>()), HOURLY); pricingTypes.put(Triple.of(ML_PRODUCT, USAGE_BASED, new HashSet<>()), HOURLY); pricingTypes.put(Triple.of(CONTAINER_PRODUCT, RECURRING_PAYMENT, new HashSet<>()), MONTHLY); pricingTypes.put(Triple.of(AMI_PRODUCT, RECURRING_PAYMENT, new HashSet<>()), MONTHLY); pricingTypes.put(Triple.of(CONTAINER_PRODUCT, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE_AND_USAGE_BASED), AFPS); pricingTypes.put(Triple.of(AMI_PRODUCT, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE_AND_USAGE_BASED), AFPS); pricingTypes.put(Triple.of(ML_PRODUCT, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE, new HashSet<>()), AFPS); pricingTypes.put(Triple.of(CONTAINER_PRODUCT, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE, new HashSet<>()), CFPS); pricingTypes.put(Triple.of(AMI_PRODUCT, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE), CFPS); pricingTypes.put(Triple.of(SAAS_PRODUCT, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE, new HashSet<>()), CFPS); pricingTypes.put(Triple.of(DATA_PRODUCT, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE, new HashSet<>()), CFPS); pricingTypes.put(Triple.of(AIQ_PRODUCT, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE, new HashSet<>()), CFPS); pricingTypes.put(Triple.of(PROSERVICE_PRODUCT, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE, new HashSet<>()), CFPS); pricingTypes.put(Triple.of(SAAS_PRODUCT, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE_AND_USAGE_BASED, new HashSet<>()), CCPFPS); pricingTypes.put(Triple.of(DATA_PRODUCT, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE_AND_USAGE_BASED, new HashSet<>()), CCPFPS); pricingTypes.put(Triple.of(AIQ_PRODUCT, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE_AND_USAGE_BASED, new HashSet<>()), CCPFPS); pricingTypes.put(Triple.of(PROSERVICE_PRODUCT, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE_AND_USAGE_BASED, new HashSet<>()), CCPFPS); pricingTypes.put(Triple.of(AMI_PRODUCT, BYOL_PRICING, new HashSet<>()), BYOL); pricingTypes.put(Triple.of(SAAS_PRODUCT, BYOL_PRICING, new HashSet<>()), BYOL); pricingTypes.put(Triple.of(PROSERVICE_PRODUCT, BYOL_PRICING, new HashSet<>()), BYOL); pricingTypes.put(Triple.of(AIQ_PRODUCT, BYOL_PRICING, new HashSet<>()), BYOL); pricingTypes.put(Triple.of(ML_PRODUCT, BYOL_PRICING, new HashSet<>()), BYOL); pricingTypes.put(Triple.of(CONTAINER_PRODUCT, BYOL_PRICING, new HashSet<>()), BYOL); pricingTypes.put(Triple.of(DATA_PRODUCT, BYOL_PRICING, new HashSet<>()), BYOL); pricingTypes.put(Triple.of(CONTAINER_PRODUCT, LEGAL, new HashSet<>()), FREE); pricingTypes.put(Triple.of(AMI_PRODUCT, FREE_TRIAL_AND_USAGE_BASED, new HashSet<>()), FTH); pricingTypes.put(Triple.of(CONTAINER_PRODUCT, FREE_TRIAL_AND_USAGE_BASED, new HashSet<>()), FTH); pricingTypes.put(Triple.of(ML_PRODUCT, FREE_TRIAL_AND_USAGE_BASED, new HashSet<>()), FTH); Triple<String, Set<String>, Set<String>> key = Triple.of(productType, agreementTermType, offerType); if (pricingTypes.containsKey(key)) { return pricingTypes.get(key); } else { return "Unknown"; } } /* * Given product type and agreement term types, some combinations need to check offer term types as well. */ public static String needToCheckOfferTermsType(String productType, Set<String> agreementTermTypes) { Map<KeyPair, String> offerTermTypes = new HashMap<>(); offerTermTypes.put(new KeyPair(CONTAINER_PRODUCT, CONFIGURABLE_UPFRONT), "Y"); offerTermTypes.put(new KeyPair(AMI_PRODUCT, CONFIGURABLE_UPFRONT), "Y"); offerTermTypes.put(new KeyPair(CONTAINER_PRODUCT, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE), "Y"); offerTermTypes.put(new KeyPair(AMI_PRODUCT, FIXED_UPFRONT_AND_PAYMENT_SCHEDULE), "Y"); KeyPair key = new KeyPair(productType, agreementTermTypes); if (offerTermTypes.containsKey(key)) { return offerTermTypes.get(key); } else { return null; } } public static List<AgreementViewSummary> getAgreementsById() { List<AgreementViewSummary> agreementSummaryList = new ArrayList<AgreementViewSummary>(); Filter partyType = Filter.builder().name(PARTY_TYPE_FILTER_NAME).values(PARTY_TYPE_FILTER_VALUE_PROPOSER).build(); Filter agreementType = Filter.builder().name(AGREEMENT_TYPE_FILTER_NAME).values(AGREEMENT_TYPE_FILTER_VALUE_PURCHASEAGREEMENT).build(); Filter customizeFilter = Filter.builder().name(FILTER_NAME).values(FILTER_VALUE).build(); SearchAgreementsRequest searchAgreementsRequest = SearchAgreementsRequest.builder() .catalog(AWS_MP_CATALOG) .filters(partyType, agreementType, customizeFilter).build(); SearchAgreementsResponse searchResultResponse = marketplaceAgreementClient.searchAgreements(searchAgreementsRequest); agreementSummaryList.addAll(searchResultResponse.agreementViewSummaries()); while (searchResultResponse.nextToken() != null && searchResultResponse.nextToken().length() > 0) { searchAgreementsRequest = SearchAgreementsRequest.builder().catalog(AWS_MP_CATALOG) .filters(partyType, agreementType).nextToken(searchResultResponse.nextToken()).build(); searchResultResponse = marketplaceAgreementClient.searchAgreements(searchAgreementsRequest); agreementSummaryList.addAll(searchResultResponse.agreementViewSummaries()); } return agreementSummaryList; } static class KeyPair { private final String first; private final Set<String> second; public KeyPair(String productType, Set<String> second) { this.first = productType; this.second = second; } @Override public int hashCode() { return Objects.hash(first, second); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || getClass() != obj.getClass()) return false; KeyPair other = (KeyPair) obj; return Objects.equals(first, other.first) && Objects.equals(second, other.second); } } /* * Get all the term types for the offer */ public static Set<String> getOfferTermTypes(String offerId) { Set<String> offerTermTypes = new HashSet<String>(); DescribeEntityRequest request = DescribeEntityRequest.builder() .catalog(AWS_MP_CATALOG) .entityId(offerId) .build(); DescribeEntityResponse result = marketplaceCatalogClient.describeEntity(request); String details = result.details(); try { ObjectMapper objectMapper = new ObjectMapper(); JsonNode rootNode = objectMapper.readTree(details); JsonNode termsNode = rootNode.get(ATTRIBUTE_TERMS); for (JsonNode termNode : termsNode) { if (termNode.get(ATTRIBUTE_TYPE_ENTITY) != null ) { offerTermTypes.add(termNode.get(ATTRIBUTE_TYPE_ENTITY).asText()); } } } catch (Exception e) { e.printStackTrace(); } return offerTermTypes; } /* * Get all the agreement term types */ public static Set<String> getAgreementTermTypes(GetAgreementTermsResponse agreementTerm) { Set<String> agreementTermTypes = new HashSet<String>(); try { for (AcceptedTerm term : agreementTerm.acceptedTerms()) { ObjectMapper objectMapper = new ObjectMapper(); JsonNode termNode = objectMapper.readTree(getJson(term)); Iterator<Map.Entry<String, JsonNode>> fieldsIterator = termNode.fields(); while (fieldsIterator.hasNext()) { Map.Entry<String, JsonNode> entry = fieldsIterator.next(); JsonNode value = entry.getValue(); if (value.isObject() && value.has(ATTRIBUTE_TYPE_AGREEMENT)) { agreementTermTypes.add(value.get(ATTRIBUTE_TYPE_AGREEMENT).asText()); } } } } catch (Exception e) { e.printStackTrace(); } return agreementTermTypes; } /* * make sure all elements in array2 exist in array1 */ public static boolean allElementsExist(Set<String> array1, Set<String> array2) { for (String element : array2) { boolean found = false; for (String str : array1) { if (element.equals(str)) { found = true; break; } } if (!found) { return false; } } return true; } /* * Find the combinations of the agreement term types for the agreement */ public static Set<String> getMatchedTermTypesCombination(Set<String> agreementTermTypes) { Set<String> matchedCombination = new HashSet<String>(); for (Set<String> element : ALL_AGREEMENT_TERM_TYPES_COMBINATION) { if (allElementsExist(agreementTermTypes, element)) { matchedCombination = element; } } return matchedCombination; } public static void main(String[] args) { List<AgreementViewSummary> agreements = getAgreementsById(); for (AgreementViewSummary summary : agreements) { String pricingType = ""; String agreementId = summary.agreementId(); System.out.println(agreementId); String offerId = summary.proposalSummary().offerId(); //get all pricing term types for the offer in the agreement Set<String> offerTermTypes = getOfferTermTypes(offerId); String productType = summary.proposalSummary().resources().get(0).type(); //get all pricing term types for the agreement GetAgreementTermsRequest getAgreementTermsRequest = GetAgreementTermsRequest.builder().agreementId(agreementId) .build(); GetAgreementTermsResponse getAgreementTermsResponse = marketplaceAgreementClient.getAgreementTerms(getAgreementTermsRequest); Set<String> agreementTermTypes = getAgreementTermTypes(getAgreementTermsResponse); //get matched pricing term type combination set Set<String> agreementMatchedTermType = getMatchedTermTypesCombination(agreementTermTypes); //check to see if this agreement pricing term combination needs additional check on offer pricing terms String needToCheckOfferType = needToCheckOfferTermsType(productType, agreementMatchedTermType); // get the pricing type for the agreement based on the product type, agreement term types and offer term types if needed if (needToCheckOfferType != null) { Set<String> offerMatchedTermType = getMatchedTermTypesCombination(offerTermTypes); pricingType = getPricingType(productType, agreementMatchedTermType, offerMatchedTermType); } else if (agreementMatchedTermType == LEGAL) { pricingType = FREE; } else { pricingType = getPricingType(productType, agreementMatchedTermType, new HashSet()); } System.out.println("Pricing type is " + pricingType); } } private static String getJson(Object result) { String json = ""; try { ObjectMapper om = new ObjectMapper(); om.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); om.registerModule(new JavaTimeModule()); ObjectWriter ow = om.writer().withDefaultPrettyPrinter(); json = ow.writeValueAsString(result); } catch (JsonProcessingException e) { e.printStackTrace(); } return json; } }
-
APIEinzelheiten finden Sie DescribeAgreementunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie den Produkttyp einer Vereinbarung ermitteln.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package com.example.awsmarketplace.agreementapi; 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; import software.amazon.awssdk.services.marketplaceagreement.model.Resource; import static com.example.awsmarketplace.utils.ReferenceCodesConstants.*; import java.util.ArrayList; import java.util.List; import com.example.awsmarketplace.utils.ReferenceCodesUtils; public class GetAgreementProductType { /* * Obtain the Product Type of the product the agreement was created on */ public static void main(String[] args) { String agreementId = args.length > 0 ? args[0] : AGREEMENT_ID; List<String> productIds = getProducts(agreementId); ReferenceCodesUtils.formatOutput(productIds); } public static List<String> getProducts(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); List<String> productIds = new ArrayList<String>(); for (Resource resource : describeAgreementResponse.proposalSummary().resources()) { productIds.add(resource.id() + ":" + resource.type()); } return productIds; } }
-
APIEinzelheiten finden Sie DescribeAgreementunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie den Status einer Vereinbarung abrufen können.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // 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.AGREEMENT_ID; 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 GetAgreementStatus { public static void main(String[] args) { String agreementId = args.length > 0 ? args[0] : AGREEMENT_ID; DescribeAgreementResponse describeAgreementResponse = getDescribeAgreementResponse(agreementId); System.out.println("Agreement status is " + describeAgreementResponse.status()); } public static DescribeAgreementResponse getDescribeAgreementResponse(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; } }
-
APIEinzelheiten finden Sie DescribeAgreementunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie die Supportbedingungen einer Vereinbarung abrufen können.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package com.example.awsmarketplace.agreementapi; 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.AcceptedTerm; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsRequest; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsResponse; import software.amazon.awssdk.services.marketplaceagreement.model.SupportTerm; import java.util.ArrayList; import java.util.List; import static com.example.awsmarketplace.utils.ReferenceCodesConstants.AGREEMENT_ID; import com.example.awsmarketplace.utils.ReferenceCodesUtils; public class GetAgreementTermsSupportTerm { /* * Obtain the support and refund policy I have provided to the customer */ public static void main(String[] args) { String agreementId = args.length > 0 ? args[0] : AGREEMENT_ID; List<SupportTerm> supportTerms = getSupportTerms(agreementId); ReferenceCodesUtils.formatOutput(supportTerms); } public static List<SupportTerm> getSupportTerms(String agreementId) { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); GetAgreementTermsRequest getAgreementTermsRequest = GetAgreementTermsRequest.builder().agreementId(agreementId) .build(); GetAgreementTermsResponse getAgreementTermsResponse = marketplaceAgreementClient.getAgreementTerms(getAgreementTermsRequest); List<SupportTerm> supportTerms = new ArrayList<>(); for (AcceptedTerm acceptedTerm : getAgreementTermsResponse.acceptedTerms()) { if (acceptedTerm.supportTerm() != null) { supportTerms.add(acceptedTerm.supportTerm()); } } return supportTerms; } }
-
APIEinzelheiten finden Sie GetAgreementTermsunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie die Bedingungen einer Vereinbarung abrufen können.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // 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.GetAgreementTermsRequest; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementTermsResponse; public class GetAgreementTerms { public static void main(String[] args) { String agreementId = args.length > 0 ? args[0] : AGREEMENT_ID; GetAgreementTermsResponse getAgreementTermsResponse = getAgreementTermsResponse(agreementId); ReferenceCodesUtils.formatOutput(getAgreementTermsResponse); } public static GetAgreementTermsResponse getAgreementTermsResponse(String agreementId) { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); GetAgreementTermsRequest getAgreementTermsRequest = GetAgreementTermsRequest.builder() .agreementId(agreementId) .build(); GetAgreementTermsResponse getAgreementTermsResponse = marketplaceAgreementClient.getAgreementTerms(getAgreementTermsRequest); return getAgreementTermsResponse; } }
-
APIEinzelheiten finden Sie GetAgreementTermsunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie nach Vereinbarungen anhand des Enddatums suchen.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package com.example.awsmarketplace.agreementapi; 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.AgreementViewSummary; import software.amazon.awssdk.services.marketplaceagreement.model.Filter; import software.amazon.awssdk.services.marketplaceagreement.model.SearchAgreementsRequest; import software.amazon.awssdk.services.marketplaceagreement.model.SearchAgreementsResponse; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import static com.example.awsmarketplace.utils.ReferenceCodesConstants.*; import com.example.awsmarketplace.utils.ReferenceCodesUtils; public class SearchAgreementsByEndDate { static String beforeOrAfterEndtimeFilterName = BeforeOrAfterEndTimeFilterName.BeforeEndTime.name(); static String cutoffDate = "2050-11-18T00:00:00Z"; static String partyTypeFilterValue = PARTY_TYPE_FILTER_VALUE_PROPOSER; public static void main(String[] args) { List<AgreementViewSummary> agreementSummaryList = getAgreements(); ReferenceCodesUtils.formatOutput(agreementSummaryList); } public static List<AgreementViewSummary> getAgreements() { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); // set up filters Filter partyTypeFilter = Filter.builder().name(PARTY_TYPE_FILTER_NAME) .values(PARTY_TYPE_FILTER_VALUE_PROPOSER).build(); Filter agreementTypeFilter = Filter.builder().name(AGREEMENT_TYPE_FILTER_NAME) .values(AGREEMENT_TYPE_FILTER_VALUE_PURCHASEAGREEMENT).build(); Filter customizeFilter = Filter.builder().name(beforeOrAfterEndtimeFilterName).values(cutoffDate).build(); List<Filter> filters = new ArrayList<Filter>(); filters.addAll(Arrays.asList(partyTypeFilter, agreementTypeFilter, customizeFilter)); // search agreement with filters SearchAgreementsRequest searchAgreementsRequest = SearchAgreementsRequest.builder() .catalog(AWS_MP_CATALOG) .filters(filters) .build(); SearchAgreementsResponse searchAgreementResponse= marketplaceAgreementClient.searchAgreements(searchAgreementsRequest); List<AgreementViewSummary> agreementSummaryList = new ArrayList<AgreementViewSummary>(); agreementSummaryList.addAll(searchAgreementResponse.agreementViewSummaries()); while (searchAgreementResponse.nextToken() != null && searchAgreementResponse.nextToken().length() > 0) { searchAgreementsRequest = SearchAgreementsRequest.builder() .catalog(AWS_MP_CATALOG) .filters(filters) .nextToken(searchAgreementResponse.nextToken()) .build(); searchAgreementResponse = marketplaceAgreementClient.searchAgreements(searchAgreementsRequest); agreementSummaryList.addAll(searchAgreementResponse.agreementViewSummaries()); } return agreementSummaryList; } }
-
APIEinzelheiten finden Sie SearchAgreementsunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie mit einem benutzerdefinierten Filter nach Vereinbarungen suchen.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package com.example.awsmarketplace.agreementapi; 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.AgreementViewSummary; import software.amazon.awssdk.services.marketplaceagreement.model.Filter; import software.amazon.awssdk.services.marketplaceagreement.model.SearchAgreementsRequest; import software.amazon.awssdk.services.marketplaceagreement.model.SearchAgreementsResponse; import static com.example.awsmarketplace.utils.ReferenceCodesConstants.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import com.example.awsmarketplace.utils.ReferenceCodesUtils; /** * To search by * offer id: OfferId; * product id: ResourceIdentifier; * customer AWS account id: AcceptorAccountId * product type: ResourceType (i.e. SaasProduct) * status: Status. status values can be: ACTIVE, CANCELED, * EXPIRED, RENEWED, REPLACED, ROLLED_BACK, SUPERSEDED, TERMINATED */ public class SearchAgreementsByOneFilter { private static final String FILTER_NAME = "ResourceType"; private static final String FILTER_VALUE = "SaaSProduct"; /* * search agreements by one customize filter */ public static void main(String[] args) { List<AgreementViewSummary> agreementSummaryList = getAgreements(); ReferenceCodesUtils.formatOutput(agreementSummaryList); } public static List<AgreementViewSummary> getAgreements() { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); Filter partyTypeFilter = Filter.builder().name(PARTY_TYPE_FILTER_NAME) .values(PARTY_TYPE_FILTER_VALUE_PROPOSER).build(); Filter agreementTypeFilter = Filter.builder().name(AGREEMENT_TYPE_FILTER_NAME) .values(AGREEMENT_TYPE_FILTER_VALUE_PURCHASEAGREEMENT).build(); Filter customizeFilter = Filter.builder().name(FILTER_NAME).values(FILTER_VALUE).build(); List<Filter> filters = new ArrayList<Filter>(); filters.addAll(Arrays.asList(partyTypeFilter, agreementTypeFilter, customizeFilter)); SearchAgreementsRequest searchAgreementsRequest = SearchAgreementsRequest.builder() .catalog(AWS_MP_CATALOG) .filters(filters) .build(); SearchAgreementsResponse searchAgreementsResponse = marketplaceAgreementClient.searchAgreements(searchAgreementsRequest); List<AgreementViewSummary> agreementSummaryList = new ArrayList<AgreementViewSummary>(); agreementSummaryList.addAll(searchAgreementsResponse.agreementViewSummaries()); while (searchAgreementsResponse.nextToken() != null && searchAgreementsResponse.nextToken().length() > 0) { searchAgreementsRequest = SearchAgreementsRequest.builder() .catalog(AWS_MP_CATALOG) .filters(filters) .nextToken(searchAgreementsResponse.nextToken()) .build(); searchAgreementsResponse = marketplaceAgreementClient.searchAgreements(searchAgreementsRequest); agreementSummaryList.addAll(searchAgreementsResponse.agreementViewSummaries()); } return agreementSummaryList; } }
-
APIEinzelheiten finden Sie SearchAgreementsunter AWS SDK for Java 2.x APIReferenz.
-
Das folgende Codebeispiel zeigt, wie Sie mit zwei benutzerdefinierten Filtern nach Vereinbarungen suchen.
- SDKfür Java 2.x
-
Anmerkung
Es gibt noch mehr dazu. GitHub Im AWS Marketplace APIReference Code Library
Repository finden Sie das vollständige Beispiel und erfahren, wie es eingerichtet und ausgeführt wird. // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package com.example.awsmarketplace.agreementapi; import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider; import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; import software.amazon.awssdk.http.SdkHttpClient; import software.amazon.awssdk.http.apache.ApacheHttpClient; import software.amazon.awssdk.services.marketplaceagreement.MarketplaceAgreementClient; import software.amazon.awssdk.services.marketplaceagreement.model.AgreementViewSummary; import software.amazon.awssdk.services.marketplaceagreement.model.Filter; import software.amazon.awssdk.services.marketplaceagreement.model.SearchAgreementsRequest; import software.amazon.awssdk.services.marketplaceagreement.model.SearchAgreementsResponse; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import static com.example.awsmarketplace.utils.ReferenceCodesConstants.*; import com.example.awsmarketplace.utils.ReferenceCodesUtils; /** * Party Type = Proposer AND Acceptor: * AfterEndTime * BeforeEndTime * ResourceIdentifier + BeforeEndTime * ResourceIdentifier + AfterEndTime * ResourceType + BeforeEndTime * ResourceType + AfterEndTime * * Party Type = Proposer * ResourceIdentifier * OfferId * AcceptorAccountId * Status (ACTIVE) * Status (ACTIVE) + ResourceIdentifier * Status (ACTIVE) + AcceptorAccountId * Status (ACTIVE) + OfferId * Status (ACTIVE) + ResourceType * AcceptorAccountId + BeforeEndTime * AcceptorAccountId + AfterEndTime * AcceptorAccountId + AfterEndTime * OfferId + BeforeEndTime * * Status values can be: ACTIVE, CANCELLED, EXPIRED, RENEWED, REPLACED, ROLLED_BACK, SUPERSEDED, TERMINATED */ public class SearchAgreementsByTwoFilters { public static final String FILTER_1_NAME = "ResourceType"; public static final String FILTER_1_VALUE = "SaaSProduct"; public static final String FILTER_2_NAME = "Status"; public static final String FILTER_2_VALUE = "ACTIVE"; /* * search agreements by two customize filter */ public static void main(String[] args) { List<AgreementViewSummary> agreementSummaryList = getAgreements(); ReferenceCodesUtils.formatOutput(agreementSummaryList); } public static List<AgreementViewSummary> getAgreements() { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); Filter partyTypeFilter = Filter.builder().name(PARTY_TYPE_FILTER_NAME) .values(PARTY_TYPE_FILTER_VALUE_PROPOSER).build(); Filter agreementTypeFilter = Filter.builder().name(AGREEMENT_TYPE_FILTER_NAME) .values(AGREEMENT_TYPE_FILTER_VALUE_PURCHASEAGREEMENT).build(); Filter customizeFilter1 = Filter.builder().name(FILTER_1_NAME).values(FILTER_1_VALUE).build(); Filter customizeFilter2 = Filter.builder().name(FILTER_2_NAME).values(FILTER_2_VALUE).build(); List<Filter> filters = new ArrayList<Filter>(); filters.addAll(Arrays.asList(partyTypeFilter, agreementTypeFilter, customizeFilter1, customizeFilter2)); SearchAgreementsRequest searchAgreementsRequest = SearchAgreementsRequest.builder() .catalog(AWS_MP_CATALOG) .filters(filters) .build(); SearchAgreementsResponse searchAgreementsResponse = marketplaceAgreementClient.searchAgreements(searchAgreementsRequest); List<AgreementViewSummary> agreementSummaryList = new ArrayList<AgreementViewSummary>(); agreementSummaryList.addAll(searchAgreementsResponse.agreementViewSummaries()); while (searchAgreementsResponse.nextToken() != null && searchAgreementsResponse.nextToken().length() > 0) { searchAgreementsRequest = SearchAgreementsRequest.builder() .catalog(AWS_MP_CATALOG) .filters(filters) .nextToken(searchAgreementsResponse.nextToken()) .build(); searchAgreementsResponse = marketplaceAgreementClient.searchAgreements(searchAgreementsRequest); agreementSummaryList.addAll(searchAgreementsResponse.agreementViewSummaries()); } return agreementSummaryList; } }
-
APIEinzelheiten finden Sie SearchAgreementsunter AWS SDK for Java 2.x APIReferenz.
-