Class DnsRecord
- Namespace
- Cloudflare.NET.Dns.Models
- Assembly
- Cloudflare.NET.dll
Represents a complete DNS record from the Cloudflare API.
This model includes all properties returned by the API, including optional fields like comments, tags, meta information, and record-specific settings.
public record DnsRecord : IEquatable<DnsRecord>
- Inheritance
-
DnsRecord
- Implements
- Inherited Members
Examples
var record = await dns.GetDnsRecordAsync(zoneId, recordId);
Console.WriteLine($"{record.Name} ({record.Type}): {record.Content}");
Console.WriteLine($" TTL: {(record.Ttl == 1 ? "Auto" : record.Ttl.ToString())}");
Console.WriteLine($" Proxied: {record.Proxied} (Proxiable: {record.Proxiable})");
if (record.Comment != null) Console.WriteLine($" Comment: {record.Comment}");
Constructors
DnsRecord(string, string, DnsRecordType, string, bool, bool, int, DateTime, DateTime, string?, IReadOnlyList<string>?, int?, DnsRecordMeta?, DnsRecordSettings?)
Represents a complete DNS record from the Cloudflare API.
This model includes all properties returned by the API, including optional fields like comments, tags, meta information, and record-specific settings.
public DnsRecord(string Id, string Name, DnsRecordType Type, string Content, bool Proxied, bool Proxiable, int Ttl, DateTime CreatedOn, DateTime ModifiedOn, string? Comment = null, IReadOnlyList<string>? Tags = null, int? Priority = null, DnsRecordMeta? Meta = null, DnsRecordSettings? Settings = null)
Parameters
IdstringThe unique identifier of the DNS record.
NamestringThe record name (hostname).
TypeDnsRecordTypeThe DNS record type.
ContentstringThe record content (value varies by type: IP address, hostname, text, etc.).
ProxiedboolWhether the record is proxied through Cloudflare.
ProxiableboolWhether the record can be proxied (depends on type and configuration).
TtlintTime to live in seconds. A value of 1 means "automatic" (Cloudflare chooses optimal TTL).
CreatedOnDateTimeWhen the record was created.
ModifiedOnDateTimeWhen the record was last modified.
CommentstringOptional comment describing the record.
TagsIReadOnlyList<string>Optional tags in "name:value" format for organizing records.
Priorityint?Record priority (required for MX records, optional for SRV records).
MetaDnsRecordMetaAdditional metadata about the record, such as whether it was auto-added.
SettingsDnsRecordSettingsOptional settings for the record (e.g., IPv4/IPv6-only resolution).
Examples
var record = await dns.GetDnsRecordAsync(zoneId, recordId);
Console.WriteLine($"{record.Name} ({record.Type}): {record.Content}");
Console.WriteLine($" TTL: {(record.Ttl == 1 ? "Auto" : record.Ttl.ToString())}");
Console.WriteLine($" Proxied: {record.Proxied} (Proxiable: {record.Proxiable})");
if (record.Comment != null) Console.WriteLine($" Comment: {record.Comment}");
- See Also
Properties
Comment
Optional comment describing the record.
[JsonPropertyName("comment")]
public string? Comment { get; init; }
Property Value
Content
The record content (value varies by type: IP address, hostname, text, etc.).
[JsonPropertyName("content")]
public string Content { get; init; }
Property Value
CreatedOn
When the record was created.
[JsonPropertyName("created_on")]
public DateTime CreatedOn { get; init; }
Property Value
Id
The unique identifier of the DNS record.
[JsonPropertyName("id")]
public string Id { get; init; }
Property Value
Meta
Additional metadata about the record, such as whether it was auto-added.
[JsonPropertyName("meta")]
public DnsRecordMeta? Meta { get; init; }
Property Value
ModifiedOn
When the record was last modified.
[JsonPropertyName("modified_on")]
public DateTime ModifiedOn { get; init; }
Property Value
Name
The record name (hostname).
[JsonPropertyName("name")]
public string Name { get; init; }
Property Value
Priority
Record priority (required for MX records, optional for SRV records).
[JsonPropertyName("priority")]
public int? Priority { get; init; }
Property Value
- int?
Proxiable
Whether the record can be proxied (depends on type and configuration).
[JsonPropertyName("proxiable")]
public bool Proxiable { get; init; }
Property Value
Proxied
Whether the record is proxied through Cloudflare.
[JsonPropertyName("proxied")]
public bool Proxied { get; init; }
Property Value
Settings
Optional settings for the record (e.g., IPv4/IPv6-only resolution).
[JsonPropertyName("settings")]
public DnsRecordSettings? Settings { get; init; }
Property Value
Tags
Optional tags in "name:value" format for organizing records.
[JsonPropertyName("tags")]
public IReadOnlyList<string>? Tags { get; init; }
Property Value
Ttl
Time to live in seconds. A value of 1 means "automatic" (Cloudflare chooses optimal TTL).
[JsonPropertyName("ttl")]
public int Ttl { get; init; }
Property Value
Type
The DNS record type.
[JsonPropertyName("type")]
public DnsRecordType Type { get; init; }