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
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GandiV5
|
4
|
+
class Template
|
5
|
+
class Payload
|
6
|
+
# Web forwarding details of a configuration template.
|
7
|
+
# @!attribute [r] type
|
8
|
+
# @return [:cloak, :http301, :http302]
|
9
|
+
# @!attribute [r] target
|
10
|
+
# @return [String]
|
11
|
+
# @!attribute [r] fqdn
|
12
|
+
# @return [String, nil]
|
13
|
+
# @!attribute [r] override
|
14
|
+
# @return [Boolean, nil]
|
15
|
+
# when you create a redirection on a domain, a DNS record is created if it does not exist.
|
16
|
+
# When the record already exists and this parameter is set to true it will
|
17
|
+
# overwrite the record. Otherwise it will trigger an error.
|
18
|
+
# @!attribute [r] protocol
|
19
|
+
# @return [:http, :https, :https_only, nil]
|
20
|
+
class WebForwarding
|
21
|
+
include GandiV5::Data
|
22
|
+
|
23
|
+
member :type, converter: GandiV5::Data::Converter::Symbol
|
24
|
+
member :target, gandi_key: 'url'
|
25
|
+
member :fqdn, gandi_key: 'host'
|
26
|
+
member :override
|
27
|
+
member(
|
28
|
+
:protocol,
|
29
|
+
converter: GandiV5::Data::Converter.new(
|
30
|
+
from_gandi: lambda { |value|
|
31
|
+
{
|
32
|
+
'http' => :http,
|
33
|
+
'https' => :https,
|
34
|
+
'httpsonly' => :https_only
|
35
|
+
}.fetch(value)
|
36
|
+
}
|
37
|
+
)
|
38
|
+
)
|
39
|
+
|
40
|
+
# Check if this is an HTTP 301 (permanent) redirection.
|
41
|
+
def http301?
|
42
|
+
type == :http301
|
43
|
+
end
|
44
|
+
|
45
|
+
# Check if this is an HTTP 302 (found) redirection.
|
46
|
+
def http302?
|
47
|
+
type == :http302
|
48
|
+
end
|
49
|
+
|
50
|
+
# Check if this is an HTTP 301 (permanent) redirection.
|
51
|
+
def permanent?
|
52
|
+
type == :http301
|
53
|
+
end
|
54
|
+
|
55
|
+
# Check if this is an HTTP 302 (found) redirection.
|
56
|
+
def found?
|
57
|
+
type == :http302
|
58
|
+
end
|
59
|
+
|
60
|
+
# Check if this is a temporary redirection.
|
61
|
+
def temporary?
|
62
|
+
type == :http302
|
63
|
+
end
|
64
|
+
|
65
|
+
# Check if it's an http end point
|
66
|
+
def http?
|
67
|
+
protocol == :http || protocol == :https
|
68
|
+
end
|
69
|
+
|
70
|
+
# Check if it's an https end point
|
71
|
+
def https?
|
72
|
+
protocol == :https || protocol == :https_only
|
73
|
+
end
|
74
|
+
|
75
|
+
# Check if it's an https only
|
76
|
+
def https_only?
|
77
|
+
protocol == :https_only
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/lib/gandi_v5/version.rb
CHANGED
data/spec/.rubocop.yml
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.6.0
|
5
|
+
NewCops: enable
|
3
6
|
Layout/LineLength:
|
4
7
|
Max: 125
|
5
|
-
|
6
|
-
Enabled:
|
7
|
-
|
8
|
-
|
9
|
-
Style/HashTransformValues:
|
10
|
-
Enabled: true
|
11
|
-
|
8
|
+
Lint/ConstantDefinitionInBlock:
|
9
|
+
Enabled: false
|
10
|
+
Metrics/BlockLength:
|
11
|
+
Max: 750
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe 'Examples', :vcr do
|
4
|
+
it 'List domain renewals' do
|
5
|
+
expect($stdout).to receive(:puts).with("2021-03-12\t£8.87\texample.com")
|
6
|
+
|
7
|
+
# For each domain (sorted by assending renewal date) print <date>\t<cost>\t<fqdn>
|
8
|
+
GandiV5::Domain.list.each do |domain|
|
9
|
+
puts [
|
10
|
+
domain.dates.registry_ends_at.to_date,
|
11
|
+
"£#{domain.renewal_price.price_after_taxes}",
|
12
|
+
domain.fqdn
|
13
|
+
].join("\t")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe 'Examples', :vcr do
|
4
|
+
it 'List email addresses' do
|
5
|
+
expect($stdout).to receive(:puts).with("alias@example.com\talias for user@example.com").ordered
|
6
|
+
expect($stdout).to receive(:puts).with("forward@example.com\tforwards to user@example.com").ordered
|
7
|
+
expect($stdout).to receive(:puts).with("user@example.com\tstandard mailbox (0% of 3GB used)").ordered
|
8
|
+
|
9
|
+
# For each domain:
|
10
|
+
# 1. Create an empty hash to store address => description
|
11
|
+
# 2. Get the mailboxes and add them to the hash
|
12
|
+
# 3. Get the forwards and add them to the hash
|
13
|
+
# 4. Sort the hash by email address
|
14
|
+
# 5. Print the list
|
15
|
+
GandiV5::Domain.list.each do |domain|
|
16
|
+
emails = {}
|
17
|
+
|
18
|
+
mailboxes = GandiV5::Email::Mailbox.list(domain.fqdn)
|
19
|
+
mailboxes.each do |mailbox|
|
20
|
+
mailbox.refresh
|
21
|
+
emails["#{mailbox.login}@#{domain.fqdn}"] = "#{mailbox.type} mailbox " \
|
22
|
+
"(#{mailbox.quota_usage.to_i}% " \
|
23
|
+
"of #{(mailbox.quota / 1024**3).round}GB used)"
|
24
|
+
mailbox.aliases.each do |alias_name|
|
25
|
+
emails["#{alias_name}@#{domain.fqdn}"] = "alias for #{mailbox.login}@#{domain.fqdn}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
forwards = GandiV5::Email::Forward.list(domain.fqdn)
|
30
|
+
forwards.each do |forward|
|
31
|
+
emails["#{forward.source}@#{domain.fqdn}"] = "forwards to #{forward.destinations.join(', ')}"
|
32
|
+
end
|
33
|
+
|
34
|
+
emails.sort.each do |address, text|
|
35
|
+
puts "#{address}\t#{text}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
created_at: '2011-02-21T10:39:00Z'
|
3
|
+
owner_contact: owner contact
|
4
|
+
params:
|
5
|
+
domain: example.com
|
6
|
+
duration: 1
|
7
|
+
reseller: reseller-uuid
|
8
|
+
tld: com
|
9
|
+
version: 0
|
10
|
+
step: step text
|
11
|
+
step_nb: 2
|
12
|
+
updated_at: '2011-02-22T10:39:00Z'
|
13
|
+
errortype: error-type
|
14
|
+
errortype_label: error label
|
15
|
+
foa:
|
16
|
+
- answer: ans
|
17
|
+
email: user@example.com
|
18
|
+
inner_step: inner-step
|
19
|
+
regac_at: '2011-02-23T10:39:00Z'
|
20
|
+
start_at: '2011-02-24T10:39:00Z'
|
21
|
+
transfer_procedure: transfer-procedure
|
@@ -0,0 +1,80 @@
|
|
1
|
+
---
|
2
|
+
access_information:
|
3
|
+
admin_url: admin.example.com/
|
4
|
+
database:
|
5
|
+
admins:
|
6
|
+
- type: phpMyAdmin
|
7
|
+
url: admin.example.com/phpmyadmin
|
8
|
+
username: database admin username
|
9
|
+
host: database.example.com
|
10
|
+
port: 1234
|
11
|
+
socket: /socket/for/database
|
12
|
+
deploy:
|
13
|
+
- cli:
|
14
|
+
init: cli init string
|
15
|
+
git:
|
16
|
+
deploy: git deploy string
|
17
|
+
remote: git remote string
|
18
|
+
url: git url string
|
19
|
+
sftp:
|
20
|
+
directory: sftp directory
|
21
|
+
document_root: sftp document root
|
22
|
+
server: sftp server
|
23
|
+
url: sftp url
|
24
|
+
vhost:
|
25
|
+
fqdn: example.com
|
26
|
+
href: link/to/href/details/virtualhost-uuid
|
27
|
+
user: A user
|
28
|
+
available_upgrade: false
|
29
|
+
console:
|
30
|
+
enabled: true
|
31
|
+
url: console.example.com/
|
32
|
+
created_at: 2020-01-02T12:34:56+00
|
33
|
+
database:
|
34
|
+
name: database name
|
35
|
+
status: database status
|
36
|
+
version: database version
|
37
|
+
datacenter:
|
38
|
+
code: FR-SD5
|
39
|
+
name: SD5
|
40
|
+
region: FR
|
41
|
+
expire_at: 2021-01-02T12:34:56+00
|
42
|
+
id: instance-uuid
|
43
|
+
is_trial: false
|
44
|
+
language:
|
45
|
+
name: ruby
|
46
|
+
single_application: true
|
47
|
+
status: great
|
48
|
+
version: "2.7"
|
49
|
+
name: instance name
|
50
|
+
sharing_space:
|
51
|
+
id: sharing-space-uuid
|
52
|
+
name: sharing space name
|
53
|
+
size: s+
|
54
|
+
snapshot_enabled: true
|
55
|
+
status: active
|
56
|
+
storage:
|
57
|
+
additional:
|
58
|
+
unit: GB
|
59
|
+
value: 10
|
60
|
+
base:
|
61
|
+
unit: GB
|
62
|
+
value: 20
|
63
|
+
total:
|
64
|
+
unit: GB
|
65
|
+
value: 30
|
66
|
+
vhosts:
|
67
|
+
- fqdn: vhost1.example.com
|
68
|
+
href: link/to.vhost/details
|
69
|
+
autorenew:
|
70
|
+
duration: 1
|
71
|
+
duration_type: m
|
72
|
+
compatible_applications:
|
73
|
+
- name: compatable name
|
74
|
+
parameters: {}
|
75
|
+
password_updated_at: 2020-06-02T12:34:56+00
|
76
|
+
upgrade_to:
|
77
|
+
- name: upgrade to name
|
78
|
+
status: upgrade to status
|
79
|
+
type: database
|
80
|
+
version: upgrade to version
|
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
- available_upgrade: true
|
3
|
+
created_at: 2020-01-02T12:34:56+00
|
4
|
+
database:
|
5
|
+
name: database name
|
6
|
+
status: database status
|
7
|
+
version: database version
|
8
|
+
datacenter:
|
9
|
+
code: FR-SD5
|
10
|
+
name: SD5
|
11
|
+
region: FR
|
12
|
+
expire_at: 2021-01-02T12:34:56+00
|
13
|
+
id: instance-uuid
|
14
|
+
language:
|
15
|
+
name: ruby
|
16
|
+
single_application: true
|
17
|
+
status: great
|
18
|
+
version: "2.7"
|
19
|
+
name: instance name
|
20
|
+
sharing_space:
|
21
|
+
id: sharing-space-uuid
|
22
|
+
name: sharing space name
|
23
|
+
size: s+
|
24
|
+
snapshot_enabled: true
|
25
|
+
status: active
|
26
|
+
storage:
|
27
|
+
additional:
|
28
|
+
unit: GB
|
29
|
+
value: 10
|
30
|
+
base:
|
31
|
+
unit: GB
|
32
|
+
value: 20
|
33
|
+
total:
|
34
|
+
unit: GB
|
35
|
+
value: 30
|
36
|
+
autorenew:
|
37
|
+
duration: 1
|
38
|
+
duration_type: m
|
@@ -0,0 +1,26 @@
|
|
1
|
+
---
|
2
|
+
created_at: 2020-01-02T12:34:56+00
|
3
|
+
fqdn: vh.example.com
|
4
|
+
is_a_test_vhost: false
|
5
|
+
linked_dns_zone:
|
6
|
+
allow_alteration: true
|
7
|
+
cname: cn
|
8
|
+
domain: example.com
|
9
|
+
ipv4: 1.2.3.4
|
10
|
+
ipv6: 1:2::3:4
|
11
|
+
is_alterable: true
|
12
|
+
is_root: true
|
13
|
+
key: www
|
14
|
+
txt: abcd1234
|
15
|
+
last_checked_status: unknown
|
16
|
+
last_checked_at: 2020-02-03T23:45:56+00
|
17
|
+
status: running
|
18
|
+
application:
|
19
|
+
name: app-name
|
20
|
+
status: being_created
|
21
|
+
parameters: {}
|
22
|
+
certificates:
|
23
|
+
- href: example.com
|
24
|
+
id: cert-id
|
25
|
+
pending: true
|
26
|
+
https_strategy: redirect_HTTP_to_HTTPS
|