diff --git a/src/CloudflareDnsync.Models/DnsRecord.cs b/src/CloudflareDnsync.Models/DnsRecord.cs new file mode 100644 index 0000000..66cef48 --- /dev/null +++ b/src/CloudflareDnsync.Models/DnsRecord.cs @@ -0,0 +1,57 @@ +using Newtonsoft.Json; + +namespace CloudflareDnsync.Models; + +public sealed class DnsRecord +{ + [JsonProperty("content")] + public string Content { get; init; } = null!; + + [JsonProperty("name")] + public string Name { get; init; } = null!; + + [JsonProperty("proxied")] + public bool Proxied { get; init; } + + [JsonProperty("type")] + public string Type { get; init; } = null!; + + [JsonProperty("comment")] + public string? Comment { get; init; } + + [JsonProperty("id")] + public string Id { get; init; } = null!; + + [JsonProperty("locked")] + public bool Locked { get; init; } + + [JsonProperty("modified_on")] + public DateTime ModifiedOn { get; init; } + + [JsonProperty("proxiable")] + public bool Proxiable { get; init; } + + [JsonProperty("tags")] + public List Tags { get; init; } = []; + + [JsonProperty("zone_id")] + public string ZoneId { get; init; } = null!; + + [JsonProperty("zone_name")] + public string ZoneName { get; init; } = null!; + + [JsonProperty("ttl")] + public int Ttl { get; init; } + + [JsonProperty("meta")] + public DnsRecord_Meta? Meta { get; init; } + + public class DnsRecord_Meta + { + [JsonProperty("auto_added")] + public bool AutoAdded { get; init; } + + [JsonProperty("source")] + public string? Source { get; init; } + } +} diff --git a/src/CloudflareDnsync.Services/CloudflareService.cs b/src/CloudflareDnsync.Services/CloudflareService.cs index d619eb8..2795126 100644 --- a/src/CloudflareDnsync.Services/CloudflareService.cs +++ b/src/CloudflareDnsync.Services/CloudflareService.cs @@ -35,6 +35,14 @@ public Task>> GetZonesAsync(int page = 1, int perP public Task> VerifyTokenAsync() => SendAsync>(HttpMethod.Get, "user/tokens/verify"); + public Task>> GetDnsRecordsAsync( + string zoneId, + int page = 1, + int perPage = 20) + => SendAsync>>( + HttpMethod.Get, + $"zones/{zoneId}/dns_records?page={page}&per_page={perPage}&type=A"); + private async Task SendAsync(HttpMethod method, string url, object? data = null) { var request = new HttpRequestMessage(HttpMethod.Get, url);