gandi_v5 0.8.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +49 -9
  3. data/README.md +64 -15
  4. data/lib/gandi_v5/billing/info/prepaid.rb +1 -0
  5. data/lib/gandi_v5/data/converter/array_of.rb +3 -2
  6. data/lib/gandi_v5/data/converter/integer.rb +3 -2
  7. data/lib/gandi_v5/data/converter/symbol.rb +3 -2
  8. data/lib/gandi_v5/data/converter/time.rb +3 -2
  9. data/lib/gandi_v5/data/converter.rb +3 -2
  10. data/lib/gandi_v5/data.rb +13 -14
  11. data/lib/gandi_v5/domain/availability/product/period.rb +1 -1
  12. data/lib/gandi_v5/domain/contact.rb +5 -5
  13. data/lib/gandi_v5/domain/tld.rb +2 -2
  14. data/lib/gandi_v5/domain/transfer_in/availability.rb +51 -0
  15. data/lib/gandi_v5/domain/transfer_in.rb +172 -0
  16. data/lib/gandi_v5/domain/web_forwarding.rb +182 -0
  17. data/lib/gandi_v5/domain.rb +52 -13
  18. data/lib/gandi_v5/email/forward.rb +1 -1
  19. data/lib/gandi_v5/email/mailbox.rb +6 -6
  20. data/lib/gandi_v5/email/slot.rb +1 -1
  21. data/lib/gandi_v5/email.rb +3 -0
  22. data/lib/gandi_v5/error/gandi_error.rb +1 -0
  23. data/lib/gandi_v5/live_dns/domain/dnssec_key.rb +16 -11
  24. data/lib/gandi_v5/live_dns/domain/snapshot.rb +5 -1
  25. data/lib/gandi_v5/live_dns/domain/tsig_key.rb +8 -5
  26. data/lib/gandi_v5/live_dns/domain.rb +29 -1
  27. data/lib/gandi_v5/live_dns.rb +2 -0
  28. data/lib/gandi_v5/simple_hosting/instance/application.rb +1 -0
  29. data/lib/gandi_v5/simple_hosting/instance/database.rb +1 -0
  30. data/lib/gandi_v5/simple_hosting/instance/language.rb +1 -1
  31. data/lib/gandi_v5/simple_hosting/instance/upgrade.rb +1 -0
  32. data/lib/gandi_v5/simple_hosting/instance/virtual_host/linked_dns_zone.rb +2 -1
  33. data/lib/gandi_v5/simple_hosting/instance/virtual_host.rb +90 -5
  34. data/lib/gandi_v5/simple_hosting/instance.rb +9 -0
  35. data/lib/gandi_v5/simple_hosting.rb +1 -0
  36. data/lib/gandi_v5/template/dispatch.rb +109 -0
  37. data/lib/gandi_v5/template/payload/dns_record.rb +23 -0
  38. data/lib/gandi_v5/template/payload/web_forwarding.rb +82 -0
  39. data/lib/gandi_v5/template/payload.rb +64 -0
  40. data/lib/gandi_v5/template.rb +271 -0
  41. data/lib/gandi_v5/version.rb +1 -1
  42. data/lib/gandi_v5.rb +115 -66
  43. data/spec/.rubocop.yml +3 -50
  44. data/spec/features/list_domain_renewals_spec.rb +16 -0
  45. data/spec/features/list_email_addresses_spec.rb +39 -0
  46. data/spec/fixtures/bodies/GandiV5_Domain_TransferIn/fetch.yml +21 -0
  47. data/spec/fixtures/bodies/GandiV5_Domain_TransferIn_Availability/fetch.yml +10 -0
  48. data/spec/fixtures/bodies/GandiV5_Domain_WebForwarding/fetch.yml +9 -0
  49. data/spec/fixtures/bodies/GandiV5_Domain_WebForwarding/list.yml +9 -0
  50. data/spec/fixtures/bodies/GandiV5_Template/fetch.yml +41 -0
  51. data/spec/fixtures/bodies/GandiV5_Template/list.yml +20 -0
  52. data/spec/fixtures/bodies/GandiV5_Template_Dispatch/fetch.yml +49 -0
  53. data/spec/fixtures/vcr/Examples/List_domain_renewals.yml +54 -0
  54. data/spec/fixtures/vcr/Examples/List_email_addresses.yml +103 -0
  55. data/spec/spec_helper.rb +8 -7
  56. data/spec/units/gandi_v5/domain/transfer_in/availability_spec.rb +49 -0
  57. data/spec/units/gandi_v5/domain/transfer_in_spec.rb +143 -0
  58. data/spec/units/gandi_v5/domain/web_forwarding_spec.rb +150 -0
  59. data/spec/units/gandi_v5/domain_spec.rb +50 -0
  60. data/spec/units/gandi_v5/simple_hosting/instance/virtual_host_spec.rb +125 -0
  61. data/spec/units/gandi_v5/simple_hosting/instance_spec.rb +8 -0
  62. data/spec/units/gandi_v5/template/dispatch_spec.rb +70 -0
  63. data/spec/units/gandi_v5/template/payload/web_forwarding_spec.rb +44 -0
  64. data/spec/units/gandi_v5/template_spec.rb +341 -0
  65. data/spec/units/gandi_v5_spec.rb +1 -1
  66. metadata +191 -57
  67. data/.gitignore +0 -26
  68. data/.rspec +0 -3
  69. data/.rubocop.yml +0 -74
  70. data/.travis.yml +0 -38
  71. data/FUNDING.yml +0 -10
  72. data/Gemfile +0 -6
  73. data/Guardfile +0 -39
  74. data/Rakefile +0 -3
  75. data/bin/console +0 -13
  76. data/gandi_v5.gemspec +0 -42
  77. data/spec/units/gandi_v5/billing/info_spec.rb +0 -4
  78. data/spec/units/gandi_v5/domain/availability/product/period_spec.rb +0 -4
  79. data/spec/units/gandi_v5/domain/availability/product/price_spec.rb +0 -4
  80. data/spec/units/gandi_v5/domain/availability/product_spec.rb +0 -4
  81. data/spec/units/gandi_v5/domain/availability/tax_spec.rb +0 -4
  82. data/spec/units/gandi_v5/domain/contract_spec.rb +0 -4
  83. data/spec/units/gandi_v5/domain/dates_spec.rb +0 -4
  84. data/spec/units/gandi_v5/domain/restore_information_spec.rb +0 -4
  85. data/spec/units/gandi_v5/error_spec.rb +0 -4
  86. data/spec/units/gandi_v5/sharing_space_spec.rb +0 -4
  87. data/spec/units/gandi_v5/simple_hosting/instance/database_spec.rb +0 -4
  88. data/spec/units/gandi_v5/simple_hosting/instance/language_spec.rb +0 -4
  89. data/spec/units/gandi_v5/simple_hosting/instance/upgrade_spec.rb +0 -4
