L' Centrale Partner AWS API Reference è stato ristrutturato. Per ulteriori informazioni sulle operazioni API supportate, consulta l'Centrale Partner AWS API Reference.
Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.
Utilizzare AssociateOpportunitycon un AWS SDK
Gli esempi di codice seguenti mostrano come utilizzare AssociateOpportunity.
Gli esempi di operazioni sono estratti di codice da programmi più grandi e devono essere eseguiti nel contesto. È possibile visualizzare questa operazione nel contesto nel seguente esempio di codice:
- Java
-
- SDK per Java 2.x
-
Crea un’associazione formale tra un’opportunità e varie entità correlate.
package org.example;
import static org.example.utils.Constants.*;
import org.example.utils.Constants;
import org.example.utils.ReferenceCodesUtils;
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
import software.amazon.awssdk.http.apache.ApacheHttpClient;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.partnercentralselling.PartnerCentralSellingClient;
import software.amazon.awssdk.services.partnercentralselling.model.AssociateOpportunityRequest;
import software.amazon.awssdk.services.partnercentralselling.model.AssociateOpportunityResponse;
/*
Purpose
PC-API -11 Associating a product
PC-API -12 Associating a solution
PC-API -13 Associating an offer
entity_type = Solutions | AWSProducts | AWSMarketplaceOffers
*/
public class AssociateOpportunity {
static PartnerCentralSellingClient client = PartnerCentralSellingClient.builder()
.region(Region.US_EAST_1)
.credentialsProvider(DefaultCredentialsProvider.create())
.httpClient(ApacheHttpClient.builder().build())
.build();
public static void main(String[] args) {
String opportunityId = args.length > 0 ? args[0] : OPPORTUNITY_ID;
String entityType = "Solutions";
String entityIdentifier = "S-0000000";
AssociateOpportunityResponse response = getResponse(opportunityId, entityType, entityIdentifier );
ReferenceCodesUtils.formatOutput(response);
}
static AssociateOpportunityResponse getResponse(String opportunityId, String entityType, String entityIdentifier) {
AssociateOpportunityRequest associateOpportunityRequest = AssociateOpportunityRequest.builder()
.catalog(Constants.CATALOG_TO_USE)
.opportunityIdentifier(opportunityId)
.relatedEntityType(entityType)
.relatedEntityIdentifier(entityIdentifier)
.build();
AssociateOpportunityResponse response = client.associateOpportunity(associateOpportunityRequest);
return response;
}
}
- Python
-
- SDK per Python (Boto3)
-
Crea un’associazione formale tra un’opportunità e varie entità correlate.
#!/usr/bin/env python
"""
Purpose
PC-API -11 Associating a product
PC-API -12 Associating a solution
PC-API -13 Associating an offer
"""
import logging
import boto3
import utils.helpers as helper
from botocore.client import ClientError
from utils.constants import CATALOG_TO_USE
serviceName = "partnercentral-selling"
partner_central_client = boto3.client(
service_name=serviceName,
region_name='us-east-1'
)
def associate_opportunity(entity_type, entity_identifier, opportunityIdentifier):
associate_opportunity_request ={
"Catalog": CATALOG_TO_USE,
"OpportunityIdentifier" : opportunityIdentifier,
"RelatedEntityType" : entity_type,
"RelatedEntityIdentifier" : entity_identifier
}
try:
# Perform an API call
response = partner_central_client.associate_opportunity(**associate_opportunity_request)
return response
except ClientError as err:
# Catch all client exceptions
print(err.response)
def usage_demo():
#entity_type = Solutions | AWSProducts | AWSMarketplaceOffers
entity_type = "Solutions"
entity_identifier = "S-0059717"
opportunityIdentifier = "O5465588"
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
print("-" * 88)
print("Associate Opportunity.")
print("-" * 88)
helper.pretty_print_datetime(associate_opportunity(entity_type, entity_identifier, opportunityIdentifier))
if __name__ == "__main__":
usage_demo()
Per un elenco completo delle guide per sviluppatori AWS SDK e degli esempi di codice, consulta. Utilizzo AWS API Partner Central con un AWS SDK Questo argomento include anche informazioni su come iniziare e dettagli sulle versioni precedenti dell’SDK.