using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json.Serialization;
namespace AMWD.Net.Api.Cloudflare.Zones
{
///
/// DNS record.
///
public class DnsRecord
{
///
/// Identifier.
///
[JsonProperty("id")]
public string? Id { get; set; }
///
/// Identifier of the zone.
///
[JsonProperty("zone_id")]
public string? ZoneId { get; set; }
///
/// Name of the zone.
///
[JsonProperty("zone_name")]
public string? ZoneName { get; set; }
///
/// DNS record name (or @ for the zone apex) in Punycode.
///
[JsonProperty("name")]
public string? Name { get; set; }
///
/// Record type.
///
[JsonProperty("type")]
public DnsRecordType Type { get; set; }
///
/// A valid record content.
///
[JsonProperty("content")]
public string? Content { get; set; }
///
/// The priority.
///
///
/// Required for , and records; unused by other record types.
/// Records with lower priorities are preferred.
///
[JsonProperty("priority")]
public ushort? Priority { get; set; }
///
/// Components associated with the record.
///
[JsonProperty("data")]
public object? Data { get; set; }
///
/// Whether the record can be proxied by Cloudflare or not.
///
[JsonProperty("proxiable")]
public bool Proxiable { get; set; }
///
/// Whether the record is receiving the performance and security benefits of Cloudflare.
///
[JsonProperty("proxied")]
public bool Proxied { get; set; }
///
/// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'.
/// Value must be between 60 and 86400, with the minimum reduced to 30 for Enterprise zones.
///
/// Unit: seconds. Range: 60 <= X <= 86400
[JsonProperty("ttl")]
public int Ttl { get; set; }
///
/// Settings for the DNS record.
///
[JsonProperty("settings")]
public object? Settings { get; set; }
///
/// Extra Cloudflare-specific information about the record.
///
[JsonProperty("meta")]
public DnsRecordMeta? Meta { get; set; }
///
/// Comments or notes about the DNS record. This field has no effect on DNS responses.
///
[JsonProperty("comment")]
public string? Comment { get; set; }
///
/// Custom tags for the DNS record. This field has no effect on DNS responses.
///
[JsonProperty("tags")]
public IList? Tags { get; set; }
///
/// When the record was created.
///
[JsonProperty("created_on")]
public DateTime CreatedOn { get; set; }
///
/// When the record was last modified.
///
[JsonProperty("modified_on")]
public DateTime ModifiedOn { get; set; }
///
/// When the record comment was last modified. Omitted if there is no comment.
///
[JsonProperty("comment_modified_on")]
public DateTime? CommentModifiedOn { get; set; }
///
/// When the record tags were last modified. Omitted if there are no tags.
///
[JsonProperty("tags_modified_on")]
public DateTime? TagsModifiedOn { get; set; }
#region Type definitions for data fields
///
/// Components of a CAA record.
///
public class CaaData(byte flags, string tag, string value)
{
///
/// Flags for the CAA record
///
/// Range: 0 <= X <= 255
[JsonProperty("flags")]
public byte Flags { get; set; } = flags;
///
/// Name of the property controlled by this record (e.g.: issue, issuewild, iodef).
///
[JsonProperty("tag")]
public string Tag { get; set; } = tag;
///
/// Value of the record. This field's semantics depend on the chosen tag.
///
[JsonProperty("value")]
public string Value { get; set; } = value;
}
///
/// Components of a CERT record.
///
public class CertData(byte algorithm, string certificate, ushort keyTag, ushort type)
{
///
/// Algorithm of the certificate
///
[JsonProperty("algorithm")]
public byte Algorithm { get; set; } = algorithm;
///
/// Base64 encoded certificate.
///
[JsonProperty("certificate")]
public string Certificate { get; set; } = certificate;
///
/// Key tag.
///
[JsonProperty("key_tag")]
public ushort KeyTag { get; set; } = keyTag;
///
/// Type.
///
[JsonProperty("type")]
public ushort Type { get; set; } = type;
}
///
/// Components of a DNSKEY record.
///
public class DnsKeyData(byte algorithm, ushort flags, byte protocol, string publicKey)
{
///
/// Algorithm of the certificate
///
[JsonProperty("algorithm")]
public byte Algorithm { get; set; } = algorithm;
///
/// Algorithm of the certificate
///
[JsonProperty("flags")]
public ushort Flags { get; set; } = flags;
///
/// Algorithm of the certificate
///
[JsonProperty("protocol")]
public byte Protocol { get; set; } = protocol;
///
/// Public key.
///
[JsonProperty("public_key")]
public string PublicKey { get; set; } = publicKey;
}
///
/// Components of a DS record.
///
public class DsData(byte algorithm, string digest, byte digestType, ushort keyTag)
{
///
/// Algorithm of the certificate
///
[JsonProperty("algorithm")]
public byte Algorithm { get; set; } = algorithm;
///
/// Digest.
///
[JsonProperty("digest")]
public string Digest { get; set; } = digest;
///
/// Digest type.
///
[JsonProperty("digest_type")]
public byte DigestType { get; set; } = digestType;
///
/// Key tag.
///
[JsonProperty("key_tag")]
public ushort KeyTag { get; set; } = keyTag;
}
///
/// Components of an HTTPS record.
///
public class HttpsData(ushort priority, string target, string value)
{
///
/// Priority.
///
[JsonProperty("priority")]
public ushort Priority { get; set; } = priority;
///
/// Target.
///
[JsonProperty("target")]
public string Target { get; set; } = target;
///
/// Value.
///
[JsonProperty("Value")]
public string Value { get; set; } = value;
}
///
/// Components of a LOC record.
///
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)
{
///
/// Degrees of latitude.
///
/// Unit: degree. Range: 0 <= X <= 90
[JsonProperty("lat_degrees")]
public int LatitudeDegrees { get; set; } = latitudeDegrees;
///
/// Minutes of latitude.
///
/// Unit: minute. Range: 0 <= X <= 59
[JsonProperty("lat_minutes")]
public int LatitudeMinutes { get; set; } = latitudeMinutes;
///
/// Seconds of latitude.
///
/// Unit: second. Range: 0 <= X <= 59.999
[JsonProperty("lat_seconds")]
public double LatitudeSeconds { get; set; } = latitudeSeconds;
///
/// Latitude direction.
///
[JsonProperty("lat_direction")]
public LatitudeDirection LatitudeDirection { get; set; } = latitudeDirection;
///
/// Degrees of longitude.
///
/// Unit: degree. Range: 0 <= X <= 180
[JsonProperty("long_degrees")]
public int LongitudeDegrees { get; set; } = longitudeDegrees;
///
/// Minutes of longitude.
///
/// Unit: minute. Range: 0 <= X <= 59
[JsonProperty("long_minutes")]
public int LongitudeMinutes { get; set; } = longitudeMinutes;
///
/// Seconds of longitude.
///
/// Unit: second. Range: 0 <= X <= 59.999
[JsonProperty("long_seconds")]
public double LongitudeSeconds { get; set; } = longitudeSeconds;
///
/// Longitude direction.
///
[JsonProperty("long_direction")]
public LongitudeDirection LongitudeDirection { get; set; } = longitudeDirection;
///
/// Altitude of location in meters.
///
/// Unit: meter. Range: -100_000.00 <= X <= 42_849_672.95
[JsonProperty("altitude")]
public double Altitude { get; set; } = altitude;
///
/// Size of location in meters.
///
/// Unit: meter. Range: 0 <= X <= 90_000_000
[JsonProperty("size")]
public int Size { get; set; } = size;
///
/// Horizontal precision of location.
///
/// Unit: meter. Range: 0 <= X <= 90_000_000
[JsonProperty("precision_horz")]
public int PrecisionHorizontal { get; set; } = precisionHorizontal;
///
/// Vertical precision of location.
///
/// Unit: meter. Range: 0 <= X <= 90_000_000
[JsonProperty("precision_vert")]
public int PrecisionVertical { get; set; } = precisionVertical;
}
///
/// Components of a NAPTR record.
///
public class NaPtrData(string flags, ushort order, ushort preference, string regex, string replacement, string service)
{
///
/// Flags.
///
[JsonProperty("flags")]
public string Flags { get; set; } = flags;
///
/// Order.
///
[JsonProperty("order")]
public ushort Order { get; set; } = order;
///
/// Preference.
///
[JsonProperty("preference")]
public ushort Preference { get; set; } = preference;
///
/// Service.
///
[JsonProperty("regex")]
public string Regex { get; set; } = regex;
///
/// Replacement.
///
[JsonProperty("replacement")]
public string Replacement { get; set; } = replacement;
///
/// Service.
///
[JsonProperty("service")]
public string Service { get; set; } = service;
}
///
/// Components of a SMIMEA record.
///
public class SMimeAData(string certificate, byte matchingType, byte selector, byte usage)
{
///
/// Certificate.
///
[JsonProperty("certificate")]
public string Certificate { get; set; } = certificate;
///
/// Matching type.
///
[JsonProperty("matching_type")]
public byte MatchingType { get; set; } = matchingType;
///
/// Selector.
///
[JsonProperty("selector")]
public byte Selector { get; set; } = selector;
///
/// Usage.
///
[JsonProperty("usage")]
public byte Usage { get; set; } = usage;
}
///
/// Components of a SRV record.
///
public class SrvData(ushort port, ushort priority, string target, ushort weight)
{
///
/// The port of the service.
///
[JsonProperty("port")]
public ushort Port { get; set; } = port;
///
/// The priority of the service.
///
///
/// Required for , and records; unused by other record types.
/// Records with lower priorities are preferred.
///
[JsonProperty("priority")]
public ushort Priority { get; set; } = priority;
///
/// A valid hostname.
///
[JsonProperty("target")]
public string Target { get; set; } = target;
///
/// The weight of the record.
///
[JsonProperty("weight")]
public ushort Weight { get; set; } = weight;
}
///
/// Components of a SSHFP record.
///
public class SshFpData(byte algorithm, string fingerprint, byte type)
{
///
/// Algorithm.
///
[JsonProperty("algorithm")]
public byte Algorithm { get; set; } = algorithm;
///
/// Fingerprint.
///
[JsonProperty("fingerprint")]
public string Fingerprint { get; set; } = fingerprint;
///
/// Type.
///
[JsonProperty("type")]
public byte Type { get; set; } = type;
}
///
/// Components of a SVCB record.
///
public class SvcBData(ushort priority, string target, string value)
{
///
/// The priority of the service binding.
///
[JsonProperty("priority")]
public ushort Priority { get; set; } = priority;
///
/// A valid target.
///
[JsonProperty("target")]
public string Target { get; set; } = target;
///
/// The value of the service binding.
///
///
/// e.g. alpn="h3,h2" ipv4hint="127.0.0.1" ipv6hint="::1"
///
[JsonProperty("value")]
public string Value { get; set; } = value;
}
///
/// Components of a TLSA record.
///
public class TlsAData(string certificate, byte matchingType, byte selector, byte usage)
{
///
/// Certificate.
///
[JsonProperty("certificate")]
public string Certificate { get; set; } = certificate;
///
/// Matching type.
///
[JsonProperty("matching_type")]
public byte MatchingType { get; set; } = matchingType;
///
/// Selector.
///
[JsonProperty("selector")]
public byte Selector { get; set; } = selector;
///
/// Usage.
///
[JsonProperty("usage")]
public byte Usage { get; set; } = usage;
}
///
/// Components of a URI record.
///
public class UriData(string target, ushort weight)
{
///
/// A valid target.
///
[JsonProperty("target")]
public string Target { get; set; } = target;
///
/// The weight of the record.
///
[JsonProperty("weight")]
public ushort Weight { get; set; } = weight;
}
#region Enums for data fields
///
/// Directions for latitude.
///
public enum LatitudeDirection
{
///
/// North.
///
[EnumMember(Value = "N")]
North = 1,
///
/// South.
///
[EnumMember(Value = "S")]
South = 2
}
///
/// Directions for longitude.
///
public enum LongitudeDirection
{
///
/// East.
///
[EnumMember(Value = "E")]
East = 1,
///
/// West.
///
[EnumMember(Value = "W")]
West = 2
}
#endregion Enums for data fields
#endregion Type definitions for data fields
#region Type definitions for settings fields
///
/// Settings for the DNS record.
///
public class CnameSettings(bool flattenCname)
{
///
/// 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.
///
[JsonProperty("flatten_cname")]
public bool FlattenCname { get; set; } = flattenCname;
}
#endregion Type definitions for settings fields
}
}