Ada lebih banyak AWS SDK contoh yang tersedia di GitHub repo SDKContoh AWS Dokumen
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
AWS Marketplace APIContoh perjanjian menggunakan SDK untuk Java 2.x
Contoh kode berikut menunjukkan kepada Anda cara melakukan tindakan dan menerapkan skenario umum dengan menggunakan AWS Marketplace Perjanjian AWS SDK for Java 2.x denganAPI.
Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.
Topik
Perjanjian
Contoh kode berikut menunjukkan cara mendapatkan semua kesepakatanIDs.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat SearchAgreementsdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mendapatkan semua perjanjian.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat SearchAgreementsdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mendapatkan ID pelanggan dari perjanjian.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat DescribeAgreementdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mendapatkan detail keuangan dari suatu perjanjian.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat DescribeAgreementdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mendapatkan detail uji coba gratis dari perjanjian.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat DescribeAgreementdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mendapatkan informasi tentang perjanjian.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat DescribeAgreementdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mendapatkan detail produk dan penawaran dari perjanjian.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat DescribeAgreementdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mendapatkan perjanjian. EULA
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat GetAgreementTermsdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mendapatkan ketentuan perpanjangan otomatis dari suatu perjanjian.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat GetAgreementTermsdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mendapatkan dimensi yang dibeli dalam perjanjian.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat GetAgreementTermsdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mendapatkan contoh dari setiap dimensi yang dibeli dalam perjanjian.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat GetAgreementTermsdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mendapatkan jadwal pembayaran perjanjian.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat GetAgreementTermsdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mendapatkan harga per dimensi dalam suatu perjanjian.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat GetAgreementTermsdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mendapatkan jenis harga perjanjian.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat DescribeAgreementdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mendapatkan jenis produk dari suatu perjanjian.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat DescribeAgreementdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mendapatkan status perjanjian.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat DescribeAgreementdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mendapatkan ketentuan dukungan dari suatu perjanjian.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat GetAgreementTermsdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mendapatkan ketentuan perjanjian.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat GetAgreementTermsdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mencari perjanjian berdasarkan tanggal akhir.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat SearchAgreementsdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mencari perjanjian dengan satu filter khusus.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat SearchAgreementsdi AWS SDK for Java 2.x APIReferensi.
-
Contoh kode berikut menunjukkan cara mencari perjanjian dengan dua filter khusus.
- SDKuntuk Java 2.x
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankan di repositori Perpustakaan Kode AWS Marketplace API Referensi
. // 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; } }
-
Untuk API detailnya, lihat SearchAgreementsdi AWS SDK for Java 2.x APIReferensi.
-