La version 4 (V4) du AWS SDK pour .NET est sortie !
Pour commencer à utiliser la nouvelle version du SDK, consultez le guide du développeur AWS SDK pour .NET (V4), en particulier la rubrique relative à la migration vers la version 4.
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 d'utilisation de Partner Central SDK pour .NET
Les exemples de code suivants vous montrent comment effectuer des actions et implémenter des scénarios courants à l' AWS SDK pour .NET 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.
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.
Rubriques
Actions
L'exemple de code suivant montre comment utiliserCreateOpportunity
.
- SDK pour .NET
-
Créez une opportunité.
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // PDX-License-Identifier: Apache-2.0 using System; using Newtonsoft.Json; using Amazon; using Amazon.Runtime; using Amazon.PartnerCentralSelling; using Amazon.PartnerCentralSelling.Model; namespace AWSExample { class Program { static readonly string catalogToUse = "AWS"; static async Task Main(string[] args) { // Initialize credentials from .aws/credentials file var credentials = new Amazon.Runtime.CredentialManagement.SharedCredentialsFile(); if (credentials.TryGetProfile("default", out var profile)) { AWSCredentials awsCredentials = profile.GetAWSCredentials(credentials); var client = new AmazonPartnerCentralSellingClient(awsCredentials); var request = new CreateOpportunityRequest { Catalog = catalogToUse, Origin = "Partner Referral", Customer = new Customer { Account = new Account { Address = new Address { CountryCode = "US", PostalCode = "99502", StateOrRegion = "Alaska" }, CompanyName = "TestCompanyName", Duns = "123456789", WebsiteUrl = "www.test.io", Industry = "Automotive" }, Contacts = new List<Contact> { new Contact { Email = "test@test.io", FirstName = "John ", LastName = "Doe", Phone = "+14444444444", BusinessTitle = "test title" } } }, LifeCycle = new LifeCycle { ReviewStatus = "Submitted", TargetCloseDate = "2024-12-30" }, Marketing = new Marketing { Source = "None" }, OpportunityType = "Net New Business", PrimaryNeedsFromAws = new List<string> { "Co-Sell - Architectural Validation" }, Project = new Project { Title = "Moin Test UUID", CustomerBusinessProblem = "Sandbox is not working as expected", CustomerUseCase = "AI Machine Learning and Analytics", DeliveryModels = new List<string> { "SaaS or PaaS" }, ExpectedCustomerSpend = new List<ExpectedCustomerSpend> { new ExpectedCustomerSpend { Amount = "2000.0", CurrencyCode = "USD", Frequency = "Monthly", TargetCompany = "Ibexlabs" } }, SalesActivities = new List<string> { "Initialized discussions with customer" } } }; try { var response = await client.CreateOpportunityAsync(request); Console.WriteLine(response.HttpStatusCode); string formattedJson = JsonConvert.SerializeObject(response, Formatting.Indented); Console.WriteLine(formattedJson); } catch (ValidationException ex) { Console.WriteLine("Validation error: " + ex.Message); } catch (AmazonPartnerCentralSellingException e) { Console.WriteLine("Failed:"); Console.WriteLine(e.RequestId); Console.WriteLine(e.ErrorCode); Console.WriteLine(e.Message); } } else { Console.WriteLine("Profile not found."); } } } }
-
Pour plus de détails sur l'API, reportez-vous CreateOpportunityà la section Référence des AWS SDK pour .NET API.
-
L'exemple de code suivant montre comment utiliserGetOpportunity
.
- SDK pour .NET
-
Profitez d'une opportunité.
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // PDX-License-Identifier: Apache-2.0 using System; using Newtonsoft.Json; using Amazon; using Amazon.Runtime; using Amazon.PartnerCentralSelling; using Amazon.PartnerCentralSelling.Model; namespace AWSExample { class Program { static readonly string catalogToUse = "AWS"; static readonly string identifier = "O1111111"; static async Task Main(string[] args) { // Initialize credentials from .aws/credentials file var credentials = new Amazon.Runtime.CredentialManagement.SharedCredentialsFile(); if (credentials.TryGetProfile("default", out var profile)) { AWSCredentials awsCredentials = profile.GetAWSCredentials(credentials); var client = new AmazonPartnerCentralSellingClient(awsCredentials); var request = new GetOpportunityRequest { Catalog = catalogToUse, Identifier = identifier }; try { var response = await client.GetOpportunityAsync(request); Console.WriteLine(response.HttpStatusCode); string formattedJson = JsonConvert.SerializeObject(response, Formatting.Indented); Console.WriteLine(formattedJson); } catch(ValidationException ex) { Console.WriteLine("Validation error: " + ex.Message); } catch (AmazonPartnerCentralSellingException e) { Console.WriteLine("Failed:"); Console.WriteLine(e.RequestId); Console.WriteLine(e.ErrorCode); Console.WriteLine(e.Message); } } else { Console.WriteLine("Profile not found."); } } } }
-
Pour plus de détails sur l'API, reportez-vous GetOpportunityà la section Référence des AWS SDK pour .NET API.
-
L'exemple de code suivant montre comment utiliserListOpportunities
.
- SDK pour .NET
-
Énumérez les opportunités.
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // PDX-License-Identifier: Apache-2.0 using System; using Newtonsoft.Json; using Amazon; using Amazon.Runtime; using Amazon.PartnerCentralSelling; using Amazon.PartnerCentralSelling.Model; namespace AWSExample { class Program { static readonly string catalogToUse = "Sandbox"; static async Task Main(string[] args) { // Initialize credentials from .aws/credentials file var credentials = new Amazon.Runtime.CredentialManagement.SharedCredentialsFile(); if (credentials.TryGetProfile("default", out var profile)) { AWSCredentials awsCredentials = profile.GetAWSCredentials(credentials); //var config = new AmazonPartnerCentralSellingConfig() //{ // ServiceURL = "https://partnercentral-selling.us-east-1.api.aws", //}; //var client = new AmazonPartnerCentralSellingClient(awsCredentials, config); var client = new AmazonPartnerCentralSellingClient(awsCredentials); var request = new ListOpportunitiesRequest { Catalog = catalogToUse, MaxResults = 2 }; try { var response = await client.ListOpportunitiesAsync(request); Console.WriteLine(response.HttpStatusCode); foreach (var opportunity in response.OpportunitySummaries) { Console.WriteLine("Opportunity id: " + opportunity.Id); } string formattedJson = JsonConvert.SerializeObject(response.OpportunitySummaries, Formatting.Indented); Console.WriteLine(formattedJson); } catch(ValidationException ex) { Console.WriteLine("Validation error: " + ex.Message); } catch (AmazonPartnerCentralSellingException e) { Console.WriteLine("Failed:"); Console.WriteLine(e.RequestId); Console.WriteLine(e.ErrorCode); Console.WriteLine(e.Message); } } else { Console.WriteLine("Profile not found."); } } } }
-
Pour plus de détails sur l'API, reportez-vous ListOpportunitiesà la section Référence des AWS SDK pour .NET API.
-