gandi_v5 0.5.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +69 -5
- data/LICENSE.md +2 -6
- data/README.md +67 -18
- data/lib/gandi_v5.rb +137 -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 +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 +4 -10
- 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 +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/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/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 +174 -53
- 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 -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 -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/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
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GandiV5
|
4
|
+
class SimpleHosting
|
5
|
+
class Instance
|
6
|
+
# An application running on a simple hosting instance.
|
7
|
+
# @!attribute [r] name
|
8
|
+
# @return [String]
|
9
|
+
# @!attribute [r] parameters
|
10
|
+
# @return [String]
|
11
|
+
# @!attribute [r] status
|
12
|
+
# @return [Symbol] :error, :running, :being_created, :cancelled
|
13
|
+
class Application
|
14
|
+
include GandiV5::Data
|
15
|
+
|
16
|
+
members :name, :parameters
|
17
|
+
member :status, converter: GandiV5::Data::Converter::Symbol
|
18
|
+
|
19
|
+
# Check if the appliaction is currently being created
|
20
|
+
# @return [Boolean]
|
21
|
+
def being_created?
|
22
|
+
status == :being_created
|
23
|
+
end
|
24
|
+
|
25
|
+
# Check if the appliaction has been cancelled
|
26
|
+
# @return [Boolean]
|
27
|
+
def cancelled?
|
28
|
+
status == :cancelled
|
29
|
+
end
|
30
|
+
|
31
|
+
# Check if the appliaction is running
|
32
|
+
# @return [Boolean]
|
33
|
+
def running?
|
34
|
+
status == :running
|
35
|
+
end
|
36
|
+
|
37
|
+
# Check if the appliaction is in an error condition
|
38
|
+
# @return [Boolean]
|
39
|
+
def error?
|
40
|
+
status == :error
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GandiV5
|
4
|
+
class SimpleHosting
|
5
|
+
class Instance
|
6
|
+
# A simple hosting instance.
|
7
|
+
# @!attribute [r] name
|
8
|
+
# @return [String]
|
9
|
+
# @!attribute [r] status
|
10
|
+
# @return [String]
|
11
|
+
# @!attribute [r] version
|
12
|
+
# @return [String]
|
13
|
+
class Database
|
14
|
+
include GandiV5::Data
|
15
|
+
|
16
|
+
members :name, :status, :version
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GandiV5
|
4
|
+
class SimpleHosting
|
5
|
+
class Instance
|
6
|
+
# A language running on a simple hosting instance.
|
7
|
+
# @!attribute [r] name
|
8
|
+
# @return [String]
|
9
|
+
# @!attribute [r] single_application
|
10
|
+
# @return [Boolean]
|
11
|
+
# @!attribute [r] status
|
12
|
+
# @return [String]
|
13
|
+
# @!attribute [r] version
|
14
|
+
# @return [String]
|
15
|
+
class Language
|
16
|
+
include GandiV5::Data
|
17
|
+
|
18
|
+
members :name, :single_application, :status, :version
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GandiV5
|
4
|
+
class SimpleHosting
|
5
|
+
class Instance
|
6
|
+
# An available upgrade on a simple hosting instance.
|
7
|
+
# @!attribute [r] name
|
8
|
+
# @return [String]
|
9
|
+
# @!attribute [r] status
|
10
|
+
# @return [String]
|
11
|
+
# @!attribute [r] type
|
12
|
+
# @return [String] "database" or "language"
|
13
|
+
# @!attribute [r] version
|
14
|
+
# @return [String]
|
15
|
+
class Upgrade
|
16
|
+
include GandiV5::Data
|
17
|
+
|
18
|
+
members :name, :status, :type, :version
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,187 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Namespace for classes which access LiveDNS details.
|
4
|
+
class GandiV5
|
5
|
+
class SimpleHosting
|
6
|
+
class Instance
|
7
|
+
# A virtual host on a simple hosting instance.
|
8
|
+
# @see https://api.gandi.net/docs/simplehosting/
|
9
|
+
# @!attribute [r] created_at
|
10
|
+
# @return [Time]
|
11
|
+
# @!attribute [r] fqdn
|
12
|
+
# @return [String] fully qualified domain name of the virtual host.
|
13
|
+
# @!attribute [r] instance_uuid
|
14
|
+
# @return [String] UUID of the simple hosting instance which 'owns' the host.
|
15
|
+
# @!attribute [r] is_a_test_virtual_host
|
16
|
+
# @return [Boolean]
|
17
|
+
# @!attribute [r] status
|
18
|
+
# @return [Symbol] :being_created, :running, :being_deleted,
|
19
|
+
# :locked, :waiting_ownership, :ownership_validated,
|
20
|
+
# :validation_failed
|
21
|
+
# @!attribute [r] https_strategy
|
22
|
+
# @return [Symbol] :http_only, :allow_http_and_https,
|
23
|
+
# :redirect_http_to_https
|
24
|
+
# @!attribute [r] Application
|
25
|
+
# @return [GandiV5::SimpleHosting::Instance::Application]
|
26
|
+
# @!attribute [r] certificates
|
27
|
+
# @return [Hash<String => Boolean>] Hash - certificate ID to pendingness
|
28
|
+
# @!attribute [r] linked_dns_zone
|
29
|
+
# @return [GandiV5::SimpleHosting::Instance::VirtualHost::LinkedDnsZone]
|
30
|
+
class VirtualHost
|
31
|
+
include GandiV5::Data
|
32
|
+
|
33
|
+
members :created_at, :fqdn, :instance_uuid
|
34
|
+
|
35
|
+
member :is_a_test_virtual_host, gandi_key: 'is_a_test_vhost'
|
36
|
+
member :status, converter: GandiV5::Data::Converter::Symbol
|
37
|
+
|
38
|
+
member(
|
39
|
+
:https_strategy,
|
40
|
+
converter: GandiV5::Data::Converter.new(from_gandi: ->(data) { data.downcase.to_sym })
|
41
|
+
)
|
42
|
+
|
43
|
+
member(
|
44
|
+
:application,
|
45
|
+
converter: GandiV5::SimpleHosting::Instance::Application
|
46
|
+
)
|
47
|
+
|
48
|
+
member(
|
49
|
+
:certificates,
|
50
|
+
converter: GandiV5::Data::Converter.new(
|
51
|
+
from_gandi: ->(array) { Hash[array.map { |h| [h['id'], h['pending']] }] }
|
52
|
+
)
|
53
|
+
)
|
54
|
+
|
55
|
+
member(
|
56
|
+
:linked_dns_zone,
|
57
|
+
converter: GandiV5::SimpleHosting::Instance::VirtualHost::LinkedDnsZone
|
58
|
+
)
|
59
|
+
|
60
|
+
# Requery Gandi fo this hosts's information.
|
61
|
+
# @return [GandiV5::SimpleHosting::Instance::VirtualHost]
|
62
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
63
|
+
def refresh
|
64
|
+
_response, data = GandiV5.get url
|
65
|
+
from_gandi data
|
66
|
+
end
|
67
|
+
|
68
|
+
# Check if the virtual host is being created
|
69
|
+
# @return [Boolean]
|
70
|
+
def being_created?
|
71
|
+
status == :being_created
|
72
|
+
end
|
73
|
+
|
74
|
+
# Check if the virtual host is running
|
75
|
+
# @return [Boolean]
|
76
|
+
def running?
|
77
|
+
status == :running
|
78
|
+
end
|
79
|
+
|
80
|
+
# Check if the virtual host is being deleted
|
81
|
+
# @return [Boolean]
|
82
|
+
def being_deleted?
|
83
|
+
status == :being_deleted
|
84
|
+
end
|
85
|
+
|
86
|
+
# Check if the virtual host is locked
|
87
|
+
# @return [Boolean]
|
88
|
+
def locked?
|
89
|
+
status == :locked
|
90
|
+
end
|
91
|
+
|
92
|
+
# Check if the virtual host is waiting for an ownership check
|
93
|
+
# @return [Boolean]
|
94
|
+
def waiting_ownership?
|
95
|
+
status == :waiting_ownership
|
96
|
+
end
|
97
|
+
|
98
|
+
# Check if the virtual host has it's ownership validated
|
99
|
+
# @return [Boolean]
|
100
|
+
def ownership_validated?
|
101
|
+
status == :ownership_validated
|
102
|
+
end
|
103
|
+
|
104
|
+
# Check if the virtual host failed it's ownership check
|
105
|
+
# @return [Boolean]
|
106
|
+
def validation_failed?
|
107
|
+
status == :validation_failed
|
108
|
+
end
|
109
|
+
|
110
|
+
# Check if the virtual host is serving HTTP only
|
111
|
+
# @return [Boolean]
|
112
|
+
def http_only?
|
113
|
+
https_strategy == :http_only
|
114
|
+
end
|
115
|
+
|
116
|
+
# Check if the virtual host is serving HTTP and HTTPS
|
117
|
+
# @return [Boolean]
|
118
|
+
def http_and_https?
|
119
|
+
https_strategy == :http_and_https
|
120
|
+
end
|
121
|
+
|
122
|
+
# Check if the virtual host is serving HTTPS and redirecting HTTP to HTTPS
|
123
|
+
# @return [Boolean]
|
124
|
+
def redirect_http_to_https?
|
125
|
+
https_strategy == :redirect_http_to_https
|
126
|
+
end
|
127
|
+
|
128
|
+
# Check if the virtual host is serving HTTP requests
|
129
|
+
# @return [Boolean]
|
130
|
+
def http?
|
131
|
+
https_strategy == :http_only || https_strategy == :http_and_https
|
132
|
+
end
|
133
|
+
|
134
|
+
# Check if the virtual host is serving HTTPS requests
|
135
|
+
# @return [Boolean]
|
136
|
+
def https?
|
137
|
+
https_strategy == :http_and_https
|
138
|
+
end
|
139
|
+
|
140
|
+
# Get information on a virtual host.
|
141
|
+
# @see https://api.gandi.net/docs/simplehosting#get-v5-simplehosting-instances-instance_id-vhosts-vhost_fqdn
|
142
|
+
# @param instance_uuid [String, #to_s] the UUID of the simple hosting instance.
|
143
|
+
# @param fqdn [String, #to_s] the fully qualified domain name of the virtual host.
|
144
|
+
# @return [GandiV5::SimpleHosting::Instance]
|
145
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
146
|
+
def self.fetch(instance_uuid, fqdn)
|
147
|
+
_response, data = GandiV5.get url(instance_uuid, fqdn)
|
148
|
+
from_gandi data.merge('instance_uuid' => instance_uuid)
|
149
|
+
end
|
150
|
+
|
151
|
+
# List instances.
|
152
|
+
# @see https://api.gandi.net/docs/simplehosting#get-v5-simplehosting-instances-instance_id-vhosts
|
153
|
+
# @param page [#each<Integer, #to_s>] the page(s) of results to retrieve.
|
154
|
+
# If page is not provided keep querying until an empty list is returned.
|
155
|
+
# If page responds to .each then iterate until an empty list is returned.
|
156
|
+
# @param per_page [Integer, #to_s] (optional default 100) how many results to get per page.
|
157
|
+
# @param status [String, #to_s] (optional)
|
158
|
+
# filter the list by the virtual host's status.
|
159
|
+
# @param fqdn [String, #to_s] (optional)
|
160
|
+
# filter the list by the virtual host's domain name, allows * as wildcard.
|
161
|
+
# @param sort_by [String, #to_s] (optional default "created_at")
|
162
|
+
# how to sort the list, prefix with a minus to reverse sort order.
|
163
|
+
# @return [Array<GandiV5::SimpleHosting::Instance::VirtualHost>]
|
164
|
+
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
165
|
+
def self.list(instance_uuid, page: (1..), per_page: 100, **params)
|
166
|
+
instances = []
|
167
|
+
GandiV5.paginated_get(url(instance_uuid), page, per_page, params: params) do |data|
|
168
|
+
instances += data.map { |item| from_gandi item.merge('instance_uuid' => instance_uuid) }
|
169
|
+
end
|
170
|
+
instances
|
171
|
+
end
|
172
|
+
|
173
|
+
private
|
174
|
+
|
175
|
+
def url
|
176
|
+
"#{BASE}simplehosting/instances/#{instance_uuid}/vhosts/#{CGI.escape(fqdn)}"
|
177
|
+
end
|
178
|
+
|
179
|
+
def self.url(instance_uuid, fqdn = nil)
|
180
|
+
"#{BASE}simplehosting/instances/#{instance_uuid}/vhosts" +
|
181
|
+
(fqdn ? "/#{CGI.escape fqdn}" : '')
|
182
|
+
end
|
183
|
+
private_class_method :url
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GandiV5
|
4
|
+
class SimpleHosting
|
5
|
+
class Instance
|
6
|
+
class VirtualHost
|
7
|
+
# A DNS Zone linked to a virtual host on a simple hosting instance.
|
8
|
+
# @!attribute [r] allow_zone_alteration
|
9
|
+
# @return [Boolean]
|
10
|
+
# @!attribute [r] cname
|
11
|
+
# @return [String]
|
12
|
+
# @!attribute [r] domain
|
13
|
+
# @return [String]
|
14
|
+
# @!attribute [r] ipv4
|
15
|
+
# @return [String]
|
16
|
+
# @!attribute [r] ipv6
|
17
|
+
# @return [String]
|
18
|
+
# @!attribute [r] is_alterable
|
19
|
+
# @return [Boolean]
|
20
|
+
# @!attribute [r] is_root
|
21
|
+
# @return [Boolean]
|
22
|
+
# @!attribute [r] key
|
23
|
+
# @return [String]
|
24
|
+
# @!attribute [r] txt
|
25
|
+
# @return [String]
|
26
|
+
# @!attribute [r] last_checked_at
|
27
|
+
# @return [Time]
|
28
|
+
# @!attribute [r] status
|
29
|
+
# @return [Symbol] :altered, :livedns_conflict, :livedns_done, :livedns_error, :unknown
|
30
|
+
class LinkedDnsZone
|
31
|
+
include GandiV5::Data
|
32
|
+
|
33
|
+
members :allow_alteration, :is_alterable, :last_checked_at,
|
34
|
+
:cname, :domain, :is_root, :ipv4, :ipv6, :key, :txt
|
35
|
+
|
36
|
+
member(
|
37
|
+
:status,
|
38
|
+
gandi_key: 'last_checked_status',
|
39
|
+
converter: GandiV5::Data::Converter::Symbol
|
40
|
+
)
|
41
|
+
|
42
|
+
# Check if the linked zone is currently in an altered state
|
43
|
+
# @return [Boolean]
|
44
|
+
def altered?
|
45
|
+
status == :altered
|
46
|
+
end
|
47
|
+
|
48
|
+
# Check if the linked zone is currently in a conflicted state
|
49
|
+
# @return [Boolean]
|
50
|
+
def livedns_conflict?
|
51
|
+
status == :livedns_conflict
|
52
|
+
end
|
53
|
+
|
54
|
+
# Check if the linked zone has been updated
|
55
|
+
# @return [Boolean]
|
56
|
+
def livedns_done?
|
57
|
+
status == :livedns_done
|
58
|
+
end
|
59
|
+
|
60
|
+
# Check if the linked zone had an error updating
|
61
|
+
# @return [Boolean]
|
62
|
+
def livedns_error?
|
63
|
+
status == :livedns_error
|
64
|
+
end
|
65
|
+
|
66
|
+
# Check if the linked zone is in an unknown state
|
67
|
+
# @return [Boolean]
|
68
|
+
def unknown?
|
69
|
+
status == :unknown
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
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
|