gandi_v5 0.3.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +56 -2
- data/.travis.yml +6 -1
- data/CHANGELOG.md +61 -0
- data/LICENSE.md +2 -6
- data/README.md +15 -9
- data/gandi_v5.gemspec +2 -2
- data/lib/gandi_v5.rb +40 -14
- data/lib/gandi_v5/data.rb +1 -2
- data/lib/gandi_v5/data/converter/integer.rb +26 -0
- data/lib/gandi_v5/domain.rb +13 -14
- data/lib/gandi_v5/email/forward.rb +2 -8
- data/lib/gandi_v5/email/mailbox.rb +57 -11
- data/lib/gandi_v5/email/slot.rb +11 -3
- data/lib/gandi_v5/live_dns.rb +0 -12
- data/lib/gandi_v5/live_dns/domain.rb +313 -29
- data/lib/gandi_v5/live_dns/domain/dnssec_key.rb +115 -0
- data/lib/gandi_v5/live_dns/domain/record.rb +81 -0
- data/lib/gandi_v5/live_dns/domain/snapshot.rb +107 -0
- data/lib/gandi_v5/live_dns/domain/tsig_key.rb +71 -0
- data/lib/gandi_v5/organization.rb +10 -0
- data/lib/gandi_v5/organization/customer.rb +90 -0
- data/lib/gandi_v5/sharing_space.rb +27 -0
- data/lib/gandi_v5/simple_hosting.rb +12 -0
- data/lib/gandi_v5/simple_hosting/instance.rb +242 -0
- data/lib/gandi_v5/simple_hosting/instance/application.rb +44 -0
- data/lib/gandi_v5/simple_hosting/instance/database.rb +19 -0
- data/lib/gandi_v5/simple_hosting/instance/language.rb +22 -0
- data/lib/gandi_v5/simple_hosting/instance/upgrade.rb +21 -0
- data/lib/gandi_v5/simple_hosting/instance/virtual_host.rb +187 -0
- data/lib/gandi_v5/simple_hosting/instance/virtual_host/linked_dns_zone.rb +74 -0
- data/lib/gandi_v5/version.rb +1 -1
- data/spec/.rubocop.yml +56 -2
- data/spec/fixtures/bodies/GandiV5_Domain/fetch.yml +8 -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_Organization_Customer/list.yml +8 -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/units/gandi_v5/data/converter/integer_spec.rb +16 -0
- data/spec/units/gandi_v5/domain_spec.rb +53 -43
- data/spec/units/gandi_v5/email/forward_spec.rb +5 -34
- data/spec/units/gandi_v5/email/mailbox_spec.rb +119 -37
- data/spec/units/gandi_v5/email/slot_spec.rb +10 -2
- 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/organization/customer_spec.rb +81 -0
- data/spec/units/gandi_v5/organization_spec.rb +14 -0
- data/spec/units/gandi_v5/sharing_space_spec.rb +4 -0
- data/spec/units/gandi_v5/simple_hosting/instance/application_spec.rb +37 -0
- data/spec/units/gandi_v5/simple_hosting/instance/database_spec.rb +4 -0
- data/spec/units/gandi_v5/simple_hosting/instance/language_spec.rb +4 -0
- data/spec/units/gandi_v5/simple_hosting/instance/upgrade_spec.rb +4 -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 +199 -0
- data/spec/units/gandi_v5/simple_hosting/instance_spec.rb +182 -0
- data/spec/units/gandi_v5/simple_hosting_spec.rb +9 -0
- data/spec/units/gandi_v5_spec.rb +139 -30
- metadata +50 -31
- data/lib/gandi_v5/domain/sharing_space.rb +0 -21
- 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 -45
- 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/domain/sharing_space_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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bcedab1f98eded02f20893ca2f4b8c5a47abe1d72d3e055ef5688b2969104df
|
4
|
+
data.tar.gz: 6db74218bd3914c662c2b6cac47c76a4d9497368f80b3ef4f31ad7e6537604a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29dad44ec126323a917bcc5c4ac8dd200e1acc7ac32cfdf7c4608a919dd872e9f2071031b371d7ad8bae8a2ed09e6bd2bf660d0095b59999859e91d180b53e70
|
7
|
+
data.tar.gz: 1d2c599205a31b449c003cf4e2628b0326cf90d45ae3c75a68356879e463ee708c6d81f5fb64e1ee75ffe73fbc5402cc3e2fc290fddfe6777c0fb304ccb45a8f
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -4,17 +4,71 @@ AllCops:
|
|
4
4
|
TargetRubyVersion: 2.6.0
|
5
5
|
Gemspec/RequiredRubyVersion:
|
6
6
|
Enabled: false
|
7
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
8
|
+
Enabled: true
|
9
|
+
Layout/SpaceAroundMethodCallOperator:
|
10
|
+
Enabled: true
|
11
|
+
Lint/DeprecatedOpenSSLConstant:
|
12
|
+
Enabled: true
|
13
|
+
Lint/MixedRegexpCaptureTypes:
|
14
|
+
Enabled: true
|
15
|
+
Lint/RaiseException:
|
16
|
+
Enabled: true
|
17
|
+
Lint/StructNewOverride:
|
18
|
+
Enabled: true
|
7
19
|
Metrics/AbcSize:
|
8
20
|
Max: 20
|
9
21
|
Metrics/ClassLength:
|
10
22
|
Max: 250
|
11
|
-
Metrics/
|
12
|
-
Max:
|
23
|
+
Metrics/CyclomaticComplexity:
|
24
|
+
Max: 8
|
13
25
|
Metrics/MethodLength:
|
14
26
|
Max: 15
|
15
27
|
Metrics/ModuleLength:
|
16
28
|
Max: 200
|
29
|
+
Metrics/ParameterLists:
|
30
|
+
Max: 6
|
31
|
+
Performance/AncestorsInclude:
|
32
|
+
Enabled: true
|
33
|
+
Performance/BigDecimalWithNumericArgument:
|
34
|
+
Enabled: true
|
35
|
+
Performance/RedundantSortBlock:
|
36
|
+
Enabled: true
|
37
|
+
Performance/RedundantStringChars:
|
38
|
+
Enabled: true
|
39
|
+
Performance/ReverseFirst:
|
40
|
+
Enabled: true
|
41
|
+
Performance/SortReverse:
|
42
|
+
Enabled: true
|
43
|
+
Performance/Squeeze:
|
44
|
+
Enabled: true
|
45
|
+
Performance/StringInclude:
|
46
|
+
Enabled: true
|
47
|
+
Style/AccessorGrouping:
|
48
|
+
Enabled: true
|
49
|
+
Style/BisectedAttrAccessor:
|
50
|
+
Enabled: true
|
17
51
|
Style/DocumentationMethod:
|
18
52
|
Enabled: true
|
53
|
+
Style/ExponentialNotation:
|
54
|
+
Enabled: true
|
55
|
+
Style/HashEachMethods:
|
56
|
+
Enabled: true
|
57
|
+
Style/HashTransformKeys:
|
58
|
+
Enabled: true
|
59
|
+
Style/HashTransformValues:
|
60
|
+
Enabled: true
|
61
|
+
Style/RedundantAssignment:
|
62
|
+
Enabled: true
|
63
|
+
Style/RedundantFetchBlock:
|
64
|
+
Enabled: true
|
65
|
+
Style/RedundantRegexpCharacterClass:
|
66
|
+
Enabled: true
|
67
|
+
Style/RedundantRegexpEscape:
|
68
|
+
Enabled: true
|
19
69
|
Style/SignalException:
|
20
70
|
Enabled: false
|
71
|
+
Style/SlicingWithRange:
|
72
|
+
Enabled: true
|
73
|
+
Layout/LineLength:
|
74
|
+
Max: 100
|
data/.travis.yml
CHANGED
@@ -5,6 +5,11 @@ rvm:
|
|
5
5
|
- 2.6.2
|
6
6
|
- 2.6.3
|
7
7
|
- 2.6.4
|
8
|
+
- 2.6.5
|
9
|
+
- 2.6.6
|
10
|
+
- 2.7.0
|
11
|
+
- 2.7.1
|
12
|
+
- truffleruby-20.1.0
|
8
13
|
gemfile:
|
9
14
|
- Gemfile
|
10
15
|
branches:
|
@@ -21,7 +26,7 @@ before_install: gem update bundler
|
|
21
26
|
before_script:
|
22
27
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter && chmod +x ./cc-test-reporter && ./cc-test-reporter before-build
|
23
28
|
script:
|
24
|
-
- bundle exec rubocop
|
29
|
+
- if [[ $(echo $TRAVIS_JOB_NUMBER | awk -F . '{ print $2 }') == '1' ]]; then bundle exec rubocop; fi
|
25
30
|
- bundle exec rspec
|
26
31
|
after_script:
|
27
32
|
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,66 @@
|
|
1
1
|
# Gandi V5 API Gem Changelog
|
2
2
|
|
3
|
+
## Version 0.8.0
|
4
|
+
|
5
|
+
* Domain:
|
6
|
+
* .list - add resellee_id filter
|
7
|
+
* Added simple hosting: (I don't use simple hosting myself so it's possible I've misread the docs and a bug is waiting to be found, please add an issue if I have)
|
8
|
+
* SimpleHosting::Instance
|
9
|
+
* SimpleHosting::Instance::VirtualHost
|
10
|
+
* SimpleHosting::Instance::Application
|
11
|
+
* SimpleHosting::Instance::Database
|
12
|
+
* SimpleHosting::Instance::Language
|
13
|
+
* SimpleHosting::Instance::Upgrade
|
14
|
+
* GandiV5::Domain::SharingSpace moved to GandiV5::SharingSpace
|
15
|
+
|
16
|
+
## Version 0.7.0
|
17
|
+
|
18
|
+
* LiveDNS:
|
19
|
+
* Rename LiveDNS::RecordSet to LiveDNS::Domain::Record
|
20
|
+
* Domains:
|
21
|
+
* .list now returns an array of strings
|
22
|
+
* Can no longer change the zone used by a domain
|
23
|
+
* Added automatic_snapshots attribute for whether snapshots are automatically created when a modification is made to this domain's records
|
24
|
+
* #replace_records and #replace_records_for merged into #replace_records
|
25
|
+
* If replacing with a zone file use the new #replace_zone_lines
|
26
|
+
* Added:
|
27
|
+
* .create
|
28
|
+
* .record_types
|
29
|
+
* .generic_name_servers(fqdn)
|
30
|
+
* #name_servers and #fetch_name_servers
|
31
|
+
* #tsig_keys, #fetch_tsig_keys, #add_tsig_key, #remove_tsig_key
|
32
|
+
* #axfr_clients, #fetch_axfr_clients, #add_axfr_client, #remove_axfr_client
|
33
|
+
* ::DnssecKeys, #dnssec_keys, #fetch_dnssec_keys
|
34
|
+
* Snapshots:
|
35
|
+
* Moved to live under LiveDNS::Domain not LiveDNS::Zone
|
36
|
+
* Are now accessed via the fully qualified domain name NOT the zone's UUID
|
37
|
+
* Ability to access the zone from a snapshot is removed
|
38
|
+
* Taking a snapshot now allows for named snapshots
|
39
|
+
* Added automatic attribute for when a snapshot was taken due to a zone change
|
40
|
+
* .list now returns an array of snapshots (records are fetched in a seperate request when first needed)
|
41
|
+
* Zone removed.
|
42
|
+
|
43
|
+
## Version 0.6.0
|
44
|
+
|
45
|
+
* GandiV5::Email::Slot.create now supports sharing_id
|
46
|
+
* GandiV5::Email::Slot.create's type argument is now named not positional
|
47
|
+
* Add reseller information to GandiV5::Domain
|
48
|
+
|
49
|
+
## Version 0.5.0
|
50
|
+
|
51
|
+
* Add support for truffleruby 20.1.0
|
52
|
+
* Fix issue with rails in production
|
53
|
+
|
54
|
+
## Version 0.4.0
|
55
|
+
|
56
|
+
* Fix exception when delete returns no content-type
|
57
|
+
* Add support for ruby 2.7.0
|
58
|
+
* Add up/downgrading mailbox offer
|
59
|
+
* Add dry run option to creating a mailbox
|
60
|
+
* Add sharing_id & dry run option for renewing domain
|
61
|
+
* Add listing customers under a reseller organization (GandiV5::Organization::Customer.list and GandiV5::Organization#customers)
|
62
|
+
* Add creating customer under a reseller organization (GandiV5::Organization::Customer.create and GandiV5::Organization#create_customer)
|
63
|
+
|
3
64
|
## Version 0.3.0
|
4
65
|
|
5
66
|
* Additions to GandiV5::Domain
|
data/LICENSE.md
CHANGED
@@ -1,14 +1,10 @@
|
|
1
|
-
##
|
2
|
-
Copyright (c) 2018, Robert Gauld. All rights reserved.
|
3
|
-
|
4
|
-
|
5
|
-
##License
|
1
|
+
## License
|
6
2
|
This code can be used under the BSD License (reproduced below).
|
7
3
|
Commiters to the project give Robert Gauld the right to redistribute their commits
|
8
4
|
under the BSD license.
|
9
5
|
|
10
6
|
|
11
|
-
###BSD License
|
7
|
+
### BSD License
|
12
8
|
Redistribution and use in source and binary forms, with or without modification,
|
13
9
|
are permitted provided that the following conditions are met:
|
14
10
|
|
data/README.md
CHANGED
@@ -8,9 +8,10 @@
|
|
8
8
|
This gem supports the following versions of ruby, it may work on other versions but is not tested against them so don't rely on it.
|
9
9
|
|
10
10
|
* ruby:
|
11
|
-
* 2.6.0 - 2.6.
|
11
|
+
* 2.6.0 - 2.6.6
|
12
|
+
* 2.7.0 - 2.7.1
|
13
|
+
* truffleruby 20.1.0
|
12
14
|
* jruby, once it's reached parity with ruby 2.6.x
|
13
|
-
* truffleruby, once it's reached parity with ruby 2.6.x
|
14
15
|
* rubinius, once it's reached parity with ruby 2.6.x
|
15
16
|
|
16
17
|
|
@@ -35,12 +36,12 @@ Details of the API can be found at:
|
|
35
36
|
If you're using bundler then add it to your Gemfile and run the bundle command.
|
36
37
|
|
37
38
|
```ruby
|
38
|
-
gem 'gandi_v5', '~> 0.
|
39
|
+
gem 'gandi_v5', '~> 0.7'
|
39
40
|
```
|
40
41
|
|
41
42
|
If you're not using bundler then install it from the command line.
|
42
43
|
```bash
|
43
|
-
gem install gandi_v5 -v '~> 0.
|
44
|
+
gem install gandi_v5 -v '~> 0.7'
|
44
45
|
```
|
45
46
|
|
46
47
|
## Usage
|
@@ -74,11 +75,16 @@ TODO: More examples!
|
|
74
75
|
|
75
76
|
We follow the [Semantic Versioning](http://semver.org/) concept.
|
76
77
|
|
77
|
-
| Gem Version | Gandi API Release Date
|
78
|
-
| --------------- |
|
79
|
-
| 0.
|
80
|
-
| 0.
|
81
|
-
| 0.
|
78
|
+
| Gem Version | Gandi API Release Date |
|
79
|
+
| --------------- | ------------------------ |
|
80
|
+
| 0.8.0 | 2020-07-10 |
|
81
|
+
| 0.7.0 | 2020-05-07 |
|
82
|
+
| 0.6.0 | 2020-05-07 (not LiveDNS) |
|
83
|
+
| 0.5.0 | 2019-10-01 |
|
84
|
+
| 0.4.0 | 2019-10-01 |
|
85
|
+
| 0.3.0 | 2019-08-22 |
|
86
|
+
| 0.2.0 | 2019-05-16 |
|
87
|
+
| 0.1.0 | 2019-05-16 |
|
82
88
|
|
83
89
|
See <https://api.gandi.net/docs/reference#API-Changelog> to find out what
|
84
90
|
Gandi changed on each date.
|
data/gandi_v5.gemspec
CHANGED
@@ -33,8 +33,8 @@ Gem::Specification.new do |gem|
|
|
33
33
|
gem.add_development_dependency 'rb-inotify', '~> 0.9'
|
34
34
|
gem.add_development_dependency 'rspec', '>= 3.7', '< 4'
|
35
35
|
gem.add_development_dependency 'rspec-its', '~> 1.3'
|
36
|
-
gem.add_development_dependency 'rubocop', '~> 0.
|
37
|
-
gem.add_development_dependency 'rubocop-performance', '~> 1.
|
36
|
+
gem.add_development_dependency 'rubocop', '~> 0.87'
|
37
|
+
gem.add_development_dependency 'rubocop-performance', '~> 1.7'
|
38
38
|
gem.add_development_dependency 'simplecov', '~> 0.7'
|
39
39
|
gem.add_development_dependency 'timecop', '~> 0.5'
|
40
40
|
gem.add_development_dependency 'vcr', '~> 4.0'
|
data/lib/gandi_v5.rb
CHANGED
@@ -17,6 +17,8 @@ class MyInflector < Zeitwerk::Inflector
|
|
17
17
|
'LiveDNS'
|
18
18
|
when 'tld'
|
19
19
|
'TLD'
|
20
|
+
when 'version'
|
21
|
+
'VERSION'
|
20
22
|
else
|
21
23
|
super
|
22
24
|
end
|
@@ -80,6 +82,36 @@ class GandiV5
|
|
80
82
|
handle_bad_request(e)
|
81
83
|
end
|
82
84
|
|
85
|
+
# Might raise:
|
86
|
+
# * RestClient::NotFound
|
87
|
+
# * RestClient::Unauthorized
|
88
|
+
# Bad authentication attempt because of a wrong API Key.
|
89
|
+
# * RestClient::Forbidden
|
90
|
+
# Access to the resource is denied.
|
91
|
+
# Mainly due to a lack of permissions to access it.
|
92
|
+
# * GandiV5::Error
|
93
|
+
# * JSON::ParserError
|
94
|
+
def paginated_get(url, page = (1..), per_page = 100, **headers)
|
95
|
+
unless page.respond_to?(:each)
|
96
|
+
fail ArgumentError, 'page must be positive' unless page.positive?
|
97
|
+
|
98
|
+
page = [page]
|
99
|
+
end
|
100
|
+
|
101
|
+
headers[:params] ||= {}
|
102
|
+
headers[:params].transform_keys!(&:to_s)
|
103
|
+
headers[:params]['per_page'] = per_page
|
104
|
+
|
105
|
+
page.each do |page_number|
|
106
|
+
headers[:params]['page'] = page_number
|
107
|
+
_resp, this_data = get(url, **headers)
|
108
|
+
break if this_data.empty?
|
109
|
+
|
110
|
+
yield this_data
|
111
|
+
break if this_data.count < per_page
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
83
115
|
# Might raise:
|
84
116
|
# * RestClient::NotFound
|
85
117
|
# * RestClient::Unauthorized
|
@@ -93,7 +125,10 @@ class GandiV5
|
|
93
125
|
def delete(url, **headers)
|
94
126
|
prepare_headers headers, url
|
95
127
|
response = RestClient.delete url, **headers
|
96
|
-
[
|
128
|
+
[
|
129
|
+
response,
|
130
|
+
response.headers.key?(:content_type) ? parse_response(response) : nil
|
131
|
+
]
|
97
132
|
rescue RestClient::BadRequest => e
|
98
133
|
handle_bad_request(e)
|
99
134
|
end
|
@@ -164,16 +199,6 @@ class GandiV5
|
|
164
199
|
@api_key ||= ENV.fetch('GANDI_API_KEY')
|
165
200
|
end
|
166
201
|
|
167
|
-
def authorisation_header(url)
|
168
|
-
if url.start_with?(BASE)
|
169
|
-
{ Authorization: "Apikey #{api_key}" }
|
170
|
-
elsif url.start_with?(GandiV5::LiveDNS::BASE)
|
171
|
-
{ 'X-Api-Key': api_key }
|
172
|
-
else
|
173
|
-
fail ArgumentError, "Don't know how to authorise for url: #{url}"
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
202
|
def parse_response(response)
|
178
203
|
type = response.headers.fetch(:content_type).split(';').first.chomp
|
179
204
|
case type
|
@@ -191,10 +216,11 @@ class GandiV5
|
|
191
216
|
end
|
192
217
|
end
|
193
218
|
|
194
|
-
def prepare_headers(headers,
|
195
|
-
headers.transform_keys!
|
219
|
+
def prepare_headers(headers, _url)
|
220
|
+
headers.transform_keys! { |key| key.to_s.downcase.to_sym }
|
196
221
|
headers[:accept] ||= 'application/json'
|
197
|
-
headers
|
222
|
+
headers[:authorization] = "Apikey #{api_key}"
|
223
|
+
headers
|
198
224
|
end
|
199
225
|
|
200
226
|
def handle_bad_request(exception)
|
data/lib/gandi_v5/data.rb
CHANGED
@@ -179,9 +179,8 @@ class GandiV5
|
|
179
179
|
define_method "#{name}=" do |value|
|
180
180
|
instance_variable_set("@#{name}", value)
|
181
181
|
end
|
182
|
-
|
182
|
+
|
183
183
|
private "#{name}="
|
184
|
-
# rubocop:enable Style/AccessModifierDeclarations
|
185
184
|
end
|
186
185
|
|
187
186
|
# @api private
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GandiV5
|
4
|
+
module Data
|
5
|
+
class Converter
|
6
|
+
# Methods for converting strings to/from integerss.
|
7
|
+
class Integer
|
8
|
+
# @param value [Integer]
|
9
|
+
# @return [String]
|
10
|
+
def self.to_gandi(value)
|
11
|
+
return nil if value.nil?
|
12
|
+
|
13
|
+
value.to_s
|
14
|
+
end
|
15
|
+
|
16
|
+
# @param [String]
|
17
|
+
# @return value [Integer]
|
18
|
+
def self.from_gandi(value)
|
19
|
+
return nil if value.nil?
|
20
|
+
|
21
|
+
value.to_i
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/gandi_v5/domain.rb
CHANGED
@@ -15,7 +15,7 @@ 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",
|
@@ -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(
|
@@ -211,10 +211,13 @@ class GandiV5
|
|
211
211
|
# @param duration [Integer, #to_s] how long to renew for (in years).
|
212
212
|
# @return [String] confirmation message from Gandi.
|
213
213
|
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
214
|
-
def renew_for(duration = 1)
|
214
|
+
def renew_for(duration = 1, sharing_id: nil, dry_run: false)
|
215
215
|
body = { duration: duration }.to_json
|
216
|
-
|
217
|
-
|
216
|
+
url_ = url('renew')
|
217
|
+
url_ = sharing_id ? "#{url_}?sharing_id=#{sharing_id}" : url_
|
218
|
+
|
219
|
+
_response, data = GandiV5.post(url_, body, 'Dry-Run': dry_run ? 1 : 0)
|
220
|
+
dry_run ? data : data['message']
|
218
221
|
end
|
219
222
|
|
220
223
|
# Restoration information for the domain.
|
@@ -489,24 +492,20 @@ class GandiV5
|
|
489
492
|
# @param page [#each<Integer, #to_s>] the page(s) of results to retrieve.
|
490
493
|
# If page is not provided keep querying until an empty list is returned.
|
491
494
|
# If page responds to .each then iterate until an empty list is returned.
|
492
|
-
# @param per_page [Integer, #to_s] (optional default 100) how many results
|
495
|
+
# @param per_page [Integer, #to_s] (optional default 100) how many results to get per page.
|
493
496
|
# @param fqdn [String, #to_s] (optional)
|
494
497
|
# filters the list by domain name, with optional patterns.
|
495
498
|
# e.g. "example.net", "example.*", "*ample.com"
|
496
|
-
# @param
|
499
|
+
# @param resellee_id [String, #to_s] (optional)
|
500
|
+
# filters the list by resellee_id (from the Organization API).
|
497
501
|
# @param tld [String, #to_s] (optional) used to filter by just the top level domain.
|
502
|
+
# @param sort_by [String, #to_s] (optional default "fqdn") how to sort the list.
|
498
503
|
# @return [Array<GandiV5::Domain>]
|
499
504
|
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
500
505
|
def self.list(page: (1..), per_page: 100, **params)
|
501
|
-
page = [page.to_i] unless page.respond_to?(:each)
|
502
|
-
|
503
506
|
domains = []
|
504
|
-
|
505
|
-
_resp, data = GandiV5.get url, params: params.merge(page: page_number, per_page: per_page)
|
506
|
-
break if data.empty?
|
507
|
-
|
507
|
+
GandiV5.paginated_get(url, page, per_page, params: params) do |data|
|
508
508
|
domains += data.map { |domain| from_gandi domain }
|
509
|
-
break if data.count < per_page
|
510
509
|
end
|
511
510
|
domains
|
512
511
|
end
|