Last active
May 12, 2024 08:53
-
-
Save Laiteux/bc505c5350421c31f8bd448bdacb6ff8 to your computer and use it in GitHub Desktop.
Revisions
-
Laiteux revised this gist
May 12, 2024 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,3 @@ using System; using System.Linq; using System.Net.Http; @@ -8,6 +6,7 @@ namespace CloudflareDnsCleaner { // NOTE: Old, idk if it still works or anything public static class Program { private const string AuthKey = "YOUR_AUTH_KEY"; // Global API Key: https://dash.cloudflare.com/profile/api-tokens -
Laiteux renamed this gist
May 12, 2024 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,12 @@ // old, idk if it still works of anything using System; using System.Linq; using System.Net.Http; using System.Text.Json; using System.Threading.Tasks; namespace CloudflareDnsCleaner { public static class Program { -
Laiteux revised this gist
Dec 22, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public static async Task Main() await httpClient.DeleteAsync($"dns_records/{record.GetProperty("id").GetString()}"); } if (records.Count - perPage < 0) { break; } -
Laiteux revised this gist
Dec 22, 2021 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,9 +8,9 @@ namespace CloudflareDNSCleaner { public static class Program { private const string AuthKey = "YOUR_AUTH_KEY"; // Global API Key: https://dash.cloudflare.com/profile/api-tokens private const string AuthEmail = "YOUR_AUTH_EMAIL"; // Account Email: https://dash.cloudflare.com/profile private const string ZoneId = "YOUR_ZONE_ID"; // Zone ID: Can be found on your website dashboard public static async Task Main() { -
Laiteux revised this gist
Sep 8, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,14 +29,14 @@ public static async Task Main() using var responseMessage = await httpClient.GetAsync($"dns_records?per_page={perPage}"); var responseJson = JsonSerializer.Deserialize<JsonElement>(await responseMessage.Content.ReadAsStringAsync()); var records = responseJson.GetProperty("result").EnumerateArray().ToList(); foreach (var record in records) { await httpClient.DeleteAsync($"dns_records/{record.GetProperty("id").GetString()}"); } if (records.Count - perPage <= 0) { break; } -
Laiteux revised this gist
Aug 11, 2021 . No changes.There are no files selected for viewing
-
Laiteux revised this gist
Jul 24, 2021 . No changes.There are no files selected for viewing
-
Laiteux revised this gist
Jan 9, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public static async Task Main() foreach (var record in records) { await httpClient.DeleteAsync($"dns_records/{record.GetProperty("id").GetString()}"); } if (records.Count() - perPage <= 0) -
Laiteux revised this gist
Jan 9, 2021 . 1 changed file with 9 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ using System; using System.Linq; using System.Net.Http; using System.Text.Json; using System.Threading.Tasks; @@ -23,18 +24,21 @@ public static async Task Main() while (true) { const int perPage = 100; using var responseMessage = await httpClient.GetAsync($"dns_records?per_page={perPage}"); var responseJson = JsonSerializer.Deserialize<JsonElement>(await responseMessage.Content.ReadAsStringAsync()); var records = responseJson.GetProperty("result").EnumerateArray(); foreach (var record in records) { await httpClient.DeleteAsync(string.Join('/', "dns_records", record.GetProperty("id").GetString())); } if (records.Count() - perPage <= 0) { break; } } } -
Laiteux revised this gist
Jan 9, 2021 . 1 changed file with 2 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,4 @@ using System; using System.Net.Http; using System.Text.Json; using System.Threading.Tasks; @@ -28,14 +27,12 @@ public static async Task Main() var responseJson = JsonSerializer.Deserialize<JsonElement>(await responseMessage.Content.ReadAsStringAsync()); if (responseJson.GetProperty("result_info").GetProperty("total_count").GetInt16() == 0) { break; } foreach (JsonElement record in responseJson.GetProperty("result").EnumerateArray()) { await httpClient.DeleteAsync(string.Join('/', "dns_records", record.GetProperty("id").GetString())); } -
Laiteux revised this gist
Jan 9, 2021 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ using System; using System.Linq; using System.Net.Http; using System.Text.Json; using System.Threading.Tasks; @@ -27,12 +28,14 @@ public static async Task Main() var responseJson = JsonSerializer.Deserialize<JsonElement>(await responseMessage.Content.ReadAsStringAsync()); var records = responseJson.GetProperty("result").EnumerateArray(); if (!records.Any()) { break; } foreach (var record in records) { await httpClient.DeleteAsync(string.Join('/', "dns_records", record.GetProperty("id").GetString())); } -
Laiteux revised this gist
Jan 9, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public static async Task Main() foreach (JsonElement record in responseJson.GetProperty("result").EnumerateArray()) { await httpClient.DeleteAsync(string.Join('/', "dns_records", record.GetProperty("id").GetString())); } } } -
Laiteux created this gist
Jan 9, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ using System; using System.Net.Http; using System.Text.Json; using System.Threading.Tasks; namespace CloudflareDNSCleaner { public static class Program { private const string AuthKey = "YOUR_AUTH_KEY"; private const string AuthEmail = "YOUR_AUTH_EMAIL"; private const string ZoneId = "YOUR_ZONE_ID"; public static async Task Main() { var httpClient = new HttpClient() { BaseAddress = new Uri($"https://api.cloudflare.com/client/v4/zones/{ZoneId}/") }; httpClient.DefaultRequestHeaders.Add("X-Auth-Key", AuthKey); httpClient.DefaultRequestHeaders.Add("X-Auth-Email", AuthEmail); while (true) { using var responseMessage = await httpClient.GetAsync("dns_records"); var responseJson = JsonSerializer.Deserialize<JsonElement>(await responseMessage.Content.ReadAsStringAsync()); if (responseJson.GetProperty("result_info").GetProperty("total_count").GetInt16() == 0) { break; } foreach (JsonElement record in responseJson.GetProperty("result").EnumerateArray()) { await httpClient.DeleteAsync("dns_records/" + record.GetProperty("id").GetString()); } } } } }