gandi_v5 0.2.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +13 -3
- data/.travis.yml +15 -1
- data/CHANGELOG.md +63 -0
- data/FUNDING.yml +10 -0
- data/LICENSE.md +2 -6
- data/README.md +16 -21
- data/gandi_v5.gemspec +3 -2
- data/lib/gandi_v5.rb +64 -24
- data/lib/gandi_v5/billing.rb +0 -2
- data/lib/gandi_v5/billing/info.rb +0 -2
- data/lib/gandi_v5/data.rb +1 -4
- data/lib/gandi_v5/data/converter.rb +0 -4
- data/lib/gandi_v5/data/converter/integer.rb +26 -0
- data/lib/gandi_v5/domain.rb +167 -28
- data/lib/gandi_v5/domain/availability.rb +0 -3
- data/lib/gandi_v5/domain/availability/product.rb +0 -3
- data/lib/gandi_v5/domain/live_dns.rb +42 -0
- data/lib/gandi_v5/domain/renewal_information.rb +0 -3
- data/lib/gandi_v5/domain/sharing_space.rb +10 -2
- data/lib/gandi_v5/email.rb +0 -4
- data/lib/gandi_v5/email/forward.rb +102 -0
- data/lib/gandi_v5/email/mailbox.rb +57 -13
- data/lib/gandi_v5/email/slot.rb +11 -3
- data/lib/gandi_v5/error.rb +0 -2
- data/lib/gandi_v5/live_dns.rb +0 -16
- data/lib/gandi_v5/live_dns/domain.rb +221 -80
- 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 +38 -5
- data/lib/gandi_v5/organization/customer.rb +90 -0
- data/lib/gandi_v5/version.rb +1 -1
- data/spec/.rubocop.yml +9 -2
- data/spec/fixtures/bodies/GandiV5_Billing/{info.yaml → info.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Domain/{get.yaml → fetch.yml} +8 -0
- data/spec/fixtures/bodies/GandiV5_Domain/{fetch_contacts.yaml → fetch_contacts.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Domain/fetch_glue_records.yml +7 -0
- data/spec/fixtures/bodies/GandiV5_Domain/fetch_livedns.yml +6 -0
- data/spec/fixtures/bodies/GandiV5_Domain/fetch_name_servers.yml +2 -0
- data/spec/fixtures/bodies/GandiV5_Domain/{renewal_info.yaml → fetch_renewal_info.yml} +0 -3
- data/spec/fixtures/bodies/GandiV5_Domain/{restore_info.yaml → fetch_restore_info.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Domain/{list.yaml → list.yml} +1 -0
- data/spec/fixtures/bodies/GandiV5_Domain_Availability/{fetch.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Domain_TLD/{fetch.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Domain_TLD/{list.yaml → list.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Email_Forward/list.yml +6 -0
- data/spec/fixtures/bodies/GandiV5_Email_Mailbox/{get.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Email_Mailbox/{list.yaml → list.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Email_Slot/{get.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Email_Slot/{list.yaml → list.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/fetch.yml +3 -0
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Domain/{list.yaml → list.yml} +0 -0
- 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/fetch.yaml → 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/{get.yaml → fetch.yml} +0 -0
- data/spec/fixtures/bodies/GandiV5_Organization/list.yml +7 -0
- data/spec/fixtures/bodies/GandiV5_Organization_Customer/list.yml +8 -0
- data/spec/spec_helper.rb +2 -2
- data/spec/units/gandi_v5/billing_spec.rb +2 -2
- data/spec/units/gandi_v5/data/converter/integer_spec.rb +16 -0
- data/spec/units/gandi_v5/domain/availability_spec.rb +1 -1
- data/spec/units/gandi_v5/domain/live_dns_spec.rb +45 -0
- data/spec/units/gandi_v5/domain/tld_spec.rb +2 -2
- data/spec/units/gandi_v5/domain_spec.rb +294 -65
- data/spec/units/gandi_v5/email/forward_spec.rb +92 -0
- data/spec/units/gandi_v5/email/mailbox_spec.rb +122 -40
- data/spec/units/gandi_v5/email/slot_spec.rb +13 -5
- 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 +299 -120
- 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 +52 -1
- data/spec/units/gandi_v5_spec.rb +139 -30
- metadata +68 -95
- data/doc/GandiV5.html +0 -1183
- data/doc/GandiV5/Billing.html +0 -293
- data/doc/GandiV5/Billing/Info.html +0 -641
- data/doc/GandiV5/Billing/Info/Prepaid.html +0 -817
- data/doc/GandiV5/Data.html +0 -785
- data/doc/GandiV5/Data/ClassMethods.html +0 -223
- data/doc/GandiV5/Data/Converter.html +0 -433
- data/doc/GandiV5/Data/Converter/ArrayOf.html +0 -413
- data/doc/GandiV5/Data/Converter/Symbol.html +0 -322
- data/doc/GandiV5/Data/Converter/Time.html +0 -330
- data/doc/GandiV5/Domain.html +0 -16847
- data/doc/GandiV5/Domain/AutoRenew.html +0 -1237
- data/doc/GandiV5/Domain/Availability.html +0 -1020
- data/doc/GandiV5/Domain/Availability/Product.html +0 -988
- data/doc/GandiV5/Domain/Availability/Product/Period.html +0 -220
- data/doc/GandiV5/Domain/Availability/Product/Price.html +0 -1031
- data/doc/GandiV5/Domain/Availability/Tax.html +0 -440
- data/doc/GandiV5/Domain/Contact.html +0 -4459
- data/doc/GandiV5/Domain/Contract.html +0 -520
- data/doc/GandiV5/Domain/Dates.html +0 -1313
- data/doc/GandiV5/Domain/RenewalInformation.html +0 -1147
- data/doc/GandiV5/Domain/RestoreInformation.html +0 -339
- data/doc/GandiV5/Domain/SharingSpace.html +0 -437
- data/doc/GandiV5/Domain/TLD.html +0 -1565
- data/doc/GandiV5/Email.html +0 -144
- data/doc/GandiV5/Email/Mailbox.html +0 -6307
- data/doc/GandiV5/Email/Mailbox/Responder.html +0 -1560
- data/doc/GandiV5/Email/Offer.html +0 -514
- data/doc/GandiV5/Email/Slot.html +0 -4244
- data/doc/GandiV5/Error.html +0 -151
- data/doc/GandiV5/Error/GandiError.html +0 -270
- data/doc/GandiV5/LiveDNS.html +0 -300
- data/doc/GandiV5/LiveDNS/Domain.html +0 -2984
- data/doc/GandiV5/LiveDNS/RecordSet.html +0 -1593
- data/doc/GandiV5/LiveDNS/Zone.html +0 -8891
- data/doc/GandiV5/LiveDNS/Zone/Snapshot.html +0 -1556
- data/doc/GandiV5/Organization.html +0 -2341
- data/doc/_index.html +0 -474
- data/doc/class_list.html +0 -51
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -58
- data/doc/css/style.css +0 -496
- data/doc/file.README.html +0 -175
- data/doc/file_list.html +0 -56
- data/doc/frames.html +0 -17
- data/doc/index.html +0 -175
- data/doc/js/app.js +0 -303
- data/doc/js/full_list.js +0 -216
- data/doc/js/jquery.js +0 -4
- data/doc/method_list.html +0 -2427
- data/doc/top-level-namespace.html +0 -110
- data/lib/gandi_v5/live_dns/record_set.rb +0 -79
- data/lib/gandi_v5/live_dns/zone.rb +0 -305
- 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_Domain/get.yaml +0 -4
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/get.yaml +0 -11
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone/list.yaml +0 -11
- data/spec/fixtures/bodies/GandiV5_LiveDNS_Zone_Snapshot/list.yaml +0 -3
- data/spec/fixtures/vcr/Domain_features/List_domains.yml +0 -54
- 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/live_dns/zone/snapshot_spec.rb +0 -66
- data/spec/units/gandi_v5/live_dns/zone_spec.rb +0 -347
@@ -1,110 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
-
<title>
|
7
|
-
Top Level Namespace
|
8
|
-
|
9
|
-
— Documentation by YARD 0.9.19
|
10
|
-
|
11
|
-
</title>
|
12
|
-
|
13
|
-
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
14
|
-
|
15
|
-
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
16
|
-
|
17
|
-
<script type="text/javascript" charset="utf-8">
|
18
|
-
pathId = "";
|
19
|
-
relpath = '';
|
20
|
-
</script>
|
21
|
-
|
22
|
-
|
23
|
-
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
24
|
-
|
25
|
-
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
26
|
-
|
27
|
-
|
28
|
-
</head>
|
29
|
-
<body>
|
30
|
-
<div class="nav_wrap">
|
31
|
-
<iframe id="nav" src="class_list.html?1"></iframe>
|
32
|
-
<div id="resizer"></div>
|
33
|
-
</div>
|
34
|
-
|
35
|
-
<div id="main" tabindex="-1">
|
36
|
-
<div id="header">
|
37
|
-
<div id="menu">
|
38
|
-
|
39
|
-
<a href="_index.html">Index</a> »
|
40
|
-
|
41
|
-
|
42
|
-
<span class="title">Top Level Namespace</span>
|
43
|
-
|
44
|
-
</div>
|
45
|
-
|
46
|
-
<div id="search">
|
47
|
-
|
48
|
-
<a class="full_list_link" id="class_list_link"
|
49
|
-
href="class_list.html">
|
50
|
-
|
51
|
-
<svg width="24" height="24">
|
52
|
-
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
-
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
-
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
-
</svg>
|
56
|
-
</a>
|
57
|
-
|
58
|
-
</div>
|
59
|
-
<div class="clear"></div>
|
60
|
-
</div>
|
61
|
-
|
62
|
-
<div id="content"><h1>Top Level Namespace
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
</h1>
|
67
|
-
<div class="box_info">
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
</div>
|
80
|
-
|
81
|
-
<h2>Defined Under Namespace</h2>
|
82
|
-
<p class="children">
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
<strong class="classes">Classes:</strong> <span class='object_link'><a href="GandiV5.html" title="GandiV5 (class)">GandiV5</a></span>
|
88
|
-
|
89
|
-
|
90
|
-
</p>
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
</div>
|
101
|
-
|
102
|
-
<div id="footer">
|
103
|
-
Generated on Mon Jul 22 16:44:23 2019 by
|
104
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
105
|
-
0.9.19 (ruby-2.6.3).
|
106
|
-
</div>
|
107
|
-
|
108
|
-
</div>
|
109
|
-
</body>
|
110
|
-
</html>
|
@@ -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
|
@@ -1,305 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'zone/snapshot'
|
4
|
-
|
5
|
-
class GandiV5
|
6
|
-
class LiveDNS
|
7
|
-
# A zone within the LiveDNS system.
|
8
|
-
# Zones can be used by any number of domains.
|
9
|
-
# @!attribute [r] uuid
|
10
|
-
# @return [String]
|
11
|
-
# @!attribute [r] name
|
12
|
-
# @return [String]
|
13
|
-
# @!attribute [r] sharing_uuid
|
14
|
-
# @return [String]
|
15
|
-
# @!attribute [r] soa_retry
|
16
|
-
# @return [Integer] retry period, as reported in SOA record.
|
17
|
-
# @!attribute [r] soa_minimum
|
18
|
-
# @return [Integer] minimum and negative TTL, as reported in SOA record.
|
19
|
-
# @!attribute [r] soa_refresh
|
20
|
-
# @return [Integer] refresh period, as reported in SOA record.
|
21
|
-
# @!attribute [r] soa_expire
|
22
|
-
# @return [Integer] expire period, as reported in SOA record.
|
23
|
-
# @!attribute [r] soa_serial
|
24
|
-
# @return [Integer] serial number, as reported in SOA record.
|
25
|
-
# @!attribute [r] soa_email
|
26
|
-
# @return [String] admin email address, as reported in SOA record.
|
27
|
-
# @!attribute [r] soa_primary_ns
|
28
|
-
# @return [String] primary name server, as reported in SOA record.
|
29
|
-
class Zone
|
30
|
-
include GandiV5::Data
|
31
|
-
|
32
|
-
members :uuid, :name
|
33
|
-
member :sharing_uuid, gandi_key: 'sharing_id'
|
34
|
-
member :soa_retry, gandi_key: 'retry'
|
35
|
-
member :soa_minimum, gandi_key: 'minimum'
|
36
|
-
member :soa_refresh, gandi_key: 'refresh'
|
37
|
-
member :soa_expire, gandi_key: 'expire'
|
38
|
-
member :soa_serial, gandi_key: 'serial'
|
39
|
-
member :soa_email, gandi_key: 'email'
|
40
|
-
member :soa_primary_ns, gandi_key: 'primary_ns'
|
41
|
-
|
42
|
-
alias zone_uuid uuid
|
43
|
-
|
44
|
-
# Generate SOA record for the zone
|
45
|
-
# @return [String]
|
46
|
-
def to_s
|
47
|
-
"@\tIN\tSOA\t#{soa_primary_ns} #{soa_email} (\n" \
|
48
|
-
"\t#{soa_serial}\t;Serial\n" \
|
49
|
-
"\t#{soa_refresh}\t\t;Refresh\n" \
|
50
|
-
"\t#{soa_retry}\t\t;Retry\n" \
|
51
|
-
"\t#{soa_expire}\t\t;Expire\n" \
|
52
|
-
"\t#{soa_minimum}\t\t;Minimum & Negative TTL\n" \
|
53
|
-
')'
|
54
|
-
end
|
55
|
-
|
56
|
-
# @overload fetch_records()
|
57
|
-
# Fetch all records for this zone.
|
58
|
-
# @overload fetch_records(name)
|
59
|
-
# Fetch records for a name.
|
60
|
-
# @param name [String] the name to fetch records for.
|
61
|
-
# @overload fetch_records(name, type)
|
62
|
-
# Fetch records of a type for a name.
|
63
|
-
# @param name [String] the name to fetch records for.
|
64
|
-
# @param type [String] the record type to fetch.
|
65
|
-
# @return [Array<GandiV5::LiveDNS::RecordSet>]
|
66
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
67
|
-
def fetch_records(name = nil, type = nil)
|
68
|
-
GandiV5::LiveDNS.require_valid_record_type type if type
|
69
|
-
|
70
|
-
url_ = "#{url}/records"
|
71
|
-
url_ += "/#{CGI.escape name}" if name
|
72
|
-
url_ += "/#{CGI.escape type}" if type
|
73
|
-
|
74
|
-
_response, data = GandiV5.get url_
|
75
|
-
data = [data] unless data.is_a?(Array)
|
76
|
-
data.map { |item| GandiV5::LiveDNS::RecordSet.from_gandi item }
|
77
|
-
end
|
78
|
-
|
79
|
-
# @overload fetch_zone_lines()
|
80
|
-
# Fetch all records for this zone.
|
81
|
-
# @overload fetch_zone_lines(name)
|
82
|
-
# Fetch records for a name.
|
83
|
-
# @param name [String] the name to fetch records for.
|
84
|
-
# @overload fetch_zone_lines(name, type)
|
85
|
-
# Fetch records of a type for a name.
|
86
|
-
# @param name [String] the name to fetch records for.
|
87
|
-
# @param type [String] the record type to fetch.
|
88
|
-
# @return [String]
|
89
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
90
|
-
def fetch_zone_lines(name = nil, type = nil)
|
91
|
-
GandiV5::LiveDNS.require_valid_record_type type if type
|
92
|
-
|
93
|
-
url_ = "#{url}/records"
|
94
|
-
url_ += "/#{CGI.escape name}" if name
|
95
|
-
url_ += "/#{CGI.escape type}" if type
|
96
|
-
|
97
|
-
GandiV5.get(url_, accept: 'text/plain').last
|
98
|
-
end
|
99
|
-
|
100
|
-
# Add record to this zone.
|
101
|
-
# @param name [String]
|
102
|
-
# @param type [String]
|
103
|
-
# @param ttl [Integer]
|
104
|
-
# @param values [Array<String>]
|
105
|
-
# @return [String] The confirmation message from Gandi.
|
106
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
107
|
-
def add_record(name, type, ttl, *values)
|
108
|
-
GandiV5::LiveDNS.require_valid_record_type type
|
109
|
-
fail ArgumentError, 'ttl must be positive and non-zero' unless ttl.positive?
|
110
|
-
fail ArgumentError, 'there must be at least one value' if values.none?
|
111
|
-
|
112
|
-
body = {
|
113
|
-
rrset_name: name,
|
114
|
-
rrset_type: type,
|
115
|
-
rrset_ttl: ttl,
|
116
|
-
rrset_values: values
|
117
|
-
}.to_json
|
118
|
-
_response, data = GandiV5.post "#{url}/records", body
|
119
|
-
data['message']
|
120
|
-
end
|
121
|
-
|
122
|
-
# @overload delete_records()
|
123
|
-
# Delete all records for this zone.
|
124
|
-
# @overload delete_records(name)
|
125
|
-
# Delete records for a name.
|
126
|
-
# @param name [String] the name to delete records for.
|
127
|
-
# @overload delete_records(name, type)
|
128
|
-
# Delete records of a type for a name.
|
129
|
-
# @param name [String] the name to delete records for.
|
130
|
-
# @param type [String] the record type to delete.
|
131
|
-
# @return [nil]
|
132
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
133
|
-
def delete_records(name = nil, type = nil)
|
134
|
-
GandiV5::LiveDNS.require_valid_record_type type if type
|
135
|
-
|
136
|
-
url_ = "#{url}/records"
|
137
|
-
url_ += "/#{CGI.escape name}" if name
|
138
|
-
url_ += "/#{CGI.escape type}" if type
|
139
|
-
GandiV5.delete(url_).last
|
140
|
-
end
|
141
|
-
|
142
|
-
# Replace all records for this zone.
|
143
|
-
# @param records
|
144
|
-
# [Array<Hash<:name, :type => String, :ttl => Integer, :values => Array<String>>>]
|
145
|
-
# the records to add.
|
146
|
-
# @param text [String] zone file lines to replace the records with.
|
147
|
-
# @return [String] The confirmation message from Gandi.
|
148
|
-
# @raise [ArgumentError] if neither/both of records & test are passed.
|
149
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
150
|
-
def replace_records(records: nil, text: nil)
|
151
|
-
unless [records, text].one?(&:nil?)
|
152
|
-
fail ArgumentError, 'you must pass ONE of records: or text:'
|
153
|
-
end
|
154
|
-
|
155
|
-
if records
|
156
|
-
body = {
|
157
|
-
items: records.map { |r| r.transform_keys { |k| "rrset_#{k}" } }
|
158
|
-
}.to_json
|
159
|
-
_response, data = GandiV5.put "#{url}/records", body
|
160
|
-
elsif text
|
161
|
-
_response, data = GandiV5.put "#{url}/records", text, 'content-type': 'text/plain'
|
162
|
-
end
|
163
|
-
data['message']
|
164
|
-
end
|
165
|
-
|
166
|
-
# @override replace_records_for(name, records)
|
167
|
-
# Replace records for a name in this zone.
|
168
|
-
# @param name [String]
|
169
|
-
# @param records
|
170
|
-
# [Array<Hash<type: String, ttl: Integer, values: Array<String>>>]
|
171
|
-
# the records to add.
|
172
|
-
# @override replace_records_for(name, values, type: nil, ttl: nil)
|
173
|
-
# Replace records for a name in this zone.
|
174
|
-
# @param name [String]
|
175
|
-
# @param type [String] the record type.
|
176
|
-
# @param ttl [Integer] the TTL to set for the record.
|
177
|
-
# @param values [Array<String>] the values to set for the record.
|
178
|
-
# @raise [ArgumentError] if ttl is present and type is absent.
|
179
|
-
# @return [String] The confirmation message from Gandi.
|
180
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
181
|
-
def replace_records_for(name, records, type: nil, ttl: nil)
|
182
|
-
fail ArgumentError, 'missing keyword: type' if ttl && type.nil?
|
183
|
-
|
184
|
-
if type
|
185
|
-
GandiV5::LiveDNS.require_valid_record_type type
|
186
|
-
body = { rrset_values: records, rrset_ttl: ttl }
|
187
|
-
# body[:rrset_ttl] = ttl if ttl
|
188
|
-
_response, data = GandiV5.put "#{url}/records/#{name}/#{type}", body.to_json
|
189
|
-
|
190
|
-
else
|
191
|
-
body = {
|
192
|
-
items: records.map { |r| r.transform_keys { |k| "rrset_#{k}" } }
|
193
|
-
}
|
194
|
-
_response, data = GandiV5.put "#{url}/records/#{name}", body.to_json
|
195
|
-
end
|
196
|
-
|
197
|
-
data['message']
|
198
|
-
end
|
199
|
-
|
200
|
-
# List the domains that use this zone.
|
201
|
-
# @return [Array<String>] The FQDNs.
|
202
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
203
|
-
def list_domains
|
204
|
-
_response, data = GandiV5.get "#{url}/domains"
|
205
|
-
data.map { |item| item['fqdn'] }
|
206
|
-
end
|
207
|
-
|
208
|
-
# Attach domain to this zone.
|
209
|
-
# @param fqdn [String, #fqdn, #to_s] the fully qualified domain name
|
210
|
-
# that should start using this zone.
|
211
|
-
# @return [String] The confirmation message from Gandi.
|
212
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
213
|
-
def attach_domain(fqdn)
|
214
|
-
fqdn = fqdn.fqdn if fqdn.respond_to?(:fqdn)
|
215
|
-
_resp, data = GandiV5.patch "#{BASE}domains/#{CGI.escape fqdn}", { zone_uuid: uuid }.to_json
|
216
|
-
data['message']
|
217
|
-
end
|
218
|
-
|
219
|
-
# Get snapshot UUIDs for this zone from Gandi.
|
220
|
-
# @return [Hash{String => Time}] Mapping snapshot UUID to time made.
|
221
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
222
|
-
def snapshots
|
223
|
-
GandiV5::LiveDNS::Zone::Snapshot.list uuid
|
224
|
-
end
|
225
|
-
|
226
|
-
# Get snapshot from Gandi.
|
227
|
-
# @param uuid [String] the UUID of the snapshot to fetch.
|
228
|
-
# @return [GandiV5::LiveDNS::Zone::Snapshot]
|
229
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
230
|
-
def snapshot(uuid)
|
231
|
-
GandiV5::LiveDNS::Zone::Snapshot.fetch self.uuid, uuid
|
232
|
-
end
|
233
|
-
|
234
|
-
# Take a snapshot of this zone.
|
235
|
-
# @return [GandiV5::LiveDNS::Zone::Snapshot]
|
236
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
237
|
-
def take_snapshot
|
238
|
-
_response, data = GandiV5.post "#{url}/snapshots"
|
239
|
-
snapshot data['uuid']
|
240
|
-
end
|
241
|
-
|
242
|
-
# Update this zone.
|
243
|
-
# @param name [String, #to_s] new name for the zone.
|
244
|
-
# @return [String] The confirmation message from Gandi.
|
245
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
246
|
-
def update(name:)
|
247
|
-
_response, data = GandiV5.patch url, { name: name }.to_json
|
248
|
-
self.name = name
|
249
|
-
data['message']
|
250
|
-
end
|
251
|
-
|
252
|
-
# Delete this zone from Gandi.
|
253
|
-
# @return [nil]
|
254
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
255
|
-
def delete
|
256
|
-
GandiV5.delete url
|
257
|
-
end
|
258
|
-
|
259
|
-
# Create a new zone.
|
260
|
-
# @param name [String] the name for the created zone.
|
261
|
-
# @param sharing_id [String] the UUID of the account to ceate the zone under.
|
262
|
-
# @return [GandiV5::LiveDNS::Zone] The created zone.
|
263
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
264
|
-
def self.create(name, sharing_id: nil)
|
265
|
-
params = sharing_id ? { sharing_id: sharing_id } : {}
|
266
|
-
|
267
|
-
response, _data = GandiV5.post(
|
268
|
-
url,
|
269
|
-
{ name: name }.to_json,
|
270
|
-
params: params
|
271
|
-
)
|
272
|
-
|
273
|
-
fetch response.headers[:location].split('/').last
|
274
|
-
end
|
275
|
-
|
276
|
-
# List the zones.
|
277
|
-
# @return [Array<GandiV5::LiveDNS::Zone>]
|
278
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
279
|
-
def self.list
|
280
|
-
_response, data = GandiV5.get url
|
281
|
-
data.map { |item| from_gandi item }
|
282
|
-
end
|
283
|
-
|
284
|
-
# Get a zone from Gandi.
|
285
|
-
# @param uuid [String, #to_s] the UUID of the zone to fetch.
|
286
|
-
# @return [GandiV5::LiveDNS::Zone]
|
287
|
-
# @raise [GandiV5::Error::GandiError] if Gandi returns an error.
|
288
|
-
def self.fetch(uuid)
|
289
|
-
_response, data = GandiV5.get url(uuid)
|
290
|
-
from_gandi data
|
291
|
-
end
|
292
|
-
|
293
|
-
private
|
294
|
-
|
295
|
-
def url
|
296
|
-
"#{BASE}zones/#{CGI.escape uuid}"
|
297
|
-
end
|
298
|
-
|
299
|
-
def self.url(uuid = nil)
|
300
|
-
BASE + (uuid ? "zones/#{CGI.escape(uuid)}" : 'zones')
|
301
|
-
end
|
302
|
-
private_class_method :url
|
303
|
-
end
|
304
|
-
end
|
305
|
-
end
|