La référence de l'API AWS Marketplace a été restructurée. Pour plus d'informations sur les opérations d'API prises en charge, consultez le manuel AWS Marketplace API Reference.
Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.
Recherchez des accords par ID d'accord à l'aide d'un AWS Kit SDK
L’exemple de code suivant montre comment rechercher des accords par ID d’accord.
- Python
-
- Kit SDK for Python (Boto3)
-
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
"""
Purpose
Shows how to use the AWS SDK for Python (Boto3) to search for agreements give id information
AG-02-A
"""
import logging
import boto3
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", ".."))
import utils.helpers as helper
from botocore.exceptions import ClientError
# To search by offer id: OfferId; by product id: ResourceIdentifier; by product type: ResourceType
idType = "ResourceType"
# replace id value as needed
idValue = "SaaSProduct"
MAX_PAGE_RESULTS = 10
logger = logging.getLogger(__name__)
def get_agreements(mp_client):
AgreementSummaryList = []
# Set PartyType to "Proposer" to return agreements where you are the proposer.
# Change to "Acceptor" to return agreements where you are the acceptor.
partyTypes = ["Proposer"]
for value in partyTypes:
try:
agreement = mp_client.search_agreements(
catalog="AWSMarketplace",
maxResults=MAX_PAGE_RESULTS,
filters=[
{"name": "PartyType", "values": [value]},
{"name": idType, "values": [idValue]},
{"name": "AgreementType", "values": ["PurchaseAgreement"]},
],
)
except ClientError as e:
logger.error("Could not complete search_agreements request.")
raise e
AgreementSummaryList.extend(agreement["agreementViewSummaries"])
while "nextToken" in agreement and agreement["nextToken"] is not None:
try:
agreement = mp_client.search_agreements(
catalog="AWSMarketplace",
maxResults=MAX_PAGE_RESULTS,
nextToken=agreement["nextToken"],
filters=[
{"name": "PartyType", "values": [value]},
{"name": idType, "values": [idValue]},
{"name": "AgreementType", "values": ["PurchaseAgreement"]},
],
)
except ClientError as e:
logger.error("Could not complete search_agreements request.")
raise e
AgreementSummaryList.extend(agreement["agreementViewSummaries"])
return AgreementSummaryList
def usage_demo():
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
print("-" * 88)
print("Looking for an agreement in the AWS Marketplace Catalog.")
print("-" * 88)
mp_client = boto3.client("marketplace-agreement")
helper.pretty_print_datetime(get_agreements(mp_client))
if __name__ == "__main__":
usage_demo()
Pour obtenir la liste complète des guides du développeur du AWS SDK et des exemples de code, consultezL'utilisation de ce service avec AWS Kit SDK. Cette rubrique comprend également des informations sur le démarrage et sur les versions précédentes du kit SDK.