@@ -0,0 +1,182 @@
1
+ # frozen_string_literal: true
2
+
3
+ class GandiV5
4
+ class Domain
5
+ # Manage web forwarding.
6
+ # @!attribute [r] created_at
7
+ # @return [Time, nil]
8
+ # @!attribute [r] updated_at
9
+ # @return [Time, nil]
10
+ # @!attribute [r] type
11
+ # @return [:cloak, :http301, :http302]
12
+ # @!attribute [r] fqdn
13
+ # @return [String]
14
+ # @!attribute [r] protocol
15
+ # @return [:http, :https, :https_only, nil]
16
+ # @!attribute [r] target
17
+ # @return [String]
18
+ # @!attribute [r] cert_status
19
+ # @return [String, nil]
20
+ # @!attribute [r] cert_uuid
21
+ # @return [String, nil]
22
+ class WebForwarding
23
+ include GandiV5::Data
24
+
25
+ members :cert_uuid, :cert_status
26
+ member :target, gandi_key: 'url'
27
+ member :fqdn, gandi_key: 'host'
28
+ member :type, converter: GandiV5::Data::Converter::Symbol
29
+ member :created_at, converter: GandiV5::Data::Converter::Time
30
+ member :updated_at, converter: GandiV5::Data::Converter::Time
31
+ member(
32
+ :protocol,
33
+ converter: GandiV5::Data::Converter.new(
34
+ from_gandi: lambda { |value|
35
+ {
36
+ 'http' => :http,
37
+ 'https' => :https,
38
+ 'httpsonly' => :https_only
39
+ }.fetch(value)
40
+ }
41
+ )
42
+ )
43
+
44
+ # Update the redirection in Gandi.
45
+ # @see https://api.gandi.net/docs/domains/#patch-v5-domain-domains-domain-webredirs-host
46
+ # @param target [String, #to_s] the url to redirect to (e.g. www.example.com/path).
47
+ # @param protocol [:http, :https, :https_only]
48
+ # @param type [:cloak, :http301, :http302]
49
+ # @param override [Boolean] If true, a DNS record will be created.
50
+ # When the value is false and no matching DNS record exists, it will trigger an error.
51
+ # @return [GandiV5::Domain::WebRedirection]
52
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error
53
+ def update(target: nil, protocol: nil, type: nil, override: nil)
54
+ body = {}
55
+ body['url'] = target.to_s unless target.nil?
56
+ body['protocol'] = protocol.to_s.delete('_') unless protocol.nil?
57
+ body['type'] = type.to_s unless type.nil?
58
+ body['override'] = override unless override.nil?
59
+
60
+ GandiV5.patch url, body.to_json
61
+ refresh
62
+ end
63
+
64
+ # Delete this web redirection from Gandi.
65
+ # @see https://api.gandi.net/docs/domains/#delete-v5-domain-domains-domain-webredirs-host
66
+ # @return [String] The confirmation message from Gandi.
67
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
68
+ def delete
69
+ _response, data = GandiV5.delete url
70
+ data['message']
71
+ end
72
+
73
+ # Check if this is an HTTP 301 (permanent) redirection.
74
+ def http301?
75
+ type == :http301
76
+ end
77
+
78
+ # Check if this is an HTTP 302 (found) redirection.
79
+ def http302?
80
+ type == :http302
81
+ end
82
+
83
+ # Check if this is an HTTP 301 (permanent) redirection.
84
+ def permanent?
85
+ type == :http301
86
+ end
87
+
88
+ # Check if this is an HTTP 302 (found) redirection.
89
+ def found?
90
+ type == :http302
91
+ end
92
+
93
+ # Check if this is a temporary redirection.
94
+ def temporary?
95
+ type == :http302
96
+ end
97
+
98
+ # Check if it's an http end point
99
+ def http?
100
+ protocol == :http || protocol == :https
101
+ end
102
+
103
+ # Check if it's an https end point
104
+ def https?
105
+ protocol == :https || protocol == :https_only
106
+ end
107
+
108
+ # Check if it's an https only
109
+ def https_only?
110
+ protocol == :https_only
111
+ end
112
+
113
+ # Create a new web redirection.
114
+ # @see https://api.gandi.net/docs/domains/#post-v5-domain-domains-domain-webredirs
115
+ # @param domain [String, #to_s] the domain name to create the redirection in.
116
+ # @param host [String, #to_s] the host name to redirect from.
117
+ # @param target [String, #to_s] the url to redirect to (e.g. www.example.com/path).
118
+ # @param protocol [:http, :https, :https_only]
119
+ # @param type [:cloak, :http301, :http302]
120
+ # @param override [Boolean] When you create a redirection on a domain, a DNS record is created
121
+ # if it does not exist. When the record already exists and this parameter is set to true it
122
+ # will overwrite the record. Otherwise it will trigger an error.
123
+ # @return [GandiV5::Domain::WebRedirection] the created redirection
124
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error
125
+ def self.create(domain:, host:, target:, protocol:, type:, override: false)
126
+ body = {
127
+ 'host' => host.to_s,
128
+ 'protocol' => protocol.to_s.delete('_'),
129
+ 'type' => type.to_s,
130
+ 'url' => target.to_s,
131
+ 'override' => override
132
+ }.to_json
133
+
134
+ GandiV5.post url(domain), body
135
+ fetch domain, host
136
+ end
137
+
138
+ # Get web redirect for a host in a domain.
139
+ # @see https://api.gandi.net/docs/domains/#get-v5-domain-domains-domain-webredirs-host
140
+ # @param domain [String, #to_s] the domain to get the web redirection for.
141
+ # @param host [String, #to_s] the host name to get the web redirection for.
142
+ # @return [GandiV5::Domain::WebRedirect]
143
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
144
+ def self.fetch(domain, host)
145
+ _response, data = GandiV5.get url(domain, host)
146
+ redirect = from_gandi data
147
+ redirect.instance_exec { @domain = domain }
148
+ redirect
149
+ end
150
+
151
+ # List web redirects for a domain.
152
+ # @see https://api.gandi.net/docs/domains/#get-v5-domain-domains-domain-webredirs-host
153
+ # @param domain [String, #to_s] the domain to get the web redirections for.
154
+ # @param page [#each<Integer, #to_s>] the page(s) of results to retrieve.
155
+ # If page is not provided keep querying until an empty list is returned.
156
+ # If page responds to .each then iterate until an empty list is returned.
157
+ # @param per_page [Integer, #to_s] (optional default 100) how many results to get per page.
158
+ # @return [Array<GandiV5::Domain::WebRedirect>]
159
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
160
+ def self.list(domain, page: (1..), per_page: 100)
161
+ redirects = []
162
+ GandiV5.paginated_get(url(domain), page, per_page) do |data|
163
+ redirects += data.map { |redirect| from_gandi redirect }
164
+ end
165
+ redirects.each { |redirect| redirect.instance_exec { @domain = domain } }
166
+ redirects
167
+ end
168
+
169
+ private
170
+
171
+ def url
172
+ "#{BASE}domain/domains/#{CGI.escape @domain}/webredirs/#{fqdn}"
173
+ end
174
+
175
+ def self.url(domain, host = nil)
176
+ "#{BASE}domain/domains/#{CGI.escape domain}/webredirs" +
177
+ (host ? "/#{CGI.escape host}.#{CGI.escape domain}" : '')
178
+ end
179
+ private_class_method :url
180
+ end
181
+ end
182
+ end
@@ -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
- # @see https://docs.gandi.net/en/domain_names/register/idn.html
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
@@ -20,7 +20,7 @@ class GandiV5
20
20
  # @return [String] one of: "clientHold", "clientUpdateProhibited", "clientTransferProhibited",
