Ada lebih banyak contoh AWS SDK yang tersedia di repo Contoh SDK AWS Doc
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Gunakan StartEngagementByAcceptingInvitationTask
dengan AWS SDK
Contoh kode berikut menunjukkan cara menggunakanStartEngagementByAcceptingInvitationTask
.
- Java
-
- SDK untuk Java 2.x
-
Memulai pertunangan dengan menerima EngagementInvitation.
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.StartEngagementByAcceptingInvitationTaskRequest; import software.amazon.awssdk.services.partnercentralselling.model.StartEngagementByAcceptingInvitationTaskResponse; import software.amazon.awssdk.services.partnercentralselling.model.GetEngagementInvitationRequest; import software.amazon.awssdk.services.partnercentralselling.model.GetEngagementInvitationResponse; import software.amazon.awssdk.services.partnercentralselling.model.InvitationStatus; /* Purpose PC-API-04: Start Engagement By Accepting InvitationTask for AWS Originated(AO) opportunity */ public class StartEngagementByAcceptingInvitationTask { static PartnerCentralSellingClient client = PartnerCentralSellingClient.builder() .region(Region.US_EAST_1) .credentialsProvider(DefaultCredentialsProvider.create()) .httpClient(ApacheHttpClient.builder().build()) .build(); static String clientToken = "test-a30d161"; public static void main(String[] args) { String opportunityId = args.length > 0 ? args[0] : OPPORTUNITY_ID; StartEngagementByAcceptingInvitationTaskResponse response = getResponse(opportunityId); if ( response == null) { System.out.println("Opportunity is not AWS Originated."); } else { ReferenceCodesUtils.formatOutput(response); } } private static GetEngagementInvitationResponse getInvitation(String invitationId) { GetEngagementInvitationRequest getRequest = GetEngagementInvitationRequest.builder() .catalog(Constants.CATALOG_TO_USE) .identifier(invitationId) .build(); GetEngagementInvitationResponse response = client.getEngagementInvitation(getRequest); return response; } static StartEngagementByAcceptingInvitationTaskResponse getResponse(String invitationId) { if ( getInvitation(invitationId).status().equals(InvitationStatus.PENDING)) { StartEngagementByAcceptingInvitationTaskRequest acceptOpportunityRequest = StartEngagementByAcceptingInvitationTaskRequest.builder() .catalog(Constants.CATALOG_TO_USE) .identifier(invitationId) .clientToken(clientToken) .build(); StartEngagementByAcceptingInvitationTaskResponse response = client.startEngagementByAcceptingInvitationTask(acceptOpportunityRequest); return response; } return null; } }
-
Untuk detail API, lihat StartEngagementByAcceptingInvitationTaskdi Referensi AWS SDK for Java 2.x API.
-
- Python
-
- SDK untuk Python (Boto3)
-
Memulai pertunangan dengan menerima EngagementInvitation.
#!/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 get_opportunity(identifier): get_opportunity_request ={ "Identifier": identifier, "Catalog": CATALOG_TO_USE } try: # Perform an API call response = partner_central_client.get_engagement_invitation(**get_opportunity_request) return response except ClientError as err: # Catch all client exceptions print(err.response) def start_engagement_by_accepting_invitation_task(identifier): response = get_opportunity(identifier) if ( response['Status'] == 'PENDING') : accept_opportunity_engagement_invitation_request ={ "Catalog": CATALOG_TO_USE, "Identifier" : identifier, "ClientToken": "test-123456" } try: # Perform an API call response = partner_central_client.start_engagement_by_accepting_invitation_task(**accept_opportunity_engagement_invitation_request) return response except ClientError as err: # Catch all client exceptions print(err.response) return None else: return None def usage_demo(): identifier = "arn:aws:partnercentral:us-east-1::catalog/Sandbox/engagement-invitation/engi-0000002isusga" logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s") print("-" * 88) print("Get updated Opportunity.") print("-" * 88) helper.pretty_print_datetime(start_engagement_by_accepting_invitation_task(identifier)) if __name__ == "__main__": usage_demo()
-
Untuk detail API, lihat StartEngagementByAcceptingInvitationTaskdi AWS SDK for Python (Boto3) Referensi API.
-
RejectEngagementInvitation
StartEngagementFromOpportunityTask