Reorganize Zone Extension
This commit is contained in:
@@ -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; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user