21
21
  # "clientDeleteProhibited", "clientRenewProhibited", "serverHold", "pendingTransfer",
22
22
  # "serverTransferProhibited"
23
- # @see https://docs.gandi.net/en/domain_names/faq/domain_statuses.html
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
@@ -84,10 +84,10 @@ class GandiV5
84
84
  hash = hash.transform_keys(&:to_sym)
85
85
  .transform_values { |value| GandiV5::Domain::Contact.from_gandi value }
86
86
 
87
- hash.define_singleton_method(:owner) { send :'[]', :owner }
88
- hash.define_singleton_method(:admin) { send :'[]', :admin }
89
- hash.define_singleton_method(:bill) { send :'[]', :bill }
90
- hash.define_singleton_method(:tech) { send :'[]', :tech }
87
+ hash.define_singleton_method(:owner) { send :[], :owner }
88
+ hash.define_singleton_method(:admin) { send :[], :admin }
89
+ hash.define_singleton_method(:bill) { send :[], :bill }
90
+ hash.define_singleton_method(:tech) { send :[], :tech }
91
91
 
92
92
  hash
93
93
  }
@@ -138,10 +138,8 @@ class GandiV5
138
138
 
139
139
  alias domain_uuid uuid
140
140
 
141
- # rubocop:disable Style/AsciiComments
142
141
  # Returns the string representation of the domain.
