文档 AWS SDK 示例 GitHub 存储库中还有更多 S AWS DK 示例
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
与 AWS SDK RejectEngagementInvitation
配合使用
以下代码示例演示如何使用 RejectEngagementInvitation
。
- Java
-
- 适用于 Java 的 SDK 2.x
-
拒绝 AWS 共享 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.RejectEngagementInvitationRequest; import software.amazon.awssdk.services.partnercentralselling.model.RejectEngagementInvitationResponse; /* * Purpose * PC-API-05 AWS Originated(AO) rejection */ public class RejectEngagementInvitation { 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; RejectEngagementInvitationResponse response = getResponse(opportunityId); ReferenceCodesUtils.formatOutput(response); } static RejectEngagementInvitationResponse getResponse(String invitationId) { RejectEngagementInvitationRequest rejectOpportunityRequest = RejectEngagementInvitationRequest.builder() .catalog(Constants.CATALOG_TO_USE) .identifier(invitationId) .rejectionReason("Unable to support") .build(); RejectEngagementInvitationResponse response = client.rejectEngagementInvitation(rejectOpportunityRequest); return response; } }
-
有关 API 的详细信息,请参阅 AWS SDK for Java 2.x API 参考RejectEngagementInvitation中的。
-
- Python
-
- 适用于 Python 的 SDK(Boto3)
-
拒绝 AWS 共享 EngagementInvitation 的内容。
#!/usr/bin/env python """ Purpose PC-API-05 AWS Originated AO rejection - RejectOpportunityEngagementInvitation - Rejects a engagement invitation. This action indicates that the partner does not wish to participate in the engagement and provides a reason for the rejection. Upon rejection, a OpportunityEngagementInvitationRejected event is triggered. Subsequently, the invitation will no longer be available for the partner to act on. """ import json import logging import boto3 import utils.helpers as helper from utils.constants import CATALOG_TO_USE serviceName = "partnercentral-selling" partner_central_client = boto3.client( service_name=serviceName, region_name='us-east-1' ) def reject_opportunity_engagement_invitation(identifier, reject_reason): reject_opportunity_engagement_invitation_request ={ "Catalog": CATALOG_TO_USE, "Identifier": identifier, "RejectionReason": reject_reason } try: # Perform an API call response = partner_central_client.reject_engagement_invitation(**reject_opportunity_engagement_invitation_request) return response except Exception as err: # Catch all client exceptions print(json.dumps(err.response)) def usage_demo(): identifier = "arn:aws:partnercentral:us-east-1::catalog/Sandbox/engagement-invitation/engi-0000002isviga" reject_reason = "Customer problem unclear" logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s") print("-" * 88) print("Given the ARN identifier and reject reason, reject the Opportunity Engagement Invitation.") print("-" * 88) helper.pretty_print_datetime(reject_opportunity_engagement_invitation(identifier, reject_reason)) if __name__ == "__main__": usage_demo()
-
有关 API 的详细信息,请参阅适用RejectEngagementInvitation于 Python 的AWS SDK (Boto3) API 参考。
-
ListSolutions
StartEngagementByAcceptingInvitationTask