gandi_v5 0.6.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +81 -5
- data/README.md +65 -14
- data/lib/gandi_v5.rb +139 -70
- data/lib/gandi_v5/billing/info/prepaid.rb +1 -0
- data/lib/gandi_v5/data.rb +3 -2
- data/lib/gandi_v5/data/converter.rb +3 -2
- data/lib/gandi_v5/data/converter/array_of.rb +3 -2
- data/lib/gandi_v5/data/converter/integer.rb +3 -2
- data/lib/gandi_v5/data/converter/symbol.rb +3 -2
- data/lib/gandi_v5/data/converter/time.rb +3 -2
- data/lib/gandi_v5/domain.rb +55 -18
- data/lib/gandi_v5/domain/availability/product/period.rb +1 -1
- data/lib/gandi_v5/domain/contact.rb +5 -5
- data/lib/gandi_v5/domain/tld.rb +2 -2
- data/lib/gandi_v5/domain/transfer_in.rb +172 -0
- data/lib/gandi_v5/domain/transfer_in/availability.rb +51 -0
- data/lib/gandi_v5/domain/web_forwarding.rb +182 -0
- data/lib/gandi_v5/email.rb +3 -0
- data/lib/gandi_v5/email/forward.rb +3 -9
- data/lib/gandi_v5/email/mailbox.rb +5 -11
- data/lib/gandi_v5/error/gandi_error.rb +1 -0
- data/lib/gandi_v5/live_dns.rb +2 -12
- data/lib/gandi_v5/live_dns/domain.rb +340 -29
- data/lib/gandi_v5/live_dns/domain/dnssec_key.rb +120 -0
- data/lib/gandi_v5/live_dns/domain/record.rb +81 -0
- data/lib/gandi_v5/live_dns/domain/snapshot.rb +111 -0
- data/lib/gandi_v5/live_dns/domain/tsig_key.rb +74 -0
- data/lib/gandi_v5/sharing_space.rb +27 -0
- data/lib/gandi_v5/simple_hosting.rb +13 -0
- data/lib/gandi_v5/simple_hosting/instance.rb +251 -0
- data/lib/gandi_v5/simple_hosting/instance/application.rb +45 -0
- data/lib/gandi_v5/simple_hosting/instance/database.rb +20 -0
- data/lib/gandi_v5/simple_hosting/instance/language.rb +22 -0
- data/lib/gandi_v5/simple_hosting/instance/upgrade.rb +22 -0
- data/lib/gandi_v5/simple_hosting/instance/virtual_host.rb +272 -0
- data/lib/gandi_v5/simple_hosting/instance/virtual_host/linked_dns_zone.rb +75 -0
- data/lib/gandi_v5/template.rb +271 -0
- data/lib/gandi_v5/template/dispatch.rb +109 -0
- data/lib/gandi_v5/template/payload.rb +64 -0
- data/lib/gandi_v5/template/payload/dns_record.rb +23 -0
- data/lib/gandi_v5/template/payload/web_forwarding.rb +82 -0
- data/lib/gandi_v5/version.rb +1 -1
- data/spec/.rubocop.yml +9 -9
- data/spec/features/list_domain_renewals_spec.rb +16 -0
- data/spec/features/list_email_addresses_spec.rb +39 -0
- data/spec/fixtures/bodies/GandiV5_Domain_TransferIn/fetch.yml +21 -0
- data/spec/fixtures/bodies/GandiV5_Domain_TransferIn_Availability/fetch.yml +10 -0
- data/spec/fixtures/bodies/GandiV5_Domain_WebForwarding/fetch.yml +9 -0
- data/spec/fixtures/bodies/GandiV5_Domain_WebForwarding/list.yml +9 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/fetch.yml +1 -2
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/list_tsig.yml +3 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/nameservers.yml +3 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_DnssecKey/fetch.yml +12 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_DnssecKey/list.yml +9 -0
- data/spec/fixtures/bodies/{GandiV5_LiveDNS_Zone_Snapshot → GandiV5_LiveDNS_Domain_Snapshot}/fetch.yml +4 -3
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_Snapshot/list.yml +5 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_TsigKey/fetch.yml +9 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain_TsigKey/list.yml +4 -0
- data/spec/fixtures/bodies/GandiV5_SimpleHosting_Instance/fetch.yml +80 -0
- data/spec/fixtures/bodies/GandiV5_SimpleHosting_Instance/list.yml +38 -0
- data/spec/fixtures/bodies/GandiV5_SimpleHosting_Instance_VirtualHost/fetch.yml +26 -0
- data/spec/fixtures/bodies/GandiV5_SimpleHosting_Instance_VirtualHost/list.yml +18 -0
- data/spec/fixtures/bodies/GandiV5_Template/fetch.yml +41 -0
- data/spec/fixtures/bodies/GandiV5_Template/list.yml +20 -0
- data/spec/fixtures/bodies/GandiV5_Template_Dispatch/fetch.yml +49 -0
- data/spec/fixtures/vcr/Examples/List_domain_renewals.yml +54 -0
- data/spec/fixtures/vcr/Examples/List_email_addresses.yml +103 -0
- data/spec/spec_helper.rb +8 -7
- data/spec/units/gandi_v5/domain/transfer_in/availability_spec.rb +49 -0
- data/spec/units/gandi_v5/domain/transfer_in_spec.rb +143 -0
- data/spec/units/gandi_v5/domain/web_forwarding_spec.rb +150 -0
- data/spec/units/gandi_v5/domain_spec.rb +56 -37
- data/spec/units/gandi_v5/email/forward_spec.rb +5 -34
- data/spec/units/gandi_v5/email/mailbox_spec.rb +4 -34
- data/spec/units/gandi_v5/live_dns/domain/dnssec_key_spec.rb +128 -0
- data/spec/units/gandi_v5/live_dns/{record_set_spec.rb → domain/record_spec.rb} +1 -1
- data/spec/units/gandi_v5/live_dns/domain/snapshot_spec.rb +101 -0
- data/spec/units/gandi_v5/live_dns/domain/tsig_key_spec.rb +78 -0
- data/spec/units/gandi_v5/live_dns/domain_spec.rb +297 -118
- data/spec/units/gandi_v5/live_dns_spec.rb +0 -12
- data/spec/units/gandi_v5/simple_hosting/instance/application_spec.rb +37 -0
- data/spec/units/gandi_v5/simple_hosting/instance/virtual_host/linked_dns_zone_spec.rb +50 -0
- data/spec/units/gandi_v5/simple_hosting/instance/virtual_host_spec.rb +324 -0
- data/spec/units/gandi_v5/simple_hosting/instance_spec.rb +190 -0
- data/spec/units/gandi_v5/simple_hosting_spec.rb +9 -0
- data/spec/units/gandi_v5/template/dispatch_spec.rb +70 -0
- data/spec/units/gandi_v5/template/payload/web_forwarding_spec.rb +44 -0
- data/spec/units/gandi_v5/template_spec.rb +341 -0
- data/spec/units/gandi_v5_spec.rb +111 -14
- metadata +226 -79
- data/.gitignore +0 -26
- data/.rspec +0 -3
- data/.rubocop.yml +0 -30
- data/.travis.yml +0 -38
- data/FUNDING.yml +0 -10
- data/Gemfile +0 -6
- data/Guardfile +0 -39
- data/Rakefile +0 -3
- data/bin/console +0 -13
- data/gandi_v5.gemspec +0 -42
- data/lib/gandi_v5/domain/sharing_space.rb +0 -29
- data/lib/gandi_v5/live_dns/has_zone_records.rb +0 -153
- data/lib/gandi_v5/live_dns/record_set.rb +0 -79
- data/lib/gandi_v5/live_dns/zone.rb +0 -160
- data/lib/gandi_v5/live_dns/zone/snapshot.rb +0 -81
- data/spec/features/domain_spec.rb +0 -45
- data/spec/features/livedns_domain_spec.rb +0 -8
- data/spec/features/livedns_zone_spec.rb +0 -44
- data/spec/features/mailbox_spec.rb +0 -18
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/fetch.yml +0 -11
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/list.yml +0 -11
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/list.yml +0 -3
- data/spec/fixtures/vcr/Domain_features/List_domains.yml +0 -55
- data/spec/fixtures/vcr/Domain_features/Renew_domain.yml +0 -133
- data/spec/fixtures/vcr/LiveDNS_Domain_features/List_domains.yml +0 -32
- data/spec/fixtures/vcr/LiveDNS_Zone_features/List_zones.yml +0 -42
- data/spec/fixtures/vcr/LiveDNS_Zone_features/Make_and_save_snapshot.yml +0 -72
- data/spec/fixtures/vcr/LiveDNS_Zone_features/Save_zone_to_file.yml +0 -28
- data/spec/fixtures/vcr/Mailbox_features/List_mailboxes.yml +0 -39
- data/spec/units/gandi_v5/billing/info_spec.rb +0 -4
- data/spec/units/gandi_v5/domain/availability/product/period_spec.rb +0 -4
- data/spec/units/gandi_v5/domain/availability/product/price_spec.rb +0 -4
- data/spec/units/gandi_v5/domain/availability/product_spec.rb +0 -4
- data/spec/units/gandi_v5/domain/availability/tax_spec.rb +0 -4
- data/spec/units/gandi_v5/domain/contract_spec.rb +0 -4
- data/spec/units/gandi_v5/domain/dates_spec.rb +0 -4
- data/spec/units/gandi_v5/domain/restore_information_spec.rb +0 -4
- data/spec/units/gandi_v5/domain/sharing_space_spec.rb +0 -4
- data/spec/units/gandi_v5/error_spec.rb +0 -4
- data/spec/units/gandi_v5/live_dns/zone/snapshot_spec.rb +0 -66
- data/spec/units/gandi_v5/live_dns/zone_spec.rb +0 -347
data/lib/gandi_v5/data.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
class GandiV5
|
4
4
|
# Addin providing a DSL to manage declaring attributes and how to map
|
5
5
|
# and convert to/from Gandi's fields.
|
6
|
+
# @api private
|
6
7
|
module Data
|
7
8
|
# api private
|
8
9
|
# Add contents of ClassMethods to the Class which includes this module.
|
@@ -149,8 +150,8 @@ class GandiV5
|
|
149
150
|
return nil if data.nil?
|
150
151
|
|
151
152
|
new(
|
152
|
-
translate_gandi(data).transform_keys(&:to_sym)
|
153
|
-
|
153
|
+
**translate_gandi(data).transform_keys(&:to_sym)
|
154
|
+
.select { |k, _v| data_member?(k) }
|
154
155
|
)
|
155
156
|
end
|
156
157
|
|
@@ -3,6 +3,7 @@
|
|
3
3
|
class GandiV5
|
4
4
|
module Data
|
5
5
|
# Namespace for converters to/from Gandi's format.
|
6
|
+
# @api private
|
6
7
|
class Converter
|
7
8
|
# Initialize a new simple converter.
|
8
9
|
# The passed procs will be run at the appropriate time.
|
@@ -21,8 +22,8 @@ class GandiV5
|
|
21
22
|
to_gandi_proc.call value
|
22
23
|
end
|
23
24
|
|
24
|
-
# @param [Object]
|
25
|
-
# @return
|
25
|
+
# @param value [Object]
|
26
|
+
# @return [Object]
|
26
27
|
def from_gandi(value)
|
27
28
|
return value unless from_gandi_proc
|
28
29
|
|
@@ -4,6 +4,7 @@ class GandiV5
|
|
4
4
|
module Data
|
5
5
|
class Converter
|
6
6
|
# Used for applying the same converter to each item in an array.
|
7
|
+
# @api private
|
7
8
|
class ArrayOf
|
8
9
|
# @param converter the converter to apply to each item in the array.
|
9
10
|
def initialize(converter)
|
@@ -18,8 +19,8 @@ class GandiV5
|
|
18
19
|
value.map { |item| converter.to_gandi(item) }
|
19
20
|
end
|
20
21
|
|
21
|
-
# @param [Array<Object>]
|
22
|
-
# @return
|
22
|
+
# @param value [Array<Object>]
|
23
|
+
# @return [Array<Object>]
|
23
24
|
def from_gandi(value)
|
24
25
|
return nil if value.nil?
|
25
26
|
|
@@ -4,6 +4,7 @@ class GandiV5
|
|
4
4
|
module Data
|
5
5
|
class Converter
|
6
6
|
# Methods for converting strings to/from integerss.
|
7
|
+
# @api private
|
7
8
|
class Integer
|
8
9
|
# @param value [Integer]
|
9
10
|
# @return [String]
|
@@ -13,8 +14,8 @@ class GandiV5
|
|
13
14
|
value.to_s
|
14
15
|
end
|
15
16
|
|
16
|
-
# @param [String]
|
17
|
-
# @return
|
17
|
+
# @param value [String]
|
18
|
+
# @return [Integer]
|
18
19
|
def self.from_gandi(value)
|
19
20
|
return nil if value.nil?
|
20
21
|
|
@@ -4,6 +4,7 @@ class GandiV5
|
|
4
4
|
module Data
|
5
5
|
class Converter
|
6
6
|
# Methods for converting strings to/from symbols.
|
7
|
+
# @api private
|
7
8
|
class Symbol
|
8
9
|
# @param value [Symbol]
|
9
10
|
# @return [String]
|
@@ -13,8 +14,8 @@ class GandiV5
|
|
13
14
|
value.to_s
|
14
15
|
end
|
15
16
|
|
16
|
-
# @param [String]
|
17
|
-
# @return
|
17
|
+
# @param value [String]
|
18
|
+
# @return [Symbol]
|
18
19
|
def self.from_gandi(value)
|
19
20
|
return nil if value.nil?
|
20
21
|
|
@@ -4,6 +4,7 @@ class GandiV5
|
|
4
4
|
module Data
|
5
5
|
class Converter
|
6
6
|
# Methods for converting times to/from Gandi ("2019-02-13T11:04:18Z").
|
7
|
+
# @api private
|
7
8
|
class Time
|
8
9
|
# Convert a time to Gandi's prefered string format.
|
9
10
|
# @param value [Time]
|
@@ -15,8 +16,8 @@ class GandiV5
|
|
15
16
|
end
|
16
17
|
|
17
18
|
# Convert a time from Gandi's prefered string format.
|
18
|
-
# @param [String]
|
19
|
-
# @return
|
19
|
+
# @param value [String]
|
20
|
+
# @return [Time]
|
20
21
|
def self.from_gandi(value)
|
21
22
|
return nil if value.nil?
|
22
23
|
|
data/lib/gandi_v5/domain.rb
CHANGED
@@ -7,7 +7,7 @@ class GandiV5
|
|
7
7
|
# @return [String] fully qualified domain name, written in its native alphabet (IDN).
|
8
8
|
# @!attribute [r] fqdn_unicode
|
9
9
|
# @return [String] fully qualified domain name, written in unicode.
|
10
|
-
#
|
10
|
+
# @see https://docs.gandi.net/en/domain_names/register/idn.html
|
11
11
|
# @!attribute [r] name_servers
|
12
12
|
# @return [Array<String>]
|
13
13
|
# @!attribute [r] services
|
@@ -15,12 +15,12 @@ class GandiV5
|
|
15
15
|
# gandidns, redirection, gandimail, packmail, dnssec, blog, hosting,
|
16
16
|
# paas, site, certificate, gandilivedns, mailboxv2
|
17
17
|
# @!attribute [r] sharing_space
|
18
|
-
# @return [GandiV5::
|
18
|
+
# @return [GandiV5::SharingSpace]
|
19
19
|
# @!attribute [r] status
|
20
20
|
# @return [String] one of: "clientHold", "clientUpdateProhibited", "clientTransferProhibited",
|
21
21
|
# "clientDeleteProhibited", "clientRenewProhibited", "serverHold", "pendingTransfer",
|
22
22
|
# "serverTransferProhibited"
|
23
|
-
#
|
23
|
+
# @see https://docs.gandi.net/en/domain_names/faq/domain_statuses.html
|
24
24
|
# @!attribute [r] tld
|
25
25
|
# @return [String]
|
26
26
|
# @!attribute [r] dates
|
@@ -107,7 +107,7 @@ class GandiV5
|
|
107
107
|
member(
|
108
108
|
:sharing_space,
|
109
109
|
gandi_key: 'sharing_space',
|
110
|
-
converter: GandiV5::
|
110
|
+
converter: GandiV5::SharingSpace
|
111
111
|
)
|
112
112
|
|
113
113
|
member(
|
@@ -181,7 +181,7 @@ class GandiV5
|
|
181
181
|
admin: admin.respond_to?(:to_gandi) ? admin.to_gandi : admin,
|
182
182
|
bill: bill.respond_to?(:to_gandi) ? bill.to_gandi : bill,
|
183
183
|
tech: tech.respond_to?(:to_gandi) ? tech.to_gandi : tech
|
184
|
-
}.
|
184
|
+
}.compact { |_k, v| v.nil? }.to_json
|
185
185
|
|
186
186
|
GandiV5.patch url('contacts'), body
|
187
187
|
fetch_contacts
|
@@ -206,7 +206,7 @@ class GandiV5
|
|
206
206
|
end
|
207
207
|
|
208
208
|
# Renew domain.
|
209
|
-
#
|
209
|
+
# @note This is not a free operation. Please ensure your prepaid account has enough credit.
|
210
210
|
# @see https://api.gandi.net/docs/domains#post-v5-domain-domains-domain-renew
|
211
211
|
# @param duration [Integer, #to_s] how long to renew for (in years).
|
212
212
|
# @return [String] confirmation message from Gandi.
|
@@ -242,7 +242,7 @@ class GandiV5
|
|
242
242
|
end
|
243
243
|
|
244
244
|
# Restore an expired domain.
|
245
|
-
#
|
245
|
+
# @note This is not a free operation. Please ensure your prepaid account has enough credit.
|
246
246
|
# @see https://docs.gandi.net/en/domain_names/renew/restore.html
|
247
247
|
# @see https://api.gandi.net/docs/domains#post-v5-domain-domains-domain-restore
|
248
248
|
# @return [String] The confirmation message from Gandi.
|
@@ -252,6 +252,29 @@ class GandiV5
|
|
252
252
|
data['message']
|
253
253
|
end
|
254
254
|
|
255
|
+
# Lock this domain - preventing it from being transfered.
|
256
|
+
# @see https://api.gandi.net/docs/domains/#patch-v5-domain-domains-domain-status
|
257
|
+
# Most extensions have a transfer protection mechanism, that consists of a lock that can be put
|
258
|
+
# on the domain. When the transfer lock is enabled, the domain can't be transferred.
|
259
|
+
# @params lock [Boolean] whether the domain should be locked (true) or unlocked (false)
|
260
|
+
# @return [String] The confirmation message from Gandi.
|
261
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
262
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
263
|
+
def transfer_lock(lock = true)
|
264
|
+
_response, data = GandiV5.patch url('status'), { 'clientTransferProhibited' => lock }.to_json
|
265
|
+
@status = lock ? 'clientTransferProhibited' : nil
|
266
|
+
data['message']
|
267
|
+
end
|
268
|
+
# rubocop:enable Style/OptionalBooleanParameter
|
269
|
+
|
270
|
+
# Unlock this domain - allowing it to be transfered.
|
271
|
+
# @see https://api.gandi.net/docs/domains/#patch-v5-domain-domains-domain-status
|
272
|
+
# @return [String] The confirmation message from Gandi.
|
273
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
274
|
+
def transfer_unlock
|
275
|
+
transfer_lock false
|
276
|
+
end
|
277
|
+
|
255
278
|
# Requery Gandi fo this domain's information.
|
256
279
|
# @return [GandiV5::Domain]
|
257
280
|
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
@@ -399,23 +422,39 @@ class GandiV5
|
|
399
422
|
data['message']
|
400
423
|
end
|
401
424
|
|
425
|
+
# Get email mailboxes for the domain.
|
402
426
|
# @see GandiV5::Email::Mailbox.list
|
403
427
|
def mailboxes(**params)
|
404
428
|
GandiV5::Email::Mailbox.list(**params, fqdn: fqdn)
|
405
429
|
end
|
406
430
|
|
431
|
+
# Get email slots for the domain.
|
407
432
|
# @see GandiV5::Email::Slot.list
|
408
433
|
def mailbox_slots(**params)
|
409
434
|
GandiV5::Email::Slot.list(**params, fqdn: fqdn)
|
410
435
|
end
|
411
436
|
|
437
|
+
# Get email forwards for the domain.
|
412
438
|
# @see GandiV5::Email::Forward.list
|
413
439
|
def email_forwards(**params)
|
414
440
|
GandiV5::Email::Forward.list(**params, fqdn: fqdn)
|
415
441
|
end
|
416
442
|
|
443
|
+
# Get web forwardings for the domain.
|
444
|
+
# @see GandiV5::Domain::WebRedirection.list
|
445
|
+
def web_forwardings(**params)
|
446
|
+
GandiV5::Domain::WebForwarding.list(fqdn, **params)
|
447
|
+
end
|
448
|
+
|
449
|
+
# Get a web forwarding.
|
450
|
+
# @see GandiV5::Domain::WebRedirection.fetch
|
451
|
+
# @param host [String, #to_s] the host the redirection is setup on.
|
452
|
+
def web_forwarding(host)
|
453
|
+
GandiV5::Domain::WebForwarding.fetch(fqdn, host)
|
454
|
+
end
|
455
|
+
|
417
456
|
# Create (register) a new domain.
|
418
|
-
#
|
457
|
+
# @note This is not a free operation. Please ensure your prepaid account has enough credit.
|
419
458
|
# @see https://api.gandi.net/docs/domains#post-v5-domain-domains
|
420
459
|
# @param fqdn [String, #to_s] the fully qualified domain name to create.
|
421
460
|
# @param dry_run [Boolean]
|
@@ -455,11 +494,13 @@ class GandiV5
|
|
455
494
|
# List of nameservers. Gandi's LiveDNS nameservers are used if omitted..
|
456
495
|
# @param price [Numeric, #to_gandi, #to_json] (optional) unknown - not documented at Gandi.
|
457
496
|
# @param resellee_id [String, #to_gandi, #to_json] (optional) unknown - not documented at Gandi.
|
497
|
+
# @param template_id [String, #to_gandi] (optional)
|
498
|
+
# Template to be applied when the domain is created.
|
458
499
|
# @param smd [String, #to_gandi, #to_json] (optional)
|
459
500
|
# Contents of a Signed Mark Data file (used for newgtld sunrises, tld_period must be sunrise).
|
460
501
|
# @param tld_period ["sunrise", "landrush", "eap1", "eap2", "eap3", "eap4", "eap5", "eap6",
|
461
502
|
# "eap7", "eap8", "eap9", "golive", #to_gandi, #to_json] (optional)
|
462
|
-
#
|
503
|
+
# @see https://docs.gandi.net/en/domain_names/register/new_gtld.html
|
463
504
|
# @return [GandiV5::Domain] the created domain
|
464
505
|
# @return [Hash] if doing a dry run, you get what Gandi returns
|
465
506
|
# @raise [GandiV5::Error::GandiError] if Gandi returns an error
|
@@ -492,24 +533,20 @@ class GandiV5
|
|
492
533
|
# @param page [#each<Integer, #to_s>] the page(s) of results to retrieve.
|
493
534
|
# If page is not provided keep querying until an empty list is returned.
|
494
535
|
# If page responds to .each then iterate until an empty list is returned.
|
495
|
-
# @param per_page [Integer, #to_s] (optional default 100) how many results
|
536
|
+
# @param per_page [Integer, #to_s] (optional default 100) how many results to get per page.
|
496
537
|
# @param fqdn [String, #to_s] (optional)
|
497
538
|
# filters the list by domain name, with optional patterns.
|
498
539
|
# e.g. "example.net", "example.*", "*ample.com"
|
499
|
-
# @param
|
540
|
+
# @param resellee_id [String, #to_s] (optional)
|
541
|
+
# filters the list by resellee_id (from the Organization API).
|
500
542
|
# @param tld [String, #to_s] (optional) used to filter by just the top level domain.
|
543
|
+
# @param sort_by [String, #to_s] (optional default "fqdn") how to sort the list.
|
501
544
|
# @return [Array<GandiV5::Domain>]
|
502
545
|
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
503
546
|
def self.list(page: (1..), per_page: 100, **params)
|
504
|
-
page = [page.to_i] unless page.respond_to?(:each)
|
505
|
-
|
506
547
|
domains = []
|
507
|
-
|
508
|
-
_resp, data = GandiV5.get url, params: params.merge(page: page_number, per_page: per_page)
|
509
|
-
break if data.empty?
|
510
|
-
|
548
|
+
GandiV5.paginated_get(url, page, per_page, params: params) do |data|
|
511
549
|
domains += data.map { |domain| from_gandi domain }
|
512
|
-
break if data.count < per_page
|
513
550
|
end
|
514
551
|
domains
|
515
552
|
end
|
@@ -4,15 +4,15 @@ class GandiV5
|
|
4
4
|
class Domain
|
5
5
|
# Information for a single contact for a domain.
|
6
6
|
# @!attribute [r] country
|
7
|
-
# @return [String]
|
7
|
+
# @return [String]
|
8
8
|
# @!attribute [r] email
|
9
|
-
# @return [String]
|
9
|
+
# @return [String]
|
10
10
|
# @!attribute [r] family
|
11
|
-
# @return [String]
|
11
|
+
# @return [String]
|
12
12
|
# @!attribute [r] given
|
13
|
-
# @return [String]
|
13
|
+
# @return [String]
|
14
14
|
# @!attribute [r] address
|
15
|
-
# @return [String]
|
15
|
+
# @return [String]
|
16
16
|
# @!attribute [r] type
|
17
17
|
# @return [:person, :company, :association, :'public body', :reseller]
|
18
18
|
# @!attribute [r] brand_number
|
data/lib/gandi_v5/domain/tld.rb
CHANGED
@@ -12,7 +12,7 @@ class GandiV5
|
|
12
12
|
# @!attribute [r] category
|
13
13
|
# @return [String]
|
14
14
|
# @!attribute [r] change_owner
|
15
|
-
# @return [Boolean]
|
15
|
+
# @return [Boolean] whether changing owner is pemritted.
|
16
16
|
# @!attribute [r] corporate
|
17
17
|
# @return [Boolean] whether this is a corporate TLD.
|
18
18
|
# @!attribute [r] ext_trade
|
@@ -27,7 +27,7 @@ class GandiV5
|
|
27
27
|
|
28
28
|
# List of available TLDs.
|
29
29
|
# @see https://api.gandi.net/docs/domains#get-v5-domain-tlds
|
30
|
-
# @return Array<GandiV5::Domain::TLD>
|
30
|
+
# @return [Array<GandiV5::Domain::TLD>]
|
31
31
|
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
32
32
|
def self.list
|
33
33
|
GandiV5.get(url)
|
@@ -0,0 +1,172 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GandiV5
|
4
|
+
class Domain
|
5
|
+
# Manage a domain's transfer to Gandi.
|
6
|
+
# @!attribute [r] fqdn
|
7
|
+
# @return [String] the fully qualified domain name being transfered
|
8
|
+
# @!attribute [r] created_at
|
9
|
+
# @return [Time]
|
10
|
+
# @!attribute [r] updated_at
|
11
|
+
# @return [Time]
|
12
|
+
# @!attribute [r] owner_contact
|
13
|
+
# @return [String]
|
14
|
+
# @!attribute [r] step
|
15
|
+
# @return [String]
|
16
|
+
# @!attribute [r] step_number
|
17
|
+
# @return [Integer]
|
18
|
+
# @!attribute [r] errortype
|
19
|
+
# @return [String] (optional)
|
20
|
+
# @!attribute [r] errortype_label
|
21
|
+
# @return [String] (optional)
|
22
|
+
# @!attribute [r] duration
|
23
|
+
# @return [Integer] (optional)
|
24
|
+
# @!attribute [r] reseller_uuid
|
25
|
+
# @return [String] (optional)
|
26
|
+
# @!attribute [r] version
|
27
|
+
# @return [Integer] (optional)
|
28
|
+
# @!attribute [r] foa
|
29
|
+
# @return [Hash{String=>String}] (optional) email => status
|
30
|
+
# @!attribute [r] inner_step
|
31
|
+
# @return [String] (optional)
|
32
|
+
# @!attribute [r] transfer_procedure
|
33
|
+
# @return [String] (optional)
|
34
|
+
# @!attribute [r] start_at
|
35
|
+
# @return [Time] (optional)
|
36
|
+
# @!attribute [r] regac_at
|
37
|
+
# @return [Time] (optional)
|
38
|
+
class TransferIn
|
39
|
+
include GandiV5::Data
|
40
|
+
|
41
|
+
members :fqdn, :owner_contact, :step, :errortype, :errortype_label, :inner_step,
|
42
|
+
:transfer_procedure, :reseller_uuid, :version, :foa_status, :duration
|
43
|
+
|
44
|
+
member :step_number, gandi_key: 'step_nb'
|
45
|
+
member :created_at, converter: GandiV5::Data::Converter::Time
|
46
|
+
member :updated_at, converter: GandiV5::Data::Converter::Time
|
47
|
+
member :regac_at, converter: GandiV5::Data::Converter::Time
|
48
|
+
member :start_at, converter: GandiV5::Data::Converter::Time
|
49
|
+
|
50
|
+
# Relaunch the transfer process after something went wrong.
|
51
|
+
# @see https://api.gandi.net/docs/domains/#put-v5-domain-transferin-domain
|
52
|
+
# @return [String] the confirmation message from Gandi
|
53
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
54
|
+
def relaunch
|
55
|
+
TransferIn.relaunch fqdn
|
56
|
+
end
|
57
|
+
|
58
|
+
# Resend the {https://icannwiki.org/FOA Form Of Authorization} email.
|
59
|
+
# @see https://api.gandi.net/docs/domains/#post-v5-domain-transferin-domain-foa
|
60
|
+
# @return [String] the confirmation message from Gandi
|
61
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
62
|
+
def resend_foa_emails(email_address)
|
63
|
+
TransferIn.resend_foa_emails fqdn, email_address
|
64
|
+
end
|
65
|
+
|
66
|
+
# Start the transfer of a domain to Gandi.
|
67
|
+
# @note This is not a free operation. Please ensure your prepaid account has enough credit.
|
68
|
+
# @see https://api.gandi.net/docs/domains/#post-v5-domain-transferin
|
69
|
+
# @param fqdn [String, #to_s] the fully qualified domain name to create.
|
70
|
+
# @param dry_run [Boolean]
|
71
|
+
# whether the details should be checked instead of actually creating the domain.
|
72
|
+
# @param sharing_id [String] either:
|
73
|
+
# * nil (default) - nothing special happens
|
74
|
+
# * an organization ID - pay using another organization
|
75
|
+
# (you need to have billing permissions on the organization
|
76
|
+
# and use the same organization name for the domain name's owner).
|
77
|
+
# The invoice will be edited using this organization's information.
|
78
|
+
# * a reseller ID - buy a domain for a customer using a reseller account
|
79
|
+
# (you need to have billing permissions on the reseller organization
|
80
|
+
# and have your customer's information for the owner).
|
81
|
+
# The invoice will be edited using the reseller organization's information.
|
82
|
+
# @param owner [GandiV5::Domain::Contact, #to_gandi, #to_h] (required)
|
83
|
+
# the owner of the new domain.
|
84
|
+
# @param admin [GandiV5::Domain::Contact, #to_gandi, #to_h] (optional, defaults to owner)
|
85
|
+
# the administrative contact for the new domain.
|
86
|
+
# @param bill [GandiV5::Domain::Contact, #to_gandi, #to_h] (optional, defaults to owner)
|
87
|
+
# the billing contact for the new domain.
|
88
|
+
# @param tech [GandiV5::Domain::Contact, #to_gandi, #to_h] (optional, defaults to owner)
|
89
|
+
# the technical contact for the new domain.
|
90
|
+
# @param currency ["EUR", "USD", "GBP", "TWD", "CNY"] (optional)
|
91
|
+
# the currency you wish to be charged in.
|
92
|
+
# @param duration [Integer] (optional, default 1, minimum 1 maximum 10)
|
93
|
+
# how many years to register for.
|
94
|
+
# @param enforce_premium [Boolean] (optional)
|
95
|
+
# must be set to true if the domain is a premium domain.
|
96
|
+
# @param extra_parameters [Hash, #to_gandi, #to_json] (optional)
|
97
|
+
# unknown - not documented at Gandi.
|
98
|
+
# @param nameserver_ips [Hash<String => Array<String>>, #to_gandi, #to_json] (optional)
|
99
|
+
# For glue records only - dictionnary associating a nameserver to a list of IP addresses.
|
100
|
+
# @param nameservers [Array<String>, #to_gandi, #to_json] (optional)
|
101
|
+
# List of nameservers. Gandi's LiveDNS nameservers are used if omitted..
|
102
|
+
# @param price [Numeric, #to_gandi, #to_json] (optional) unknown - not documented at Gandi.
|
103
|
+
# @param resellee_id [String, #to_gandi, #to_json] (optional)
|
104
|
+
# unknown - not documented at Gandi.
|
105
|
+
# @param change_owner [Boolean] (optional)
|
106
|
+
# whether the change the domain's owner during the transfer.
|
107
|
+
# @param auth_code [String] (optional) authorization code (if required).
|
108
|
+
# @param template_id [String, #to_gandi] (optional)
|
109
|
+
# Template to be applied when the transfer is done.
|
110
|
+
# @return [String] the confirmation message from Gandi
|
111
|
+
# @return [Hash] if doing a dry run, you get what Gandi returns
|
112
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error
|
113
|
+
def self.create(fqdn, dry_run: false, sharing_id: nil, **params)
|
114
|
+
fail ArgumentError, 'missing keyword: owner' unless params.key?(:owner)
|
115
|
+
|
116
|
+
body = params.merge(fqdn: fqdn)
|
117
|
+
.transform_values { |val| val.respond_to?(:to_gandi) ? val.to_gandi : val }
|
118
|
+
.to_json
|
119
|
+
url_ = sharing_id ? "#{url}?sharing_id=#{sharing_id}" : url
|
120
|
+
|
121
|
+
_response, data = GandiV5.post(url_, body, 'Dry-Run': dry_run ? 1 : 0)
|
122
|
+
dry_run ? data : data['message']
|
123
|
+
end
|
124
|
+
|
125
|
+
# Get information on an existing transfer.
|
126
|
+
# @see https://api.gandi.net/docs/domains/#get-v5-domain-transferin-domain
|
127
|
+
# @param fqdn [String, #to_s] the fully qualified domain name to check.
|
128
|
+
# @return [GandiV5::Domain::TransferIn]
|
129
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
130
|
+
def self.fetch(fqdn)
|
131
|
+
_response, data = GandiV5.get url(fqdn)
|
132
|
+
transfer = from_gandi data
|
133
|
+
transfer.instance_exec { @fqdn = data.dig('params', 'domain') }
|
134
|
+
transfer.instance_exec { @reseller_uuid = data.dig('params', 'reseller') }
|
135
|
+
transfer.instance_exec { @version = data.dig('params', 'version') }
|
136
|
+
transfer.instance_exec { @duration = data.dig('params', 'duration') }
|
137
|
+
if data.key?('foa')
|
138
|
+
transfer.instance_exec do
|
139
|
+
@foa_status = Hash[data['foa'].map { |hash| hash.values_at('email', 'answer') }]
|
140
|
+
end
|
141
|
+
end
|
142
|
+
transfer
|
143
|
+
end
|
144
|
+
|
145
|
+
# Relaunch the transfer process after something went wrong.
|
146
|
+
# @see https://api.gandi.net/docs/domains/#put-v5-domain-transferin-domain
|
147
|
+
# @return [String] the confirmation message from Gandi
|
148
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
149
|
+
def self.relaunch(fqdn)
|
150
|
+
_response, data = GandiV5.put url(fqdn)
|
151
|
+
data['message']
|
152
|
+
end
|
153
|
+
|
154
|
+
# Resend the {https://icannwiki.org/FOA Form Of Authorization} email.
|
155
|
+
# @see https://api.gandi.net/docs/domains/#post-v5-domain-transferin-domain-foa
|
156
|
+
# @return [String] the confirmation message from Gandi
|
157
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
158
|
+
def self.resend_foa_emails(fqdn, email_address)
|
159
|
+
_response, data = GandiV5.post "#{url(fqdn)}/foa", { 'email' => email_address }.to_json
|
160
|
+
data['message']
|
161
|
+
end
|
162
|
+
|
163
|
+
private
|
164
|
+
|
165
|
+
def self.url(fqdn = nil)
|
166
|
+
"#{BASE}domain/transferin" +
|
167
|
+
(fqdn ? "/#{CGI.escape fqdn}" : '')
|
168
|
+
end
|
169
|
+
private_class_method :url
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|