143
142
  # @return [String] e.g. "example.com", "😀.com (xn--e28h.uk.com)"
144
- # rubocop:enable Style/AsciiComments
145
143
  def to_s
146
144
  string = fqdn_unicode
147
145
  string += " (#{fqdn})" unless fqdn == fqdn_unicode
@@ -181,7 +179,7 @@ class GandiV5
181
179
  admin: admin.respond_to?(:to_gandi) ? admin.to_gandi : admin,
182
180
  bill: bill.respond_to?(:to_gandi) ? bill.to_gandi : bill,
183
181
  tech: tech.respond_to?(:to_gandi) ? tech.to_gandi : tech
184
- }.reject { |_k, v| v.nil? }.to_json
182
+ }.compact { |_k, v| v.nil? }.to_json
185
183
 
186
184
  GandiV5.patch url('contacts'), body
187
185
  fetch_contacts
@@ -206,7 +204,7 @@ class GandiV5
206
204
  end
207
205
 
208
206
  # Renew domain.
209
- # Warning! This is not a free operation. Please ensure your prepaid account has enough credit.
207
+ # @note This is not a free operation. Please ensure your prepaid account has enough credit.
210
208
  # @see https://api.gandi.net/docs/domains#post-v5-domain-domains-domain-renew
211
209
  # @param duration [Integer, #to_s] how long to renew for (in years).
