gandi_v5 0.4.0 → 0.9.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 +70 -5
- data/LICENSE.md +2 -6
- data/README.md +65 -17
- data/lib/gandi_v5.rb +139 -70
- data/lib/gandi_v5/billing/info/prepaid.rb +1 -0
- data/lib/gandi_v5/data.rb +1 -0
- 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 +27 -0
- 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 +16 -17
- 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 +170 -0
- data/lib/gandi_v5/domain/transfer_in/availability.rb +51 -0
- data/lib/gandi_v5/email.rb +1 -0
- data/lib/gandi_v5/email/forward.rb +2 -8
- data/lib/gandi_v5/email/mailbox.rb +3 -9
- data/lib/gandi_v5/email/slot.rb +11 -3
- 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 +245 -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 +187 -0
- data/lib/gandi_v5/simple_hosting/instance/virtual_host/linked_dns_zone.rb +75 -0
- data/lib/gandi_v5/version.rb +1 -1
- data/spec/.rubocop.yml +50 -3
- 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/fetch.yml +8 -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_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/vcr/Examples/List_domain_renewals.yml +54 -0
- data/spec/fixtures/vcr/Examples/List_email_addresses.yml +103 -0
- data/spec/units/gandi_v5/data/converter/integer_spec.rb +16 -0
- 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_spec.rb +13 -39
- 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/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/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 +111 -14
- metadata +171 -48
- data/.gitignore +0 -26
- data/.rspec +0 -3
- data/.rubocop.yml +0 -30
- data/.travis.yml +0 -37
- 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 -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
data/.gitignore
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# Because this is a gem, ignore Gemfile.lock:
|
2
|
-
|
3
|
-
Gemfile.lock
|
4
|
-
|
5
|
-
# And because this is Ruby, ignore the following
|
6
|
-
# (source: https://github.com/github/gitignore/blob/master/Ruby.gitignore):
|
7
|
-
|
8
|
-
.ruby-version
|
9
|
-
notes.txt
|
10
|
-
todo.txt
|
11
|
-
*.gem
|
12
|
-
*.rbc
|
13
|
-
.bundle
|
14
|
-
.config
|
15
|
-
coverage
|
16
|
-
InstalledFiles
|
17
|
-
lib/bundler/man
|
18
|
-
pkg
|
19
|
-
rdoc
|
20
|
-
doc
|
21
|
-
spec/reports
|
22
|
-
test/tmp
|
23
|
-
test/version_tmp
|
24
|
-
tmp
|
25
|
-
gemfiles/*.lock
|
26
|
-
.yardoc
|
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require:
|
2
|
-
- rubocop-performance
|
3
|
-
AllCops:
|
4
|
-
TargetRubyVersion: 2.6.0
|
5
|
-
Gemspec/RequiredRubyVersion:
|
6
|
-
Enabled: false
|
7
|
-
Metrics/AbcSize:
|
8
|
-
Max: 20
|
9
|
-
Metrics/ClassLength:
|
10
|
-
Max: 250
|
11
|
-
Metrics/CyclomaticComplexity:
|
12
|
-
Max: 8
|
13
|
-
Metrics/MethodLength:
|
14
|
-
Max: 15
|
15
|
-
Metrics/ModuleLength:
|
16
|
-
Max: 200
|
17
|
-
Metrics/ParameterLists:
|
18
|
-
Max: 6
|
19
|
-
Style/DocumentationMethod:
|
20
|
-
Enabled: true
|
21
|
-
Style/HashEachMethods:
|
22
|
-
Enabled: true
|
23
|
-
Style/HashTransformKeys:
|
24
|
-
Enabled: true
|
25
|
-
Style/HashTransformValues:
|
26
|
-
Enabled: true
|
27
|
-
Style/SignalException:
|
28
|
-
Enabled: false
|
29
|
-
Layout/LineLength:
|
30
|
-
Max: 100
|
data/.travis.yml
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.6.0
|
4
|
-
- 2.6.1
|
5
|
-
- 2.6.2
|
6
|
-
- 2.6.3
|
7
|
-
- 2.6.4
|
8
|
-
- 2.6.5
|
9
|
-
- 2.6.6
|
10
|
-
- 2.7.0
|
11
|
-
- 2.7.1
|
12
|
-
gemfile:
|
13
|
-
- Gemfile
|
14
|
-
branches:
|
15
|
-
only:
|
16
|
-
- master
|
17
|
-
- staging
|
18
|
-
- /gh(?:\d)+(?:-.+)?/
|
19
|
-
- /dev_ver_\d+\.\d+/
|
20
|
-
env:
|
21
|
-
global:
|
22
|
-
# CC_TEST_REPORTER_ID for reporting test coverage to code climate
|
23
|
-
- secure: "C3AcK+/2A4h2+ZayJXc89EQp76o8/2RL03PdtVjWPI6cfBSwN174ImWSdIcs6+Bjv8GH+bADsM4epkTjI7H24wh80If/4jAZJMB6LsAxVC3rZVx2UfDghp1Lwcy6BkNx4VVXMQJUR4rA8fXNd1l6n2a72RbPhTaGYxggw+yiKYNjj5m/u3HWPzTQ9wIx/rLzb2shQU1P9tDX4eRqJixYsd8LvStvXewUKlTQSaxNczzfcSOmeJrrytJGuPQxgBx67hlN40cs84oEbhndjlekZRwYepsRcan9umJEDHnE+k0wLlz/vb2cshYp5tdcfkqspaEhUSV7Vr7ZQNIppI3XyY1hs/pTYc2Vytp3OiY0EXBjKRmiHcnmA8EIkrV9i4OSt6Af3EQJaYU56a0BCaEqzRoQJWOZDS8bVowuO4rY8/xINQBwTojIYAplI/vqX/7xvlRbzIgeWdpvQipPC01d2JtmI/5D1FdGWtzYcDCTRTbHyWmjhr7Jt8qEDMFkbpkcAQiS61baEQ0p4CxaLYm/lpPco1U3e/gMOb/EXDhOrF1I8lSBmVJE/Uz2/3kfOa1DQSxDSRmV1nU3pSd7PUi25Pdx0rezJjRl1UC2gnsNZrCLbplk+VkImXTt3iirV/RuHDo+YVT0efaws7TVH7Uf87jqWf4VZEw/KI3tzfF43CE="
|
24
|
-
before_install: gem update bundler
|
25
|
-
before_script:
|
26
|
-
- 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
|
27
|
-
script:
|
28
|
-
- bundle exec rubocop
|
29
|
-
- bundle exec rspec
|
30
|
-
after_script:
|
31
|
-
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
32
|
-
notifications:
|
33
|
-
slack:
|
34
|
-
on_success: always
|
35
|
-
on_failure: always
|
36
|
-
rooms:
|
37
|
-
- secure: Nx1TmVs32ILAvH3Cv+jX6rZh1hgx3YaY9azC3PIaJba/bF9xXY1l8L4wF0dJGupQlFP3lWN3Y/aPIJo3SNbH+qll9o317105FfTecPWloyiDgWvz5qPz+oh5MImBUs220jW2XsaACfZkGTUsQt8OUCfhtUeUiW+YqqfAZEwnl+0TyTSFBSLKSNdMcT0sKYPb0IuX5WrOspokSoE9+QL5k0cNN8d78MvtUIC6Em5/ffKVbk4TulQhbzyUhIlPDoxVELq16dQ7njyWJb58khOCaJGV7a2NdFvFCJqImFVQPRT5Ad6EJMQ461cdPY5+ZwxDGlIkA5Srt1L+CyV2wJtMarCIPoGQaxuOTVjNiedEmzblg3K9VXkI7Q5LupJ+vOBhtUS54ODYVBnQgoNVPuRe6T81VZ7NCejeest9bqga8QAVVNhKvMvb6l+YXabnPo7okDZM4+4AlaG/pBKWKjxDJ5QXlbRUZqnJt36sA7y3wvIxnYMX45oaqLD9OS8DQ7Va9+9bsPGZnI0oQrkoPGazGnCryvNtEdl+Qy2KSFaocJL7XLavmAYCmqnNGIaO0eiI+VoX9rvOadDNaPJoa6G4YpO+yTBlx1mxLjneY3FfCHZ1lma7UxzV0t0AVYZtnYBalXbw3mvIWEg6PPRI2uXGCvwUBrNCQqonULsRTFSseMw=
|
data/FUNDING.yml
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
2
|
-
patreon: robertgauld
|
3
|
-
open_collective: # Replace with a single Open Collective username
|
4
|
-
ko_fi: # Replace with a single Ko-fi username
|
5
|
-
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
6
|
-
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
7
|
-
liberapay: # Replace with a single Liberapay username
|
8
|
-
issuehunt: # Replace with a single IssueHunt username
|
9
|
-
otechie: # Replace with a single Otechie username
|
10
|
-
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
data/Gemfile
DELETED
data/Guardfile
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
guard :bundler do
|
4
|
-
watch(/^Gemfile(?:\.lock)$/)
|
5
|
-
watch(/^.+\.gemspec$/)
|
6
|
-
end
|
7
|
-
|
8
|
-
# rubocop:disable Metrics/BlockLength
|
9
|
-
group :red_green_refactor, halt_on_fail: true do
|
10
|
-
group :rspec do
|
11
|
-
guard(
|
12
|
-
:rspec,
|
13
|
-
all_on_start: true,
|
14
|
-
all_after_pass: false,
|
15
|
-
notification: :failed,
|
16
|
-
cmd: 'bundle exec rspec'
|
17
|
-
) do
|
18
|
-
watch(%r{^spec/.+_spec\.rb$})
|
19
|
-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/units/#{m[1]}_spec.rb" }
|
20
|
-
watch('spec/spec_helper.rb') { 'spec' }
|
21
|
-
watch(%r{^spec/.+_shared\.rb$}) { 'spec' }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
group :rubocop do
|
26
|
-
guard(
|
27
|
-
:rubocop,
|
28
|
-
all_on_start: true,
|
29
|
-
all_after_pass: false,
|
30
|
-
notification: :failed,
|
31
|
-
keep_failed: false
|
32
|
-
) do
|
33
|
-
watch(%r{^lib/(.+)\.rb$}) { |m| [m[0], "spec/units/#{m[1]}_spec.rb"] }
|
34
|
-
watch(%r{^spec/.+?/(.+)_spec\.rb$}) { |m| [m[0], "lib/#{m[1]}.rb"] }
|
35
|
-
watch(%r{^(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
# rubocop:enable Metrics/BlockLength
|
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
Dotenv.load
|
5
|
-
|
6
|
-
unless ENV.key?('GANDI_API_KEY')
|
7
|
-
puts 'YOU MUST SET YOUR API KEY -> GandiV5.api_key = \'…\''
|
8
|
-
puts 'You can avoid having to do this by'
|
9
|
-
puts 'setting the environment variable GANDI_API_KEY.'
|
10
|
-
end
|
11
|
-
|
12
|
-
require 'irb'
|
13
|
-
IRB.start
|
data/gandi_v5.gemspec
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
4
|
-
require File.join(File.dirname(__FILE__), 'lib', 'gandi_v5', 'version')
|
5
|
-
|
6
|
-
Gem::Specification.new do |gem|
|
7
|
-
gem.name = 'gandi_v5'
|
8
|
-
gem.license = 'BSD 3 clause'
|
9
|
-
gem.version = GandiV5::VERSION
|
10
|
-
gem.authors = ['Robert Gauld']
|
11
|
-
gem.email = ['robert@robertgauld.co.uk']
|
12
|
-
gem.homepage = 'https://github.com/robertgauld/gandi_v5'
|
13
|
-
gem.summary = 'Make use of Gandi\'s V5 API.'
|
14
|
-
|
15
|
-
gem.files = `git ls-files`.split("\n")
|
16
|
-
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
-
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
18
|
-
gem.require_paths = ['lib']
|
19
|
-
|
20
|
-
gem.required_ruby_version = '>= 2.4'
|
21
|
-
gem.required_rubygems_version = '>= 2.6.14'
|
22
|
-
|
23
|
-
gem.add_dependency 'dotenv', '~> 2.5'
|
24
|
-
gem.add_dependency 'rest-client', '>= 2', '< 3'
|
25
|
-
gem.add_dependency 'zeitwerk', '~> 2.1'
|
26
|
-
|
27
|
-
gem.add_development_dependency 'coveralls', '~> 0.8'
|
28
|
-
gem.add_development_dependency 'guard', '~> 2.15'
|
29
|
-
gem.add_development_dependency 'guard-bundler', '~> 2.2'
|
30
|
-
gem.add_development_dependency 'guard-rspec', '~> 4.2', '>= 4.2.5'
|
31
|
-
gem.add_development_dependency 'guard-rubocop', '~> 1.3'
|
32
|
-
gem.add_development_dependency 'rake', '~> 12.0'
|
33
|
-
gem.add_development_dependency 'rb-inotify', '~> 0.9'
|
34
|
-
gem.add_development_dependency 'rspec', '>= 3.7', '< 4'
|
35
|
-
gem.add_development_dependency 'rspec-its', '~> 1.3'
|
36
|
-
gem.add_development_dependency 'rubocop', '~> 0.73'
|
37
|
-
gem.add_development_dependency 'rubocop-performance', '~> 1.1'
|
38
|
-
gem.add_development_dependency 'simplecov', '~> 0.7'
|
39
|
-
gem.add_development_dependency 'timecop', '~> 0.5'
|
40
|
-
gem.add_development_dependency 'vcr', '~> 4.0'
|
41
|
-
gem.add_development_dependency 'webmock', '~> 3.6'
|
42
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class GandiV5
|
4
|
-
class Domain
|
5
|
-
# Sharing space which contains a domain.
|
6
|
-
# @!attribute [r] uuid
|
7
|
-
# @return [String]
|
8
|
-
# @!attribute [r] name
|
9
|
-
# @return [String]
|
10
|
-
# @!attribute [r] reseller
|
11
|
-
# @return [nil, Boolean]
|
12
|
-
class SharingSpace
|
13
|
-
include GandiV5::Data
|
14
|
-
|
15
|
-
members :name, :reseller
|
16
|
-
member :uuid, gandi_key: 'id'
|
17
|
-
|
18
|
-
alias sharing_space_uuid uuid
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,153 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class GandiV5
|
4
|
-
class LiveDNS
|
5
|
-
# Methods for handling record related requests in both
|
6
|
-
# GandiV5::LiveDNS::Domain and GandiV5::LiveDNS::Zone.
|
7
|
-
module HasZoneRecords
|
8
|
-
# @overload fetch_records()
|
9
|
-
# Fetch all records for this domain.
|
10
|
-
# @overload fetch_records(name)
|
11
|
-
# Fetch records for a name.
|
12
|
-
# @param name [String] the name to fetch records for.
|
13
|
-
# @overload fetch_records(name, type)
|
14
|
-
# Fetch records of a type for a name.
|
15
|
-
# @param name [String] the name to fetch records for.
|
16
|
-
# @param type [String] the record type to fetch.
|
17
|
-
# @return [Array<GandiV5::LiveDNS::RecordSet>]
|
18
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
19
|
-
def fetch_records(name = nil, type = nil)
|
20
|
-
GandiV5::LiveDNS.require_valid_record_type type if type
|
21
|
-
|
22
|
-
url_ = "#{url}/records"
|
23
|
-
url_ += "/#{CGI.escape name}" if name
|
24
|
-
url_ += "/#{CGI.escape type}" if type
|
25
|
-
|
26
|
-
_response, data = GandiV5.get url_
|
27
|
-
data = [data] unless data.is_a?(Array)
|
28
|
-
data.map { |item| GandiV5::LiveDNS::RecordSet.from_gandi item }
|
29
|
-
end
|
30
|
-
|
31
|
-
# @overload fetch_zone_lines()
|
32
|
-
# Fetch all records for this domain.
|
33
|
-
# @overload fetch_zone_lines(name)
|
34
|
-
# Fetch records for a name.
|
35
|
-
# @param name [String] the name to fetch records for.
|
36
|
-
# @overload fetch_zone_lines(name, type)
|
37
|
-
# Fetch records of a type for a name.
|
38
|
-
# @param name [String] the name to fetch records for.
|
39
|
-
# @param type [String] the record type to fetch.
|
40
|
-
# @return [String]
|
41
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
42
|
-
def fetch_zone_lines(name = nil, type = nil)
|
43
|
-
GandiV5::LiveDNS.require_valid_record_type type if type
|
44
|
-
|
45
|
-
url_ = "#{url}/records"
|
46
|
-
url_ += "/#{CGI.escape name}" if name
|
47
|
-
url_ += "/#{CGI.escape type}" if type
|
48
|
-
|
49
|
-
GandiV5.get(url_, accept: 'text/plain').last
|
50
|
-
end
|
51
|
-
|
52
|
-
# Add record to this domain.
|
53
|
-
# @param name [String]
|
54
|
-
# @param type [String]
|
55
|
-
# @param ttl [Integer]
|
56
|
-
# @param values [Array<String>]
|
57
|
-
# @return [String] The confirmation message from Gandi.
|
58
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
59
|
-
def add_record(name, type, ttl, *values)
|
60
|
-
GandiV5::LiveDNS.require_valid_record_type type
|
61
|
-
fail ArgumentError, 'ttl must be positive and non-zero' unless ttl.positive?
|
62
|
-
fail ArgumentError, 'there must be at least one value' if values.none?
|
63
|
-
|
64
|
-
body = {
|
65
|
-
rrset_name: name,
|
66
|
-
rrset_type: type,
|
67
|
-
rrset_ttl: ttl,
|
68
|
-
rrset_values: values
|
69
|
-
}.to_json
|
70
|
-
_response, data = GandiV5.post "#{url}/records", body
|
71
|
-
data['message']
|
72
|
-
end
|
73
|
-
|
74
|
-
# @overload delete_records()
|
75
|
-
# Delete all records for this domain.
|
76
|
-
# @overload delete_records(name)
|
77
|
-
# Delete records for a name.
|
78
|
-
# @param name [String] the name to delete records for.
|
79
|
-
# @overload delete_records(name, type)
|
80
|
-
# Delete records of a type for a name.
|
81
|
-
# @param name [String] the name to delete records for.
|
82
|
-
# @param type [String] the record type to delete.
|
83
|
-
# @return [nil]
|
84
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
85
|
-
def delete_records(name = nil, type = nil)
|
86
|
-
GandiV5::LiveDNS.require_valid_record_type(type) if type
|
87
|
-
|
88
|
-
url_ = "#{url}/records"
|
89
|
-
url_ += "/#{CGI.escape name}" if name
|
90
|
-
url_ += "/#{CGI.escape type}" if type
|
91
|
-
GandiV5.delete(url_).last
|
92
|
-
end
|
93
|
-
|
94
|
-
# Replace all records for this domain.
|
95
|
-
# @param records
|
96
|
-
# [Array<Hash<:name, :type => String, :ttl => Integer, :values => Array<String>>>]
|
97
|
-
# the records to add.
|
98
|
-
# @param text [String] zone file lines to replace the records with.
|
99
|
-
# @return [String] The confirmation message from Gandi.
|
100
|
-
# @raise [ArgumentError] if neither/both of records & test are passed.
|
101
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
102
|
-
def replace_records(records: nil, text: nil)
|
103
|
-
unless [records, text].count(&:nil?).eql?(1)
|
104
|
-
fail ArgumentError, 'you must pass ONE of records: or text:'
|
105
|
-
end
|
106
|
-
|
107
|
-
if records
|
108
|
-
body = {
|
109
|
-
items: records.map { |r| r.transform_keys { |k| "rrset_#{k}" } }
|
110
|
-
}.to_json
|
111
|
-
_response, data = GandiV5.put "#{url}/records", body
|
112
|
-
elsif text
|
113
|
-
_response, data = GandiV5.put "#{url}/records", text, 'content-type': 'text/plain'
|
114
|
-
end
|
115
|
-
data['message']
|
116
|
-
end
|
117
|
-
|
118
|
-
# @override replace_records_for(name, records)
|
119
|
-
# Replace records for a name in this domain.
|
120
|
-
# @param name [String]
|
121
|
-
# @param records
|
122
|
-
# [Array<Hash<type: String, ttl: Integer, values: Array<String>>>]
|
123
|
-
# the records to add.
|
124
|
-
# @override replace_records_for(name, values, type: nil, ttl: nil)
|
125
|
-
# Replace records for a name in this domain.
|
126
|
-
# @param name [String]
|
127
|
-
# @param type [String] the record type.
|
128
|
-
# @param ttl [Integer] the TTL to set for the record.
|
129
|
-
# @param values [Array<String>] the values to set for the record.
|
130
|
-
# @raise [ArgumentError] if ttl is present and type is absent.
|
131
|
-
# @return [String] The confirmation message from Gandi.
|
132
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
133
|
-
def replace_records_for(name, records, type: nil, ttl: nil)
|
134
|
-
fail ArgumentError, 'missing keyword: type' if ttl && type.nil?
|
135
|
-
|
136
|
-
if type
|
137
|
-
GandiV5::LiveDNS.require_valid_record_type type
|
138
|
-
body = { rrset_values: records, rrset_ttl: ttl }
|
139
|
-
# body[:rrset_ttl] = ttl if ttl
|
140
|
-
_response, data = GandiV5.put "#{url}/records/#{name}/#{type}", body.to_json
|
141
|
-
|
142
|
-
else
|
143
|
-
body = {
|
144
|
-
items: records.map { |r| r.transform_keys { |k| "rrset_#{k}" } }
|
145
|
-
}
|
146
|
-
_response, data = GandiV5.put "#{url}/records/#{name}", body.to_json
|
147
|
-
end
|
148
|
-
|
149
|
-
data['message']
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class GandiV5
|
4
|
-
class LiveDNS
|
5
|
-
# A record set which comes from either a domain or zone.
|
6
|
-
# @!attribute [r] type
|
7
|
-
# @return [String]
|
8
|
-
# @!attribute [r] ttl
|
9
|
-
# @return [Integer]
|
10
|
-
# @!attribute [r] name
|
11
|
-
# @return [String]
|
12
|
-
# @!attribute [r] values
|
13
|
-
# @return [Array<String>]
|
14
|
-
class RecordSet
|
15
|
-
include GandiV5::Data
|
16
|
-
|
17
|
-
member :type, gandi_key: 'rrset_type'
|
18
|
-
member :ttl, gandi_key: 'rrset_ttl'
|
19
|
-
member :name, gandi_key: 'rrset_name'
|
20
|
-
member :values, gandi_key: 'rrset_values'
|
21
|
-
|
22
|
-
# Generate zone file lines for the record.
|
23
|
-
# @return [String]
|
24
|
-
def to_s
|
25
|
-
values.map do |value|
|
26
|
-
"#{name}\t#{ttl}\tIN\t#{type}\t#{value}"
|
27
|
-
end.join("\n")
|
28
|
-
end
|
29
|
-
|
30
|
-
GandiV5::LiveDNS::RECORD_TYPES.each do |t|
|
31
|
-
# Check the record type.
|
32
|
-
# @return [Boolean]
|
33
|
-
define_method "#{t.downcase}?" do
|
34
|
-
type.eql?(t)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# Check the TTL's value in seconds.
|
39
|
-
# @param number [Integer] the number of second(s) to check against.
|
40
|
-
# @return [Boolean]
|
41
|
-
def second?(number = 1)
|
42
|
-
ttl == number
|
43
|
-
end
|
44
|
-
alias seconds? second?
|
45
|
-
|
46
|
-
# Check the TTL's value in minutes.
|
47
|
-
# @param number [Integer] the number of minute(s) to check against.
|
48
|
-
# @return [Boolean]
|
49
|
-
def minute?(number = 1)
|
50
|
-
ttl == number * 60
|
51
|
-
end
|
52
|
-
alias minutes? minute?
|
53
|
-
|
54
|
-
# Check the TTL's value in hours.
|
55
|
-
# @param number [Integer] the number of hour(s) to check against.
|
56
|
-
# @return [Boolean]
|
57
|
-
def hour?(number = 1)
|
58
|
-
ttl == number * 3_600
|
59
|
-
end
|
60
|
-
alias hours? hour?
|
61
|
-
|
62
|
-
# Check the TTL's value in days.
|
63
|
-
# @param number [Integer] the number of day(s) to check against.
|
64
|
-
# @return [Boolean]
|
65
|
-
def day?(number = 1)
|
66
|
-
ttl == number * 86_400
|
67
|
-
end
|
68
|
-
alias days? day?
|
69
|
-
|
70
|
-
# Check the TTL's value in weeks.
|
71
|
-
# @param number [Integer] the number of week(s) to check against.
|
72
|
-
# @return [Boolean]
|
73
|
-
def week?(number = 1)
|
74
|
-
ttl == number * 604_800
|
75
|
-
end
|
76
|
-
alias weeks? day?
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|