@@ -30,10 +30,7 @@ public async Task<IReadOnlyList<DnsZone>> ListZonesAsync()
30
30
{
31
31
var zones = await _client . ListZonesAsync ( ) ;
32
32
33
- // Do NOT include the PrimaryNameServer element from the DnsZone list for now,
34
- // the return value from Gandi when returning zones is not the expected value when doing the intersect at the Dns01Precondition method
35
-
36
- return zones . Select ( x => new DnsZone ( this ) { Id = x . Uuid , Name = x . Name } ) . ToArray ( ) ;
33
+ return zones . Select ( x => new DnsZone ( this ) { Id = x . Fqdn , Name = x . FqdnUnicode } ) . ToArray ( ) ;
37
34
}
38
35
39
36
public Task CreateTxtRecordAsync ( DnsZone zone , string relativeRecordName , IEnumerable < string > values )
@@ -54,27 +51,28 @@ public GandiClient(string apiKey)
54
51
55
52
_httpClient = new HttpClient
56
53
{
57
- BaseAddress = new Uri ( "https://dns. api.gandi.net/api /v5/" )
54
+ BaseAddress = new Uri ( "https://api.gandi.net/v5/" )
58
55
} ;
59
56
60
57
_httpClient . DefaultRequestHeaders . Accept . Add ( new MediaTypeWithQualityHeaderValue ( "application/json" ) ) ;
61
- _httpClient . DefaultRequestHeaders . TryAddWithoutValidation ( "X-Api-Key" , apiKey ) ;
58
+ _httpClient . DefaultRequestHeaders . TryAddWithoutValidation ( "Authorization" , "Bearer " + apiKey ) ;
62
59
}
63
60
64
61
private readonly HttpClient _httpClient ;
65
62
66
- public async Task < IReadOnlyList < Zone > > ListZonesAsync ( )
63
+ public async Task < IReadOnlyList < Domain > > ListZonesAsync ( )
67
64
{
68
- var response = await _httpClient . GetAsync ( "zones " ) ;
65
+ var response = await _httpClient . GetAsync ( "domain/domains " ) ;
69
66
70
67
response . EnsureSuccessStatusCode ( ) ;
68
+ var domains = await response . Content . ReadAsAsync < Domain [ ] > ( ) ;
71
69
72
- return await response . Content . ReadAsAsync < Zone [ ] > ( ) ;
70
+ return domains . Where ( x => x . Nameserver . Current == "livedns" ) . ToArray ( ) ;
73
71
}
74
72
75
73
public async Task DeleteRecordAsync ( string zoneName , string relativeRecordName )
76
74
{
77
- var response = await _httpClient . DeleteAsync ( $ "domains/{ zoneName } /records/{ relativeRecordName } /TXT") ;
75
+ var response = await _httpClient . DeleteAsync ( $ "livedns/ domains/{ zoneName } /records/{ relativeRecordName } /TXT") ;
78
76
79
77
if ( response . StatusCode != HttpStatusCode . NotFound )
80
78
{
@@ -84,7 +82,7 @@ public async Task DeleteRecordAsync(string zoneName, string relativeRecordName)
84
82
85
83
public async Task AddRecordAsync ( string zoneName , string relativeRecordName , IEnumerable < string > values )
86
84
{
87
- var response = await _httpClient . PostAsync ( $ "domains/{ zoneName } /records/{ relativeRecordName } /TXT", new
85
+ var response = await _httpClient . PostAsync ( $ "livedns/ domains/{ zoneName } /records/{ relativeRecordName } /TXT", new
88
86
{
89
87
rrset_values = values . ToArray ( ) ,
90
88
rrset_ttl = 300 //300 is the minimal value
@@ -93,37 +91,66 @@ public async Task AddRecordAsync(string zoneName, string relativeRecordName, IEn
93
91
response . EnsureSuccessStatusCode ( ) ;
94
92
}
95
93
}
96
-
97
- public class Zone
94
+ public class Domain
98
95
{
99
- [ JsonProperty ( "uuid" ) ]
100
- public string Uuid { get ; set ; }
96
+ [ JsonProperty ( "fqdn" ) ]
97
+ public string Fqdn { get ; set ; }
98
+
99
+ [ JsonProperty ( "tld" ) ]
100
+ public string Tld { get ; set ; }
101
+
102
+ [ JsonProperty ( "status" ) ]
103
+ public List < string > Status { get ; set ; }
104
+
105
+ [ JsonProperty ( "dates" ) ]
106
+ public Dates Dates { get ; set ; }
107
+
108
+ [ JsonProperty ( "nameserver" ) ]
109
+ public Nameserver Nameserver { get ; set ; }
110
+
111
+ [ JsonProperty ( "autorenew" ) ]
112
+ public bool Autorenew { get ; set ; }
101
113
102
- [ JsonProperty ( "name " ) ]
103
- public string Name { get ; set ; }
114
+ [ JsonProperty ( "domain_owner " ) ]
115
+ public string DomainOwner { get ; set ; }
104
116
105
- [ JsonProperty ( "primary_ns " ) ]
106
- public string PrimaryNameServer { get ; set ; }
117
+ [ JsonProperty ( "orga_owner " ) ]
118
+ public string OrgaOwner { get ; set ; }
107
119
108
- [ JsonProperty ( "email " ) ]
109
- public string Email { get ; set ; }
120
+ [ JsonProperty ( "owner " ) ]
121
+ public string Owner { get ; set ; }
110
122
111
- [ JsonProperty ( "serial " ) ]
112
- public int Serial { get ; set ; }
123
+ [ JsonProperty ( "id " ) ]
124
+ public string Id { get ; set ; }
113
125
114
- [ JsonProperty ( "user_uuid " ) ]
115
- public string UserUuid { get ; set ; }
126
+ [ JsonProperty ( "tags " ) ]
127
+ public List < string > Tags { get ; set ; }
116
128
117
- [ JsonProperty ( "refresh " ) ]
118
- public int Refresh { get ; set ; }
129
+ [ JsonProperty ( "href " ) ]
130
+ public string Href { get ; set ; }
119
131
120
- [ JsonProperty ( "minimum" ) ]
121
- public int Minimum { get ; set ; }
132
+ [ JsonProperty ( "fqdn_unicode" ) ]
133
+ public string FqdnUnicode { get ; set ; }
134
+ }
135
+
136
+ public class Dates
137
+ {
138
+ [ JsonProperty ( "created_at" ) ]
139
+ public DateTime CreatedAt { get ; set ; }
140
+
141
+ [ JsonProperty ( "registry_created_at" ) ]
142
+ public DateTime RegistryCreatedAt { get ; set ; }
122
143
123
- [ JsonProperty ( "expire " ) ]
124
- public int Expire { get ; set ; }
144
+ [ JsonProperty ( "registry_ends_at " ) ]
145
+ public DateTime RegistryEndsAt { get ; set ; }
125
146
126
- [ JsonProperty ( "retry" ) ]
127
- public int Retry { get ; set ; }
147
+ [ JsonProperty ( "updated_at" ) ]
148
+ public DateTime UpdatedAt { get ; set ; }
149
+ }
150
+
151
+ public class Nameserver
152
+ {
153
+ [ JsonProperty ( "current" ) ]
154
+ public string Current { get ; set ; }
128
155
}
129
156
}
0 commit comments