212
210
  # @return [String] confirmation message from Gandi.
@@ -242,7 +240,7 @@ class GandiV5
242
240
  end
243
241
 
244
242
  # Restore an expired domain.
245
- # Warning! This is not a free operation. Please ensure your prepaid account has enough credit.
243
+ # @note This is not a free operation. Please ensure your prepaid account has enough credit.
246
244
  # @see https://docs.gandi.net/en/domain_names/renew/restore.html
247
245
  # @see https://api.gandi.net/docs/domains#post-v5-domain-domains-domain-restore
248
246
  # @return [String] The confirmation message from Gandi.
@@ -252,6 +250,29 @@ class GandiV5
252
250
  data['message']
253
251
  end
254
252
 
253
+ # Lock this domain - preventing it from being transfered.
254
+ # @see https://api.gandi.net/docs/domains/#patch-v5-domain-domains-domain-status
255
+ # Most extensions have a transfer protection mechanism, that consists of a lock that can be put
256
+ # on the domain. When the transfer lock is enabled, the domain can't be transferred.
257
+ # @params lock [Boolean] whether the domain should be locked (true) or unlocked (false)
258
+ # @return [String] The confirmation message from Gandi.
259
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
260
+ # rubocop:disable Style/OptionalBooleanParameter
261
+ def transfer_lock(lock = true)
262
+ _response, data = GandiV5.patch url('status'), { 'clientTransferProhibited' => lock }.to_json
263
+ @status = lock ? 'clientTransferProhibited' : nil
264
+ data['message']
265
+ end
266
+ # rubocop:enable Style/OptionalBooleanParameter
267
+
268
+ # Unlock this domain - allowing it to be transfered.
269
+ # @see https://api.gandi.net/docs/domains/#patch-v5-domain-domains-domain-status
270
+ # @return [String] The confirmation message from Gandi.
271
+ # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
272
+ def transfer_unlock
273
+ transfer_lock false
274
+ end
275
+
255
276
  # Requery Gandi fo this domain's information.
256
277
  # @return [GandiV5::Domain]
257
278
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
@@ -399,23 +420,39 @@ class GandiV5
399
420
  data['message']
400
421
  end
401
422
 
423
+ # Get email mailboxes for the domain.
402
424
  # @see GandiV5::Email::Mailbox.list
403
425
  def mailboxes(**params)
404
426
  GandiV5::Email::Mailbox.list(**params, fqdn: fqdn)
405
427
  end
406
428
 
429
+ # Get email slots for the domain.
407
430
  # @see GandiV5::Email::Slot.list
408
431
  def mailbox_slots(**params)
409
432
  GandiV5::Email::Slot.list(**params, fqdn: fqdn)
410
433
  end
411
434
 
435
+ # Get email forwards for the domain.
412
436
  # @see GandiV5::Email::Forward.list
413
437
  def email_forwards(**params)
414
438
  GandiV5::Email::Forward.list(**params, fqdn: fqdn)
415
439
  end
416
440
 
441
+ # Get web forwardings for the domain.
442
+ # @see GandiV5::Domain::WebRedirection.list
443
+ def web_forwardings(**params)
444
+ GandiV5::Domain::WebForwarding.list(fqdn, **params)
445
+ end
446
+
447
+ # Get a web forwarding.
448
+ # @see GandiV5::Domain::WebRedirection.fetch
449
+ # @param host [String, #to_s] the host the redirection is setup on.
450
+ def web_forwarding(host)
451
+ GandiV5::Domain::WebForwarding.fetch(fqdn, host)
452
+ end
453
+
417
454
  # Create (register) a new domain.
418
- # Warning! This is not a free operation. Please ensure your prepaid account has enough credit.
455
+ # @note This is not a free operation. Please ensure your prepaid account has enough credit.
419
456
  # @see https://api.gandi.net/docs/domains#post-v5-domain-domains
420
457
  # @param fqdn [String, #to_s] the fully qualified domain name to create.
421
458
  # @param dry_run [Boolean]
@@ -455,11 +492,13 @@ class GandiV5
455
492
  # List of nameservers. Gandi's LiveDNS nameservers are used if omitted..
456
493
  # @param price [Numeric, #to_gandi, #to_json] (optional) unknown - not documented at Gandi.
457
494
  # @param resellee_id [String, #to_gandi, #to_json] (optional) unknown - not documented at Gandi.
