View a markdown version of this page

Describa una oferta pública mediante un AWS SDK - AWS Marketplace

Se reestructuró la referencia de la API de AWS Marketplace. Para obtener más información sobre las operaciones de API compatibles, consulte la referencia de API de AWS Marketplace.

Las traducciones son generadas a través de traducción automática. En caso de conflicto entre la traducción y la version original de inglés, prevalecerá la version en inglés.

Describa una oferta pública mediante un AWS SDK

Los siguientes ejemplos de código muestran cómo describir una oferta pública.

Java
SDK para Java 2.x
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurarlo y ejecutarlo en el repositorio Biblioteca de código de referencia de la API de AWS Marketplace.

package com.example.awsmarketplace.catalogapi; 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.marketplacecatalog.MarketplaceCatalogClient; import software.amazon.awssdk.services.marketplacecatalog.model.DescribeEntityRequest; import software.amazon.awssdk.services.marketplacecatalog.model.DescribeEntityResponse; public class DescribeEntity { /* * Describe my AMI or SaaS or Container product and check if it contains all the information I need to know about the product */ public static void main(String[] args) { String offerId = args.length > 0 ? args[0] : OFFER_ID; DescribeEntityResponse describeEntityResponse = getDescribeEntityResponse(offerId); ReferenceCodesUtils.formatOutput(describeEntityResponse); } public static DescribeEntityResponse getDescribeEntityResponse(String offerId) { 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); return describeEntityResponse; } }
  • Para obtener más información sobre la API, consulta DescribeEntity la Referencia de AWS SDK for Java 2.x API.

Python
SDK para Python (Boto3)
nota

Hay más información al respecto GitHub. Busque el ejemplo completo y aprenda a configurarlo y ejecutarlo en el repositorio Biblioteca de código de referencia de la API de AWS Marketplace.

# 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) search for offer information in the AWS Marketplace Catalog CAPI-29 """ import json import logging import boto3 from botocore.exceptions import ClientError logger = logging.getLogger(__name__) OFFER_ID = "offer-1111111111111" def pretty_print(response): json_object = json.dumps(response, indent=4) print(json_object) def get_offer_information(mp_client, entity_id): """ Returns information about a given offer Args: entity_id str: Entity to return Returns: dict: Dictionary of offer information """ try: response = mp_client.describe_entity( Catalog="AWSMarketplace", EntityId=entity_id, ) return response except ClientError as e: if e.response["Error"]["Code"] == "ResourceNotFoundException": logger.error("Offer with ID %s not found.", entity_id) else: logger.error("Unexpected error: %s", e) def usage_demo(): logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s") print("-" * 88) print("Looking for an offer in the AWS Marketplace Catalog.") print("-" * 88) mp_client = boto3.client("marketplace-catalog") pretty_print(get_offer_information(mp_client, OFFER_ID)) if __name__ == "__main__": usage_demo()
  • Para obtener más información sobre la API, consulta DescribeEntity la AWS referencia de la API del SDK para Python (Boto3).

Para obtener una lista completa de las guías para desarrolladores del AWS SDK y los ejemplos de código, consulte. Uso de este servicio con un AWS SDK En este tema también se incluye información sobre cómo empezar a utilizar el SDK y detalles sobre sus versiones anteriores.