using System.Threading; using System.Threading.Tasks; using AMWD.Net.Api.Cloudflare.Zones.Internals; using Newtonsoft.Json.Linq; namespace AMWD.Net.Api.Cloudflare.Zones { /// /// Extensions for Registrar. /// public static class RegistrarExtensions { /// /// Show individual domain. /// /// The instance. /// The account id. /// The domain name. /// A cancellation token used to propagate notification that this operation should be canceled. public static Task> GetDomain(this ICloudflareClient client, string accountId, string domainName, CancellationToken cancellationToken = default) { accountId.ValidateCloudflareId(); if (string.IsNullOrWhiteSpace(domainName)) throw new ArgumentNullException(nameof(domainName)); return client.GetAsync($"/accounts/{accountId}/registrar/domains/{domainName}", cancellationToken: cancellationToken); } /// /// List domains handled by Registrar. /// /// The instance. /// The account id. /// A cancellation token used to propagate notification that this operation should be canceled. public static Task>> ListDomains(this ICloudflareClient client, string accountId, CancellationToken cancellationToken = default) { accountId.ValidateCloudflareId(); return client.GetAsync>($"/accounts/{accountId}/registrar/domains", cancellationToken: cancellationToken); } /// /// Update individual domain. /// /// The instance. /// The request. /// A cancellation token used to propagate notification that this operation should be canceled. public static Task> UpdateDomain(this ICloudflareClient client, UpdateDomainRequest request, CancellationToken cancellationToken = default) { request.AccountId.ValidateCloudflareId(); if (string.IsNullOrWhiteSpace(request.DomainName)) throw new ArgumentNullException(nameof(request.DomainName)); var req = new InternalUpdateDomainRequest { AutoRenew = request.AutoRenew, Locked = request.Locked, Privacy = request.Privacy }; return client.PutAsync($"/accounts/{request.AccountId}/registrar/domains/{request.DomainName}", req, cancellationToken); } } }