495
+ # @param template_id [String, #to_gandi] (optional)
496
+ # Template to be applied when the domain is created.
458
497
  # @param smd [String, #to_gandi, #to_json] (optional)
459
498
  # Contents of a Signed Mark Data file (used for newgtld sunrises, tld_period must be sunrise).
460
499
  # @param tld_period ["sunrise", "landrush", "eap1", "eap2", "eap3", "eap4", "eap5", "eap6",
461
500
  # "eap7", "eap8", "eap9", "golive", #to_gandi, #to_json] (optional)
462
- # @see https://docs.gandi.net/en/domain_names/register/new_gtld.html
501
+ # @see https://docs.gandi.net/en/domain_names/register/new_gtld.html
463
502
  # @return [GandiV5::Domain] the created domain
464
503
  # @return [Hash] if doing a dry run, you get what Gandi returns
465
504
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error
@@ -77,7 +77,7 @@ class GandiV5
77
77
  # @return [Array<GandiV5::Email::Forward>]
78
78
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
79
79
  def self.list(fqdn, page: (1..), per_page: 100, **params)
80
- params.reject! { |_k, v| v.nil? }
80
+ params.compact! { |_k, v| v.nil? }
81
81
 
82
82
  mailboxes = []
83
83
  GandiV5.paginated_get(url(fqdn), page, per_page, params: params) do |data|
@@ -29,9 +29,9 @@ class GandiV5
29
29
 
30
30
  TYPES = %i[standard premium free].freeze
31
31
  QUOTAS = {
32
- free: 3 * 1024**3,
33
- standard: 3 * 1024**3,
34
- premium: 50 * 1024**3
32
+ free: 3 * (1024**3),
33
+ standard: 3 * (1024**3),
34
+ premium: 50 * (1024**3)
35
35
  }.freeze
36
36
 
37
37
  members :address, :login, :quota_used, :aliases, :fallback_email
@@ -43,7 +43,7 @@ class GandiV5
43
43
  alias mailbox_uuid uuid
44
44
 
45
45
  # Create a new GandiV5::Email::Mailbox
46
- # @param members [Hash<Symbol => Object>]
46
+ # @param members [Hash{Symbol => Object}]
47
47
  # @return [GandiV5::Email::Slot]
48
48
  def initialize(**members)
49
49
  super(**members)
@@ -199,7 +199,7 @@ class GandiV5
199
199
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
200
200
  def self.list(fqdn, page: (1..), per_page: 100, **params)
201
201
  params['~login'] = params.delete(:login)
202
- params.reject! { |_k, v| v.nil? }
202
+ params.compact! { |_k, v| v.nil? }
203
203
 
204
204
  mailboxes = []
205
205
  GandiV5.paginated_get(url(fqdn), page, per_page, params: params) do |data|
@@ -265,7 +265,7 @@ class GandiV5
265
265
  def self.crypt_password(password)
266
266
  # You can also send a hashed password in sha512-crypt ie: {SHA512-CRYPT}$6$xxxx$yyyy
267
267
  salt = SecureRandom.random_number(36**8).to_s(36)
268
- password.crypt('$6$' + salt)
268
+ password.crypt("$6$#{salt}")
269
269
  end
270
270
  private_class_method :crypt_password
271
271
 
@@ -29,7 +29,7 @@ class GandiV5
29
29
  member(
30
30
  :capacity,
31
31
  converter: GandiV5::Data::Converter.new(
32
- from_gandi: ->(value) { value * 1_024**2 }
32
+ from_gandi: ->(value) { value * (1_024**2) }
33
33
  )
34
34
  )
35
35
  member :created_at, converter: GandiV5::Data::Converter::Time
@@ -2,6 +2,9 @@
2
2
 
3
3
  class GandiV5
4
4
  # Gandi Email Mailbox Management API.
5
+ # @see https://api.gandi.net/docs/email/
6
+ # rubocop:disable Lint/EmptyClass
5
7
  class Email
6
8
  end
9
+ # rubocop:enable Lint/EmptyClass
7
10
  end
@@ -5,6 +5,7 @@ class GandiV5
5
5
  # Generic error class for errors returned by Gandi.
6
6
  class GandiError < GandiV5::Error
7
7
  # Generate a new GandiV5::Error::GandiError from the hash returned by Gandi.
8
+ # @api private
8
9
  # @param hash [Hash] the hash returned by Gandi.
