Reorganize Zone Extension
This commit is contained in:
@@ -1,600 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AMWD.Net.Api.Cloudflare.Zones.Internals.Requests;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Extends the <see cref="ICloudflareClient"/> with methods for working with zones.
|
||||
/// </summary>
|
||||
public static class DnsRecordsExtensions
|
||||
{
|
||||
private static readonly IReadOnlyCollection<DnsRecordType> _dataComponentTypes = [
|
||||
DnsRecordType.Caa,
|
||||
DnsRecordType.Cert,
|
||||
DnsRecordType.DnsKey,
|
||||
DnsRecordType.Ds,
|
||||
DnsRecordType.Https,
|
||||
DnsRecordType.Loc,
|
||||
DnsRecordType.NaPtr,
|
||||
DnsRecordType.SMimeA,
|
||||
DnsRecordType.Srv,
|
||||
DnsRecordType.SshFp,
|
||||
DnsRecordType.SvcB,
|
||||
DnsRecordType.TlsA,
|
||||
DnsRecordType.Uri,
|
||||
];
|
||||
|
||||
private static readonly IReadOnlyCollection<DnsRecordType> _priorityTypes = [
|
||||
DnsRecordType.Mx,
|
||||
DnsRecordType.Srv,
|
||||
DnsRecordType.Uri,
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// List, search, sort, and filter a zones' DNS records.
|
||||
/// </summary>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="options">Filter options (optional).</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<IReadOnlyList<DnsRecord>>> ListDnsRecords(this ICloudflareClient client, string zoneId, ListDnsRecordsFilter? options = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
return client.GetAsync<IReadOnlyList<DnsRecord>>($"zones/{zoneId}/dns_records", options, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new DNS record for a zone.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <list type="bullet">
|
||||
/// <item>A/AAAA records cannot exist on the same name as CNAME records.</item>
|
||||
/// <item>NS records cannot exist on the same name as any other record type.</item>
|
||||
/// <item>Domain names are always represented in Punycode, even if Unicode characters were used when creating the record.</item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="request">The request information.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<DnsRecord>> CreateDnsRecord(this ICloudflareClient client, CreateDnsRecordRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
request.ZoneId.ValidateCloudflareId();
|
||||
|
||||
var req = ValidateDnsRecordRequest(request);
|
||||
|
||||
return client.PostAsync<DnsRecord, InternalDnsRecordRequest>($"zones/{request.ZoneId}/dns_records", req, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a Batch of DNS Record API calls to be executed together.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <list type="bullet">
|
||||
/// <item>
|
||||
/// Although Cloudflare will execute the batched operations in a single database transaction,
|
||||
/// Cloudflare's distributed KV store must treat each record change as a single key-value pair.
|
||||
/// This means that the propagation of changes is not atomic.
|
||||
/// See <see href="https://developers.cloudflare.com/dns/manage-dns-records/how-to/batch-record-changes/">the documentation</see> for more information.
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// The operations you specify within the batch request body are always executed in the following order
|
||||
/// <list type="number">
|
||||
/// <item>Deletes (delete)</item>
|
||||
/// <item>Updates (patch)</item>
|
||||
/// <item>Overwrites (put)</item>
|
||||
/// <item>Creates (post)</item>
|
||||
/// </list>
|
||||
/// </item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="request">The request information.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<BatchDnsRecordsResult>> BatchDnsRecords(this ICloudflareClient client, BatchDnsRecordsRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
request.ZoneId.ValidateCloudflareId();
|
||||
|
||||
// Validate Deletes
|
||||
var deletes = new List<InternalDnsRecordId>();
|
||||
foreach (string recordId in request.DnsRecordIdsToDelete)
|
||||
{
|
||||
recordId.ValidateCloudflareId();
|
||||
deletes.Add(new InternalDnsRecordId { Id = recordId });
|
||||
}
|
||||
|
||||
// Validate Updates
|
||||
var updates = new List<InternalBatchUpdateRequest>();
|
||||
foreach (var update in request.DnsRecordsToUpdate)
|
||||
{
|
||||
update.Id.ValidateCloudflareId();
|
||||
if (update.ZoneId != request.ZoneId)
|
||||
throw new ArgumentException($"The ZoneId of the update request ({update.ZoneId}) does not match the ZoneId of the batch request ({request.ZoneId}).");
|
||||
|
||||
var baseReq = ValidateDnsRecordRequest(update);
|
||||
updates.Add(new InternalBatchUpdateRequest(update.Id, baseReq));
|
||||
}
|
||||
|
||||
// Validate Overwrites
|
||||
var overwrites = new List<InternalBatchUpdateRequest>();
|
||||
foreach (var overwrite in request.DnsRecordsToOverwrite)
|
||||
{
|
||||
overwrite.Id.ValidateCloudflareId();
|
||||
if (overwrite.ZoneId != request.ZoneId)
|
||||
throw new ArgumentException($"The ZoneId of the overwrite request ({overwrite.ZoneId}) does not match the ZoneId of the batch request ({request.ZoneId}).");
|
||||
|
||||
var baseReq = ValidateDnsRecordRequest(overwrite);
|
||||
overwrites.Add(new InternalBatchUpdateRequest(overwrite.Id, baseReq));
|
||||
}
|
||||
|
||||
// Validate Creates
|
||||
var creates = new List<InternalDnsRecordRequest>();
|
||||
foreach (var create in request.DnsRecordsToCreate)
|
||||
creates.Add(ValidateDnsRecordRequest(create));
|
||||
|
||||
var req = new InternalBatchRequest();
|
||||
|
||||
if (deletes.Count > 0)
|
||||
req.Deletes = deletes;
|
||||
|
||||
if (updates.Count > 0)
|
||||
req.Patches = updates;
|
||||
|
||||
if (overwrites.Count > 0)
|
||||
req.Puts = overwrites;
|
||||
|
||||
if (creates.Count > 0)
|
||||
req.Posts = creates;
|
||||
|
||||
return client.PostAsync<BatchDnsRecordsResult, InternalBatchRequest>($"zones/{request.ZoneId}/dns_records/batch", req, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// You can export your <see href="https://en.wikipedia.org/wiki/Zone_file">BIND config</see> through this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See <see href="https://developers.cloudflare.com/dns/manage-dns-records/how-to/import-and-export/">the documentation</see> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<string>> ExportDnsRecords(this ICloudflareClient client, string zoneId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
return client.GetAsync<string>($"zones/{zoneId}/dns_records/export", cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// You can upload your BIND config through this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the documentation for more information.
|
||||
/// </remarks>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="request">The request information.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<ImportDnsRecordsResult>> ImportDnsRecords(this ICloudflareClient client, ImportDnsRecordsRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
request.ZoneId.ValidateCloudflareId();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(request.File))
|
||||
throw new ArgumentNullException(nameof(request.File));
|
||||
|
||||
var req = new MultipartFormDataContent();
|
||||
|
||||
if (request.Proxied.HasValue)
|
||||
req.Add(new StringContent(request.Proxied.Value.ToString().ToLowerInvariant()), "proxied");
|
||||
|
||||
byte[] content = File.Exists(request.File)
|
||||
? File.ReadAllBytes(request.File)
|
||||
: Encoding.UTF8.GetBytes(request.File);
|
||||
|
||||
req.Add(new ByteArrayContent(content), "file");
|
||||
|
||||
return client.PostAsync<ImportDnsRecordsResult, MultipartFormDataContent>($"zones/{request.ZoneId}/dns_records/import", req, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scan for common DNS records on your domain and automatically add them to your zone.
|
||||
/// <br/>
|
||||
/// Useful if you haven't updated your nameservers yet.
|
||||
/// </summary>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<ImportDnsRecordsResult>> ScanDnsRecords(this ICloudflareClient client, string zoneId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
return client.PostAsync<ImportDnsRecordsResult, object>($"zones/{zoneId}/dns_records/scan", null, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a DNS record.
|
||||
/// </summary>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="dnsRecordId">The record ID.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<IdResponse>> DeleteDnsRecord(this ICloudflareClient client, string zoneId, string dnsRecordId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
dnsRecordId.ValidateCloudflareId();
|
||||
return client.DeleteAsync<IdResponse>($"zones/{zoneId}/dns_records/{dnsRecordId}", cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns details for a DNS record.
|
||||
/// </summary>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="dnsRecordId">The record ID.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<DnsRecord>> DnsRecordDetails(this ICloudflareClient client, string zoneId, string dnsRecordId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
dnsRecordId.ValidateCloudflareId();
|
||||
return client.GetAsync<DnsRecord>($"zones/{zoneId}/dns_records/{dnsRecordId}", cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update an existing DNS record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <list type="bullet">
|
||||
/// <item>A/AAAA records cannot exist on the same name as CNAME records.</item>
|
||||
/// <item>NS records cannot exist on the same name as any other record type.</item>
|
||||
/// <item>Domain names are always represented in Punycode, even if Unicode characters were used when creating the record.</item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="request">The request information.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<DnsRecord>> UpdateDnsRecord(this ICloudflareClient client, UpdateDnsRecordRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
request.ZoneId.ValidateCloudflareId();
|
||||
request.Id.ValidateCloudflareId();
|
||||
|
||||
var req = ValidateDnsRecordRequest(request);
|
||||
|
||||
return client.PatchAsync<DnsRecord, InternalDnsRecordRequest>($"zones/{request.ZoneId}/dns_records/{request.Id}", req, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overwrite an existing DNS record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <list type="bullet">
|
||||
/// <item>A/AAAA records cannot exist on the same name as CNAME records.</item>
|
||||
/// <item>NS records cannot exist on the same name as any other record type.</item>
|
||||
/// <item>Domain names are always represented in Punycode, even if Unicode characters were used when creating the record.</item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="request">The request information.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<DnsRecord>> OverwriteDnsRecord(this ICloudflareClient client, OverwriteDnsRecordRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
request.ZoneId.ValidateCloudflareId();
|
||||
request.Id.ValidateCloudflareId();
|
||||
|
||||
var req = ValidateDnsRecordRequest(request);
|
||||
|
||||
return client.PutAsync<DnsRecord, InternalDnsRecordRequest>($"zones/{request.ZoneId}/dns_records/{request.Id}", req, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
private static InternalDnsRecordRequest ValidateDnsRecordRequest(CreateDnsRecordRequest request)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(request.Name))
|
||||
throw new ArgumentNullException(nameof(request.Name));
|
||||
|
||||
if (!Enum.IsDefined(typeof(DnsRecordType), request.Type))
|
||||
throw new ArgumentOutOfRangeException(nameof(request.Type), request.Type, "Value must be one of the 'ZoneDnsRecordType' enum values.");
|
||||
|
||||
var req = new InternalDnsRecordRequest(request.Type, request.Name)
|
||||
{
|
||||
Comment = request.Comment?.Trim(),
|
||||
Proxied = request.Proxied,
|
||||
Tags = request.Tags?.Where(t => !string.IsNullOrWhiteSpace(t)).ToList()
|
||||
};
|
||||
|
||||
if (!_dataComponentTypes.Contains(request.Type) && string.IsNullOrWhiteSpace(request.Content))
|
||||
throw new ArgumentNullException(nameof(request.Content));
|
||||
else
|
||||
req.Content = request.Content?.Trim();
|
||||
|
||||
if (request.Type == DnsRecordType.Cname && request.Settings != null && request.Settings is DnsRecord.CnameSettings cnameSettings)
|
||||
req.Settings = new DnsRecord.CnameSettings(cnameSettings.FlattenCname);
|
||||
|
||||
if (_dataComponentTypes.Contains(request.Type) && request.Data == null)
|
||||
throw new ArgumentNullException(nameof(request.Data));
|
||||
|
||||
if (_priorityTypes.Contains(request.Type))
|
||||
{
|
||||
if (!request.Priority.HasValue)
|
||||
throw new ArgumentNullException(nameof(request.Priority));
|
||||
|
||||
req.Priority = request.Priority.Value;
|
||||
}
|
||||
|
||||
if (request.Ttl.HasValue)
|
||||
{
|
||||
if (request.Ttl == 1)
|
||||
{
|
||||
req.Ttl = 1;
|
||||
}
|
||||
else if (request.Ttl < 30 || 86400 < request.Ttl)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(request.Ttl), request.Ttl, "Value must be between 60 (Enterprise: 30) and 86400.");
|
||||
}
|
||||
else
|
||||
{
|
||||
req.Ttl = request.Ttl;
|
||||
}
|
||||
}
|
||||
|
||||
switch (request.Type)
|
||||
{
|
||||
case DnsRecordType.Caa:
|
||||
if (request.Data is DnsRecord.CaaData caaData)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(caaData.Tag))
|
||||
throw new ArgumentNullException(nameof(caaData.Tag));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(caaData.Value))
|
||||
throw new ArgumentNullException(nameof(caaData.Value));
|
||||
|
||||
req.Data = new DnsRecord.CaaData(caaData.Flags, caaData.Tag, caaData.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Value must be of type 'CaaData'.", nameof(request.Data));
|
||||
}
|
||||
break;
|
||||
|
||||
case DnsRecordType.Cert:
|
||||
if (request.Data is DnsRecord.CertData certData)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(certData.Certificate))
|
||||
throw new ArgumentNullException(nameof(certData.Certificate));
|
||||
|
||||
req.Data = new DnsRecord.CertData(certData.Algorithm, certData.Certificate, certData.KeyTag, certData.Type);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Value must be of type 'CertData'.", nameof(request.Data));
|
||||
}
|
||||
break;
|
||||
|
||||
case DnsRecordType.DnsKey:
|
||||
if (request.Data is DnsRecord.DnsKeyData dnsKeyData)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(dnsKeyData.PublicKey))
|
||||
throw new ArgumentNullException(nameof(dnsKeyData.PublicKey));
|
||||
|
||||
req.Data = new DnsRecord.DnsKeyData(dnsKeyData.Algorithm, dnsKeyData.Flags, dnsKeyData.Protocol, dnsKeyData.PublicKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Value must be of type 'DnsKeyData'.", nameof(request.Data));
|
||||
}
|
||||
break;
|
||||
|
||||
case DnsRecordType.Ds:
|
||||
if (request.Data is DnsRecord.DsData dsData)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(dsData.Digest))
|
||||
throw new ArgumentNullException(nameof(dsData.Digest));
|
||||
|
||||
req.Data = new DnsRecord.DsData(dsData.Algorithm, dsData.Digest, dsData.DigestType, dsData.KeyTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Value must be of type 'DsData'.", nameof(request.Data));
|
||||
}
|
||||
break;
|
||||
|
||||
case DnsRecordType.Https:
|
||||
if (request.Data is DnsRecord.HttpsData httpsData)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(httpsData.Target))
|
||||
throw new ArgumentNullException(nameof(httpsData.Target));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(httpsData.Value))
|
||||
throw new ArgumentNullException(nameof(httpsData.Value));
|
||||
|
||||
req.Data = new DnsRecord.HttpsData(httpsData.Priority, httpsData.Target, httpsData.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Value must be of type 'HttpsData'.", nameof(request.Data));
|
||||
}
|
||||
break;
|
||||
|
||||
case DnsRecordType.Loc:
|
||||
if (request.Data is DnsRecord.LocData locData)
|
||||
{
|
||||
if (locData.LatitudeDegrees < 0 || 90 < locData.LatitudeDegrees)
|
||||
throw new ArgumentOutOfRangeException(nameof(locData.LatitudeDegrees), locData.LatitudeDegrees, "Value must be between 0 and 90.");
|
||||
|
||||
if (locData.LatitudeMinutes < 0 || 59 < locData.LatitudeMinutes)
|
||||
throw new ArgumentOutOfRangeException(nameof(locData.LatitudeMinutes), locData.LatitudeMinutes, "Value must be between 0 and 59.");
|
||||
|
||||
if (locData.LatitudeSeconds < 0 || 59.999 < locData.LatitudeSeconds)
|
||||
throw new ArgumentOutOfRangeException(nameof(locData.LatitudeSeconds), locData.LatitudeSeconds, "Value must be between 0 and 59.999.");
|
||||
|
||||
if (!Enum.IsDefined(typeof(DnsRecord.LatitudeDirection), locData.LatitudeDirection))
|
||||
throw new ArgumentOutOfRangeException(nameof(locData.LatitudeDirection), locData.LatitudeDirection, "Value must be one of the 'ZoneDnsRecord.LatitudeDirection' enum values.");
|
||||
|
||||
if (locData.LongitudeDegrees < 0 || 180 < locData.LongitudeDegrees)
|
||||
throw new ArgumentOutOfRangeException(nameof(locData.LongitudeDegrees), locData.LongitudeDegrees, "Value must be between 0 and 180.");
|
||||
|
||||
if (locData.LongitudeMinutes < 0 || 59 < locData.LongitudeMinutes)
|
||||
throw new ArgumentOutOfRangeException(nameof(locData.LongitudeMinutes), locData.LongitudeMinutes, "Value must be between 0 and 59.");
|
||||
|
||||
if (locData.LongitudeSeconds < 0 || 59.999 < locData.LongitudeSeconds)
|
||||
throw new ArgumentOutOfRangeException(nameof(locData.LongitudeSeconds), locData.LongitudeSeconds, "Value must be between 0 and 59.999.");
|
||||
|
||||
if (!Enum.IsDefined(typeof(DnsRecord.LongitudeDirection), locData.LongitudeDirection))
|
||||
throw new ArgumentOutOfRangeException(nameof(locData.LongitudeDirection), locData.LongitudeDirection, "Value must be one of the 'ZoneDnsRecord.LongitudeDirection' enum values.");
|
||||
|
||||
if (locData.Altitude < -100_000 || 42_849_672.95 < locData.Altitude)
|
||||
throw new ArgumentOutOfRangeException(nameof(locData.Altitude), locData.Altitude, "Value must be between -100,000.00 and 42,849,672.95.");
|
||||
|
||||
if (locData.Size < 0 || 90_000_000 < locData.Size)
|
||||
throw new ArgumentOutOfRangeException(nameof(locData.Size), locData.Size, "Value must be between 0 and 90,000,000.");
|
||||
|
||||
if (locData.PrecisionHorizontal < 0 || 90_000_000 < locData.PrecisionHorizontal)
|
||||
throw new ArgumentOutOfRangeException(nameof(locData.PrecisionHorizontal), locData.PrecisionHorizontal, "Value must be between 0 and 90,000,000.");
|
||||
|
||||
if (locData.PrecisionVertical < 0 || 90_000_000 < locData.PrecisionVertical)
|
||||
throw new ArgumentOutOfRangeException(nameof(locData.PrecisionVertical), locData.PrecisionVertical, "Value must be between 0 and 90,000,000.");
|
||||
|
||||
req.Data = new DnsRecord.LocData(
|
||||
latitudeDegrees: locData.LatitudeDegrees,
|
||||
latitudeMinutes: locData.LatitudeMinutes,
|
||||
latitudeSeconds: Math.Floor(locData.LatitudeSeconds * 1000) / 1000, // Truncate to 3 decimal places
|
||||
latitudeDirection: locData.LatitudeDirection,
|
||||
longitudeDegrees: locData.LongitudeDegrees,
|
||||
longitudeMinutes: locData.LongitudeMinutes,
|
||||
longitudeSeconds: Math.Floor(locData.LongitudeSeconds * 1000) / 1000, // Truncate to 3 decimal places
|
||||
longitudeDirection: locData.LongitudeDirection,
|
||||
altitude: Math.Floor(locData.Altitude * 100) / 100, // Truncate to 2 decimal places
|
||||
size: locData.Size,
|
||||
precisionHorizontal: locData.PrecisionHorizontal,
|
||||
precisionVertical: locData.PrecisionVertical
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Value must be of type 'LocData'.", nameof(request.Data));
|
||||
}
|
||||
break;
|
||||
|
||||
case DnsRecordType.NaPtr:
|
||||
if (request.Data is DnsRecord.NaPtrData naPtrData)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(naPtrData.Flags))
|
||||
throw new ArgumentNullException(nameof(naPtrData.Flags));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(naPtrData.Regex))
|
||||
throw new ArgumentNullException(nameof(naPtrData.Regex));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(naPtrData.Replacement))
|
||||
throw new ArgumentNullException(nameof(naPtrData.Replacement));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(naPtrData.Service))
|
||||
throw new ArgumentNullException(nameof(naPtrData.Service));
|
||||
|
||||
req.Data = new DnsRecord.NaPtrData(
|
||||
naPtrData.Flags,
|
||||
naPtrData.Order,
|
||||
naPtrData.Preference,
|
||||
naPtrData.Regex,
|
||||
naPtrData.Replacement,
|
||||
naPtrData.Service
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Value must be of type 'NaPtrData'.", nameof(request.Data));
|
||||
}
|
||||
break;
|
||||
|
||||
case DnsRecordType.SMimeA:
|
||||
if (request.Data is DnsRecord.SMimeAData sMimeAData)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(sMimeAData.Certificate))
|
||||
throw new ArgumentNullException(nameof(sMimeAData.Certificate));
|
||||
|
||||
req.Data = new DnsRecord.SMimeAData(sMimeAData.Certificate, sMimeAData.MatchingType, sMimeAData.Selector, sMimeAData.Usage);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Value must be of type 'SMimeAData'.", nameof(request.Data));
|
||||
}
|
||||
break;
|
||||
|
||||
case DnsRecordType.Srv:
|
||||
if (request.Data is DnsRecord.SrvData srvData)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(srvData.Target))
|
||||
throw new ArgumentNullException(nameof(srvData.Target));
|
||||
|
||||
req.Data = new DnsRecord.SrvData(srvData.Port, srvData.Priority, srvData.Target, srvData.Weight);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Value must be of type 'SrvData'.", nameof(request.Data));
|
||||
}
|
||||
break;
|
||||
|
||||
case DnsRecordType.SshFp:
|
||||
if (request.Data is DnsRecord.SshFpData sshFpData)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(sshFpData.Fingerprint))
|
||||
throw new ArgumentNullException(nameof(sshFpData.Fingerprint));
|
||||
|
||||
req.Data = new DnsRecord.SshFpData(sshFpData.Algorithm, sshFpData.Fingerprint, sshFpData.Type);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Value must be of type 'SshFpData'.", nameof(request.Data));
|
||||
}
|
||||
break;
|
||||
|
||||
case DnsRecordType.SvcB:
|
||||
if (request.Data is DnsRecord.SvcBData svcBData)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(svcBData.Target))
|
||||
throw new ArgumentNullException(nameof(svcBData.Target));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(svcBData.Value))
|
||||
throw new ArgumentNullException(nameof(svcBData.Value));
|
||||
|
||||
req.Data = new DnsRecord.SvcBData(svcBData.Priority, svcBData.Target, svcBData.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Value must be of type 'SvcBData'.", nameof(request.Data));
|
||||
}
|
||||
break;
|
||||
|
||||
case DnsRecordType.TlsA:
|
||||
if (request.Data is DnsRecord.TlsAData tlsAData)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(tlsAData.Certificate))
|
||||
throw new ArgumentNullException(nameof(tlsAData.Certificate));
|
||||
|
||||
req.Data = new DnsRecord.TlsAData(tlsAData.Certificate, tlsAData.MatchingType, tlsAData.Selector, tlsAData.Usage);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Value must be of type 'TlsAData'.", nameof(request.Data));
|
||||
}
|
||||
break;
|
||||
|
||||
case DnsRecordType.Uri:
|
||||
if (request.Data is DnsRecord.UriData uriData)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(uriData.Target))
|
||||
throw new ArgumentNullException(nameof(uriData.Target));
|
||||
|
||||
req.Data = new DnsRecord.UriData(uriData.Target, uriData.Weight);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Value must be of type 'UriData'.", nameof(request.Data));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return req;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,269 +0,0 @@
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// DNS record types.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A list with short description can be found <see href="https://en.wikipedia.org/wiki/List_of_DNS_record_types">@wikipedia</see>.
|
||||
/// </remarks>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum DnsRecordType : int
|
||||
{
|
||||
/// <summary>
|
||||
/// Address record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Returns a 32-bit IPv4 address, most commonly used to map hostnames to an IP address of the host, but it is also used for DNSBLs, storing subnet masks in RFC 1101, etc.
|
||||
/// <code>
|
||||
/// example.com. 3600 IN A 93.184.215.14
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "A")]
|
||||
A = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Name server record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Delegates a DNS zone to use the given authoritative name servers.
|
||||
/// <code>
|
||||
/// example.com. 86400 IN NS a.iana-servers.net.
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "NS")]
|
||||
Ns = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Canonical name record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Alias of one name to another: the DNS lookup will continue by retrying the lookup with the new name.
|
||||
/// <code>
|
||||
/// autodiscover.example.com. 86400 IN CNAME mail.example.com.
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "CNAME")]
|
||||
Cname = 5,
|
||||
|
||||
/// <summary>
|
||||
/// PTR Resource Record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Pointer to a canonical name. Unlike a CNAME, DNS processing stops and just the name is returned. The most common use is for implementing reverse DNS lookups, but other uses include such things as DNS-SD.
|
||||
/// <code>
|
||||
/// 14.215.184.93.in-addr.arpa. 86400 IN PTR example.com.
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "PTR")]
|
||||
Ptr = 12,
|
||||
|
||||
/// <summary>
|
||||
/// Mail exchange record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// List of mail exchange servers that accept email for a domain.
|
||||
/// <code>
|
||||
/// example.com. 43200 IN MX 0 mail.example.com.
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "MX")]
|
||||
Mx = 15,
|
||||
|
||||
/// <summary>
|
||||
/// Text record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Originally for arbitrary human-readable text in a DNS record. Since the early 1990s, however, this record more often carries machine-readable data, such as specified by RFC 1464, opportunistic encryption, Sender Policy Framework, DKIM, DMARC, DNS-SD, etc.
|
||||
/// <br/>
|
||||
/// More information about TXT records on <see href="https://www.cloudflare.com/learning/dns/dns-records/dns-txt-record/">Cloudflare</see>.
|
||||
/// <code>
|
||||
/// example.com. 86400 IN TXT "v=spf1 -all"
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "TXT")]
|
||||
Txt = 16,
|
||||
|
||||
/// <summary>
|
||||
/// IPv6 address record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Returns a 128-bit IPv6 address, most commonly used to map hostnames to an IP address of the host.
|
||||
/// <code>
|
||||
/// example.com. 3600 IN AAAA 2606:2800:21f:cb07:6820:80da:af6b:8b2c
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "AAAA")]
|
||||
Aaaa = 28,
|
||||
|
||||
/// <summary>
|
||||
/// Location record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Specifies a geographical location associated with a domain name.
|
||||
/// <code>
|
||||
/// SW1A2AA.find.me.uk. 2592000 IN LOC 51 30 12.748 N 0 7 39.611 W 0.00m 0.00m 0.00m 0.00m
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "LOC")]
|
||||
Loc = 29,
|
||||
|
||||
/// <summary>
|
||||
/// Service locator.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Generalized service location record, used for newer protocols instead of creating protocol-specific records such as MX.
|
||||
/// <code>
|
||||
/// _autodiscover._tcp.example.com. 604800 IN SRV 1 0 443 mail.example.com.
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "SRV")]
|
||||
Srv = 33,
|
||||
|
||||
/// <summary>
|
||||
/// Naming Authority Pointer.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Allows regular-expression-based rewriting of domain names which can then be used as URIs, further domain names to lookups, etc.
|
||||
/// <code>
|
||||
/// example.com. 86400 IN NAPTR 100 10 "S" "SIP+D2T" "" _sip._tcp.example.com.
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "NAPTR")]
|
||||
NaPtr = 35,
|
||||
|
||||
/// <summary>
|
||||
/// Certificate record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Stores PKIX, SPKI, PGP, etc.
|
||||
/// <code>
|
||||
/// example.com. 86400 IN CERT 2 77 2 TUlJQ1l6Q0NBY3lnQXdJQkFnSUJBREFOQmdrcWh
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "CERT")]
|
||||
Cert = 37,
|
||||
|
||||
/// <summary>
|
||||
/// Delegation signer.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The record used to identify the DNSSEC signing key of a delegated zone.
|
||||
/// <code>
|
||||
/// example.com. 86400 IN DS 370 13 2 BE74359954660069D5C63D200C39F5603827D7DD02B56F120EE9F3A8 6764247C
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "DS")]
|
||||
Ds = 43,
|
||||
|
||||
/// <summary>
|
||||
/// SSH Public Key Fingerprint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Resource record for publishing SSH public host key fingerprints in the DNS, in order to aid in verifying the authenticity of the host. RFC 6594 defines ECC SSH keys and SHA-256 hashes. See the IANA SSHFP RR parameters registry for details.
|
||||
/// <code>
|
||||
/// example.com. 600 IN SSHFP 2 1 123456789abcdef67890123456789abcdef67890
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "SSHFP")]
|
||||
SshFp = 44,
|
||||
|
||||
/// <summary>
|
||||
/// DNS Key record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The key record used in DNSSEC. Uses the same format as the KEY record.
|
||||
/// <code>
|
||||
/// example.com. 3600 IN DNSKEY 256 3 13 OtuN/SL9sE+SDQ0tOLeezr1KzUNi77FflTjxQylUhm3V7m13Vz9tYQuc SGK0pyxISo9CQsszubAwJSypq3li3g==
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "DNSKEY")]
|
||||
DnsKey = 48,
|
||||
|
||||
/// <summary>
|
||||
/// TLSA certificate association.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A record for DANE. RFC 6698 defines "The TLSA DNS resource record is used to associate a TLS server certificate or public key with the domain name where the record is found, thus forming a 'TLSA certificate association'".
|
||||
/// <code>
|
||||
/// _443._tcp.example.com. 3600 IN TLSA 3 0 18cb0fc6c527506a053f4f14c8464bebbd6dede2738d11468dd953d7d6a3021f1
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "TLSA")]
|
||||
TlsA = 52,
|
||||
|
||||
/// <summary>
|
||||
/// S/MIME cert association.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Associates an S/MIME certificate with a domain name for sender authentication.
|
||||
/// <code>
|
||||
/// example.com. 3600 IN SMIMEA 0 0 0 keyKEY1234keyKEY
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "SMIMEA")]
|
||||
SMimeA = 53,
|
||||
|
||||
/// <summary>
|
||||
/// OpenPGP public key record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A DNS-based Authentication of Named Entities (DANE) method for publishing and locating OpenPGP public keys in DNS for a specific email address using an OPENPGPKEY DNS resource record.
|
||||
/// <code>
|
||||
/// 00d8d3f11739d2f3537099982b4674c29fc59a8fda350fca1379613a._openpgpkey.example.com. 3600 IN OPENPGPKEY a2V5S0VZMTIzNGtleUtFWQ==
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "OPENPGPKEY")]
|
||||
OpenPgpgKey = 61,
|
||||
|
||||
/// <summary>
|
||||
/// Service Binding.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// RR that improves performance for clients that need to resolve many resources to access a domain.
|
||||
/// <code>
|
||||
/// example.com. 3600 IN SVCB 1 . alpn="h2,http/1.1"
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "SVCB")]
|
||||
SvcB = 64,
|
||||
|
||||
/// <summary>
|
||||
/// HTTPS Binding.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// RR that improves performance for clients that need to resolve many resources to access a domain.
|
||||
/// <code>
|
||||
/// example.com. 3600 IN HTTPS 1 svc.example.com. alpn=h2
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "HTTPS")]
|
||||
Https = 65,
|
||||
|
||||
/// <summary>
|
||||
/// Uniform Resource Identifier.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Can be used for publishing mappings from hostnames to URIs.
|
||||
/// <code>
|
||||
/// _ftp._tcp.example.com. 3600 IN URI 10 1 "ftp://ftp.example.com/public"
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "URI")]
|
||||
Uri = 256,
|
||||
|
||||
/// <summary>
|
||||
/// Certification Authority Authorization
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// DNS Certification Authority Authorization, constraining acceptable CAs for a host/domain.
|
||||
/// <code>
|
||||
/// example.com. 604800 IN CAA 0 issue "letsencrypt.org"
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "CAA")]
|
||||
Caa = 257,
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Possible fields to order DNS records by.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum DnsRecordsOrderBy
|
||||
{
|
||||
/// <summary>
|
||||
/// Order by record type.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "type")]
|
||||
Type = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Order by record name.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "name")]
|
||||
Name = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Order by record content.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "content")]
|
||||
Content = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Order by record TTL.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "ttl")]
|
||||
Ttl = 4,
|
||||
|
||||
/// <summary>
|
||||
/// Order by record proxied.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "proxied")]
|
||||
Proxied = 5
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// The nameserver type.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum NameserverType
|
||||
{
|
||||
/// <summary>
|
||||
/// Cloudflare standard.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "cloudflare.standard")]
|
||||
CloudflareStandard = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Cloudflare random.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "cloudflare.standard.random")]
|
||||
CloudflareRandom = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Custom specified by account.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "custom.account")]
|
||||
CustomAccount = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Custom specified by tenant.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "custom.tenant")]
|
||||
CustomTenant = 4,
|
||||
|
||||
/// <summary>
|
||||
/// Custom specified by zone.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "custom.zone")]
|
||||
CustomZone = 5,
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Zone modes.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum ZoneMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Standard.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "standard")]
|
||||
Standard = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Only as CDN.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "cdn_only")]
|
||||
CdnOnly = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Only as DNS.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "dns_only")]
|
||||
DnsOnly = 3,
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// A zone status.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum ZoneStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// Zone is initializing.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "initializing")]
|
||||
Initializing = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Zone is pending.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "pending")]
|
||||
Pending = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Zone is active.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "active")]
|
||||
Active = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Zone has been moved.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "moved")]
|
||||
Moved = 4,
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Zone type.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A full zone implies that DNS is hosted with Cloudflare.
|
||||
/// A partial zone is typically a partner-hosted zone or a CNAME setup.
|
||||
/// </remarks>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum ZoneType
|
||||
{
|
||||
/// <summary>
|
||||
/// Full Setup (most common).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Use Cloudflare as your primary DNS provider and manage your DNS records on Cloudflare.
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "full")]
|
||||
Full = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Zone transfers.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Use Cloudflare and another DNS provider together across your entire zone to increase availability and fault tolerance.
|
||||
/// <br />
|
||||
/// DNS records will be transferred between providers using
|
||||
/// <see href="https://datatracker.ietf.org/doc/html/rfc5936">AXFR</see> or <see href="https://datatracker.ietf.org/doc/html/rfc1995">IXFR</see>.
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "secondary")]
|
||||
Secondary = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Partial (CNAME) setup.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Keep your primary DNS provider and only use Cloudflare's reverse proxy for individual subdomains.
|
||||
/// </remarks>
|
||||
[EnumMember(Value = "partial")]
|
||||
Partial = 3,
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Possible fields to order zones by.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum ZonesOrderBy
|
||||
{
|
||||
/// <summary>
|
||||
/// Order by zone name.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "name")]
|
||||
Name = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Order by zone status.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "status")]
|
||||
Status = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Order by account ID.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "account.id")]
|
||||
AccountId = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Order by account name.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "account.name")]
|
||||
AccountName = 4,
|
||||
}
|
||||
}
|
||||
@@ -1,402 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Filter for listing DNS records.
|
||||
/// </summary>
|
||||
public class ListDnsRecordsFilter : IQueryParameterFilter
|
||||
{
|
||||
#region Comment
|
||||
|
||||
/// <summary>
|
||||
/// Exact value of the DNS record comment.
|
||||
/// This is a convenience alias for <see cref="CommentExact"/>.
|
||||
/// </summary>
|
||||
public string? Comment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If this parameter is present, only records <em>without</em> a comment are returned.
|
||||
/// </summary>
|
||||
public bool? CommentAbsent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Substring of the DNS record comment.
|
||||
/// Comment filters are case-insensitive.
|
||||
/// </summary>
|
||||
public string? CommentContains { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Suffix of the DNS record comment.
|
||||
/// Comment filters are case-insensitive.
|
||||
/// </summary>
|
||||
public string? CommentEndsWith { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Exact value of the DNS record comment.
|
||||
/// Comment filters are case-insensitive.
|
||||
/// </summary>
|
||||
public string? CommentExact { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If this parameter is present, only records <em>with</em> a comment are returned.
|
||||
/// </summary>
|
||||
public bool? CommentPresent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Prefix of the DNS record comment.
|
||||
/// Comment filters are case-insensitive.
|
||||
/// </summary>
|
||||
public string? CommentStartsWith { get; set; }
|
||||
|
||||
#endregion Comment
|
||||
|
||||
#region Content
|
||||
|
||||
/// <summary>
|
||||
/// Exact value of the DNS record Content.
|
||||
/// This is a convenience alias for <see cref="ContentExact"/>.
|
||||
/// </summary>
|
||||
public string? Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Substring of the DNS record Content.
|
||||
/// Content filters are case-insensitive.
|
||||
/// </summary>
|
||||
public string? ContentContains { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Suffix of the DNS record Content.
|
||||
/// Content filters are case-insensitive.
|
||||
/// </summary>
|
||||
public string? ContentEndsWith { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Exact value of the DNS record Content.
|
||||
/// Content filters are case-insensitive.
|
||||
/// </summary>
|
||||
public string? ContentExact { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Prefix of the DNS record Content.
|
||||
/// Content filters are case-insensitive.
|
||||
/// </summary>
|
||||
public string? ContentStartsWith { get; set; }
|
||||
|
||||
#endregion Content
|
||||
|
||||
/// <summary>
|
||||
/// Direction to order DNS records in.
|
||||
/// </summary>
|
||||
public SortDirection? Direction { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to match all search requirements or at least one (any).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// If set to <see cref="FilterMatchType.All"/>, acts like a logical AND between filters.
|
||||
/// <br/>
|
||||
/// If set to <see cref="FilterMatchType.Any"/>, acts like a logical OR instead.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Note that the interaction between tag filters is controlled by the <see cref="TagMatch"/> parameter instead.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public FilterMatchType? Match { get; set; }
|
||||
|
||||
#region Name
|
||||
|
||||
/// <summary>
|
||||
/// Exact value of the DNS record Name.
|
||||
/// This is a convenience alias for <see cref="NameExact"/>.
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Substring of the DNS record Name.
|
||||
/// Name filters are case-insensitive.
|
||||
/// </summary>
|
||||
public string? NameContains { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Suffix of the DNS record Name.
|
||||
/// Name filters are case-insensitive.
|
||||
/// </summary>
|
||||
public string? NameEndsWith { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Exact value of the DNS record Name.
|
||||
/// Name filters are case-insensitive.
|
||||
/// </summary>
|
||||
public string? NameExact { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Prefix of the DNS record Name.
|
||||
/// Name filters are case-insensitive.
|
||||
/// </summary>
|
||||
public string? NameStartsWith { get; set; }
|
||||
|
||||
#endregion Name
|
||||
|
||||
/// <summary>
|
||||
/// Field to order DNS records by.
|
||||
/// </summary>
|
||||
public DnsRecordsOrderBy? OrderBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Page number of paginated results.
|
||||
/// </summary>
|
||||
/// <value>1 <= X</value>
|
||||
public int? Page { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of DNS records per page.
|
||||
/// </summary>
|
||||
/// <value>1 <= X <= 5,000,000</value>
|
||||
public int? PerPage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the record is receiving the performance and security benefits of Cloudflare.
|
||||
/// </summary>
|
||||
public bool? Proxied { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Allows searching in multiple properties of a DNS record simultaneously.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This parameter is intended for human users, not automation.
|
||||
/// Its exact behavior is intentionally left unspecified and is subject to change in the future.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <em>
|
||||
/// This parameter works independently of the <see cref="Match"/> setting.
|
||||
/// <br/>
|
||||
/// For automated searches, please use the other available parameters.
|
||||
/// </em>
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public string? Search { get; set; }
|
||||
|
||||
#region Tag
|
||||
|
||||
/// <summary>
|
||||
/// Condition on the DNS record tag.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Parameter values can be of the form <c><tag-name>:<tag-value></c> to search for an exact name:value pair,
|
||||
/// or just <c><tag-name></c> to search for records with a specific tag name regardless of its value.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This is a convenience shorthand for the more powerful <c>tag.<predicate></c> parameters.
|
||||
/// <br/>
|
||||
/// Examples:
|
||||
/// <list type="bullet">
|
||||
/// <item><c>tag=important</c> is equivalent to <c>tag.present=important</c></item>
|
||||
/// <item><c>tag=team:DNS</c> is equivalent to <c>tag.exact=team:DNS</c></item>
|
||||
/// </list>
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public string? Tag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of a tag which must <em>not</em> be present on the DNS record.
|
||||
/// Tag filters are case-insensitive.
|
||||
/// </summary>
|
||||
public string? TagAbsent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A tag and value, of the form <c><tag-name>:<tag-value></c>.
|
||||
/// Tag filters are case-insensitive.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The API will only return DNS records that have a tag named <c><tag-name></c> whose value contains <c><tag-value></c>.
|
||||
/// </remarks>
|
||||
public string? TagContains { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A tag and value, of the form <c><tag-name>:<tag-value></c>.
|
||||
/// Tag filters are case-insensitive.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The API will only return DNS records that have a tag named <c><tag-name></c> whose value ends with <c><tag-value></c>.
|
||||
/// </remarks>
|
||||
public string? TagEndsWith { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A tag and value, of the form <c><tag-name>:<tag-value></c>.
|
||||
/// Tag filters are case-insensitive.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The API will only return DNS records that have a tag named <c><tag-name></c> whose value is <c><tag-value></c>.
|
||||
/// </remarks>
|
||||
public string? TagExact { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of a tag which must be present on the DNS record.
|
||||
/// Tag filters are case-insensitive.
|
||||
/// </summary>
|
||||
public string? TagPresent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A tag and value, of the form <c><tag-name>:<tag-value></c>.
|
||||
/// Tag filters are case-insensitive.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The API will only return DNS records that have a tag named <c><tag-name></c> whose value starts with <c><tag-value></c>.
|
||||
/// </remarks>
|
||||
public string? TagStartsWith { get; set; }
|
||||
|
||||
#endregion Tag
|
||||
|
||||
/// <summary>
|
||||
/// Whether to match all tag search requirements or at least one (any).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// If set to <see cref="FilterMatchType.All"/>, acts like a logical AND between filters.
|
||||
/// <br/>
|
||||
/// If set to <see cref="FilterMatchType.Any"/>, acts like a logical OR instead.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Note that the regular <see cref="Match"/> parameter is still used to combine the resulting condition with other filters that aren't related to tags.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public FilterMatchType? TagMatch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Record type.
|
||||
/// </summary>
|
||||
public DnsRecordType? Type { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IDictionary<string, string> GetQueryParameters()
|
||||
{
|
||||
var dict = new Dictionary<string, string>();
|
||||
|
||||
#pragma warning disable CS8602, CS8604 // There will be no null value below.
|
||||
|
||||
#region Comment
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Comment))
|
||||
dict.Add("comment", Comment.Trim());
|
||||
|
||||
if (CommentAbsent.HasValue && CommentAbsent.Value)
|
||||
dict.Add("comment.absent", "true");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(CommentContains))
|
||||
dict.Add("comment.contains", CommentContains.Trim());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(CommentEndsWith))
|
||||
dict.Add("comment.endswith", CommentEndsWith.Trim());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(CommentExact))
|
||||
dict.Add("comment.exact", CommentExact.Trim());
|
||||
|
||||
if (CommentPresent.HasValue && CommentPresent.Value)
|
||||
dict.Add("comment.present", "true");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(CommentStartsWith))
|
||||
dict.Add("comment.startswith", CommentStartsWith.Trim());
|
||||
|
||||
#endregion Comment
|
||||
|
||||
#region Content
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Content))
|
||||
dict.Add("content", Content.Trim());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(ContentContains))
|
||||
dict.Add("content.contains", ContentContains.Trim());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(ContentEndsWith))
|
||||
dict.Add("content.endswith", ContentEndsWith.Trim());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(ContentExact))
|
||||
dict.Add("content.exact", ContentExact.Trim());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(ContentStartsWith))
|
||||
dict.Add("content.startswith", ContentStartsWith.Trim());
|
||||
|
||||
#endregion Content
|
||||
|
||||
if (Direction.HasValue && Enum.IsDefined(typeof(SortDirection), Direction.Value))
|
||||
dict.Add("direction", Direction.Value.GetEnumMemberValue());
|
||||
|
||||
if (Match.HasValue && Enum.IsDefined(typeof(FilterMatchType), Match.Value))
|
||||
dict.Add("match", Match.Value.GetEnumMemberValue());
|
||||
|
||||
#region Name
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Name))
|
||||
dict.Add("name", Name.Trim());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(NameContains))
|
||||
dict.Add("name.contains", NameContains.Trim());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(NameEndsWith))
|
||||
dict.Add("name.endswith", NameEndsWith.Trim());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(NameExact))
|
||||
dict.Add("name.exact", NameExact.Trim());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(NameStartsWith))
|
||||
dict.Add("name.startswith", NameStartsWith.Trim());
|
||||
|
||||
#endregion Name
|
||||
|
||||
if (OrderBy.HasValue && Enum.IsDefined(typeof(DnsRecordsOrderBy), OrderBy.Value))
|
||||
dict.Add("order", OrderBy.Value.GetEnumMemberValue());
|
||||
|
||||
if (Page.HasValue && Page.Value >= 1)
|
||||
dict.Add("page", Page.Value.ToString());
|
||||
|
||||
if (PerPage.HasValue && PerPage.Value >= 1 && PerPage.Value <= 5_000_000)
|
||||
dict.Add("per_page", PerPage.Value.ToString());
|
||||
|
||||
if (Proxied.HasValue)
|
||||
dict.Add("proxied", Proxied.Value.ToString().ToLowerInvariant());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Search))
|
||||
dict.Add("search", Search.Trim());
|
||||
|
||||
#region Tag
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Tag))
|
||||
dict.Add("tag", Tag.Trim());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(TagAbsent))
|
||||
dict.Add("tag.absent", TagAbsent.Trim());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(TagContains))
|
||||
dict.Add("tag.contains", TagContains.Trim());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(TagEndsWith))
|
||||
dict.Add("tag.endswith", TagEndsWith.Trim());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(TagExact))
|
||||
dict.Add("tag.exact", TagExact.Trim());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(TagPresent))
|
||||
dict.Add("tag.present", TagPresent.Trim());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(TagStartsWith))
|
||||
dict.Add("tag.startswith", TagStartsWith.Trim());
|
||||
|
||||
#endregion Tag
|
||||
|
||||
if (TagMatch.HasValue && Enum.IsDefined(typeof(FilterMatchType), TagMatch.Value))
|
||||
dict.Add("tag_match", TagMatch.Value.GetEnumMemberValue());
|
||||
|
||||
if (Type.HasValue && Enum.IsDefined(typeof(DnsRecordType), Type.Value))
|
||||
dict.Add("type", Type.Value.GetEnumMemberValue());
|
||||
|
||||
#pragma warning restore CS8602, CS8604
|
||||
|
||||
return dict;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Filter for listing zones.
|
||||
/// </summary>
|
||||
public class ListZonesFilter : IQueryParameterFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// An account ID.
|
||||
/// </summary>
|
||||
public string? AccountId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// An account Name.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Optional filter operators can be provided to extend refine the search:
|
||||
/// <list type="bullet">
|
||||
/// <item><description>equal</description> (default)</item>
|
||||
/// <item><description>not_equal</description></item>
|
||||
/// <item><description>starts_with</description></item>
|
||||
/// <item><description>ends_with</description></item>
|
||||
/// <item><description>contains</description></item>
|
||||
/// <item><description>starts_with_case_sensitive</description></item>
|
||||
/// <item><description>ends_with_case_sensitive</description></item>
|
||||
/// <item><description>contains_case_sensitive</description></item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
/// <example>Dev Account</example>
|
||||
/// <example>contains:Test</example>
|
||||
public string? AccountName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Direction to order zones.
|
||||
/// </summary>
|
||||
public SortDirection? Direction { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to match all search requirements or at least one (any).
|
||||
/// </summary>
|
||||
public FilterMatchType? Match { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A domain name.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Optional filter operators can be provided to extend refine the search:
|
||||
/// <list type="bullet">
|
||||
/// <item><description>equal</description> (default)</item>
|
||||
/// <item><description>not_equal</description></item>
|
||||
/// <item><description>starts_with</description></item>
|
||||
/// <item><description>ends_with</description></item>
|
||||
/// <item><description>contains</description></item>
|
||||
/// <item><description>starts_with_case_sensitive</description></item>
|
||||
/// <item><description>ends_with_case_sensitive</description></item>
|
||||
/// <item><description>contains_case_sensitive</description></item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
/// <example>example.com</example>
|
||||
/// <example>contains:.org</example>
|
||||
/// <example>ends_with:arpa</example>
|
||||
/// <example>starts_with:dev</example>
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Field to order zones by.
|
||||
/// </summary>
|
||||
public ZonesOrderBy? OrderBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Page number of paginated results.
|
||||
/// </summary>
|
||||
/// <value>1 <= X</value>
|
||||
public int? Page { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of zones per page.
|
||||
/// </summary>
|
||||
/// <value>5 <= X <= 50</value>
|
||||
public int? PerPage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A zone status.
|
||||
/// </summary>
|
||||
public ZoneStatus? Status { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IDictionary<string, string> GetQueryParameters()
|
||||
{
|
||||
var dict = new Dictionary<string, string>();
|
||||
|
||||
#pragma warning disable CS8602, CS8604 // There will be no null value below.
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(AccountId))
|
||||
dict.Add("account.id", AccountId.Trim());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(AccountName))
|
||||
dict.Add("account.name", AccountName.Trim());
|
||||
|
||||
if (Direction.HasValue && Enum.IsDefined(typeof(SortDirection), Direction.Value))
|
||||
dict.Add("direction", Direction.Value.GetEnumMemberValue());
|
||||
|
||||
if (Match.HasValue && Enum.IsDefined(typeof(FilterMatchType), Match.Value))
|
||||
dict.Add("match", Match.Value.GetEnumMemberValue());
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Name))
|
||||
dict.Add("name", Name);
|
||||
|
||||
if (OrderBy.HasValue && Enum.IsDefined(typeof(ZonesOrderBy), OrderBy.Value))
|
||||
dict.Add("order", OrderBy.Value.GetEnumMemberValue());
|
||||
|
||||
if (Page.HasValue && Page.Value >= 1)
|
||||
dict.Add("page", Page.Value.ToString());
|
||||
|
||||
if (PerPage.HasValue && PerPage.Value >= 5 && PerPage.Value <= 50)
|
||||
dict.Add("per_page", PerPage.Value.ToString());
|
||||
|
||||
if (Status.HasValue && Enum.IsDefined(typeof(ZoneStatus), Status.Value))
|
||||
dict.Add("status", Status.Value.GetEnumMemberValue());
|
||||
|
||||
#pragma warning restore CS8602, CS8604
|
||||
|
||||
return dict;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones.Internals.Filters
|
||||
{
|
||||
internal class CreateZoneHoldFilter : IQueryParameterFilter
|
||||
{
|
||||
public bool IncludeSubdomains { get; set; }
|
||||
|
||||
public IDictionary<string, string> GetQueryParameters()
|
||||
{
|
||||
var dict = new Dictionary<string, string>();
|
||||
|
||||
if (IncludeSubdomains)
|
||||
dict.Add("include_subdomains", "true");
|
||||
|
||||
return dict;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones.Internals.Filters
|
||||
{
|
||||
internal class DeleteZoneHoldFilter : IQueryParameterFilter
|
||||
{
|
||||
public DateTime? HoldAfter { get; set; }
|
||||
|
||||
public IDictionary<string, string> GetQueryParameters()
|
||||
{
|
||||
var dict = new Dictionary<string, string>();
|
||||
|
||||
if (HoldAfter.HasValue)
|
||||
dict.Add("hold_after", HoldAfter.Value.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:ss'Z'"));
|
||||
|
||||
return dict;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones.Internals.Requests
|
||||
{
|
||||
internal class InternalBatchRequest
|
||||
{
|
||||
[JsonProperty("deletes")]
|
||||
public IList<InternalDnsRecordId>? Deletes { get; set; }
|
||||
|
||||
[JsonProperty("patches")]
|
||||
public IList<InternalBatchUpdateRequest>? Patches { get; set; }
|
||||
|
||||
[JsonProperty("puts")]
|
||||
public IList<InternalBatchUpdateRequest>? Puts { get; set; }
|
||||
|
||||
[JsonProperty("posts")]
|
||||
public IList<InternalDnsRecordRequest>? Posts { get; set; }
|
||||
}
|
||||
|
||||
internal class InternalDnsRecordId
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string? Id { get; set; }
|
||||
}
|
||||
|
||||
internal class InternalBatchUpdateRequest(string id, InternalDnsRecordRequest baseInstance)
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; } = id;
|
||||
|
||||
[JsonProperty("comment")]
|
||||
public string? Comment { get; set; } = baseInstance.Comment;
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; } = baseInstance.Name;
|
||||
|
||||
[JsonProperty("proxied")]
|
||||
public bool Proxied { get; set; } = baseInstance.Proxied;
|
||||
|
||||
[JsonProperty("settings")]
|
||||
public object? Settings { get; set; } = baseInstance.Settings;
|
||||
|
||||
[JsonProperty("tags")]
|
||||
public IList<string>? Tags { get; set; } = baseInstance.Tags;
|
||||
|
||||
[JsonProperty("ttl")]
|
||||
public int? Ttl { get; set; } = baseInstance.Ttl;
|
||||
|
||||
[JsonProperty("data")]
|
||||
public object? Data { get; set; } = baseInstance.Data;
|
||||
|
||||
[JsonProperty("content")]
|
||||
public string? Content { get; set; } = baseInstance.Content;
|
||||
|
||||
[JsonProperty("priority")]
|
||||
public ushort? Priority { get; set; } = baseInstance.Priority;
|
||||
|
||||
[JsonProperty("type")]
|
||||
public DnsRecordType Type { get; set; } = baseInstance.Type;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones.Internals.Requests
|
||||
{
|
||||
internal class InternalCreateZoneRequest
|
||||
{
|
||||
public InternalCreateZoneRequest(AccountBase account, string name)
|
||||
{
|
||||
Account = account;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
[JsonProperty("account")]
|
||||
public AccountBase Account { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("type")]
|
||||
public ZoneType? Type { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones.Internals.Requests
|
||||
{
|
||||
internal class InternalDnsRecordRequest
|
||||
{
|
||||
public InternalDnsRecordRequest(DnsRecordType type, string name)
|
||||
{
|
||||
Type = type;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
[JsonProperty("comment")]
|
||||
public string? Comment { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("proxied")]
|
||||
public bool Proxied { get; set; }
|
||||
|
||||
[JsonProperty("settings")]
|
||||
public object? Settings { get; set; }
|
||||
|
||||
[JsonProperty("tags")]
|
||||
public IList<string>? Tags { get; set; }
|
||||
|
||||
[JsonProperty("ttl")]
|
||||
public int? Ttl { get; set; }
|
||||
|
||||
[JsonProperty("data")]
|
||||
public object? Data { get; set; }
|
||||
|
||||
[JsonProperty("content")]
|
||||
public string? Content { get; set; }
|
||||
|
||||
[JsonProperty("priority")]
|
||||
public ushort? Priority { get; set; }
|
||||
|
||||
[JsonProperty("type")]
|
||||
public DnsRecordType Type { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones.Internals.Requests
|
||||
{
|
||||
internal class InternalEditZoneRequest
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public ZoneType? Type { get; set; }
|
||||
|
||||
[JsonProperty("vanity_name_servers")]
|
||||
public IList<string>? VanityNameServers { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones.Internals.Requests
|
||||
{
|
||||
internal class InternalPurgeCacheRequest
|
||||
{
|
||||
[JsonProperty("purge_everything")]
|
||||
public bool? PurgeEverything { get; set; }
|
||||
|
||||
[JsonProperty("tags")]
|
||||
public IList<string>? Tags { get; set; }
|
||||
|
||||
[JsonProperty("hosts")]
|
||||
public IList<string>? Hostnames { get; set; }
|
||||
|
||||
[JsonProperty("prefixes")]
|
||||
public IList<string>? Prefixes { get; set; }
|
||||
|
||||
[JsonProperty("files")]
|
||||
public IList<string>? Urls { get; set; }
|
||||
|
||||
[JsonProperty("files")]
|
||||
public IList<PurgeUrlWithHeaders>? UrlsWithHeaders { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones.Internals.Requests
|
||||
{
|
||||
internal class InternalUpdateDnsSettingsRequest
|
||||
{
|
||||
[JsonProperty("flatten_all_cnames")]
|
||||
public bool? FlattenAllCnames { get; set; }
|
||||
|
||||
[JsonProperty("foundation_dns")]
|
||||
public bool? FoundationDns { get; set; }
|
||||
|
||||
[JsonProperty("multi_provider")]
|
||||
public bool? MultiProvider { get; set; }
|
||||
|
||||
[JsonProperty("nameservers")]
|
||||
public Nameserver? Nameservers { get; set; }
|
||||
|
||||
[JsonProperty("ns_ttl")]
|
||||
public int? NameserverTtl { get; set; }
|
||||
|
||||
[JsonProperty("secondary_overrides")]
|
||||
public bool? SecondaryOverrides { get; set; }
|
||||
|
||||
[JsonProperty("soa")]
|
||||
public StartOfAuthority? Soa { get; set; }
|
||||
|
||||
[JsonProperty("zone_mode")]
|
||||
public ZoneMode? Mode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones.Internals.Requests
|
||||
{
|
||||
internal class InternalUpdateSecurityTxtRequest
|
||||
{
|
||||
[JsonProperty("acknowledgements")]
|
||||
public IList<string>? Acknowledgements { get; set; }
|
||||
|
||||
[JsonProperty("canonical")]
|
||||
public IList<string>? Canonical { get; set; }
|
||||
|
||||
[JsonProperty("contact")]
|
||||
public IList<string>? Contact { get; set; }
|
||||
|
||||
[JsonProperty("enabled")]
|
||||
public bool? Enabled { get; set; }
|
||||
|
||||
[JsonProperty("encryption")]
|
||||
public IList<string>? Encryption { get; set; }
|
||||
|
||||
[JsonProperty("expires")]
|
||||
public DateTime? Expires { get; set; }
|
||||
|
||||
[JsonProperty("hiring")]
|
||||
public IList<string>? Hiring { get; set; }
|
||||
|
||||
[JsonProperty("policy")]
|
||||
public IList<string>? Policy { get; set; }
|
||||
|
||||
[JsonProperty("preferredLanguages")]
|
||||
public string? PreferredLanguages { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones.Internals.Requests
|
||||
{
|
||||
internal class PurgeUrlWithHeaders
|
||||
{
|
||||
[JsonProperty("headers")]
|
||||
public Dictionary<string, string> Headers { get; set; } = [];
|
||||
|
||||
[JsonProperty("url")]
|
||||
public string? Url { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// The DNS batch execution response.
|
||||
/// </summary>
|
||||
public class BatchDnsRecordsResult
|
||||
{
|
||||
/// <summary>
|
||||
/// The deleted records.
|
||||
/// </summary>
|
||||
[JsonProperty("deletes")]
|
||||
public IList<DnsRecord>? DeletedRecords { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The updated records.
|
||||
/// </summary>
|
||||
[JsonProperty("patches")]
|
||||
public IList<DnsRecord>? UpdatedRecords { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The overwritten records.
|
||||
/// </summary>
|
||||
[JsonProperty("puts")]
|
||||
public IList<DnsRecord>? OverwrittenRecords { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The created records.
|
||||
/// </summary>
|
||||
[JsonProperty("posts")]
|
||||
public IList<DnsRecord>? CreatedRecords { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,702 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// DNS record.
|
||||
/// </summary>
|
||||
public class DnsRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifier.
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
public string? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Identifier of the zone.
|
||||
/// </summary>
|
||||
[JsonProperty("zone_id")]
|
||||
public string? ZoneId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of the zone.
|
||||
/// </summary>
|
||||
[JsonProperty("zone_name")]
|
||||
public string? ZoneName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// DNS record name (or @ for the zone apex) in Punycode.
|
||||
/// </summary>
|
||||
[JsonProperty("name")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Record type.
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
public DnsRecordType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A valid record content.
|
||||
/// </summary>
|
||||
[JsonProperty("content")]
|
||||
public string? Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The priority.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Required for <see cref="DnsRecordType.Mx"/>, <see cref="DnsRecordType.Srv"/> and <see cref="DnsRecordType.Uri"/> records; unused by other record types.
|
||||
/// Records with lower priorities are preferred.
|
||||
/// </remarks>
|
||||
[JsonProperty("priority")]
|
||||
public ushort? Priority { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Components associated with the record.
|
||||
/// </summary>
|
||||
[JsonProperty("data")]
|
||||
public object? Data { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the record can be proxied by Cloudflare or not.
|
||||
/// </summary>
|
||||
[JsonProperty("proxiable")]
|
||||
public bool Proxiable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the record is receiving the performance and security benefits of Cloudflare.
|
||||
/// </summary>
|
||||
[JsonProperty("proxied")]
|
||||
public bool Proxied { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'.
|
||||
/// Value must be between 60 and 86400, <em>with the minimum reduced to 30 for Enterprise zones</em>.
|
||||
/// </summary>
|
||||
/// <value>Unit: seconds. Range: <c>60 <=</c> X <c><= 86400</c></value>
|
||||
[JsonProperty("ttl")]
|
||||
public int Ttl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Settings for the DNS record.
|
||||
/// </summary>
|
||||
[JsonProperty("settings")]
|
||||
public object? Settings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Extra Cloudflare-specific information about the record.
|
||||
/// </summary>
|
||||
[JsonProperty("meta")]
|
||||
public DnsRecordMeta? Meta { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Comments or notes about the DNS record. This field has no effect on DNS responses.
|
||||
/// </summary>
|
||||
[JsonProperty("comment")]
|
||||
public string? Comment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Custom tags for the DNS record. This field has no effect on DNS responses.
|
||||
/// </summary>
|
||||
[JsonProperty("tags")]
|
||||
public IList<string>? Tags { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// When the record was created.
|
||||
/// </summary>
|
||||
[JsonProperty("created_on")]
|
||||
public DateTime CreatedOn { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// When the record was last modified.
|
||||
/// </summary>
|
||||
[JsonProperty("modified_on")]
|
||||
public DateTime ModifiedOn { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// When the record comment was last modified. Omitted if there is no comment.
|
||||
/// </summary>
|
||||
[JsonProperty("comment_modified_on")]
|
||||
public DateTime? CommentModifiedOn { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// When the record tags were last modified. Omitted if there are no tags.
|
||||
/// </summary>
|
||||
[JsonProperty("tags_modified_on")]
|
||||
public DateTime? TagsModifiedOn { get; set; }
|
||||
|
||||
#region Type definitions for data fields
|
||||
|
||||
/// <summary>
|
||||
/// Returns the data strong typed (as <see cref="Data"/> might be <see cref="JObject"/> from deserialization).
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public object? GetTypedData()
|
||||
{
|
||||
return Type switch
|
||||
{
|
||||
DnsRecordType.Caa => GetTypedData<CaaData>(),
|
||||
DnsRecordType.Cert => GetTypedData<CertData>(),
|
||||
DnsRecordType.DnsKey => GetTypedData<DnsKeyData>(),
|
||||
DnsRecordType.Ds => GetTypedData<DsData>(),
|
||||
DnsRecordType.Https => GetTypedData<HttpsData>(),
|
||||
DnsRecordType.Loc => GetTypedData<LocData>(),
|
||||
DnsRecordType.NaPtr => GetTypedData<NaPtrData>(),
|
||||
DnsRecordType.SMimeA => GetTypedData<SMimeAData>(),
|
||||
DnsRecordType.Srv => GetTypedData<SrvData>(),
|
||||
DnsRecordType.SshFp => GetTypedData<SshFpData>(),
|
||||
DnsRecordType.SvcB => GetTypedData<SvcBData>(),
|
||||
DnsRecordType.TlsA => GetTypedData<TlsAData>(),
|
||||
DnsRecordType.Uri => GetTypedData<UriData>(),
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the data strong typed (as <see cref="Data"/> might be <see cref="JObject"/> from deserialization).
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the data.</typeparam>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public T? GetTypedData<T>()
|
||||
where T : class
|
||||
{
|
||||
if (Data == null)
|
||||
return default;
|
||||
|
||||
if (Data is JObject jo)
|
||||
return jo.ToObject<T>();
|
||||
|
||||
return (T)Data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Components of a CAA record.
|
||||
/// </summary>
|
||||
public class CaaData(byte flags, string tag, string value)
|
||||
{
|
||||
/// <summary>
|
||||
/// Flags for the CAA record
|
||||
/// </summary>
|
||||
/// <value>Range: <c>0 <=</c> X <c><= 255</c></value>
|
||||
[JsonProperty("flags")]
|
||||
public byte Flags { get; set; } = flags;
|
||||
|
||||
/// <summary>
|
||||
/// Name of the property controlled by this record (e.g.: issue, issuewild, iodef).
|
||||
/// </summary>
|
||||
[JsonProperty("tag")]
|
||||
public string Tag { get; set; } = tag;
|
||||
|
||||
/// <summary>
|
||||
/// Value of the record. This field's semantics depend on the chosen tag.
|
||||
/// </summary>
|
||||
[JsonProperty("value")]
|
||||
public string Value { get; set; } = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Components of a CERT record.
|
||||
/// </summary>
|
||||
public class CertData(byte algorithm, string certificate, ushort keyTag, ushort type)
|
||||
{
|
||||
/// <summary>
|
||||
/// Algorithm of the certificate
|
||||
/// </summary>
|
||||
[JsonProperty("algorithm")]
|
||||
public byte Algorithm { get; set; } = algorithm;
|
||||
|
||||
/// <summary>
|
||||
/// Base64 encoded certificate.
|
||||
/// </summary>
|
||||
[JsonProperty("certificate")]
|
||||
public string Certificate { get; set; } = certificate;
|
||||
|
||||
/// <summary>
|
||||
/// Key tag.
|
||||
/// </summary>
|
||||
[JsonProperty("key_tag")]
|
||||
public ushort KeyTag { get; set; } = keyTag;
|
||||
|
||||
/// <summary>
|
||||
/// Type.
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
public ushort Type { get; set; } = type;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Components of a DNSKEY record.
|
||||
/// </summary>
|
||||
public class DnsKeyData(byte algorithm, ushort flags, byte protocol, string publicKey)
|
||||
{
|
||||
/// <summary>
|
||||
/// Algorithm of the certificate
|
||||
/// </summary>
|
||||
[JsonProperty("algorithm")]
|
||||
public byte Algorithm { get; set; } = algorithm;
|
||||
|
||||
/// <summary>
|
||||
/// Algorithm of the certificate
|
||||
/// </summary>
|
||||
[JsonProperty("flags")]
|
||||
public ushort Flags { get; set; } = flags;
|
||||
|
||||
/// <summary>
|
||||
/// Algorithm of the certificate
|
||||
/// </summary>
|
||||
[JsonProperty("protocol")]
|
||||
public byte Protocol { get; set; } = protocol;
|
||||
|
||||
/// <summary>
|
||||
/// Public key.
|
||||
/// </summary>
|
||||
[JsonProperty("public_key")]
|
||||
public string PublicKey { get; set; } = publicKey;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Components of a DS record.
|
||||
/// </summary>
|
||||
public class DsData(byte algorithm, string digest, byte digestType, ushort keyTag)
|
||||
{
|
||||
/// <summary>
|
||||
/// Algorithm of the certificate
|
||||
/// </summary>
|
||||
[JsonProperty("algorithm")]
|
||||
public byte Algorithm { get; set; } = algorithm;
|
||||
|
||||
/// <summary>
|
||||
/// Digest.
|
||||
/// </summary>
|
||||
[JsonProperty("digest")]
|
||||
public string Digest { get; set; } = digest;
|
||||
|
||||
/// <summary>
|
||||
/// Digest type.
|
||||
/// </summary>
|
||||
[JsonProperty("digest_type")]
|
||||
public byte DigestType { get; set; } = digestType;
|
||||
|
||||
/// <summary>
|
||||
/// Key tag.
|
||||
/// </summary>
|
||||
[JsonProperty("key_tag")]
|
||||
public ushort KeyTag { get; set; } = keyTag;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Components of an HTTPS record.
|
||||
/// </summary>
|
||||
public class HttpsData(ushort priority, string target, string value)
|
||||
{
|
||||
/// <summary>
|
||||
/// Priority.
|
||||
/// </summary>
|
||||
[JsonProperty("priority")]
|
||||
public ushort Priority { get; set; } = priority;
|
||||
|
||||
/// <summary>
|
||||
/// Target.
|
||||
/// </summary>
|
||||
[JsonProperty("target")]
|
||||
public string Target { get; set; } = target;
|
||||
|
||||
/// <summary>
|
||||
/// Value.
|
||||
/// </summary>
|
||||
[JsonProperty("Value")]
|
||||
public string Value { get; set; } = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Components of a LOC record.
|
||||
/// </summary>
|
||||
public class LocData(int latitudeDegrees, int latitudeMinutes, double latitudeSeconds, LatitudeDirection latitudeDirection,
|
||||
int longitudeDegrees, int longitudeMinutes, double longitudeSeconds, LongitudeDirection longitudeDirection,
|
||||
double altitude, int size, int precisionHorizontal, int precisionVertical)
|
||||
{
|
||||
/// <summary>
|
||||
/// Degrees of latitude.
|
||||
/// </summary>
|
||||
/// <value>Unit: degree. Range: <c>0 <= X <= 90</c></value>
|
||||
[JsonProperty("lat_degrees")]
|
||||
public int LatitudeDegrees { get; set; } = latitudeDegrees;
|
||||
|
||||
/// <summary>
|
||||
/// Minutes of latitude.
|
||||
/// </summary>
|
||||
/// <value>Unit: minute. Range: <c>0 <= X <= 59</c></value>
|
||||
[JsonProperty("lat_minutes")]
|
||||
public int LatitudeMinutes { get; set; } = latitudeMinutes;
|
||||
|
||||
/// <summary>
|
||||
/// Seconds of latitude.
|
||||
/// </summary>
|
||||
/// <value>Unit: second. Range: <c>0 <= X <= 59.999</c></value>
|
||||
[JsonProperty("lat_seconds")]
|
||||
public double LatitudeSeconds { get; set; } = latitudeSeconds;
|
||||
|
||||
/// <summary>
|
||||
/// Latitude direction.
|
||||
/// </summary>
|
||||
[JsonProperty("lat_direction")]
|
||||
public LatitudeDirection LatitudeDirection { get; set; } = latitudeDirection;
|
||||
|
||||
/// <summary>
|
||||
/// Degrees of longitude.
|
||||
/// </summary>
|
||||
/// <value>Unit: degree. Range: <c>0 <= X <= 180</c></value>
|
||||
[JsonProperty("long_degrees")]
|
||||
public int LongitudeDegrees { get; set; } = longitudeDegrees;
|
||||
|
||||
/// <summary>
|
||||
/// Minutes of longitude.
|
||||
/// </summary>
|
||||
/// <value>Unit: minute. Range: <c>0 <= X <= 59</c></value>
|
||||
[JsonProperty("long_minutes")]
|
||||
public int LongitudeMinutes { get; set; } = longitudeMinutes;
|
||||
|
||||
/// <summary>
|
||||
/// Seconds of longitude.
|
||||
/// </summary>
|
||||
/// <value>Unit: second. Range: <c>0 <= X <= 59.999</c></value>
|
||||
[JsonProperty("long_seconds")]
|
||||
public double LongitudeSeconds { get; set; } = longitudeSeconds;
|
||||
|
||||
/// <summary>
|
||||
/// Longitude direction.
|
||||
/// </summary>
|
||||
[JsonProperty("long_direction")]
|
||||
public LongitudeDirection LongitudeDirection { get; set; } = longitudeDirection;
|
||||
|
||||
/// <summary>
|
||||
/// Altitude of location in meters.
|
||||
/// </summary>
|
||||
/// <value>Unit: meter. Range: <c>-100_000.00 <= X <= 42_849_672.95</c></value>
|
||||
[JsonProperty("altitude")]
|
||||
public double Altitude { get; set; } = altitude;
|
||||
|
||||
/// <summary>
|
||||
/// Size of location in meters.
|
||||
/// </summary>
|
||||
/// <value>Unit: meter. Range: <c>0 <= X <= 90_000_000</c></value>
|
||||
[JsonProperty("size")]
|
||||
public int Size { get; set; } = size;
|
||||
|
||||
/// <summary>
|
||||
/// Horizontal precision of location.
|
||||
/// </summary>
|
||||
/// <value>Unit: meter. Range: <c>0 <= X <= 90_000_000</c></value>
|
||||
[JsonProperty("precision_horz")]
|
||||
public int PrecisionHorizontal { get; set; } = precisionHorizontal;
|
||||
|
||||
/// <summary>
|
||||
/// Vertical precision of location.
|
||||
/// </summary>
|
||||
/// <value>Unit: meter. Range: <c>0 <= X <= 90_000_000</c></value>
|
||||
[JsonProperty("precision_vert")]
|
||||
public int PrecisionVertical { get; set; } = precisionVertical;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Components of a NAPTR record.
|
||||
/// </summary>
|
||||
public class NaPtrData(string flags, ushort order, ushort preference, string regex, string replacement, string service)
|
||||
{
|
||||
/// <summary>
|
||||
/// Flags.
|
||||
/// </summary>
|
||||
[JsonProperty("flags")]
|
||||
public string Flags { get; set; } = flags;
|
||||
|
||||
/// <summary>
|
||||
/// Order.
|
||||
/// </summary>
|
||||
[JsonProperty("order")]
|
||||
public ushort Order { get; set; } = order;
|
||||
|
||||
/// <summary>
|
||||
/// Preference.
|
||||
/// </summary>
|
||||
[JsonProperty("preference")]
|
||||
public ushort Preference { get; set; } = preference;
|
||||
|
||||
/// <summary>
|
||||
/// Service.
|
||||
/// </summary>
|
||||
[JsonProperty("regex")]
|
||||
public string Regex { get; set; } = regex;
|
||||
|
||||
/// <summary>
|
||||
/// Replacement.
|
||||
/// </summary>
|
||||
[JsonProperty("replacement")]
|
||||
public string Replacement { get; set; } = replacement;
|
||||
|
||||
/// <summary>
|
||||
/// Service.
|
||||
/// </summary>
|
||||
[JsonProperty("service")]
|
||||
public string Service { get; set; } = service;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Components of a SMIMEA record.
|
||||
/// </summary>
|
||||
public class SMimeAData(string certificate, byte matchingType, byte selector, byte usage)
|
||||
{
|
||||
/// <summary>
|
||||
/// Certificate.
|
||||
/// </summary>
|
||||
[JsonProperty("certificate")]
|
||||
public string Certificate { get; set; } = certificate;
|
||||
|
||||
/// <summary>
|
||||
/// Matching type.
|
||||
/// </summary>
|
||||
[JsonProperty("matching_type")]
|
||||
public byte MatchingType { get; set; } = matchingType;
|
||||
|
||||
/// <summary>
|
||||
/// Selector.
|
||||
/// </summary>
|
||||
[JsonProperty("selector")]
|
||||
public byte Selector { get; set; } = selector;
|
||||
|
||||
/// <summary>
|
||||
/// Usage.
|
||||
/// </summary>
|
||||
[JsonProperty("usage")]
|
||||
public byte Usage { get; set; } = usage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Components of a SRV record.
|
||||
/// </summary>
|
||||
public class SrvData(ushort port, ushort priority, string target, ushort weight)
|
||||
{
|
||||
/// <summary>
|
||||
/// The port of the service.
|
||||
/// </summary>
|
||||
[JsonProperty("port")]
|
||||
public ushort Port { get; set; } = port;
|
||||
|
||||
/// <summary>
|
||||
/// The priority of the service.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Required for <see cref="DnsRecordType.Mx"/>, <see cref="DnsRecordType.Srv"/> and <see cref="DnsRecordType.Uri"/> records; unused by other record types.
|
||||
/// Records with lower priorities are preferred.
|
||||
/// </remarks>
|
||||
[JsonProperty("priority")]
|
||||
public ushort Priority { get; set; } = priority;
|
||||
|
||||
/// <summary>
|
||||
/// A valid hostname.
|
||||
/// </summary>
|
||||
[JsonProperty("target")]
|
||||
public string Target { get; set; } = target;
|
||||
|
||||
/// <summary>
|
||||
/// The weight of the record.
|
||||
/// </summary>
|
||||
[JsonProperty("weight")]
|
||||
public ushort Weight { get; set; } = weight;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Components of a SSHFP record.
|
||||
/// </summary>
|
||||
public class SshFpData(byte algorithm, string fingerprint, byte type)
|
||||
{
|
||||
/// <summary>
|
||||
/// Algorithm.
|
||||
/// </summary>
|
||||
[JsonProperty("algorithm")]
|
||||
public byte Algorithm { get; set; } = algorithm;
|
||||
|
||||
/// <summary>
|
||||
/// Fingerprint.
|
||||
/// </summary>
|
||||
[JsonProperty("fingerprint")]
|
||||
public string Fingerprint { get; set; } = fingerprint;
|
||||
|
||||
/// <summary>
|
||||
/// Type.
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
public byte Type { get; set; } = type;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Components of a SVCB record.
|
||||
/// </summary>
|
||||
public class SvcBData(ushort priority, string target, string value)
|
||||
{
|
||||
/// <summary>
|
||||
/// The priority of the service binding.
|
||||
/// </summary>
|
||||
[JsonProperty("priority")]
|
||||
public ushort Priority { get; set; } = priority;
|
||||
|
||||
/// <summary>
|
||||
/// A valid target.
|
||||
/// </summary>
|
||||
[JsonProperty("target")]
|
||||
public string Target { get; set; } = target;
|
||||
|
||||
/// <summary>
|
||||
/// The value of the service binding.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// e.g. <c>alpn="h3,h2" ipv4hint="127.0.0.1" ipv6hint="::1"</c>
|
||||
/// </remarks>
|
||||
[JsonProperty("value")]
|
||||
public string Value { get; set; } = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Components of a TLSA record.
|
||||
/// </summary>
|
||||
public class TlsAData(string certificate, byte matchingType, byte selector, byte usage)
|
||||
{
|
||||
/// <summary>
|
||||
/// Certificate.
|
||||
/// </summary>
|
||||
[JsonProperty("certificate")]
|
||||
public string Certificate { get; set; } = certificate;
|
||||
|
||||
/// <summary>
|
||||
/// Matching type.
|
||||
/// </summary>
|
||||
[JsonProperty("matching_type")]
|
||||
public byte MatchingType { get; set; } = matchingType;
|
||||
|
||||
/// <summary>
|
||||
/// Selector.
|
||||
/// </summary>
|
||||
[JsonProperty("selector")]
|
||||
public byte Selector { get; set; } = selector;
|
||||
|
||||
/// <summary>
|
||||
/// Usage.
|
||||
/// </summary>
|
||||
[JsonProperty("usage")]
|
||||
public byte Usage { get; set; } = usage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Components of a URI record.
|
||||
/// </summary>
|
||||
public class UriData(string target, ushort weight)
|
||||
{
|
||||
/// <summary>
|
||||
/// A valid target.
|
||||
/// </summary>
|
||||
[JsonProperty("target")]
|
||||
public string Target { get; set; } = target;
|
||||
|
||||
/// <summary>
|
||||
/// The weight of the record.
|
||||
/// </summary>
|
||||
[JsonProperty("weight")]
|
||||
public ushort Weight { get; set; } = weight;
|
||||
}
|
||||
|
||||
#region Enums for data fields
|
||||
|
||||
/// <summary>
|
||||
/// Directions for latitude.
|
||||
/// </summary>
|
||||
public enum LatitudeDirection
|
||||
{
|
||||
/// <summary>
|
||||
/// North.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "N")]
|
||||
North = 1,
|
||||
|
||||
/// <summary>
|
||||
/// South.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "S")]
|
||||
South = 2
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Directions for longitude.
|
||||
/// </summary>
|
||||
public enum LongitudeDirection
|
||||
{
|
||||
/// <summary>
|
||||
/// East.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "E")]
|
||||
East = 1,
|
||||
|
||||
/// <summary>
|
||||
/// West.
|
||||
/// </summary>
|
||||
[EnumMember(Value = "W")]
|
||||
West = 2
|
||||
}
|
||||
|
||||
#endregion Enums for data fields
|
||||
|
||||
#endregion Type definitions for data fields
|
||||
|
||||
#region Type definitions for settings fields
|
||||
|
||||
/// <summary>
|
||||
/// Returns the settings strong typed (as <see cref="Settings"/> might be <see cref="JObject"/> from deserialization).
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public object? GetTypedSettings()
|
||||
{
|
||||
return Type switch
|
||||
{
|
||||
DnsRecordType.Cname => GetTypedSettings<CnameSettings>(),
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the settings strong typed (as <see cref="Settings"/> might be <see cref="JObject"/> from deserialization).
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the settings.</typeparam>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public T? GetTypedSettings<T>()
|
||||
where T : class
|
||||
{
|
||||
if (Settings == null)
|
||||
return default;
|
||||
|
||||
if (Settings is JObject jo)
|
||||
return jo.ToObject<T>();
|
||||
|
||||
return (T)Settings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Settings for the DNS record.
|
||||
/// </summary>
|
||||
public class CnameSettings(bool flattenCname)
|
||||
{
|
||||
/// <summary>
|
||||
/// If enabled, causes the CNAME record to be resolved externally and the resulting address records (e.g., A and AAAA) to be returned instead of the CNAME record itself.
|
||||
/// This setting has no effect on proxied records, which are always flattened.
|
||||
/// </summary>
|
||||
[JsonProperty("flatten_cname")]
|
||||
public bool FlattenCname { get; set; } = flattenCname;
|
||||
}
|
||||
|
||||
#endregion Type definitions for settings fields
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Extra Cloudflare-specific information about the record.
|
||||
/// </summary>
|
||||
public class DnsRecordMeta
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the record was automatically added.
|
||||
/// </summary>
|
||||
[JsonProperty("auto_added")]
|
||||
public bool AutoAdded { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the record is managed by apps.
|
||||
/// </summary>
|
||||
[JsonProperty("managed_by_apps")]
|
||||
public bool ManagedByApps { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the record is managed by argo tunnel.
|
||||
/// </summary>
|
||||
[JsonProperty("managed_by_argo_tunnel")]
|
||||
public bool ManagedByArgoTunnel { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// The deleted id.
|
||||
/// </summary>
|
||||
public class IdResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifier.
|
||||
/// </summary>
|
||||
// <= 32 characters
|
||||
[JsonProperty("id")]
|
||||
public string? Id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// The DNS records import result.
|
||||
/// </summary>
|
||||
public class ImportDnsRecordsResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Number of DNS records added.
|
||||
/// </summary>
|
||||
[JsonProperty("recs_added")]
|
||||
public int? RecordsAdded { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Total number of DNS records parsed.
|
||||
/// </summary>
|
||||
[JsonProperty("total_records_parsed")]
|
||||
public int? TotalRecordsParsed { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// A nameserver.
|
||||
/// </summary>
|
||||
public class Nameserver
|
||||
{
|
||||
/// <summary>
|
||||
/// The nameserver type.
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
public NameserverType Type { get; set; }
|
||||
|
||||
// TODO: DEPRECATED? - not available on API request.
|
||||
///// <summary>
|
||||
///// Configured nameserver set to be used for this zone.
|
||||
///// </summary>
|
||||
///// <value>Range: <c>1 <=</c> X <c><= 5</c></value>
|
||||
//[JsonProperty("ns_set")]
|
||||
//public int NameserverSet { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// The security TXT record.
|
||||
/// </summary>
|
||||
public class SecurityTxt
|
||||
{
|
||||
/// <summary>
|
||||
/// The acknowledgements.
|
||||
/// </summary>
|
||||
[JsonProperty("acknowledgements")]
|
||||
public IList<string>? Acknowledgements { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The canonical.
|
||||
/// </summary>
|
||||
[JsonProperty("canonical")]
|
||||
public IList<string>? Canonical { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The contact.
|
||||
/// </summary>
|
||||
[JsonProperty("contact")]
|
||||
public IList<string>? Contact { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A value indicating whether this security.txt is enabled.
|
||||
/// </summary>
|
||||
[JsonProperty("enabled")]
|
||||
public bool? Enabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///The encryption.
|
||||
/// </summary>
|
||||
[JsonProperty("encryption")]
|
||||
public IList<string>? Encryption { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The expiry.
|
||||
/// </summary>
|
||||
[JsonProperty("expires")]
|
||||
public DateTime? Expires { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The hiring.
|
||||
/// </summary>
|
||||
[JsonProperty("hiring")]
|
||||
public IList<string>? Hiring { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The policies.
|
||||
/// </summary>
|
||||
[JsonProperty("policy")]
|
||||
public IList<string>? Policy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The preferred languages.
|
||||
/// </summary>
|
||||
[JsonProperty("preferredLanguages")]
|
||||
public string? PreferredLanguages { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// The SOA (Start of Authority) record.
|
||||
/// </summary>
|
||||
public class StartOfAuthority
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="StartOfAuthority"/> class.
|
||||
/// </summary>
|
||||
/// <param name="primaryNameserver">The primary nameserver.</param>
|
||||
/// <param name="zoneAdministrator">The zone administrator. First dot will be interpreted as @-sign.</param>
|
||||
/// <param name="ttl">The time to live of the SOA record.</param>
|
||||
/// <param name="refresh">Time in seconds after which secondary servers should re-check the SOA record to see if the zone has been updated.</param>
|
||||
/// <param name="retry">Time in seconds after which secondary servers should retry queries after the primary server was unresponsive.</param>
|
||||
/// <param name="expire">Time in seconds of being unable to query the primary server after which secondary servers should stop serving the zone.</param>
|
||||
/// <param name="minimumTtl">The time to live (TTL) for negative caching of records within the zone.</param>
|
||||
public StartOfAuthority(string primaryNameserver, string zoneAdministrator, int ttl, int refresh, int retry, int expire, int minimumTtl)
|
||||
{
|
||||
PrimaryNameserver = primaryNameserver;
|
||||
ZoneAdministrator = zoneAdministrator;
|
||||
Ttl = ttl;
|
||||
Refresh = refresh;
|
||||
Retry = retry;
|
||||
Expire = expire;
|
||||
MinimumTtl = minimumTtl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Time in seconds of being unable to query the primary server after which secondary servers should stop serving the zone.
|
||||
/// </summary>
|
||||
/// <value>Unit: seconds. Range: <c>86400 <=</c> X <c><= 2419200</c></value>
|
||||
[JsonProperty("expire")]
|
||||
public int Expire { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time to live (TTL) for negative caching of records within the zone.
|
||||
/// </summary>
|
||||
/// <value>Unit: seconds. Range: <c>60 <=</c> X <c><= 86400</c></value>
|
||||
[JsonProperty("min_ttl")]
|
||||
public int MinimumTtl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The primary nameserver, which may be used for outbound zone transfers.
|
||||
/// </summary>
|
||||
[JsonProperty("mname", NullValueHandling = NullValueHandling.Include)]
|
||||
public string PrimaryNameserver { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Time in seconds after which secondary servers should re-check the SOA record to see if the zone has been updated.
|
||||
/// </summary>
|
||||
/// <value>Unit: seconds. Range: <c>600 <=</c> X <c><= 86400</c></value>
|
||||
[JsonProperty("refresh")]
|
||||
public int Refresh { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Time in seconds after which secondary servers should retry queries after the primary server was unresponsive.
|
||||
/// </summary>
|
||||
/// <value>Unit: seconds. Range: <c>600 <=</c> X <c><= 86400</c></value>
|
||||
[JsonProperty("retry")]
|
||||
public int Retry { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The email address of the zone administrator, with the first label representing the local part of the email address.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The first dot is interpreted as @ sign.
|
||||
/// <br/>
|
||||
/// admin.example.com => admin@example.com
|
||||
/// <br/>
|
||||
/// test\.user.example.org => test.user@example.org
|
||||
/// </remarks>
|
||||
[JsonProperty("rname", NullValueHandling = NullValueHandling.Include)]
|
||||
public string ZoneAdministrator { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time to live (TTL) of the SOA record itself.
|
||||
/// </summary>
|
||||
/// <value>Unit: seconds. Range: <c>300 <=</c> X <c><= 86400</c></value>
|
||||
[JsonProperty("ttl")]
|
||||
public int Ttl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// A DNS Zone.
|
||||
/// </summary>
|
||||
public class Zone
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifier.
|
||||
/// </summary>
|
||||
// <= 32 characters
|
||||
[JsonProperty("id")]
|
||||
public string? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The account the zone belongs to.
|
||||
/// </summary>
|
||||
[JsonProperty("account")]
|
||||
public AccountBase? Account { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The last time proof of ownership was detected and the zone was made active.
|
||||
/// </summary>
|
||||
[JsonProperty("activated_on")]
|
||||
public DateTime ActivatedOn { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// When the zone was created.
|
||||
/// </summary>
|
||||
[JsonProperty("created_on")]
|
||||
public DateTime CreatedOn { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The interval (in seconds) from when development mode expires (positive integer)
|
||||
/// or last expired (negative integer) for the domain.
|
||||
/// If development mode has never been enabled, this value is 0.
|
||||
/// </summary>
|
||||
[JsonProperty("development_mode")]
|
||||
public int DevelopmentMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Metadata about the zone.
|
||||
/// </summary>
|
||||
[JsonProperty("meta")]
|
||||
public ZoneMetaData? Meta { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// When the zone was last modified.
|
||||
/// </summary>
|
||||
[JsonProperty("modified_on")]
|
||||
public DateTime ModifiedOn { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The domain name.
|
||||
/// </summary>
|
||||
// <= 253 characters
|
||||
[JsonProperty("name")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name servers Cloudflare assigns to a zone.
|
||||
/// </summary>
|
||||
[JsonProperty("name_servers")]
|
||||
public IReadOnlyList<string>? NameServers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// DNS host at the time of switching to Cloudflare.
|
||||
/// </summary>
|
||||
[JsonProperty("original_dnshost")]
|
||||
public string? OriginalDnshost { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Original name servers before moving to Cloudflare.
|
||||
/// </summary>
|
||||
[JsonProperty("original_name_servers")]
|
||||
public IReadOnlyList<string>? OriginalNameServers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Registrar for the domain at the time of switching to Cloudflare.
|
||||
/// </summary>
|
||||
[JsonProperty("original_registrar")]
|
||||
public string? OriginalRegistrar { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The owner of the zone.
|
||||
/// </summary>
|
||||
[JsonProperty("owner")]
|
||||
public OwnerBase? Owner { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the zone is only using Cloudflare DNS services.
|
||||
/// A <see langword="true"/> value means the zone will not receive security or performance benefits.
|
||||
/// </summary>
|
||||
[JsonProperty("paused")]
|
||||
public bool Paused { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The zone status on Cloudflare.
|
||||
/// </summary>
|
||||
[JsonProperty("status")]
|
||||
public ZoneStatus Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A full zone implies that DNS is hosted with Cloudflare.
|
||||
/// A partial zone is typically a partner-hosted zone or a CNAME setup..
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
public ZoneType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// An array of domains used for custom name servers.
|
||||
/// <em>This is only available for Business and Enterprise plans.</em>
|
||||
/// </summary>
|
||||
[JsonProperty("vanity_name_servers")]
|
||||
public IReadOnlyList<string>? VanityNameServers { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// The DNS settings.
|
||||
/// </summary>
|
||||
public class ZoneDnsSetting
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether to flatten all CNAME records in the zone. Note that, due to DNS limitations,
|
||||
/// a CNAME record at the zone apex will always be flattened.
|
||||
/// </summary>
|
||||
[JsonProperty("flatten_all_cnames")]
|
||||
public bool FlattenAllCnames { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to enable Foundation DNS Advanced Nameservers on the zone.
|
||||
/// </summary>
|
||||
[JsonProperty("foundation_dns")]
|
||||
public bool FoundationDns { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to enable multi-provider DNS, which causes Cloudflare to activate the zone even when non-Cloudflare NS records exist,
|
||||
/// and to respect NS records at the zone apex during outbound zone transfers.
|
||||
/// </summary>
|
||||
[JsonProperty("multi_provider")]
|
||||
public bool MultiProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Settings determining the nameservers through which the zone should be available.
|
||||
/// </summary>
|
||||
[JsonProperty("nameservers")]
|
||||
public Nameserver? Nameservers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time to live (TTL) of the zone's nameserver (NS) records.
|
||||
/// </summary>
|
||||
// 30 <= X <= 86400
|
||||
[JsonProperty("ns_ttl")]
|
||||
public int NameserverTtl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Allows a Secondary DNS zone to use (proxied) override records and CNAME flattening at the zone apex.
|
||||
/// </summary>
|
||||
[JsonProperty("secondary_overrides")]
|
||||
public bool SecondaryOverrides { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Components of the zone's SOA record.
|
||||
/// </summary>
|
||||
[JsonProperty("soa")]
|
||||
public StartOfAuthority? SOA { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the zone mode is a regular or CDN/DNS only zone.
|
||||
/// </summary>
|
||||
[JsonProperty("zone_mode")]
|
||||
public ZoneMode Mode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// A zone hold.
|
||||
/// </summary>
|
||||
public class ZoneHold
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the zone is on hold.
|
||||
/// </summary>
|
||||
[JsonProperty("hold")]
|
||||
public bool Hold { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an information whether subdomains are included in the hold.
|
||||
/// </summary>
|
||||
[JsonProperty("include_subdomains")]
|
||||
public string? IncludeSubdomains { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time after which the zone is no longer on hold.
|
||||
/// </summary>
|
||||
[JsonProperty("hold_after")]
|
||||
public DateTime HoldAfter { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// The zone metadata.
|
||||
/// </summary>
|
||||
public class ZoneMetaData
|
||||
{
|
||||
/// <summary>
|
||||
/// The zone is only configured for CDN.
|
||||
/// </summary>
|
||||
[JsonProperty("cdn_only")]
|
||||
public bool CdnOnly { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of Custom Certificates the zone can have.
|
||||
/// </summary>
|
||||
[JsonProperty("custom_certificate_quota")]
|
||||
public int CustomCertificateQuota { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The zone is only configured for DNS.
|
||||
/// </summary>
|
||||
[JsonProperty("dns_only")]
|
||||
public bool DnsOnly { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The zone is setup with Foundation DNS.
|
||||
/// </summary>
|
||||
[JsonProperty("foundation_dns")]
|
||||
public bool FoundationDns { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of Page Rules a zone can have.
|
||||
/// </summary>
|
||||
[JsonProperty("page_rule_quota")]
|
||||
public int PageRuleQuota { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The zone has been flagged for phishing.
|
||||
/// </summary>
|
||||
[JsonProperty("phishing_detected")]
|
||||
public bool PhishingDetected { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Step.
|
||||
/// </summary>
|
||||
[JsonProperty("step")]
|
||||
public int Step { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
internal static class RegexPatterns
|
||||
{
|
||||
public static readonly Regex ZoneName = new(@"^([a-zA-Z0-9][\-a-zA-Z0-9]*\.)+[\-a-zA-Z0-9]{2,20}$", RegexOptions.Compiled);
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Batch of DNS Record API calls to be executed together.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Execution order: Delete, Update, Overwrite, Create
|
||||
/// </remarks>
|
||||
public class BatchDnsRecordsRequest(string zoneId)
|
||||
{
|
||||
/// <summary>
|
||||
/// The zone identifier.
|
||||
/// </summary>
|
||||
public string ZoneId { get; set; } = zoneId;
|
||||
|
||||
/// <summary>
|
||||
/// The DNS record identifiers to delete.
|
||||
/// </summary>
|
||||
public IList<string> DnsRecordIdsToDelete { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// The DNS records to update.
|
||||
/// </summary>
|
||||
public IList<UpdateDnsRecordRequest> DnsRecordsToUpdate { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// The DNS records to overwrite.
|
||||
/// </summary>
|
||||
public IList<OverwriteDnsRecordRequest> DnsRecordsToOverwrite { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// The DNS records to create.
|
||||
/// </summary>
|
||||
public IList<CreateDnsRecordRequest> DnsRecordsToCreate { get; set; } = [];
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Request to create a new DNS record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the <see cref="CreateDnsRecordRequest"/> class.
|
||||
/// </remarks>
|
||||
/// <param name="zoneId">The zone identifier.</param>
|
||||
/// <param name="name">DNS record name (or @ for the zone apex).</param>
|
||||
/// <param name="type">Record type.</param>
|
||||
public class CreateDnsRecordRequest(string zoneId, string name, DnsRecordType type)
|
||||
{
|
||||
/// <summary>
|
||||
/// The zone identifier.
|
||||
/// </summary>
|
||||
public string ZoneId { get; set; } = zoneId;
|
||||
|
||||
/// <summary>
|
||||
/// Comments or notes about the DNS record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field has no effect on DNS responses.
|
||||
/// </remarks>
|
||||
public string? Comment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// DNS record name (or @ for the zone apex) in Punycode.
|
||||
/// </summary>
|
||||
public string Name { get; set; } = name;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the record is receiving the performance and security benefits of Cloudflare.
|
||||
/// </summary>
|
||||
public bool Proxied { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Settings for the DNS record.
|
||||
/// </summary>
|
||||
public object? Settings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Custom tags for the DNS record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This field has no effect on DNS responses.
|
||||
/// </remarks>
|
||||
public IList<string>? Tags { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Time To Live (TTL) of the DNS record in seconds.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Setting to <c>1</c> means 'automatic'.
|
||||
/// Value must be between <c>60</c> and <c>86400</c>, <em>with the minimum reduced to 30 for Enterprise zones</em>.
|
||||
/// </remarks>
|
||||
public int? Ttl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Components of a record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <strong>Caution:</strong> This field has priority over the <see cref="Content"/> field.
|
||||
/// </remarks>
|
||||
public object? Data { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A valid content.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <strong>Caution:</strong> This field has no effect for record types with specific <see cref="Data"/> values.
|
||||
/// </remarks>
|
||||
public string? Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A priority.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Required for <see cref="DnsRecordType.Mx"/>, <see cref="DnsRecordType.Srv"/> and <see cref="DnsRecordType.Uri"/> records; unused by other record types.
|
||||
/// Records with lower priorities are preferred.
|
||||
/// </remarks>
|
||||
public ushort? Priority { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Record type.
|
||||
/// </summary>
|
||||
public DnsRecordType Type { get; set; } = type;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Request to create a new zone.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Request to create a new zone.
|
||||
/// </remarks>
|
||||
/// <param name="accountId">The account identifier.</param>
|
||||
/// <param name="name">The domain name.</param>
|
||||
public class CreateZoneRequest(string accountId, string name)
|
||||
{
|
||||
/// <summary>
|
||||
/// The account identifier.
|
||||
/// </summary>
|
||||
public string AccountId { get; set; } = accountId;
|
||||
|
||||
/// <summary>
|
||||
/// The domain name.
|
||||
/// </summary>
|
||||
public string Name { get; set; } = name;
|
||||
|
||||
/// <summary>
|
||||
/// The zone type.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// A full zone implies that DNS is hosted with Cloudflare.
|
||||
/// A partial zone is typically a partner-hosted zone or a CNAME setup.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// If not set, Cloudflare will use <see cref="ZoneType.Full"/> as default.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public ZoneType? Type { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// A request to edit a zone.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the <see cref="EditZoneRequest"/> class.
|
||||
/// </remarks>
|
||||
/// <param name="id">The zone identifier.</param>
|
||||
public class EditZoneRequest(string id)
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Identifier.
|
||||
/// </summary>
|
||||
public string Id { get; set; } = id;
|
||||
|
||||
/// <summary>
|
||||
/// A full zone implies that DNS is hosted with Cloudflare. A partial zone is typically a partner-hosted zone or a CNAME setup.
|
||||
/// <br/>
|
||||
/// <em>This parameter is only available to Enterprise customers or if it has been explicitly enabled on a zone.</em>
|
||||
/// </summary>
|
||||
public ZoneType? Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// An array of domains used for custom name servers.
|
||||
/// <br/>
|
||||
/// <em>This is only available for Business and Enterprise plans.</em>
|
||||
/// </summary>
|
||||
public IList<string>? VanityNameServers { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Request to import DNS records from a BIND configuration file.
|
||||
/// </summary>
|
||||
public class ImportDnsRecordsRequest(string zoneId, string file)
|
||||
{
|
||||
/// <summary>
|
||||
/// The zone identifier.
|
||||
/// </summary>
|
||||
public string ZoneId { get; set; } = zoneId;
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not proxiable records should receive the performance and security benefits of Cloudflare.
|
||||
/// </summary>
|
||||
public bool? Proxied { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// BIND config to import.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If the property is an absolute path, the content of that file will be used as the BIND configuration.
|
||||
/// <br />
|
||||
/// Otherwise the property will be treated as BIND configuration itself.
|
||||
/// </remarks>
|
||||
public string File { get; set; } = file;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Request to overwrite a DNS record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the <see cref="OverwriteDnsRecordRequest"/> class.
|
||||
/// </remarks>
|
||||
/// <param name="id">The DNS record identifier.</param>
|
||||
/// <param name="zoneId">The zone identifier.</param>
|
||||
/// <param name="name">DNS record name (or @ for the zone apex).</param>
|
||||
/// <param name="type">Record type.</param>
|
||||
public class OverwriteDnsRecordRequest(string id, string zoneId, string name, DnsRecordType type) : CreateDnsRecordRequest(zoneId, name, type)
|
||||
{
|
||||
/// <summary>
|
||||
/// The DNS record identifier.
|
||||
/// </summary>
|
||||
public string Id { get; set; } = id;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Request to update a DNS record.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the <see cref="UpdateDnsRecordRequest"/> class.
|
||||
/// </remarks>
|
||||
/// <param name="id">The DNS record identifier.</param>
|
||||
/// <param name="zoneId">The zone identifier.</param>
|
||||
/// <param name="name">DNS record name (or @ for the zone apex).</param>
|
||||
/// <param name="type">Record type.</param>
|
||||
public class UpdateDnsRecordRequest(string id, string zoneId, string name, DnsRecordType type) : CreateDnsRecordRequest(zoneId, name, type)
|
||||
{
|
||||
/// <summary>
|
||||
/// The DNS record identifier.
|
||||
/// </summary>
|
||||
public string Id { get; set; } = id;
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Update DNS settings request.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the <see cref="UpdateDnsSettingsRequest"/> class.
|
||||
/// </remarks>
|
||||
/// <param name="id">The zone identifier.</param>
|
||||
public class UpdateDnsSettingsRequest(string id)
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The zone identifier.
|
||||
/// </summary>
|
||||
public string Id { get; set; } = id;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to flatten all CNAME records in the zone. Note that, due to DNS limitations,
|
||||
/// a CNAME record at the zone apex will always be flattened.
|
||||
/// </summary>
|
||||
public bool? FlattenAllCnames { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to enable Foundation DNS Advanced Nameservers on the zone.
|
||||
/// </summary>
|
||||
public bool? FoundationDns { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to enable multi-provider DNS, which causes Cloudflare to activate the zone even when non-Cloudflare NS records exist,
|
||||
/// and to respect NS records at the zone apex during outbound zone transfers.
|
||||
/// </summary>
|
||||
public bool? MultiProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Settings determining the nameservers through which the zone should be available.
|
||||
/// </summary>
|
||||
public Nameserver? Nameservers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time to live (TTL) of the zone's nameserver (NS) records.
|
||||
/// </summary>
|
||||
/// <value>Unit: seconds. Range: <c>30 <=</c> X <c><= 86400</c></value>
|
||||
public int? NameserverTtl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Allows a Secondary DNS zone to use (proxied) override records and CNAME flattening at the zone apex.
|
||||
/// </summary>
|
||||
public bool? SecondaryOverrides { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Components of the zone's SOA record.
|
||||
/// </summary>
|
||||
public StartOfAuthority? SOA { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the zone mode is a regular or CDN/DNS only zone.
|
||||
/// </summary>
|
||||
public ZoneMode? Mode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Request to update security.txt
|
||||
/// </summary>
|
||||
public class UpdateSecurityTxtRequest(string zoneId)
|
||||
{
|
||||
/// <summary>
|
||||
/// The zone identifier.
|
||||
/// </summary>
|
||||
public string ZoneId { get; set; } = zoneId;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the acknowledgements.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Example: <c>https://example.com/hall-of-fame.html</c>
|
||||
/// </remarks>
|
||||
public IList<string>? Acknowledgements { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the canonical.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Example: <c>https://www.example.com/.well-known/security.txt</c>
|
||||
/// </remarks>
|
||||
public IList<string>? Canonical { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the contact.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Examples:
|
||||
/// <list type="bullet">
|
||||
/// <item>mailto:security@example.com</item>
|
||||
/// <item>tel:+1-201-555-0123</item>
|
||||
/// <item>https://example.com/security-contact.html</item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
public IList<string>? Contact { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this security.txt is enabled.
|
||||
/// </summary>
|
||||
public bool? Enabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the encryption.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Examples:
|
||||
/// <list type="bullet">
|
||||
/// <item>https://example.com/pgp-key.txt</item>
|
||||
/// <item>dns:5d2d37ab76d47d36._openpgpkey.example.com?type=OPENPGPKEY</item>
|
||||
/// <item>openpgp4fpr:5f2de5521c63a801ab59ccb603d49de44b29100f</item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
public IList<string>? Encryption { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the expires.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <strong>NOTE</strong>: The value will be converted to UTC when the <see cref="DateTime.Kind"/> is not <see cref="DateTimeKind.Utc"/>.
|
||||
/// </remarks>
|
||||
public DateTime? Expires { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the hiring.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Example: <c>https://example.com/jobs.html</c>
|
||||
/// </remarks>
|
||||
public IList<string>? Hiring { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the policies.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Example: <c>https://example.com/disclosure-policy.html</c>
|
||||
/// </remarks>
|
||||
public IList<string>? Policy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the preferred languages.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Examples:
|
||||
/// <list type="bullet">
|
||||
/// <item>en</item>
|
||||
/// <item>es</item>
|
||||
/// <item>fr</item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
public IList<string>? PreferredLanguages { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Url with headers to purge.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the <see cref="ZonePurgeCachedUrlRequest"/> class.
|
||||
/// </remarks>
|
||||
/// <param name="url">The url to purge.</param>
|
||||
public class ZonePurgeCachedUrlRequest(string url)
|
||||
{
|
||||
/// <summary>
|
||||
/// Defined headers to specifiy the purge request.
|
||||
/// </summary>
|
||||
public Dictionary<string, string> Headers { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// The file url to purge.
|
||||
/// </summary>
|
||||
public string Url { get; set; } = url;
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AMWD.Net.Api.Cloudflare.Zones.Internals.Requests;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Extensions for security center section of a zone.
|
||||
/// </summary>
|
||||
public static class SecurityCenterExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Delete security.txt
|
||||
/// </summary>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static async Task<CloudflareResponse> DeleteSecurityTxt(this ICloudflareClient client, string zoneId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
return await client.DeleteAsync<object>($"zones/{zoneId}/security-center/securitytxt", cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get security.txt.
|
||||
/// </summary>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<SecurityTxt>> GetSecurityTxt(this ICloudflareClient client, string zoneId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
return client.GetAsync<SecurityTxt>($"zones/{zoneId}/security-center/securitytxt", cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update security.txt
|
||||
/// </summary>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="request">The request information.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static async Task<CloudflareResponse> UpdateSecurityTxt(this ICloudflareClient client, UpdateSecurityTxtRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
request.ZoneId.ValidateCloudflareId();
|
||||
|
||||
var req = new InternalUpdateSecurityTxtRequest();
|
||||
|
||||
if (request.Acknowledgements != null)
|
||||
req.Acknowledgements = request.Acknowledgements.Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
|
||||
|
||||
if (request.Canonical != null)
|
||||
req.Canonical = request.Canonical.Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
|
||||
|
||||
if (request.Contact != null)
|
||||
req.Contact = request.Contact.Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
|
||||
|
||||
req.Enabled = request.Enabled;
|
||||
|
||||
if (request.Encryption != null)
|
||||
req.Encryption = request.Encryption.Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
|
||||
|
||||
if (request.Expires.HasValue)
|
||||
req.Expires = request.Expires.Value.ToUniversalTime();
|
||||
|
||||
if (request.Hiring != null)
|
||||
req.Hiring = request.Hiring.Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
|
||||
|
||||
if (request.Policy != null)
|
||||
req.Policy = request.Policy.Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
|
||||
|
||||
if (request.PreferredLanguages != null)
|
||||
req.PreferredLanguages = string.Join(", ", request.PreferredLanguages.Where(s => !string.IsNullOrWhiteSpace(s)));
|
||||
|
||||
return await client.PutAsync<object, InternalUpdateSecurityTxtRequest>($"zones/{request.ZoneId}/security-center/securitytxt", req, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AMWD.Net.Api.Cloudflare.Zones.Internals.Requests;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Extends the <see cref="ICloudflareClient"/> with methods for working with zones.
|
||||
/// </summary>
|
||||
public static class ZoneCacheExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Purges all cached contents for a zone.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Removes ALL files from Cloudflare's cache. All tiers can purge everything.
|
||||
/// </remarks>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<IdResponse>> PurgeCachedContent(this ICloudflareClient client, string zoneId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
var req = new InternalPurgeCacheRequest
|
||||
{
|
||||
PurgeEverything = true
|
||||
};
|
||||
return client.PostAsync<IdResponse, InternalPurgeCacheRequest>($"zones/{zoneId}/purge_cache", req, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Purges cached contents by URLs.
|
||||
/// <br />
|
||||
/// Granularly removes one or more files from Cloudflare's cache by specifying URLs.
|
||||
/// All tiers can purge by URL.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// To purge files with custom cache keys, include the headers used to compute the cache key as in the example.
|
||||
/// If you have a device type or geo in your cache key, you will need to include the CF-Device-Type or CF-IPCountry headers.
|
||||
/// If you have lang in your cache key, you will need to include the Accept-Language header.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <strong>NB</strong>: When including the Origin header, be sure to include the <strong>scheme</strong> and <strong>hostname</strong>.
|
||||
/// The port number can be omitted if it is the default port (80 for http, 443 for https), but must be included otherwise.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <strong>NB</strong>: For Zones on Free/Pro/Business plan, you may purge up to 30 URLs in one API call.
|
||||
/// For Zones on Enterprise plan, you may purge up to 500 URLs in one API call.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="urls">List of URLs to purge.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<IdResponse>> PurgeCachedContentByUrl(this ICloudflareClient client, string zoneId, IReadOnlyList<ZonePurgeCachedUrlRequest> urls, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
|
||||
var req = new InternalPurgeCacheRequest();
|
||||
|
||||
if (urls.Any(u => u.Headers.Count > 0))
|
||||
{
|
||||
req.UrlsWithHeaders = urls.Where(u => !string.IsNullOrWhiteSpace(u.Url))
|
||||
.Select(u => new PurgeUrlWithHeaders
|
||||
{
|
||||
Url = u.Url,
|
||||
Headers = u.Headers
|
||||
.Where(kvp => !string.IsNullOrWhiteSpace(kvp.Key))
|
||||
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value)
|
||||
}).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
req.Urls = urls.Where(u => !string.IsNullOrWhiteSpace(u.Url)).Select(u => u.Url).ToList();
|
||||
}
|
||||
|
||||
return client.PostAsync<IdResponse, InternalPurgeCacheRequest>($"zones/{zoneId}/purge_cache", req, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Purges cached contents by cache-tags.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// For more information on cache tags and purging by tags, please refer to
|
||||
/// <see href="https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-tags/#purge-cache-by-cache-tags-enterprise-only">purge by cache-tags documentation page</see>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Cache-Tag purging has a rate limit of 30_000 purge API calls in every 24 hour period.
|
||||
/// You may purge up to 30 tags in one API call.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <em>This rate limit can be raised for customers who need to purge at higher volume.</em>
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="tags">List of tags to purge.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<IdResponse>> PurgeCachedContentByTag(this ICloudflareClient client, string zoneId, IReadOnlyList<string> tags, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
|
||||
if (tags == null)
|
||||
throw new ArgumentNullException(nameof(tags));
|
||||
|
||||
var req = new InternalPurgeCacheRequest
|
||||
{
|
||||
Tags = tags.Where(t => !string.IsNullOrWhiteSpace(t)).ToList()
|
||||
};
|
||||
return client.PostAsync<IdResponse, InternalPurgeCacheRequest>($"zones/{zoneId}/purge_cache", req, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Purges cached contents by hosts.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// For more information purging by hostnames, please refer to
|
||||
/// <see href="https://developers.cloudflare.com/cache/how-to/purge-cache/purge-by-hostname/">purge by hostname documentation page</see>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Host purging has a rate limit of 30_000 purge API calls in every 24 hour period.
|
||||
/// You may purge up to 30 hosts in one API call.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <em>This rate limit can be raised for customers who need to purge at higher volume.</em>
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="hosts">List of hostnames to purge.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<IdResponse>> PurgeCachedContentByHost(this ICloudflareClient client, string zoneId, IReadOnlyList<string> hosts, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
|
||||
if (hosts == null)
|
||||
throw new ArgumentNullException(nameof(hosts));
|
||||
|
||||
var req = new InternalPurgeCacheRequest
|
||||
{
|
||||
Hostnames = hosts.Where(h => !string.IsNullOrWhiteSpace(h)).ToList()
|
||||
};
|
||||
return client.PostAsync<IdResponse, InternalPurgeCacheRequest>($"zones/{zoneId}/purge_cache", req, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Purges cached contents by prefixes.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// For more information purging by prefixes, please refer to
|
||||
/// <see href="https://developers.cloudflare.com/cache/how-to/purge-cache/purge_by_prefix/">purge by prefix documentation page</see>.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Prefix purging has a rate limit of 30_000 purge API calls in every 24 hour period.
|
||||
/// You may purge up to 30 prefixes in one API call.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <em>This rate limit can be raised for customers who need to purge at higher volume.</em>
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="prefixes">List of prefixes to purge.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<IdResponse>> PurgeCachedContentByPrefix(this ICloudflareClient client, string zoneId, IReadOnlyList<string> prefixes, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
|
||||
if (prefixes == null)
|
||||
throw new ArgumentNullException(nameof(prefixes));
|
||||
|
||||
var req = new InternalPurgeCacheRequest
|
||||
{
|
||||
Prefixes = prefixes.Where(h => !string.IsNullOrWhiteSpace(h)).ToList()
|
||||
};
|
||||
return client.PostAsync<IdResponse, InternalPurgeCacheRequest>($"zones/{zoneId}/purge_cache", req, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AMWD.Net.Api.Cloudflare.Zones.Internals.Requests;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Extends the <see cref="ICloudflareClient"/> with methods for working with zones.
|
||||
/// </summary>
|
||||
public static class ZoneDnsSettingsExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Show DNS settings for a zone.
|
||||
/// </summary>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<ZoneDnsSetting>> ShowZoneDnsSettings(this ICloudflareClient client, string zoneId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
return client.GetAsync<ZoneDnsSetting>($"zones/{zoneId}/dns_settings", cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update DNS settings for a zone.
|
||||
/// </summary>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="request">The update request.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<ZoneDnsSetting>> UpdateZoneDnsSettings(this ICloudflareClient client, UpdateDnsSettingsRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
request.Id.ValidateCloudflareId();
|
||||
|
||||
if (request.Mode.HasValue && !Enum.IsDefined(typeof(ZoneMode), request.Mode))
|
||||
throw new ArgumentOutOfRangeException(nameof(request.Mode), request.Mode, "Value must be one of the ZoneMode enum values.");
|
||||
|
||||
if (request.Nameservers != null && !Enum.IsDefined(typeof(NameserverType), request.Nameservers.Type))
|
||||
throw new ArgumentOutOfRangeException(nameof(request.Nameservers.Type), request.Nameservers.Type, "Value must be one of the NameserverType enum values.");
|
||||
|
||||
if (request.NameserverTtl.HasValue && (request.NameserverTtl < 30 || 86400 < request.NameserverTtl))
|
||||
throw new ArgumentOutOfRangeException(nameof(request.NameserverTtl), request.NameserverTtl, "Value must be between 30 and 86400.");
|
||||
|
||||
if (request.SOA != null)
|
||||
{
|
||||
if (request.SOA.Expire < 86400 || 2419200 < request.SOA.Expire)
|
||||
throw new ArgumentOutOfRangeException(nameof(request.SOA.Expire), request.SOA.Expire, "Value must be between 86400 and 2419200.");
|
||||
|
||||
if (request.SOA.MinimumTtl < 60 || 86400 < request.SOA.MinimumTtl)
|
||||
throw new ArgumentOutOfRangeException(nameof(request.SOA.MinimumTtl), request.SOA.MinimumTtl, "Value must be between 60 and 86400.");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(request.SOA.PrimaryNameserver))
|
||||
throw new ArgumentNullException(nameof(request.SOA.PrimaryNameserver));
|
||||
|
||||
if (request.SOA.Refresh < 600 || 86400 < request.SOA.Refresh)
|
||||
throw new ArgumentOutOfRangeException(nameof(request.SOA.Refresh), request.SOA.Refresh, "Value must be between 600 and 86400.");
|
||||
|
||||
if (request.SOA.Retry < 600 || 86400 < request.SOA.Retry)
|
||||
throw new ArgumentOutOfRangeException(nameof(request.SOA.Retry), request.SOA.Retry, "Value must be between 600 and 86400.");
|
||||
|
||||
if (request.SOA.Ttl < 300 || 86400 < request.SOA.Ttl)
|
||||
throw new ArgumentOutOfRangeException(nameof(request.SOA.Ttl), request.SOA.Ttl, "Value must be between 300 and 86400.");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(request.SOA.ZoneAdministrator))
|
||||
throw new ArgumentNullException(nameof(request.SOA.ZoneAdministrator));
|
||||
}
|
||||
|
||||
var req = new InternalUpdateDnsSettingsRequest
|
||||
{
|
||||
FlattenAllCnames = request.FlattenAllCnames,
|
||||
FoundationDns = request.FoundationDns,
|
||||
Mode = request.Mode,
|
||||
MultiProvider = request.MultiProvider,
|
||||
Nameservers = request.Nameservers,
|
||||
NameserverTtl = request.NameserverTtl,
|
||||
SecondaryOverrides = request.SecondaryOverrides,
|
||||
};
|
||||
|
||||
if (request.SOA != null)
|
||||
{
|
||||
req.Soa = new StartOfAuthority
|
||||
(
|
||||
expire: request.SOA.Expire,
|
||||
minimumTtl: request.SOA.MinimumTtl,
|
||||
primaryNameserver: request.SOA.PrimaryNameserver,
|
||||
refresh: request.SOA.Refresh,
|
||||
retry: request.SOA.Retry,
|
||||
ttl: request.SOA.Ttl,
|
||||
zoneAdministrator: request.SOA.ZoneAdministrator
|
||||
);
|
||||
}
|
||||
|
||||
return client.PatchAsync<ZoneDnsSetting, InternalUpdateDnsSettingsRequest>($"zones/{request.Id}/dns_settings", req, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AMWD.Net.Api.Cloudflare.Zones.Internals.Requests;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Extends the <see cref="ICloudflareClient"/> with methods for working with zones.
|
||||
/// </summary>
|
||||
public static class ZoneExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Lists, searches, sorts, and filters your zones.
|
||||
/// </summary>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="options">Filter options (optional).</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<IReadOnlyList<Zone>>> ListZones(this ICloudflareClient client, ListZonesFilter? options = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return client.GetAsync<IReadOnlyList<Zone>>("zones", options, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get details for a zone.
|
||||
/// </summary>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<Zone>> ZoneDetails(this ICloudflareClient client, string zoneId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
return client.GetAsync<Zone>($"zones/{zoneId}", cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new zone.
|
||||
/// </summary>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="request">The request information.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<Zone>> CreateZone(this ICloudflareClient client, CreateZoneRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (request == null)
|
||||
throw new ArgumentNullException(nameof(request));
|
||||
|
||||
request.AccountId.ValidateCloudflareId();
|
||||
request.Name.ValidateCloudflareName();
|
||||
|
||||
if (!RegexPatterns.ZoneName.IsMatch(request.Name))
|
||||
throw new ArgumentException("Does not match the zone name pattern", nameof(request.Name));
|
||||
|
||||
if (request.Type.HasValue && !Enum.IsDefined(typeof(ZoneType), request.Type))
|
||||
throw new ArgumentOutOfRangeException(nameof(request.Type));
|
||||
|
||||
var req = new InternalCreateZoneRequest(account: new AccountBase { Id = request.AccountId }, name: request.Name)
|
||||
{
|
||||
Type = request.Type
|
||||
};
|
||||
|
||||
return client.PostAsync<Zone, InternalCreateZoneRequest>("zones", req, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes an existing zone.
|
||||
/// </summary>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<IdResponse>> DeleteZone(this ICloudflareClient client, string zoneId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
return client.DeleteAsync<IdResponse>($"zones/{zoneId}", cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Edits a zone.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Only one zone property can be changed at a time.
|
||||
/// </remarks>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="request">The request information.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<Zone>> EditZone(this ICloudflareClient client, EditZoneRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
request.Id.ValidateCloudflareId();
|
||||
|
||||
if (request.Type.HasValue && request.VanityNameServers != null)
|
||||
throw new CloudflareException("Only one zone property can be changed at a time.");
|
||||
|
||||
if (request.Type.HasValue && !Enum.IsDefined(typeof(ZoneType), request.Type.Value))
|
||||
throw new ArgumentOutOfRangeException(nameof(request.Type));
|
||||
|
||||
var req = new InternalEditZoneRequest();
|
||||
|
||||
if (request.Type.HasValue)
|
||||
req.Type = request.Type.Value;
|
||||
|
||||
if (request.VanityNameServers != null)
|
||||
req.VanityNameServers = request.VanityNameServers.Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
|
||||
|
||||
return client.PatchAsync<Zone, InternalEditZoneRequest>($"zones/{request.Id}", req, cancellationToken);
|
||||
}
|
||||
|
||||
// Triggeres a new activation check for a PENDING Zone. This can be triggered every 5 min for paygo/ent customers, every hour for FREE Zones.
|
||||
|
||||
/// <summary>
|
||||
/// Triggeres a new activation check for a <see cref="ZoneStatus.Pending"/> zone.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This can be triggered every 5 min for paygo/enterprise customers, every hour for FREE Zones.
|
||||
/// </remarks>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<IdResponse>> RerunActivationCheck(this ICloudflareClient client, string zoneId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
return client.PutAsync<IdResponse, object>($"zones/{zoneId}/activation_check", null, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AMWD.Net.Api.Cloudflare.Zones.Internals.Filters;
|
||||
|
||||
namespace AMWD.Net.Api.Cloudflare.Zones
|
||||
{
|
||||
/// <summary>
|
||||
/// Extends the <see cref="ICloudflareClient"/> with methods for working with zones.
|
||||
/// </summary>
|
||||
public static class ZoneHoldExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieve whether the zone is subject to a zone hold, and metadata about the hold.
|
||||
/// </summary>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<ZoneHold>> GetZoneHold(this ICloudflareClient client, string zoneId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
return client.GetAsync<ZoneHold>($"zones/{zoneId}/hold", cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enforce a zone hold on the zone, blocking the creation and activation of zones with this zone's hostname.
|
||||
/// </summary>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="includeSubdomains">
|
||||
/// If set, the zone hold will extend to block any subdomain of the given zone, as well as SSL4SaaS Custom Hostnames.
|
||||
/// For example, a zone hold on a zone with the hostname 'example.com' and <paramref name="includeSubdomains"/>=<see langword="true"/> will block 'example.com', 'staging.example.com', 'api.staging.example.com', etc.
|
||||
/// </param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<ZoneHold>> CreateZoneHold(this ICloudflareClient client, string zoneId, bool includeSubdomains = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
var filter = new CreateZoneHoldFilter
|
||||
{
|
||||
IncludeSubdomains = includeSubdomains
|
||||
};
|
||||
return client.PostAsync<ZoneHold, object>($"zones/{zoneId}/hold", null, filter, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop enforcement of a zone hold on the zone, permanently or temporarily, allowing the creation and activation of zones with this zone's hostname.
|
||||
/// </summary>
|
||||
/// <param name="client">The <see cref="ICloudflareClient"/>.</param>
|
||||
/// <param name="zoneId">The zone ID.</param>
|
||||
/// <param name="holdAfter">
|
||||
/// If <paramref name="holdAfter"/> is provided, the hold will be temporarily disabled, then automatically re-enabled by the system at the time specified.
|
||||
/// Otherwise, the hold will be disabled indefinitely.
|
||||
/// </param>
|
||||
/// <param name="cancellationToken">A cancellation token used to propagate notification that this operation should be canceled.</param>
|
||||
public static Task<CloudflareResponse<ZoneHold>> DeleteZoneHold(this ICloudflareClient client, string zoneId, DateTime? holdAfter = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
zoneId.ValidateCloudflareId();
|
||||
var filter = new DeleteZoneHoldFilter
|
||||
{
|
||||
HoldAfter = holdAfter
|
||||
};
|
||||
return client.DeleteAsync<ZoneHold>($"zones/{zoneId}/hold", filter, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user