Ada lebih banyak AWS SDK contoh yang tersedia di GitHub repo SDKContoh AWS Dokumen
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Route 53 contoh pendaftaran domain menggunakan AWS SDK for .NET
Contoh kode berikut menunjukkan cara melakukan tindakan dan menerapkan skenario umum dengan menggunakan pendaftaran domain AWS SDK for .NET with Route 53.
Dasar-dasar adalah contoh kode yang menunjukkan kepada Anda bagaimana melakukan operasi penting dalam suatu layanan.
Tindakan adalah kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.
Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.
Memulai
Contoh kode berikut menunjukkan cara memulai menggunakan pendaftaran domain Route 53.
- AWS SDK for .NET
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. public static class HelloRoute53Domains { static async Task Main(string[] args) { // Use the AWS .NET Core Setup package to set up dependency injection for the Amazon Route 53 domain registration service. // Use your AWS profile name, or leave it blank to use the default profile. using var host = Host.CreateDefaultBuilder(args) .ConfigureServices((_, services) => services.AddAWSService<IAmazonRoute53Domains>() ).Build(); // Now the client is available for injection. var route53Client = host.Services.GetRequiredService<IAmazonRoute53Domains>(); // You can use await and any of the async methods to get a response. var response = await route53Client.ListPricesAsync(new ListPricesRequest { Tld = "com" }); Console.WriteLine($"Hello Amazon Route 53 Domains! Following are prices for .com domain operations:"); var comPrices = response.Prices.FirstOrDefault(); if (comPrices != null) { Console.WriteLine($"\tRegistration: {comPrices.RegistrationPrice?.Price} {comPrices.RegistrationPrice?.Currency}"); Console.WriteLine($"\tRenewal: {comPrices.RenewalPrice?.Price} {comPrices.RenewalPrice?.Currency}"); } } }
-
Untuk API detailnya, lihat ListPricesdi AWS SDK for .NET APIReferensi.
-
Hal-hal mendasar
Contoh kode berikut ini menunjukkan cara:
Buat daftar domain saat ini, dan daftar operasi dalam satu tahun terakhir.
Lihat tagihan selama setahun terakhir, dan lihat harga untuk jenis domain.
Dapatkan saran domain.
Periksa ketersediaan domain dan transferabilitas.
Secara opsional, minta pendaftaran domain.
Dapatkan detail operasi.
Secara opsional, dapatkan detail domain.
- AWS SDK for .NET
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. Jalankan skenario interaktif di penggugah/prompt perintah.
public static class Route53DomainScenario { /* Before running this .NET code example, set up your development environment, including your credentials. This .NET example performs the following tasks: 1. List current domains. 2. List operations in the past year. 3. View billing for the account in the past year. 4. View prices for domain types. 5. Get domain suggestions. 6. Check domain availability. 7. Check domain transferability. 8. Optionally, request a domain registration. 9. Get an operation detail. 10. Optionally, get a domain detail. */ private static Route53Wrapper _route53Wrapper = null!; private static IConfiguration _configuration = null!; static async Task Main(string[] args) { // Set up dependency injection for the Amazon service. using var host = Host.CreateDefaultBuilder(args) .ConfigureLogging(logging => logging.AddFilter("System", LogLevel.Debug) .AddFilter<DebugLoggerProvider>("Microsoft", LogLevel.Information) .AddFilter<ConsoleLoggerProvider>("Microsoft", LogLevel.Trace)) .ConfigureServices((_, services) => services.AddAWSService<IAmazonRoute53Domains>() .AddTransient<Route53Wrapper>() ) .Build(); _configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("settings.json") // Load settings from .json file. .AddJsonFile("settings.local.json", true) // Optionally, load local settings. .Build(); var logger = LoggerFactory.Create(builder => { builder.AddConsole(); }).CreateLogger(typeof(Route53DomainScenario)); _route53Wrapper = host.Services.GetRequiredService<Route53Wrapper>(); Console.WriteLine(new string('-', 80)); Console.WriteLine("Welcome to the Amazon Route 53 domains example scenario."); Console.WriteLine(new string('-', 80)); try { await ListDomains(); await ListOperations(); await ListBillingRecords(); await ListPrices(); await ListDomainSuggestions(); await CheckDomainAvailability(); await CheckDomainTransferability(); var operationId = await RequestDomainRegistration(); await GetOperationalDetail(operationId); await GetDomainDetails(); } catch (Exception ex) { logger.LogError(ex, "There was a problem executing the scenario."); } Console.WriteLine(new string('-', 80)); Console.WriteLine("The Amazon Route 53 domains example scenario is complete."); Console.WriteLine(new string('-', 80)); } /// <summary> /// List account registered domains. /// </summary> /// <returns>Async task.</returns> private static async Task ListDomains() { Console.WriteLine(new string('-', 80)); Console.WriteLine($"1. List account domains."); var domains = await _route53Wrapper.ListDomains(); for (int i = 0; i < domains.Count; i++) { Console.WriteLine($"\t{i + 1}. {domains[i].DomainName}"); } if (!domains.Any()) { Console.WriteLine("\tNo domains found in this account."); } Console.WriteLine(new string('-', 80)); } /// <summary> /// List domain operations in the past year. /// </summary> /// <returns>Async task.</returns> private static async Task ListOperations() { Console.WriteLine(new string('-', 80)); Console.WriteLine($"2. List account domain operations in the past year."); var operations = await _route53Wrapper.ListOperations( DateTime.Today.AddYears(-1)); for (int i = 0; i < operations.Count; i++) { Console.WriteLine($"\tOperation Id: {operations[i].OperationId}"); Console.WriteLine($"\tStatus: {operations[i].Status}"); Console.WriteLine($"\tDate: {operations[i].SubmittedDate}"); } Console.WriteLine(new string('-', 80)); } /// <summary> /// List billing in the past year. /// </summary> /// <returns>Async task.</returns> private static async Task ListBillingRecords() { Console.WriteLine(new string('-', 80)); Console.WriteLine($"3. View billing for the account in the past year."); var billingRecords = await _route53Wrapper.ViewBilling( DateTime.Today.AddYears(-1), DateTime.Today); for (int i = 0; i < billingRecords.Count; i++) { Console.WriteLine($"\tBill Date: {billingRecords[i].BillDate.ToShortDateString()}"); Console.WriteLine($"\tOperation: {billingRecords[i].Operation}"); Console.WriteLine($"\tPrice: {billingRecords[i].Price}"); } if (!billingRecords.Any()) { Console.WriteLine("\tNo billing records found in this account for the past year."); } Console.WriteLine(new string('-', 80)); } /// <summary> /// List prices for a few domain types. /// </summary> /// <returns>Async task.</returns> private static async Task ListPrices() { Console.WriteLine(new string('-', 80)); Console.WriteLine($"4. View prices for domain types."); var domainTypes = new List<string> { "net", "com", "org", "co" }; var prices = await _route53Wrapper.ListPrices(domainTypes); foreach (var pr in prices) { Console.WriteLine($"\tName: {pr.Name}"); Console.WriteLine($"\tRegistration: {pr.RegistrationPrice?.Price} {pr.RegistrationPrice?.Currency}"); Console.WriteLine($"\tRenewal: {pr.RenewalPrice?.Price} {pr.RenewalPrice?.Currency}"); Console.WriteLine($"\tTransfer: {pr.TransferPrice?.Price} {pr.TransferPrice?.Currency}"); Console.WriteLine($"\tChange Ownership: {pr.ChangeOwnershipPrice?.Price} {pr.ChangeOwnershipPrice?.Currency}"); Console.WriteLine($"\tRestoration: {pr.RestorationPrice?.Price} {pr.RestorationPrice?.Currency}"); Console.WriteLine(); } Console.WriteLine(new string('-', 80)); } /// <summary> /// List domain suggestions for a domain name. /// </summary> /// <returns>Async task.</returns> private static async Task ListDomainSuggestions() { Console.WriteLine(new string('-', 80)); Console.WriteLine($"5. Get domain suggestions."); string? domainName = null; while (domainName == null || string.IsNullOrWhiteSpace(domainName)) { Console.WriteLine($"Enter a domain name to get available domain suggestions."); domainName = Console.ReadLine(); } var suggestions = await _route53Wrapper.GetDomainSuggestions(domainName, true, 5); foreach (var suggestion in suggestions) { Console.WriteLine($"\tSuggestion Name: {suggestion.DomainName}"); Console.WriteLine($"\tAvailability: {suggestion.Availability}"); } Console.WriteLine(new string('-', 80)); } /// <summary> /// Check availability for a domain name. /// </summary> /// <returns>Async task.</returns> private static async Task CheckDomainAvailability() { Console.WriteLine(new string('-', 80)); Console.WriteLine($"6. Check domain availability."); string? domainName = null; while (domainName == null || string.IsNullOrWhiteSpace(domainName)) { Console.WriteLine($"Enter a domain name to check domain availability."); domainName = Console.ReadLine(); } var availability = await _route53Wrapper.CheckDomainAvailability(domainName); Console.WriteLine($"\tAvailability: {availability}"); Console.WriteLine(new string('-', 80)); } /// <summary> /// Check transferability for a domain name. /// </summary> /// <returns>Async task.</returns> private static async Task CheckDomainTransferability() { Console.WriteLine(new string('-', 80)); Console.WriteLine($"7. Check domain transferability."); string? domainName = null; while (domainName == null || string.IsNullOrWhiteSpace(domainName)) { Console.WriteLine($"Enter a domain name to check domain transferability."); domainName = Console.ReadLine(); } var transferability = await _route53Wrapper.CheckDomainTransferability(domainName); Console.WriteLine($"\tTransferability: {transferability}"); Console.WriteLine(new string('-', 80)); } /// <summary> /// Check transferability for a domain name. /// </summary> /// <returns>Async task.</returns> private static async Task<string?> RequestDomainRegistration() { Console.WriteLine(new string('-', 80)); Console.WriteLine($"8. Optionally, request a domain registration."); Console.WriteLine($"\tNote: This example uses domain request settings in settings.json."); Console.WriteLine($"\tTo change the domain registration settings, set the values in that file."); Console.WriteLine($"\tRemember, registering an actual domain will incur an account billing cost."); Console.WriteLine($"\tWould you like to begin a domain registration? (y/n)"); var ynResponse = Console.ReadLine(); if (ynResponse != null && ynResponse.Equals("y", StringComparison.InvariantCultureIgnoreCase)) { string domainName = _configuration["DomainName"]; ContactDetail contact = new ContactDetail(); contact.CountryCode = CountryCode.FindValue(_configuration["Contact:CountryCode"]); contact.ContactType = ContactType.FindValue(_configuration["Contact:ContactType"]); _configuration.GetSection("Contact").Bind(contact); var operationId = await _route53Wrapper.RegisterDomain( domainName, Convert.ToBoolean(_configuration["AutoRenew"]), Convert.ToInt32(_configuration["DurationInYears"]), contact); if (operationId != null) { Console.WriteLine( $"\tRegistration requested. Operation Id: {operationId}"); } return operationId; } Console.WriteLine(new string('-', 80)); return null; } /// <summary> /// Get details for an operation. /// </summary> /// <returns>Async task.</returns> private static async Task GetOperationalDetail(string? operationId) { Console.WriteLine(new string('-', 80)); Console.WriteLine($"9. Get an operation detail."); var operationDetails = await _route53Wrapper.GetOperationDetail(operationId); Console.WriteLine(operationDetails); Console.WriteLine(new string('-', 80)); } /// <summary> /// Optionally, get details for a registered domain. /// </summary> /// <returns>Async task.</returns> private static async Task<string?> GetDomainDetails() { Console.WriteLine(new string('-', 80)); Console.WriteLine($"10. Get details on a domain."); Console.WriteLine($"\tNote: you must have a registered domain to get details."); Console.WriteLine($"\tWould you like to get domain details? (y/n)"); var ynResponse = Console.ReadLine(); if (ynResponse != null && ynResponse.Equals("y", StringComparison.InvariantCultureIgnoreCase)) { string? domainName = null; while (domainName == null) { Console.WriteLine($"\tEnter a domain name to get details."); domainName = Console.ReadLine(); } var domainDetails = await _route53Wrapper.GetDomainDetail(domainName); Console.WriteLine(domainDetails); } Console.WriteLine(new string('-', 80)); return null; } }
Metode pembungkus yang digunakan oleh skenario untuk tindakan pendaftaran domain Route 53.
public class Route53Wrapper { private readonly IAmazonRoute53Domains _amazonRoute53Domains; private readonly ILogger<Route53Wrapper> _logger; public Route53Wrapper(IAmazonRoute53Domains amazonRoute53Domains, ILogger<Route53Wrapper> logger) { _amazonRoute53Domains = amazonRoute53Domains; _logger = logger; } /// <summary> /// List prices for domain type operations. /// </summary> /// <param name="domainTypes">Domain types to include in the results.</param> /// <returns>The list of domain prices.</returns> public async Task<List<DomainPrice>> ListPrices(List<string> domainTypes) { var results = new List<DomainPrice>(); var paginatePrices = _amazonRoute53Domains.Paginators.ListPrices(new ListPricesRequest()); // Get the entire list using the paginator. await foreach (var prices in paginatePrices.Prices) { results.Add(prices); } return results.Where(p => domainTypes.Contains(p.Name)).ToList(); } /// <summary> /// Check the availability of a domain name. /// </summary> /// <param name="domain">The domain to check for availability.</param> /// <returns>An availability result string.</returns> public async Task<string> CheckDomainAvailability(string domain) { var result = await _amazonRoute53Domains.CheckDomainAvailabilityAsync( new CheckDomainAvailabilityRequest { DomainName = domain } ); return result.Availability.Value; } /// <summary> /// Check the transferability of a domain name. /// </summary> /// <param name="domain">The domain to check for transferability.</param> /// <returns>A transferability result string.</returns> public async Task<string> CheckDomainTransferability(string domain) { var result = await _amazonRoute53Domains.CheckDomainTransferabilityAsync( new CheckDomainTransferabilityRequest { DomainName = domain } ); return result.Transferability.Transferable.Value; } /// <summary> /// Get a list of suggestions for a given domain. /// </summary> /// <param name="domain">The domain to check for suggestions.</param> /// <param name="onlyAvailable">If true, only returns available domains.</param> /// <param name="suggestionCount">The number of suggestions to return. Defaults to the max of 50.</param> /// <returns>A collection of domain suggestions.</returns> public async Task<List<DomainSuggestion>> GetDomainSuggestions(string domain, bool onlyAvailable, int suggestionCount = 50) { var result = await _amazonRoute53Domains.GetDomainSuggestionsAsync( new GetDomainSuggestionsRequest { DomainName = domain, OnlyAvailable = onlyAvailable, SuggestionCount = suggestionCount } ); return result.SuggestionsList; } /// <summary> /// Get details for a domain action operation. /// </summary> /// <param name="operationId">The operational Id.</param> /// <returns>A string describing the operational details.</returns> public async Task<string> GetOperationDetail(string? operationId) { if (operationId == null) return "Unable to get operational details because ID is null."; try { var operationDetails = await _amazonRoute53Domains.GetOperationDetailAsync( new GetOperationDetailRequest { OperationId = operationId } ); var details = $"\tOperation {operationId}:\n" + $"\tFor domain {operationDetails.DomainName} on {operationDetails.SubmittedDate.ToShortDateString()}.\n" + $"\tMessage is {operationDetails.Message}.\n" + $"\tStatus is {operationDetails.Status}.\n"; return details; } catch (AmazonRoute53DomainsException ex) { return $"Unable to get operation details. Here's why: {ex.Message}."; } } /// <summary> /// Initiate a domain registration request. /// </summary> /// <param name="contact">Contact details.</param> /// <param name="domainName">The domain name to register.</param> /// <param name="autoRenew">True if the domain should automatically renew.</param> /// <param name="duration">The duration in years for the domain registration.</param> /// <returns>The operation Id.</returns> public async Task<string?> RegisterDomain(string domainName, bool autoRenew, int duration, ContactDetail contact) { // This example uses the same contact information for admin, registrant, and tech contacts. try { var result = await _amazonRoute53Domains.RegisterDomainAsync( new RegisterDomainRequest() { AdminContact = contact, RegistrantContact = contact, TechContact = contact, DomainName = domainName, AutoRenew = autoRenew, DurationInYears = duration, PrivacyProtectAdminContact = false, PrivacyProtectRegistrantContact = false, PrivacyProtectTechContact = false } ); return result.OperationId; } catch (InvalidInputException) { _logger.LogInformation($"Unable to request registration for domain {domainName}"); return null; } } /// <summary> /// View billing records for the account between a start and end date. /// </summary> /// <param name="startDate">The start date for billing results.</param> /// <param name="endDate">The end date for billing results.</param> /// <returns>A collection of billing records.</returns> public async Task<List<BillingRecord>> ViewBilling(DateTime startDate, DateTime endDate) { var results = new List<BillingRecord>(); var paginateBilling = _amazonRoute53Domains.Paginators.ViewBilling( new ViewBillingRequest() { Start = startDate, End = endDate }); // Get the entire list using the paginator. await foreach (var billingRecords in paginateBilling.BillingRecords) { results.Add(billingRecords); } return results; } /// <summary> /// List the domains for the account. /// </summary> /// <returns>A collection of domain summary records.</returns> public async Task<List<DomainSummary>> ListDomains() { var results = new List<DomainSummary>(); var paginateDomains = _amazonRoute53Domains.Paginators.ListDomains( new ListDomainsRequest()); // Get the entire list using the paginator. await foreach (var domain in paginateDomains.Domains) { results.Add(domain); } return results; } /// <summary> /// List operations for the account that are submitted after a specified date. /// </summary> /// <returns>A collection of operation summary records.</returns> public async Task<List<OperationSummary>> ListOperations(DateTime submittedSince) { var results = new List<OperationSummary>(); var paginateOperations = _amazonRoute53Domains.Paginators.ListOperations( new ListOperationsRequest() { SubmittedSince = submittedSince }); // Get the entire list using the paginator. await foreach (var operations in paginateOperations.Operations) { results.Add(operations); } return results; } /// <summary> /// Get details for a domain. /// </summary> /// <returns>A string with detail information about the domain.</returns> public async Task<string> GetDomainDetail(string domainName) { try { var result = await _amazonRoute53Domains.GetDomainDetailAsync( new GetDomainDetailRequest() { DomainName = domainName }); var details = $"\tDomain {domainName}:\n" + $"\tCreated on {result.CreationDate.ToShortDateString()}.\n" + $"\tAdmin contact is {result.AdminContact.Email}.\n" + $"\tAuto-renew is {result.AutoRenew}.\n"; return details; } catch (InvalidInputException) { return $"Domain {domainName} was not found in your account."; } } }
-
Untuk API detailnya, lihat topik berikut di AWS SDK for .NET APIReferensi.
-
Tindakan
Contoh kode berikut menunjukkan cara menggunakanCheckDomainAvailability
.
- AWS SDK for .NET
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. /// <summary> /// Check the availability of a domain name. /// </summary> /// <param name="domain">The domain to check for availability.</param> /// <returns>An availability result string.</returns> public async Task<string> CheckDomainAvailability(string domain) { var result = await _amazonRoute53Domains.CheckDomainAvailabilityAsync( new CheckDomainAvailabilityRequest { DomainName = domain } ); return result.Availability.Value; }
-
Untuk API detailnya, lihat CheckDomainAvailabilitydi AWS SDK for .NET APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanCheckDomainTransferability
.
- AWS SDK for .NET
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. /// <summary> /// Check the transferability of a domain name. /// </summary> /// <param name="domain">The domain to check for transferability.</param> /// <returns>A transferability result string.</returns> public async Task<string> CheckDomainTransferability(string domain) { var result = await _amazonRoute53Domains.CheckDomainTransferabilityAsync( new CheckDomainTransferabilityRequest { DomainName = domain } ); return result.Transferability.Transferable.Value; }
-
Untuk API detailnya, lihat CheckDomainTransferabilitydi AWS SDK for .NET APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanGetDomainDetail
.
- AWS SDK for .NET
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. /// <summary> /// Get details for a domain. /// </summary> /// <returns>A string with detail information about the domain.</returns> public async Task<string> GetDomainDetail(string domainName) { try { var result = await _amazonRoute53Domains.GetDomainDetailAsync( new GetDomainDetailRequest() { DomainName = domainName }); var details = $"\tDomain {domainName}:\n" + $"\tCreated on {result.CreationDate.ToShortDateString()}.\n" + $"\tAdmin contact is {result.AdminContact.Email}.\n" + $"\tAuto-renew is {result.AutoRenew}.\n"; return details; } catch (InvalidInputException) { return $"Domain {domainName} was not found in your account."; } }
-
Untuk API detailnya, lihat GetDomainDetaildi AWS SDK for .NET APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanGetDomainSuggestions
.
- AWS SDK for .NET
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. /// <summary> /// Get a list of suggestions for a given domain. /// </summary> /// <param name="domain">The domain to check for suggestions.</param> /// <param name="onlyAvailable">If true, only returns available domains.</param> /// <param name="suggestionCount">The number of suggestions to return. Defaults to the max of 50.</param> /// <returns>A collection of domain suggestions.</returns> public async Task<List<DomainSuggestion>> GetDomainSuggestions(string domain, bool onlyAvailable, int suggestionCount = 50) { var result = await _amazonRoute53Domains.GetDomainSuggestionsAsync( new GetDomainSuggestionsRequest { DomainName = domain, OnlyAvailable = onlyAvailable, SuggestionCount = suggestionCount } ); return result.SuggestionsList; }
-
Untuk API detailnya, lihat GetDomainSuggestionsdi AWS SDK for .NET APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanGetOperationDetail
.
- AWS SDK for .NET
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. /// <summary> /// Get details for a domain action operation. /// </summary> /// <param name="operationId">The operational Id.</param> /// <returns>A string describing the operational details.</returns> public async Task<string> GetOperationDetail(string? operationId) { if (operationId == null) return "Unable to get operational details because ID is null."; try { var operationDetails = await _amazonRoute53Domains.GetOperationDetailAsync( new GetOperationDetailRequest { OperationId = operationId } ); var details = $"\tOperation {operationId}:\n" + $"\tFor domain {operationDetails.DomainName} on {operationDetails.SubmittedDate.ToShortDateString()}.\n" + $"\tMessage is {operationDetails.Message}.\n" + $"\tStatus is {operationDetails.Status}.\n"; return details; } catch (AmazonRoute53DomainsException ex) { return $"Unable to get operation details. Here's why: {ex.Message}."; } }
-
Untuk API detailnya, lihat GetOperationDetaildi AWS SDK for .NET APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanListDomains
.
- AWS SDK for .NET
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. /// <summary> /// List the domains for the account. /// </summary> /// <returns>A collection of domain summary records.</returns> public async Task<List<DomainSummary>> ListDomains() { var results = new List<DomainSummary>(); var paginateDomains = _amazonRoute53Domains.Paginators.ListDomains( new ListDomainsRequest()); // Get the entire list using the paginator. await foreach (var domain in paginateDomains.Domains) { results.Add(domain); } return results; }
-
Untuk API detailnya, lihat ListDomainsdi AWS SDK for .NET APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanListOperations
.
- AWS SDK for .NET
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. /// <summary> /// List operations for the account that are submitted after a specified date. /// </summary> /// <returns>A collection of operation summary records.</returns> public async Task<List<OperationSummary>> ListOperations(DateTime submittedSince) { var results = new List<OperationSummary>(); var paginateOperations = _amazonRoute53Domains.Paginators.ListOperations( new ListOperationsRequest() { SubmittedSince = submittedSince }); // Get the entire list using the paginator. await foreach (var operations in paginateOperations.Operations) { results.Add(operations); } return results; }
-
Untuk API detailnya, lihat ListOperationsdi AWS SDK for .NET APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanListPrices
.
- AWS SDK for .NET
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. /// <summary> /// List prices for domain type operations. /// </summary> /// <param name="domainTypes">Domain types to include in the results.</param> /// <returns>The list of domain prices.</returns> public async Task<List<DomainPrice>> ListPrices(List<string> domainTypes) { var results = new List<DomainPrice>(); var paginatePrices = _amazonRoute53Domains.Paginators.ListPrices(new ListPricesRequest()); // Get the entire list using the paginator. await foreach (var prices in paginatePrices.Prices) { results.Add(prices); } return results.Where(p => domainTypes.Contains(p.Name)).ToList(); }
-
Untuk API detailnya, lihat ListPricesdi AWS SDK for .NET APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanRegisterDomain
.
- AWS SDK for .NET
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. /// <summary> /// Initiate a domain registration request. /// </summary> /// <param name="contact">Contact details.</param> /// <param name="domainName">The domain name to register.</param> /// <param name="autoRenew">True if the domain should automatically renew.</param> /// <param name="duration">The duration in years for the domain registration.</param> /// <returns>The operation Id.</returns> public async Task<string?> RegisterDomain(string domainName, bool autoRenew, int duration, ContactDetail contact) { // This example uses the same contact information for admin, registrant, and tech contacts. try { var result = await _amazonRoute53Domains.RegisterDomainAsync( new RegisterDomainRequest() { AdminContact = contact, RegistrantContact = contact, TechContact = contact, DomainName = domainName, AutoRenew = autoRenew, DurationInYears = duration, PrivacyProtectAdminContact = false, PrivacyProtectRegistrantContact = false, PrivacyProtectTechContact = false } ); return result.OperationId; } catch (InvalidInputException) { _logger.LogInformation($"Unable to request registration for domain {domainName}"); return null; } }
-
Untuk API detailnya, lihat RegisterDomaindi AWS SDK for .NET APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanViewBilling
.
- AWS SDK for .NET
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. /// <summary> /// View billing records for the account between a start and end date. /// </summary> /// <param name="startDate">The start date for billing results.</param> /// <param name="endDate">The end date for billing results.</param> /// <returns>A collection of billing records.</returns> public async Task<List<BillingRecord>> ViewBilling(DateTime startDate, DateTime endDate) { var results = new List<BillingRecord>(); var paginateBilling = _amazonRoute53Domains.Paginators.ViewBilling( new ViewBillingRequest() { Start = startDate, End = endDate }); // Get the entire list using the paginator. await foreach (var billingRecords in paginateBilling.BillingRecords) { results.Add(billingRecords); } return results; }
-
Untuk API detailnya, lihat ViewBillingdi AWS SDK for .NET APIReferensi.
-