9
10
  # @return [GandiV5::Error::GandiError]
10
11
  def self.from_hash(hash)
@@ -4,27 +4,27 @@ class GandiV5
4
4
  class LiveDNS
5
5
  class Domain
6
6
  # A DNSSEC key for a domain's DNS records.
7
- # @!attribyte [r] uuid
7
+ # @!attribute [r] uuid
8
8
  # @return [String]
9
- # @!attribyte [r] status
9
+ # @!attribute [r] status
10
10
  # @return [String]
11
- # @!attribyte [r] fqdn
11
+ # @!attribute [r] fqdn
12
12
  # @return [String]
13
- # @!attribyte [r] algorithm_id
13
+ # @!attribute [r] algorithm_id
14
14
  # @return [Integer]
15
- # @!attribyte [r] algorithm_name
15
+ # @!attribute [r] algorithm_name
16
16
  # @return [String]
17
- # @!attribyte [r] deleted
17
+ # @!attribute [r] deleted
18
18
  # @return [Boolean]
19
- # @!attribyte [r] ds
19
+ # @!attribute [r] ds
20
20
  # @return [String]
21
- # @!attribyte [r] flags
21
+ # @!attribute [r] flags
22
22
  # @return [Integer]
23
- # @!attribyte [r] fingerprint
23
+ # @!attribute [r] fingerprint
24
24
  # @return [String]
25
- # @!attribyte [r] public_key
25
+ # @!attribute [r] public_key
26
26
  # @return [String]
27
- # @!attribyte [r] tag
27
+ # @!attribute [r] tag
28
28
  # @return [String]
29
29
  class DnssecKey
30
30
  include GandiV5::Data
@@ -36,6 +36,7 @@ class GandiV5
36
36
  member :algorithm_id, gandi_key: 'algorithm'
37
37
 
38
38
  # Delete this key.
39
+ # @see https://api.gandi.net/docs/livedns/#delete-v5-livedns-domains-fqdn-keys-id
39
40
  # @return [String] The confirmation message from Gandi.
40
41
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
41
42
  def delete
@@ -45,6 +46,7 @@ class GandiV5
45
46
  end
46
47
 
47
48
  # Undelete this key.
49
+ # @see https://api.gandi.net/docs/livedns/#patch-v5-livedns-domains-fqdn-keys-id
48
50
  # @return [String] The confirmation message from Gandi.
49
51
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
50
52
  def undelete
@@ -66,6 +68,7 @@ class GandiV5
66
68
  end
67
69
 
68
70
  # Create a new DNSSEC key for a zone.
71
+ # @see https://api.gandi.net/docs/livedns/#post-v5-livedns-domains-fqdn-keys
69
72
  # @param fqdn [String, #to_s] the fully qualified domain to create the key for.
70
73
  # @param flags [Integer, :key_signing_key, :zone_signing_key] the key's flags.
71
74
  # @return [GandiV5::LiveDNS::Domain::DnssecKey]
@@ -80,6 +83,7 @@ class GandiV5
80
83
  end
81
84
 
82
85
  # Get keys for a FQDN from Gandi.
86
+ # @see https://api.gandi.net/docs/livedns/#get-v5-livedns-domains-fqdn-keys
83
87
  # @param fqdn [String, #to_s] The fully qualified domain name to get the keys for.
84
88
  # @return [Array<GandiV5::LiveDNS::Domain::DnssecKey>]
85
89
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
@@ -89,6 +93,7 @@ class GandiV5
89
93
  end
90
94
 
91
95
  # Get DNSSEC key from Gandi.
96
+ # @see https://api.gandi.net/docs/livedns/#get-v5-livedns-domains-fqdn-keys-id
92
97
  # @param fqdn [String, #to_s] The fully qualified domain name the key was made for.
93
98
  # @param uuid [String, #to_s] the UUID of the key to fetch.
94
99
  # @return [GandiV5::LiveDNS::Domain::DnssecKey]
@@ -30,6 +30,7 @@ class GandiV5
30
30
  alias snapshot_uuid uuid
31
31
 
32
32
  # Delete this snapshot.
33
+ # @see https://api.gandi.net/docs/livedns/#delete-v5-livedns-domains-fqdn-snapshots-id
33
34
  # @return [String] The confirmation message from Gandi.
34
35
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
35
36
  def delete
@@ -38,6 +39,7 @@ class GandiV5
38
39
  end
