Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deploy/uiFormDefinition.json
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@
"password": "API key",
"confirmPassword": "Confirm API key"
},
"toolTip": "IONOS DNS API key.",
"toolTip": "IONOS DNS API key in public-prefix.secret format.",
"constraints": {
"required": true
},
Expand Down
6 changes: 3 additions & 3 deletions docs/guide/dns-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,14 @@ https://www.googleapis.com/auth/ndev.clouddns.readwrite

## IONOS DNS

Use an IONOS DNS API key that can list zones and manage DNS records.
Create an API key as described in the [IONOS API getting started guide](https://developer.hosting.ionos.com/docs/getstarted). The value consists of the public prefix and secret joined by a period. Acmebot uses the [IONOS DNS API](https://developer.hosting.ionos.com/docs/dns) to list zones and manage DNS records.

| Option | Description |
| --- | --- |
| `ApiKey` | IONOS DNS API key sent in the `X-API-Key` header. |
| `ApiKey` | IONOS DNS API key in `<public-prefix>.<secret>` format, sent in the `X-API-Key` header. |

```text
Acmebot__IonosDns__ApiKey=<api-key>
Acmebot__IonosDns__ApiKey=<public-prefix>.<secret>
```

## OVH
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Acmebot uses the Google Cloud DNS read/write OAuth scope and ignores private man

| Setting | Description |
| --- | --- |
| `Acmebot__IonosDns__ApiKey` | IONOS DNS API key sent in the `X-API-Key` header. |
| `Acmebot__IonosDns__ApiKey` | IONOS DNS API key in `<public-prefix>.<secret>` format, sent in the `X-API-Key` header. See the [IONOS API getting started guide](https://developer.hosting.ionos.com/docs/getstarted). |

### OVH

Expand Down
33 changes: 20 additions & 13 deletions src/Acmebot.App/Providers/IonosDnsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ public async Task CreateTxtRecordAsync(DnsZone zone, string relativeRecordName,
{
var recordName = DnsRecordName.ToFqdn(zone.Name, relativeRecordName);

foreach (var value in values)
var records = values.Select(value => new RecordParam
{
var record = new RecordParam
{
Name = recordName,
Type = "TXT",
Content = value,
Ttl = 60
};
Name = recordName,
Type = "TXT",
Content = value,
Ttl = 60
}).ToArray();

await _ionosDnsClient.CreateRecordAsync(zone.Id, record, cancellationToken);
if (records.Length != 0)
{
await _ionosDnsClient.CreateRecordsAsync(zone.Id, records, cancellationToken);
}
}

Expand Down Expand Up @@ -97,21 +97,28 @@ public async IAsyncEnumerable<Zone> ListZonesAsync([EnumeratorCancellation] Canc

public async Task<IReadOnlyList<Record>> ListRecordsAsync(string zoneId, string recordName, CancellationToken cancellationToken = default)
{
var result = await _httpClient.GetFromJsonAsync<Zone>($"zones/{zoneId}?recordName={recordName}&recordType=TXT", cancellationToken);
var result = await _httpClient.GetFromJsonAsync<Zone>(
$"zones/{zoneId}?recordName={recordName}&recordType=TXT",
cancellationToken);
Comment thread
shibayan marked this conversation as resolved.

return result?.Records ?? [];
}

public async Task CreateRecordAsync(string zoneId, RecordParam record, CancellationToken cancellationToken = default)
public async Task CreateRecordsAsync(string zoneId, RecordParam[] records, CancellationToken cancellationToken = default)
{
var response = await _httpClient.PostAsJsonAsync($"zones/{zoneId}/records", record, cancellationToken);
using var response = await _httpClient.PostAsJsonAsync(
$"zones/{zoneId}/records",
records,
cancellationToken);

response.EnsureSuccessStatusCode();
}

public async Task DeleteRecordAsync(string zoneId, string recordId, CancellationToken cancellationToken = default)
{
var response = await _httpClient.DeleteAsync($"zones/{zoneId}/records/{recordId}", cancellationToken);
using var response = await _httpClient.DeleteAsync(
$"zones/{zoneId}/records/{recordId}",
cancellationToken);

response.EnsureSuccessStatusCode();
}
Expand Down