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.
Exemples de Partner Central utilisant le SDK pour Java 2.x
Les exemples de code suivants vous montrent comment effectuer des actions et implémenter des scénarios courants à l' AWS SDK for Java 2.x aide de Partner Central.
Les actions sont des extraits de code de programmes plus larges et doivent être exécutées dans leur contexte. Alors que les actions vous indiquent comment appeler des fonctions de service individuelles, vous pouvez les voir en contexte dans leurs scénarios associés.
Les Scénarios sont des exemples de code qui vous montrent comment accomplir des tâches spécifiques en appelant plusieurs fonctions au sein d’un même service ou combinés à d’autres Services AWS.
Chaque exemple inclut un lien vers le code source complet, où vous trouverez des instructions sur la façon de configurer et d'exécuter le code en contexte.
Actions
L'exemple de code suivant montre comment utiliserAssignOpportunity
.
- SDK pour Java 2.x
-
Réattribuez une opportunité existante à un autre utilisateur.
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.AssignOpportunityRequest; import software.amazon.awssdk.services.partnercentralselling.model.AssignOpportunityResponse; import software.amazon.awssdk.services.partnercentralselling.model.AssigneeContact; /* Purpose PC-API-07 Assigning a new owner */ public class AssignOpportunity { 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 assigneeFirstName = "John"; String assigneeLastName = "Doe"; String assigneeEmail = "test@test.com"; String businessTitle = "PartnerAccountManager"; AssignOpportunityResponse response = getResponse(opportunityId, assigneeFirstName, assigneeLastName, assigneeEmail, businessTitle); ReferenceCodesUtils.formatOutput(response); } static AssignOpportunityResponse getResponse(String opportunityId, String assigneeFirstName, String assigneeLastName, String assigneeEmail, String businessTitle) { AssignOpportunityRequest assignOpportunityRequest = AssignOpportunityRequest.builder() .catalog(Constants.CATALOG_TO_USE) .identifier(opportunityId) .assignee(AssigneeContact.builder() .firstName(assigneeFirstName) .lastName(assigneeLastName) .email(assigneeEmail) .businessTitle(businessTitle) .build()) .build(); AssignOpportunityResponse response = client.assignOpportunity(assignOpportunityRequest); return response; } }
-
Pour plus de détails sur l'API, reportez-vous AssignOpportunityà la section Référence des AWS SDK for Java 2.x API.
-
L'exemple de code suivant montre comment utiliserAssociateOpportunity
.
- SDK pour Java 2.x
-
Créez une association officielle entre une opportunité et diverses entités connexes.
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; } }
-
Pour plus de détails sur l'API, reportez-vous AssociateOpportunityà la section Référence des AWS SDK for Java 2.x API.
-
L'exemple de code suivant montre comment utiliserCreateOpportunity
.
- SDK pour Java 2.x
-
Créez une opportunité.
package org.example; import java.time.Instant; import java.util.ArrayList; import java.util.List; import static org.example.utils.Constants.*; import org.example.entity.Root; import org.example.utils.ReferenceCodesUtils; import org.example.utils.StringSerializer; 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.Account; import software.amazon.awssdk.services.partnercentralselling.model.Address; import software.amazon.awssdk.services.partnercentralselling.model.Contact; import software.amazon.awssdk.services.partnercentralselling.model.CreateOpportunityRequest; import software.amazon.awssdk.services.partnercentralselling.model.CreateOpportunityResponse; import software.amazon.awssdk.services.partnercentralselling.model.Customer; import software.amazon.awssdk.services.partnercentralselling.model.ExpectedCustomerSpend; import software.amazon.awssdk.services.partnercentralselling.model.LifeCycle; import software.amazon.awssdk.services.partnercentralselling.model.Marketing; import software.amazon.awssdk.services.partnercentralselling.model.MonetaryValue; import software.amazon.awssdk.services.partnercentralselling.model.NextStepsHistory; import software.amazon.awssdk.services.partnercentralselling.model.Project; import software.amazon.awssdk.services.partnercentralselling.model.SoftwareRevenue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.ToNumberPolicy; public class CreateOpportunity { static final Gson GSON = new GsonBuilder() .setObjectToNumberStrategy(ToNumberPolicy.LAZILY_PARSED_NUMBER) .registerTypeAdapter(String.class, new StringSerializer()) .create(); 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 inputFile = "CreateOpportunity2.json"; if (args.length > 0) inputFile = args[0]; CreateOpportunityResponse response = createOpportunity(inputFile); client.close(); } static CreateOpportunityResponse createOpportunity(String inputFile) { String inputString = ReferenceCodesUtils.readInputFileToString(inputFile); Root root = GSON.fromJson(inputString, Root.class); List<NextStepsHistory> nextStepsHistories = new ArrayList<NextStepsHistory>(); if ( root.lifeCycle != null && root.lifeCycle.nextStepsHistories != null) { for (org.example.entity.NextStepsHistory nextStepsHistoryJson : root.lifeCycle.nextStepsHistories) { NextStepsHistory nextStepsHistory = NextStepsHistory.builder() .time(Instant.parse(nextStepsHistoryJson.time)) .value(nextStepsHistoryJson.value) .build(); nextStepsHistories.add(nextStepsHistory); } } LifeCycle lifeCycle = null; if ( root.lifeCycle != null ) { lifeCycle = LifeCycle.builder() .closedLostReason(root.lifeCycle.closedLostReason) .nextSteps(root.lifeCycle.nextSteps) .nextStepsHistory(nextStepsHistories) .reviewComments(root.lifeCycle.reviewComments) .reviewStatus(root.lifeCycle.reviewStatus) .reviewStatusReason(root.lifeCycle.reviewStatusReason) .stage(root.lifeCycle.stage) .targetCloseDate(root.lifeCycle.targetCloseDate) .build(); } Marketing marketing = null; if ( root.marketing != null ) { marketing = Marketing.builder() .awsFundingUsed(root.marketing.awsFundingUsed) .campaignName(root.marketing.campaignName) .channels(root.marketing.channels) .source(root.marketing.source) .useCases(root.marketing.useCases) .build(); } Address address = null; if ( root.customer != null && root.customer.account != null && root.customer.account.address != null ) { address = Address.builder() .city(root.customer.account.address.city) .postalCode(root.customer.account.address.postalCode) .stateOrRegion(root.customer.account.address.stateOrRegion) .countryCode(root.customer.account.address.countryCode) .streetAddress(root.customer.account.address.streetAddress) .build(); } Account account = null; if ( root.customer != null && root.customer.account!= null) { account = Account.builder() .address(address) .awsAccountId(root.customer.account.awsAccountId) .duns(root.customer.account.duns) .industry(root.customer.account.industry) .otherIndustry(root.customer.account.otherIndustry) .companyName(root.customer.account.companyName) .websiteUrl(root.customer.account.websiteUrl) .build(); } List<Contact> contacts = new ArrayList<Contact>(); if ( root.customer != null && root.customer.contacts != null) { for (org.example.entity.Contact jsonContact : root.customer.contacts) { Contact contact = Contact.builder() .email(jsonContact.email) .firstName(jsonContact.firstName) .lastName(jsonContact.lastName) .phone(jsonContact.phone) .businessTitle(jsonContact.businessTitle) .build(); contacts.add(contact); } } Customer customer = Customer.builder() .account(account) .contacts(contacts) .build(); Contact oportunityTeamContact = null; if (root.opportunityTeam != null && root.opportunityTeam.get(0) != null ) { oportunityTeamContact = Contact.builder() .firstName(root.opportunityTeam.get(0).firstName) .lastName(root.opportunityTeam.get(0).lastName) .email(root.opportunityTeam.get(0).email) .phone(root.opportunityTeam.get(0).phone) .businessTitle(root.opportunityTeam.get(0).businessTitle) .build(); } List<ExpectedCustomerSpend> expectedCustomerSpends = new ArrayList<ExpectedCustomerSpend>(); if ( root.project != null && root.project.expectedCustomerSpend != null) { for (org.example.entity.ExpectedCustomerSpend expectedCustomerSpendJson : root.project.expectedCustomerSpend) { ExpectedCustomerSpend expectedCustomerSpend = null; expectedCustomerSpend = ExpectedCustomerSpend.builder() .amount(expectedCustomerSpendJson.amount) .currencyCode(expectedCustomerSpendJson.currencyCode) .frequency(expectedCustomerSpendJson.frequency) .targetCompany(expectedCustomerSpendJson.targetCompany) .build(); expectedCustomerSpends.add(expectedCustomerSpend); } } Project project = null; if ( root.project != null) { project = Project.builder() .title(root.project.title) .customerBusinessProblem(root.project.customerBusinessProblem) .customerUseCase(root.project.customerUseCase) .deliveryModels(root.project.deliveryModels) .expectedCustomerSpend(expectedCustomerSpends) .salesActivities(root.project.salesActivities) .competitorName(root.project.competitorName) .otherSolutionDescription(root.project.otherSolutionDescription) .build(); } SoftwareRevenue softwareRevenue = null; if ( root.softwareRevenue != null) { MonetaryValue monetaryValue = null; if ( root.softwareRevenue.value != null) { monetaryValue = MonetaryValue.builder() .amount(root.softwareRevenue.value.amount) .currencyCode(root.softwareRevenue.value.currencyCode) .build(); } softwareRevenue = SoftwareRevenue.builder() .deliveryModel(root.softwareRevenue.deliveryModel) .effectiveDate(root.softwareRevenue.effectiveDate) .expirationDate(root.softwareRevenue.expirationDate) .value(monetaryValue) .build(); } // Building the Actual CreateOpportunity Request CreateOpportunityRequest createOpportunityRequest = CreateOpportunityRequest.builder() .catalog(CATALOG_TO_USE) .clientToken(root.clientToken) .primaryNeedsFromAwsWithStrings(root.primaryNeedsFromAws) .opportunityType(root.opportunityType) .lifeCycle(lifeCycle) .marketing(marketing) .nationalSecurity(root.nationalSecurity) .origin(root.origin) .customer(customer) .project(project) .partnerOpportunityIdentifier(root.partnerOpportunityIdentifier) .opportunityTeam(oportunityTeamContact) .softwareRevenue(softwareRevenue) .build(); CreateOpportunityResponse response = client.createOpportunity(createOpportunityRequest); System.out.println("Successfully created: " + response); return response; } }
-
Pour plus de détails sur l'API, reportez-vous CreateOpportunityà la section Référence des AWS SDK for Java 2.x API.
-
L'exemple de code suivant montre comment utiliserDisassociateOpportunity
.
- SDK pour Java 2.x
-
Supprimez une association existante entre une opportunité et des entités associées.
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.DisassociateOpportunityRequest; import software.amazon.awssdk.services.partnercentralselling.model.DisassociateOpportunityResponse; /* Purpose PC-API -14 Removing a Solution PC-API -15 Removing an offer PC-API -16 Removing a product entity_type = Solutions | AWSProducts | AWSMarketplaceOffers */ public class DisassociateOpportunity { 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"; DisassociateOpportunityResponse response = getResponse(opportunityId, entityType, entityIdentifier ); ReferenceCodesUtils.formatOutput(response); } static DisassociateOpportunityResponse getResponse(String opportunityId, String entityType, String entityIdentifier) { DisassociateOpportunityRequest disassociateOpportunityRequest = DisassociateOpportunityRequest.builder() .catalog(Constants.CATALOG_TO_USE) .opportunityIdentifier(opportunityId) .relatedEntityType(entityType) .relatedEntityIdentifier(entityIdentifier) .build(); DisassociateOpportunityResponse response = client.disassociateOpportunity(disassociateOpportunityRequest); return response; } }
-
Pour plus de détails sur l'API, reportez-vous DisassociateOpportunityà la section Référence des AWS SDK for Java 2.x API.
-
L'exemple de code suivant montre comment utiliserGetAwsOpportunitySummary
.
- SDK pour Java 2.x
-
Récupère le résumé d'une AWS opportunité.
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.GetAwsOpportunitySummaryRequest; import software.amazon.awssdk.services.partnercentralselling.model.GetAwsOpportunitySummaryResponse; /* * Purpose * PC-API-25 Retrieves a summary of an AWS Opportunity. */ public class GetAwsOpportunitySummary { 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; GetAwsOpportunitySummaryResponse response = getResponse(opportunityId); ReferenceCodesUtils.formatOutput(response); } public static GetAwsOpportunitySummaryResponse getResponse(String opportunityId) { GetAwsOpportunitySummaryRequest getOpportunityRequest = GetAwsOpportunitySummaryRequest.builder() .catalog(Constants.CATALOG_TO_USE) .relatedOpportunityIdentifier(opportunityId) .build(); GetAwsOpportunitySummaryResponse response = client.getAwsOpportunitySummary(getOpportunityRequest); return response; } }
-
Pour plus de détails sur l'API, reportez-vous GetAwsOpportunitySummaryà la section Référence des AWS SDK for Java 2.x API.
-
L'exemple de code suivant montre comment utiliserGetEngagementInvitation
.
- SDK pour Java 2.x
-
Récupère les détails d'une invitation d'engagement partagée AWS par un partenaire.
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.GetEngagementInvitationRequest; import software.amazon.awssdk.services.partnercentralselling.model.GetEngagementInvitationResponse; /* * Purpose * PC-API-22 Get engagement invitation opportunity */ public class GetEngagementInvitation { 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; GetEngagementInvitationResponse response = getResponse(opportunityId); ReferenceCodesUtils.formatOutput(response); } static GetEngagementInvitationResponse getResponse(String opportunityId) { GetEngagementInvitationRequest getOpportunityRequest = GetEngagementInvitationRequest.builder() .catalog(Constants.CATALOG_TO_USE) .identifier(opportunityId) .build(); GetEngagementInvitationResponse response = client.getEngagementInvitation(getOpportunityRequest); return response; } }
-
Pour plus de détails sur l'API, reportez-vous GetEngagementInvitationà la section Référence des AWS SDK for Java 2.x API.
-
L'exemple de code suivant montre comment utiliserGetOpportunity
.
- SDK pour Java 2.x
-
Profitez d'une opportunité.
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.GetOpportunityRequest; import software.amazon.awssdk.services.partnercentralselling.model.GetOpportunityResponse; /* * Purpose * PC-API-08 Get updated Opportunity */ public class GetOpportunity { 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; GetOpportunityResponse response = getResponse(opportunityId); ReferenceCodesUtils.formatOutput(response); } public static GetOpportunityResponse getResponse(String opportunityId) { GetOpportunityRequest getOpportunityRequest = GetOpportunityRequest.builder() .catalog(Constants.CATALOG_TO_USE) .identifier(opportunityId) .build(); GetOpportunityResponse response = client.getOpportunity(getOpportunityRequest); return response; } }
-
Pour plus de détails sur l'API, reportez-vous GetOpportunityà la section Référence des AWS SDK for Java 2.x API.
-
L'exemple de code suivant montre comment utiliserListEngagementInvitations
.
- SDK pour Java 2.x
-
Récupère la liste des invitations à des fiançailles envoyées au partenaire.
package org.example; import java.util.ArrayList; import java.util.List; import org.example.utils.ReferenceCodesUtils; import static org.example.utils.Constants.*; 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.ListEngagementInvitationsRequest; import software.amazon.awssdk.services.partnercentralselling.model.ListEngagementInvitationsResponse; import software.amazon.awssdk.services.partnercentralselling.model.ParticipantType; import software.amazon.awssdk.services.partnercentralselling.model.EngagementInvitationSummary; public class ListEngagementInvitations { static PartnerCentralSellingClient client = PartnerCentralSellingClient.builder() .region(Region.US_EAST_1) .credentialsProvider(DefaultCredentialsProvider.create()) .httpClient(ApacheHttpClient.builder().build()) .build(); public static void main(String[] args) { List<EngagementInvitationSummary> opportunitySummaries = getResponse(); ReferenceCodesUtils.formatOutput(opportunitySummaries); } static List<EngagementInvitationSummary> getResponse() { List<EngagementInvitationSummary> opportunitySummaries = new ArrayList<EngagementInvitationSummary>(); ListEngagementInvitationsRequest listOpportunityRequest = ListEngagementInvitationsRequest.builder() .catalog(CATALOG_TO_USE) .participantType(ParticipantType.RECEIVER) .maxResults(5) .build(); ListEngagementInvitationsResponse response = client.listEngagementInvitations(listOpportunityRequest); opportunitySummaries.addAll(response.engagementInvitationSummaries()); client.close(); return opportunitySummaries; } }
-
Pour plus de détails sur l'API, reportez-vous ListEngagementInvitationsà la section Référence des AWS SDK for Java 2.x API.
-
L'exemple de code suivant montre comment utiliserListOpportunities
.
- SDK pour Java 2.x
-
Énumérez les opportunités.
package org.example; import java.util.ArrayList; import java.util.List; import org.example.utils.ReferenceCodesUtils; import static org.example.utils.Constants.*; 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.ListOpportunitiesRequest; import software.amazon.awssdk.services.partnercentralselling.model.ListOpportunitiesResponse; import software.amazon.awssdk.services.partnercentralselling.model.OpportunitySummary; /* * Purpose * PC-API-18 Getting list of Opportunities */ public class ListOpportunititesPaging { static PartnerCentralSellingClient client = PartnerCentralSellingClient.builder() .region(Region.US_EAST_1) .credentialsProvider(DefaultCredentialsProvider.create()) .httpClient(ApacheHttpClient.builder().build()) .build(); public static void main(String[] args) { List<OpportunitySummary> opportunitySummaries = getResponse(); ReferenceCodesUtils.formatOutput(opportunitySummaries); } private static List<OpportunitySummary> getResponse() { List<OpportunitySummary> opportunitySummaries = new ArrayList<OpportunitySummary>(); ListOpportunitiesRequest listOpportunityRequest = ListOpportunitiesRequest.builder() .catalog(CATALOG_TO_USE) .maxResults(5) .build(); ListOpportunitiesResponse response = client.listOpportunities(listOpportunityRequest); opportunitySummaries.addAll(response.opportunitySummaries()); while (response.nextToken() != null && response.nextToken().length() > 0) { listOpportunityRequest = ListOpportunitiesRequest.builder() .catalog(CATALOG_TO_USE) .maxResults(5) .nextToken(response.nextToken()) .build(); response = client.listOpportunities(listOpportunityRequest); opportunitySummaries.addAll(response.opportunitySummaries()); } client.close(); return opportunitySummaries; } }
-
Pour plus de détails sur l'API, reportez-vous ListOpportunitiesà la section Référence des AWS SDK for Java 2.x API.
-
L'exemple de code suivant montre comment utiliserListSolutions
.
- SDK pour Java 2.x
-
Récupère la liste des solutions partenaires que le partenaire a enregistrées sur Partner Central.
package org.example; import java.util.ArrayList; import java.util.List; import static 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.ListSolutionsRequest; import software.amazon.awssdk.services.partnercentralselling.model.ListSolutionsResponse; import software.amazon.awssdk.services.partnercentralselling.model.SolutionBase; /* * Purpose * PC-API-10 Getting list of solutions */ public class ListSolutions { static PartnerCentralSellingClient client = PartnerCentralSellingClient.builder() .region(Region.US_EAST_1) .credentialsProvider(DefaultCredentialsProvider.create()) .httpClient(ApacheHttpClient.builder().build()) .build(); public static void main(String[] args) { List<SolutionBase> solutionSummaries = getResponse(); ReferenceCodesUtils.formatOutput(solutionSummaries); } static List<SolutionBase> getResponse() { List<SolutionBase> solutionSummaries = new ArrayList<SolutionBase>(); ListSolutionsRequest listSolutionsRequest = ListSolutionsRequest.builder() .catalog(CATALOG_TO_USE) .maxResults(5) .build(); ListSolutionsResponse response = client.listSolutions(listSolutionsRequest); solutionSummaries.addAll(response.solutionSummaries()); return solutionSummaries; } }
-
Pour plus de détails sur l'API, reportez-vous ListSolutionsà la section Référence des AWS SDK for Java 2.x API.
-
L'exemple de code suivant montre comment utiliserRejectEngagementInvitation
.
- SDK pour Java 2.x
-
Rejette une annonce EngagementInvitation qui a AWS été partagée.
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; } }
-
Pour plus de détails sur l'API, reportez-vous RejectEngagementInvitationà la section Référence des AWS SDK for Java 2.x API.
-
L'exemple de code suivant montre comment utiliserStartEngagementByAcceptingInvitationTask
.
- SDK pour Java 2.x
-
Commence l'engagement en acceptant un 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; } }
-
Pour plus de détails sur l'API, reportez-vous StartEngagementByAcceptingInvitationTaskà la section Référence des AWS SDK for Java 2.x API.
-
L'exemple de code suivant montre comment utiliserStartEngagementFromOpportunityTask
.
- SDK pour Java 2.x
-
Lance le processus d'engagement à partir d'une opportunité existante en acceptant l'invitation d'engagement et en créant une opportunité correspondante dans le système du partenaire.
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.AwsSubmission; import software.amazon.awssdk.services.partnercentralselling.model.SalesInvolvementType; import software.amazon.awssdk.services.partnercentralselling.model.StartEngagementFromOpportunityTaskRequest; import software.amazon.awssdk.services.partnercentralselling.model.StartEngagementFromOpportunityTaskResponse; import software.amazon.awssdk.services.partnercentralselling.model.Visibility; /* * Purpose * PC-API-01 Partner Originated (PO) opp submission(Start Engagement From Opportunity Task for AO Originated Opportunity) */ public class StartEngagementFromOpportunityTask { 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; StartEngagementFromOpportunityTaskResponse response = getResponse(opportunityId); ReferenceCodesUtils.formatOutput(response); } static StartEngagementFromOpportunityTaskResponse getResponse(String opportunityId) { StartEngagementFromOpportunityTaskRequest submitOpportunityRequest = StartEngagementFromOpportunityTaskRequest.builder() .catalog(Constants.CATALOG_TO_USE) .identifier(opportunityId) .clientToken("test-annjqwesdsd99") .awsSubmission(AwsSubmission.builder().involvementType(SalesInvolvementType.CO_SELL).visibility(Visibility.FULL).build()) .build(); StartEngagementFromOpportunityTaskResponse response = client.startEngagementFromOpportunityTask(submitOpportunityRequest); return response; } }
-
Pour plus de détails sur l'API, reportez-vous StartEngagementFromOpportunityTaskà la section Référence des AWS SDK for Java 2.x API.
-
L'exemple de code suivant montre comment utiliserUpdateOpportunity
.
- SDK pour Java 2.x
-
Mettez à jour une opportunité.
package org.example; import java.time.Instant; import java.util.ArrayList; import java.util.List; import static org.example.utils.Constants.*; import org.example.entity.Root; import org.example.utils.Constants; import org.example.utils.ReferenceCodesUtils; import org.example.utils.StringSerializer; 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.Account; import software.amazon.awssdk.services.partnercentralselling.model.Address; import software.amazon.awssdk.services.partnercentralselling.model.Contact; import software.amazon.awssdk.services.partnercentralselling.model.Customer; import software.amazon.awssdk.services.partnercentralselling.model.ExpectedCustomerSpend; import software.amazon.awssdk.services.partnercentralselling.model.GetOpportunityRequest; import software.amazon.awssdk.services.partnercentralselling.model.GetOpportunityResponse; import software.amazon.awssdk.services.partnercentralselling.model.LifeCycle; import software.amazon.awssdk.services.partnercentralselling.model.Marketing; import software.amazon.awssdk.services.partnercentralselling.model.NextStepsHistory; import software.amazon.awssdk.services.partnercentralselling.model.Project; import software.amazon.awssdk.services.partnercentralselling.model.ReviewStatus; import software.amazon.awssdk.services.partnercentralselling.model.UpdateOpportunityRequest; import software.amazon.awssdk.services.partnercentralselling.model.UpdateOpportunityResponse; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.ToNumberPolicy; /* * Purpose * PC-API-02/06 Update opportunity when LifeCycle.ReviewStatus is not Submitted or In-Review */ public class UpdateOpportunity { static final Gson GSON = new GsonBuilder() .setObjectToNumberStrategy(ToNumberPolicy.LAZILY_PARSED_NUMBER) .registerTypeAdapter(String.class, new StringSerializer()) .create(); static PartnerCentralSellingClient client = PartnerCentralSellingClient.builder() .region(Region.US_EAST_1) .credentialsProvider(DefaultCredentialsProvider.create()) .httpClient(ApacheHttpClient.builder().build()) .build(); static String OPPORTUNITY_ORIGIN = ORIGIN_PARTNER_ORIGINATED; public static void main(String[] args) { String inputFile = "updateOpportunity.json"; if (args.length > 0) inputFile = args[0]; UpdateOpportunityResponse response = updateOpportunity(inputFile); client.close(); } public static GetOpportunityResponse getResponse(String opportunityId) { GetOpportunityRequest getOpportunityRequest = GetOpportunityRequest.builder() .catalog(Constants.CATALOG_TO_USE) .identifier(opportunityId) .build(); GetOpportunityResponse response = client.getOpportunity(getOpportunityRequest); System.out.println(opportunityId + ":" + response); return response; } public static UpdateOpportunityResponse updateOpportunity(String inputFile) { String inputString = ReferenceCodesUtils.readInputFileToString(inputFile); Root root = GSON.fromJson(inputString, Root.class); GetOpportunityResponse response = getResponse(root.identifier); if (response != null && response.lifeCycle() != null && response.lifeCycle().reviewStatus() != null && response.lifeCycle().reviewStatus() != ReviewStatus.SUBMITTED && response.lifeCycle().reviewStatus() != ReviewStatus.IN_REVIEW) { List<NextStepsHistory> nextStepsHistories = new ArrayList<NextStepsHistory>(); if ( root.lifeCycle != null && root.lifeCycle.nextStepsHistories != null) { for (org.example.entity.NextStepsHistory nextStepsHistoryJson : root.lifeCycle.nextStepsHistories) { NextStepsHistory nextStepsHistory = NextStepsHistory.builder() .time(Instant.parse(nextStepsHistoryJson.time)) .value(nextStepsHistoryJson.value) .build(); nextStepsHistories.add(nextStepsHistory); } } LifeCycle lifeCycle = null; if ( root.lifeCycle != null ) { lifeCycle = LifeCycle.builder() .closedLostReason(root.lifeCycle.closedLostReason) .nextSteps(root.lifeCycle.nextSteps) .nextStepsHistory(nextStepsHistories) .reviewComments(root.lifeCycle.reviewComments) .reviewStatus(root.lifeCycle.reviewStatus) .reviewStatusReason(root.lifeCycle.reviewStatusReason) .stage(root.lifeCycle.stage) .targetCloseDate(root.lifeCycle.targetCloseDate) .build(); } Marketing marketing = null; if ( root.marketing != null ) { marketing = Marketing.builder() .awsFundingUsed(root.marketing.awsFundingUsed) .campaignName(root.marketing.campaignName) .channels(root.marketing.channels) .source(root.marketing.source) .useCases(root.marketing.useCases) .build(); } Address address = null; if (root.customer != null && root.customer.account != null && root.customer.account.address != null) { address = Address.builder().postalCode(root.customer.account.address.postalCode) .stateOrRegion(root.customer.account.address.stateOrRegion) .countryCode(root.customer.account.address.countryCode).build(); } Account account = null; if (root.customer != null && root.customer.account != null) { account = Account.builder().address(address).duns(root.customer.account.duns) .industry(root.customer.account.industry).companyName(root.customer.account.companyName) .websiteUrl(root.customer.account.websiteUrl).build(); } List<Contact> contacts = new ArrayList<Contact>(); if ( root.customer != null && root.customer.contacts != null) { for (org.example.entity.Contact jsonContact : root.customer.contacts) { Contact contact = Contact.builder() .email(jsonContact.email) .firstName(jsonContact.firstName) .lastName(jsonContact.lastName) .phone(jsonContact.phone) .businessTitle(jsonContact.businessTitle) .build(); contacts.add(contact); } } Customer customer = Customer.builder().account(account).contacts(contacts).build(); List<ExpectedCustomerSpend> expectedCustomerSpends = new ArrayList<ExpectedCustomerSpend>(); if ( root.project != null && root.project.expectedCustomerSpend != null) { for (org.example.entity.ExpectedCustomerSpend expectedCustomerSpendJson : root.project.expectedCustomerSpend) { ExpectedCustomerSpend expectedCustomerSpend = null; expectedCustomerSpend = ExpectedCustomerSpend.builder() .amount(expectedCustomerSpendJson.amount) .currencyCode(expectedCustomerSpendJson.currencyCode) .frequency(expectedCustomerSpendJson.frequency) .targetCompany(expectedCustomerSpendJson.targetCompany) .build(); expectedCustomerSpends.add(expectedCustomerSpend); } } Project project = null; if (root.project != null) { project = Project.builder().title(root.project.title) .customerBusinessProblem(root.project.customerBusinessProblem) .customerUseCase(root.project.customerUseCase).deliveryModels(root.project.deliveryModels) .expectedCustomerSpend(expectedCustomerSpends) .salesActivities(root.project.salesActivities).competitorName(root.project.competitorName) .otherSolutionDescription(root.project.otherSolutionDescription).build(); } // Building the Actual CreateOpportunity Request UpdateOpportunityRequest updateOpportunityRequest = UpdateOpportunityRequest.builder().catalog(root.catalog) .identifier(root.identifier).lastModifiedDate(Instant.parse(root.lastModifiedDate)) .primaryNeedsFromAwsWithStrings(root.primaryNeedsFromAws).opportunityType(root.opportunityType) .lifeCycle(lifeCycle) .customer(customer) .project(project) .partnerOpportunityIdentifier(root.partnerOpportunityIdentifier) .marketing(marketing) .nationalSecurity(root.nationalSecurity) .opportunityType(root.opportunityType) .build(); UpdateOpportunityResponse updateResponse = client.updateOpportunity(updateOpportunityRequest); System.out.println("Successfully updated opportunity: " + updateResponse); return updateResponse; } else { System.out.println("Opportunity cannot be updated."); return null; } } }
-
Pour plus de détails sur l'API, reportez-vous UpdateOpportunityà la section Référence des AWS SDK for Java 2.x API.
-
Scénarios
L’exemple de code suivant illustre comment :
Dissociez une ancienne entité.
Associez une nouvelle entité.
- SDK pour Java 2.x
-
Note
Il y en a plus à ce sujet GitHub. Trouvez l’exemple complet et découvrez comment le configurer et l’exécuter dans le référentiel d’exemples de code AWS
. Mettre à jour l'entité associée à une opportunité
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; import software.amazon.awssdk.services.partnercentralselling.model.DisassociateOpportunityRequest; import software.amazon.awssdk.services.partnercentralselling.model.DisassociateOpportunityResponse; /* Purpose PC-API -17 Replacing a solution */ public class ReplaceSolution { 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 originalEntityIdentifier = "S-0000000"; String newEntityIdentifier = "S-0011111"; disassociateOppornitityResponse(opportunityId, entityType, originalEntityIdentifier ); AssociateOpportunityResponse associateOpportunityResponse = associateOpportunityResponse(opportunityId, entityType, newEntityIdentifier ); ReferenceCodesUtils.formatOutput(associateOpportunityResponse); } private static AssociateOpportunityResponse associateOpportunityResponse(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; } private static DisassociateOpportunityResponse disassociateOppornitityResponse(String opportunityId, String entityType, String entityIdentifier) { PartnerCentralSellingClient client = PartnerCentralSellingClient.builder() .region(Region.US_EAST_1) .credentialsProvider(DefaultCredentialsProvider.create()) .httpClient(ApacheHttpClient.builder().build()) .build(); DisassociateOpportunityRequest disassociateOpportunityRequest = DisassociateOpportunityRequest.builder() .catalog(Constants.CATALOG_TO_USE) .opportunityIdentifier(opportunityId) .relatedEntityType(entityType) .relatedEntityIdentifier(entityIdentifier) .build(); DisassociateOpportunityResponse response = client.disassociateOpportunity(disassociateOpportunityRequest); return response; } }
-
Pour plus d'informations sur l'API consultez les rubriques suivantes dans la référence de l'API AWS SDK for Java 2.x .
-