39
40
 
40
41
  # Update this snapshot.
42
+ # @see https://api.gandi.net/docs/livedns/#patch-v5-livedns-domains-fqdn-snapshots-id
41
43
  # @param name [String, #to_s] new name for the snapshot.
42
44
  # @return [String] The confirmation message from Gandi.
43
45
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
@@ -48,6 +50,7 @@ class GandiV5
48
50
  end
49
51
 
50
52
  # Get snapshot details for this FQDN from Gandi.
53
+ # @see https://api.gandi.net/docs/livedns/#get-v5-livedns-domains-fqdn-snapshots
51
54
  # @param fqdn [String, #to_s] The fully qualified domain name to get the snapshots for.
52
55
  # @param page [#each<Integer, #to_s>] the page(s) of results to retrieve.
53
56
  # If page is not provided keep querying until an empty list is returned.
@@ -57,7 +60,7 @@ class GandiV5
57
60
  # @return [Array<GandiV5::LiveDNS::Domain::Snapshot>]
58
61
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
59
62
  def self.list(fqdn, page: (1..), per_page: 100, **params)
60
- params.reject! { |_k, v| v.nil? }
63
+ params.compact! { |_k, v| v.nil? }
61
64
 
62
65
  snapshots = []
63
66
  GandiV5.paginated_get(url(fqdn), page, per_page, params: params) do |data|
@@ -67,6 +70,7 @@ class GandiV5
67
70
  end
68
71
 
69
72
  # Get snapshot from Gandi.
73
+ # @see https://api.gandi.net/docs/livedns/#get-v5-livedns-domains-fqdn-snapshots-id
70
74
  # @param fqdn [String, #to_s] The fully qualified domain name the snapshot was made for.
71
75
  # @param uuid [String, #to_s] the UUID of the snapshot to fetch.
72
76
  # @return [GandiV5::LiveDNS::Domain::Snapshot]
@@ -4,13 +4,13 @@ class GandiV5
4
4
  class LiveDNS
5
5
  class Domain
6
6
  # A Tsig key.
7
- # @!attribyte [r] uuid
7
+ # @!attribute [r] uuid
8
8
  # @return [String]
9
- # @!attribyte [r] name
9
+ # @!attribute [r] name
10
10
  # @return [String]
11
- # @!attribyte [r] secret
11
+ # @!attribute [r] secret
12
12
  # @return [String]
13
- # @!attribyte [r] config_examples
13
+ # @!attribute [r] config_examples
14
14
  # @return [Hash<Symbol -> String>]
15
15
  class TsigKey
16
16
  include GandiV5::Data
@@ -23,11 +23,12 @@ class GandiV5
23
23
  gandi_key: 'config_samples',
24
24
  converter: GandiV5::Data::Converter.new(
25
25
  from_gandi: ->(value) { value.transform_keys(&:to_sym) },
26
- to_gandi: ->(_value) { nil }
26
+ to_gandi: ->(_value) {}
27
27
  )
28
28
  )
29
29
 
30
30
  # Create a new DNSSEC key for a zone.
31
+ # @see https://api.gandi.net/docs/livedns/#post-v5-livedns-axfr-tsig
31
32
  # @param sharing_id [nil, String, #to_s]
32
33
  # @return [GandiV5::LiveDNS::Domain::DnssecKey]
33
34
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
@@ -42,6 +43,7 @@ class GandiV5
42
43
  # Get keys from Gandi.
43
44
  # If you need the secret, fingerprint, public_key or tag attributes you'll need
44
45
  # to use GandiV5::LiveDNS::Domain::DnssecKey.fetch on each item.
46
+ # @see https://api.gandi.net/docs/livedns/#get-v5-livedns-axfr-tsig
45
47
  # @return [Array<GandiV5::LiveDNS::Domain::TsigKey>]
46
48
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.
47
49
  def self.list
@@ -50,6 +52,7 @@ class GandiV5
50
52
  end
51
53
 
52
54
  # Get Tsig key from Gandi.
55
+ # @see https://api.gandi.net/docs/livedns/#get-v5-livedns-axfr-tsig-id
53
56
  # @param uuid [String, #to_s] the UUID of the key to fetch.
54
57
  # @return [GandiV5::LiveDNS::Domain::TsigKey]
55
58
  # @raise [GandiV5::Error::GandiError] if Gandi returns an error.