Gandi 0.0.0-alpha4
See the version list below for details.
dotnet add package Gandi --version 0.0.0-alpha4
NuGet\Install-Package Gandi -Version 0.0.0-alpha4
<PackageReference Include="Gandi" Version="0.0.0-alpha4" />
paket add Gandi --version 0.0.0-alpha4
#r "nuget: Gandi, 0.0.0-alpha4"
// Install Gandi as a Cake Addin #addin nuget:?package=Gandi&version=0.0.0-alpha4&prerelease // Install Gandi as a Cake Tool #tool nuget:?package=Gandi&version=0.0.0-alpha4&prerelease
Gandi
.NET REST client for the Gandi v5 API
This library allows you to create, read, update, and delete LiveDNS DNS records in your Gandi domains.
It's similar to G6.GandiLiveDns, but it's compatible with both Personal Access Token and API Key authentication, public types have interfaces so you can mock and actually test your dependent code, and it's compatible with a wider variety of runtimes.
Prerequisites
- .NET runtime compatible with .NET Standard 2.0
- .NET 5 or later
- .NET Core 2 or later
- .NET Framework 4.6.2 or later
- Gandi domain name
- ✅ Domain must be using LiveDNS, the default for new domains (
ns-*-*.gandi.net
) - ❌ Classic DNS (
*.dns.gandi.net
) is incompatible; you will need to migrate to LiveDNS - ❌ External nameservers (with glue records) are incompatible; you will need to update the record on the external nameserver instead of on Gandi's nameservers
- ✅ Domain must be using LiveDNS, the default for new domains (
Installation
This library is available in the Gandi
package on NuGet Gallery.
dotnet add package Gandi
Configuration
- Get a Gandi API authentication token, and pass it to the
AuthToken
property ofIGandiClient
. This token can be either an API Key or Personal Access Token.- If you already have a Gandi API Key, you can use it to authenticate this client to your Gandi account.
- If your Gandi account doesn't already have an API Key, it's too late, you can't make one anymore.
- If you don't remember your API Key, you can regenerate it using Account › Authentication options › Developer access › API key.
- You can always create a Personal Access Token.
- Go to either User Settings or Organizations › ⚙ Manage.
- Click Create a token.
- If prompted, choose the organization which owns the domain whose DNS records you want to manage, then click Next.
- Choose a name and expiration period for the token.
- Choose whether the token will be allowed to access all domains in the organization, or just a subset of them.
- Allow permission to "Manage domain name technical configurations."
- Click Create.
- Copy the token text. Keep it somewhere safe, because Gandi won't show it to you again.
- Set a calendar reminder to notify you before this token expires. There is no way for Gandi to notify you or for clients to refresh or renew tokens, so you will have to repeat all of these steps when your token eventually expires.
- Click Done.
- If you need to change the auth token of an existing
GandiClient
instance, for example if the old token expires and a new one is written to a configuration file that reloads on changes, you can set theIGandiClient.AuthToken
property.
- If you already have a Gandi API Key, you can use it to authenticate this client to your Gandi account.
- Construct a new instance of
GandiClient
, passing the Personal Access Token or API Key to the constructor.using Gandi; using IGandiClient gandi = new GandiClient("<auth token>");
Advanced configuration
- You can access the
HttpClient
instance used byGandiClient
if you want to configure timeouts, extra request headers, or add requests or response filters. - If you want to provide your own
HttpClient
, you can pass it to theGandiClient(HttpClient?)
constructor. Make sure theHttpClient
'sHttpMessageHandler
inherits fromIUnfuckedHttpHandler
(one easy way to do this is forHttpClient
to be anUnfuckedHttpClient
) so that client request authentication filters and JSON serialization work correctly.
Usage
LiveDNS
Get a LiveDNS API client for your second-level/registered domain name using IGandiClient.LiveDns(string)
. This object has async methods on it that perform HTTP calls to Gandi's LiveDNS API.
var liveDns = gandi.LiveDns("mydomain.com");
Find DNS records
Return a list of all DNS records in the domain, optionally filtered by name or type (A, CNAME, etc). If no results are found, returns an empty enumeration.
var liveDns = gandi.LiveDns("mydomain.com");
IEnumerable<DnsRecord> allRecords = await liveDns.List();
IEnumerable<DnsRecord> cnames = await liveDns.List(type: RecordType.CNAME);
IEnumerable<DnsRecord> www = await liveDns.List(name: "www");
Get a DNS record
Return one DNS record in the domain with the given name and type, or null
if it was not found.
DnsRecord? wwwRecord = await liveDns.Get(RecordType.A, "www");
Create or update a DNS record
Set a DNS record's value, automatically creating it if it didn't already exist, or modifying it if it already existed (upserting). To specify a record at the root/origin of your domain, pass @
as the name. The time to live is optional, defaults to 3 hours if you set it to null
, and is clipped to the allowed range [5 minutes, 30 days]. You must supply at least one value for the record.
await liveDns.Set(new DnsRecord(RecordType.A, "www", TimeToLive.FromHours(1), "1.2.3.4"));
Delete a record
Remove a record with the given name and optionally the given type. If the type is not specified, records of all types with the given name are deleted. This method returns successfully even if the record did not exist, because either way it doesn't exist after the method completes, so it's in the desired state.
await liveDns.Delete(RecordTytpe.CNAME, "www");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Unfucked.HTTP (>= 0.0.0-beta5)
-
net6.0
- Unfucked.HTTP (>= 0.0.0-beta5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.0.0-alpha5 | 0 | 3/11/2025 |
0.0.0-alpha4 | 64 | 3/9/2025 |
0.0.0-alpha3 | 39 | 3/8/2025 |
0.0.0-alpha2 | 161 | 3/6/2025 |
0.0.0-alpha1 | 161 | 3/6/2025 |
0.0.0-alpha0 | 278 | 3/5/2025 |