Class: GandiV5::LiveDNS::Zone
- Inherits:
-
Object
- Object
- GandiV5::LiveDNS::Zone
- Includes:
- Data, HasZoneRecords
- Defined in:
- lib/gandi_v5/live_dns/zone.rb,
lib/gandi_v5/live_dns/zone/snapshot.rb
Overview
A zone within the LiveDNS system. Zones can be used by any number of domains.
Defined Under Namespace
Classes: Snapshot
Instance Attribute Summary collapse
- #name ⇒ String readonly
- #sharing_uuid ⇒ String readonly
-
#soa_email ⇒ String
readonly
Admin email address, as reported in SOA record.
-
#soa_expire ⇒ Integer
readonly
Expire period, as reported in SOA record.
-
#soa_minimum ⇒ Integer
readonly
Minimum and negative TTL, as reported in SOA record.
-
#soa_primary_ns ⇒ String
readonly
Primary name server, as reported in SOA record.
-
#soa_refresh ⇒ Integer
readonly
Refresh period, as reported in SOA record.
-
#soa_retry ⇒ Integer
readonly
Retry period, as reported in SOA record.
-
#soa_serial ⇒ Integer
readonly
Serial number, as reported in SOA record.
- #uuid ⇒ String (also: #zone_uuid) readonly
Class Method Summary collapse
-
.create(name, sharing_id: nil) ⇒ GandiV5::LiveDNS::Zone
Create a new zone.
-
.fetch(uuid) ⇒ GandiV5::LiveDNS::Zone
Get a zone from Gandi.
-
.list ⇒ Array<GandiV5::LiveDNS::Zone>
List the zones.
Instance Method Summary collapse
-
#attach_domain(fqdn) ⇒ String
Attach domain to this zone.
-
#delete ⇒ nil
Delete this zone from Gandi.
-
#list_domains ⇒ Array<String>
List the domains that use this zone.
-
#snapshot(uuid) ⇒ GandiV5::LiveDNS::Zone::Snapshot
Get snapshot from Gandi.
-
#snapshots ⇒ Hash{String => Time}
Get snapshot UUIDs for this zone from Gandi.
-
#take_snapshot ⇒ GandiV5::LiveDNS::Zone::Snapshot
Take a snapshot of this zone.
-
#to_s ⇒ String
Generate SOA record for the zone.
-
#update(name:) ⇒ String
Update this zone.
Methods included from HasZoneRecords
#add_record, #delete_records, #fetch_records, #fetch_zone_lines, #replace_records, #replace_records_for
Methods included from Data
#from_gandi, included, #initialize, #to_gandi, #to_h, #values_at
Instance Attribute Details
#name ⇒ String (readonly)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 27 class Zone include GandiV5::Data include GandiV5::LiveDNS::HasZoneRecords members :uuid, :name member :sharing_uuid, gandi_key: 'sharing_id' member :soa_retry, gandi_key: 'retry' member :soa_minimum, gandi_key: 'minimum' member :soa_refresh, gandi_key: 'refresh' member :soa_expire, gandi_key: 'expire' member :soa_serial, gandi_key: 'serial' member :soa_email, gandi_key: 'email' member :soa_primary_ns, gandi_key: 'primary_ns' alias zone_uuid uuid # Generate SOA record for the zone # @return [String] def to_s "@\tIN\tSOA\t#{soa_primary_ns} #{soa_email} (\n" \ "\t#{soa_serial}\t;Serial\n" \ "\t#{soa_refresh}\t\t;Refresh\n" \ "\t#{soa_retry}\t\t;Retry\n" \ "\t#{soa_expire}\t\t;Expire\n" \ "\t#{soa_minimum}\t\t;Minimum & Negative TTL\n" \ ')' end # List the domains that use this zone. # @return [Array<String>] The FQDNs. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def list_domains _response, data = GandiV5.get "#{url}/domains" data.map { |item| item['fqdn'] } end # Attach domain to this zone. # @param fqdn [String, #fqdn, #to_s] the fully qualified domain name # that should start using this zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def attach_domain(fqdn) fqdn = fqdn.fqdn if fqdn.respond_to?(:fqdn) _resp, data = GandiV5.patch "#{BASE}domains/#{CGI.escape fqdn}", { zone_uuid: uuid }.to_json data['message'] end # Get snapshot UUIDs for this zone from Gandi. # @return [Hash{String => Time}] Mapping snapshot UUID to time made. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshots GandiV5::LiveDNS::Zone::Snapshot.list uuid end # Get snapshot from Gandi. # @param uuid [String] the UUID of the snapshot to fetch. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshot(uuid) GandiV5::LiveDNS::Zone::Snapshot.fetch self.uuid, uuid end # Take a snapshot of this zone. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def take_snapshot _response, data = GandiV5.post "#{url}/snapshots" snapshot data['uuid'] end # Update this zone. # @param name [String, #to_s] new name for the zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def update(name:) _response, data = GandiV5.patch url, { name: name }.to_json self.name = name data['message'] end # Delete this zone from Gandi. # @return [nil] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def delete GandiV5.delete url end # Create a new zone. # @param name [String] the name for the created zone. # @param sharing_id [String] the UUID of the account to ceate the zone under. # @return [GandiV5::LiveDNS::Zone] The created zone. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.create(name, sharing_id: nil) params = sharing_id ? { sharing_id: sharing_id } : {} response, _data = GandiV5.post( url, { name: name }.to_json, params: params ) fetch response.headers[:location].split('/').last end # List the zones. # @return [Array<GandiV5::LiveDNS::Zone>] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.list _response, data = GandiV5.get url data.map { |item| from_gandi item } end # Get a zone from Gandi. # @param uuid [String, #to_s] the UUID of the zone to fetch. # @return [GandiV5::LiveDNS::Zone] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.fetch(uuid) _response, data = GandiV5.get url(uuid) from_gandi data end private def url "#{BASE}zones/#{CGI.escape uuid}" end def self.url(uuid = nil) BASE + (uuid ? "zones/#{CGI.escape(uuid)}" : 'zones') end private_class_method :url end |
#sharing_uuid ⇒ String (readonly)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 27 class Zone include GandiV5::Data include GandiV5::LiveDNS::HasZoneRecords members :uuid, :name member :sharing_uuid, gandi_key: 'sharing_id' member :soa_retry, gandi_key: 'retry' member :soa_minimum, gandi_key: 'minimum' member :soa_refresh, gandi_key: 'refresh' member :soa_expire, gandi_key: 'expire' member :soa_serial, gandi_key: 'serial' member :soa_email, gandi_key: 'email' member :soa_primary_ns, gandi_key: 'primary_ns' alias zone_uuid uuid # Generate SOA record for the zone # @return [String] def to_s "@\tIN\tSOA\t#{soa_primary_ns} #{soa_email} (\n" \ "\t#{soa_serial}\t;Serial\n" \ "\t#{soa_refresh}\t\t;Refresh\n" \ "\t#{soa_retry}\t\t;Retry\n" \ "\t#{soa_expire}\t\t;Expire\n" \ "\t#{soa_minimum}\t\t;Minimum & Negative TTL\n" \ ')' end # List the domains that use this zone. # @return [Array<String>] The FQDNs. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def list_domains _response, data = GandiV5.get "#{url}/domains" data.map { |item| item['fqdn'] } end # Attach domain to this zone. # @param fqdn [String, #fqdn, #to_s] the fully qualified domain name # that should start using this zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def attach_domain(fqdn) fqdn = fqdn.fqdn if fqdn.respond_to?(:fqdn) _resp, data = GandiV5.patch "#{BASE}domains/#{CGI.escape fqdn}", { zone_uuid: uuid }.to_json data['message'] end # Get snapshot UUIDs for this zone from Gandi. # @return [Hash{String => Time}] Mapping snapshot UUID to time made. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshots GandiV5::LiveDNS::Zone::Snapshot.list uuid end # Get snapshot from Gandi. # @param uuid [String] the UUID of the snapshot to fetch. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshot(uuid) GandiV5::LiveDNS::Zone::Snapshot.fetch self.uuid, uuid end # Take a snapshot of this zone. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def take_snapshot _response, data = GandiV5.post "#{url}/snapshots" snapshot data['uuid'] end # Update this zone. # @param name [String, #to_s] new name for the zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def update(name:) _response, data = GandiV5.patch url, { name: name }.to_json self.name = name data['message'] end # Delete this zone from Gandi. # @return [nil] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def delete GandiV5.delete url end # Create a new zone. # @param name [String] the name for the created zone. # @param sharing_id [String] the UUID of the account to ceate the zone under. # @return [GandiV5::LiveDNS::Zone] The created zone. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.create(name, sharing_id: nil) params = sharing_id ? { sharing_id: sharing_id } : {} response, _data = GandiV5.post( url, { name: name }.to_json, params: params ) fetch response.headers[:location].split('/').last end # List the zones. # @return [Array<GandiV5::LiveDNS::Zone>] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.list _response, data = GandiV5.get url data.map { |item| from_gandi item } end # Get a zone from Gandi. # @param uuid [String, #to_s] the UUID of the zone to fetch. # @return [GandiV5::LiveDNS::Zone] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.fetch(uuid) _response, data = GandiV5.get url(uuid) from_gandi data end private def url "#{BASE}zones/#{CGI.escape uuid}" end def self.url(uuid = nil) BASE + (uuid ? "zones/#{CGI.escape(uuid)}" : 'zones') end private_class_method :url end |
#soa_email ⇒ String (readonly)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 27 class Zone include GandiV5::Data include GandiV5::LiveDNS::HasZoneRecords members :uuid, :name member :sharing_uuid, gandi_key: 'sharing_id' member :soa_retry, gandi_key: 'retry' member :soa_minimum, gandi_key: 'minimum' member :soa_refresh, gandi_key: 'refresh' member :soa_expire, gandi_key: 'expire' member :soa_serial, gandi_key: 'serial' member :soa_email, gandi_key: 'email' member :soa_primary_ns, gandi_key: 'primary_ns' alias zone_uuid uuid # Generate SOA record for the zone # @return [String] def to_s "@\tIN\tSOA\t#{soa_primary_ns} #{soa_email} (\n" \ "\t#{soa_serial}\t;Serial\n" \ "\t#{soa_refresh}\t\t;Refresh\n" \ "\t#{soa_retry}\t\t;Retry\n" \ "\t#{soa_expire}\t\t;Expire\n" \ "\t#{soa_minimum}\t\t;Minimum & Negative TTL\n" \ ')' end # List the domains that use this zone. # @return [Array<String>] The FQDNs. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def list_domains _response, data = GandiV5.get "#{url}/domains" data.map { |item| item['fqdn'] } end # Attach domain to this zone. # @param fqdn [String, #fqdn, #to_s] the fully qualified domain name # that should start using this zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def attach_domain(fqdn) fqdn = fqdn.fqdn if fqdn.respond_to?(:fqdn) _resp, data = GandiV5.patch "#{BASE}domains/#{CGI.escape fqdn}", { zone_uuid: uuid }.to_json data['message'] end # Get snapshot UUIDs for this zone from Gandi. # @return [Hash{String => Time}] Mapping snapshot UUID to time made. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshots GandiV5::LiveDNS::Zone::Snapshot.list uuid end # Get snapshot from Gandi. # @param uuid [String] the UUID of the snapshot to fetch. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshot(uuid) GandiV5::LiveDNS::Zone::Snapshot.fetch self.uuid, uuid end # Take a snapshot of this zone. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def take_snapshot _response, data = GandiV5.post "#{url}/snapshots" snapshot data['uuid'] end # Update this zone. # @param name [String, #to_s] new name for the zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def update(name:) _response, data = GandiV5.patch url, { name: name }.to_json self.name = name data['message'] end # Delete this zone from Gandi. # @return [nil] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def delete GandiV5.delete url end # Create a new zone. # @param name [String] the name for the created zone. # @param sharing_id [String] the UUID of the account to ceate the zone under. # @return [GandiV5::LiveDNS::Zone] The created zone. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.create(name, sharing_id: nil) params = sharing_id ? { sharing_id: sharing_id } : {} response, _data = GandiV5.post( url, { name: name }.to_json, params: params ) fetch response.headers[:location].split('/').last end # List the zones. # @return [Array<GandiV5::LiveDNS::Zone>] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.list _response, data = GandiV5.get url data.map { |item| from_gandi item } end # Get a zone from Gandi. # @param uuid [String, #to_s] the UUID of the zone to fetch. # @return [GandiV5::LiveDNS::Zone] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.fetch(uuid) _response, data = GandiV5.get url(uuid) from_gandi data end private def url "#{BASE}zones/#{CGI.escape uuid}" end def self.url(uuid = nil) BASE + (uuid ? "zones/#{CGI.escape(uuid)}" : 'zones') end private_class_method :url end |
#soa_expire ⇒ Integer (readonly)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 27 class Zone include GandiV5::Data include GandiV5::LiveDNS::HasZoneRecords members :uuid, :name member :sharing_uuid, gandi_key: 'sharing_id' member :soa_retry, gandi_key: 'retry' member :soa_minimum, gandi_key: 'minimum' member :soa_refresh, gandi_key: 'refresh' member :soa_expire, gandi_key: 'expire' member :soa_serial, gandi_key: 'serial' member :soa_email, gandi_key: 'email' member :soa_primary_ns, gandi_key: 'primary_ns' alias zone_uuid uuid # Generate SOA record for the zone # @return [String] def to_s "@\tIN\tSOA\t#{soa_primary_ns} #{soa_email} (\n" \ "\t#{soa_serial}\t;Serial\n" \ "\t#{soa_refresh}\t\t;Refresh\n" \ "\t#{soa_retry}\t\t;Retry\n" \ "\t#{soa_expire}\t\t;Expire\n" \ "\t#{soa_minimum}\t\t;Minimum & Negative TTL\n" \ ')' end # List the domains that use this zone. # @return [Array<String>] The FQDNs. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def list_domains _response, data = GandiV5.get "#{url}/domains" data.map { |item| item['fqdn'] } end # Attach domain to this zone. # @param fqdn [String, #fqdn, #to_s] the fully qualified domain name # that should start using this zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def attach_domain(fqdn) fqdn = fqdn.fqdn if fqdn.respond_to?(:fqdn) _resp, data = GandiV5.patch "#{BASE}domains/#{CGI.escape fqdn}", { zone_uuid: uuid }.to_json data['message'] end # Get snapshot UUIDs for this zone from Gandi. # @return [Hash{String => Time}] Mapping snapshot UUID to time made. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshots GandiV5::LiveDNS::Zone::Snapshot.list uuid end # Get snapshot from Gandi. # @param uuid [String] the UUID of the snapshot to fetch. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshot(uuid) GandiV5::LiveDNS::Zone::Snapshot.fetch self.uuid, uuid end # Take a snapshot of this zone. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def take_snapshot _response, data = GandiV5.post "#{url}/snapshots" snapshot data['uuid'] end # Update this zone. # @param name [String, #to_s] new name for the zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def update(name:) _response, data = GandiV5.patch url, { name: name }.to_json self.name = name data['message'] end # Delete this zone from Gandi. # @return [nil] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def delete GandiV5.delete url end # Create a new zone. # @param name [String] the name for the created zone. # @param sharing_id [String] the UUID of the account to ceate the zone under. # @return [GandiV5::LiveDNS::Zone] The created zone. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.create(name, sharing_id: nil) params = sharing_id ? { sharing_id: sharing_id } : {} response, _data = GandiV5.post( url, { name: name }.to_json, params: params ) fetch response.headers[:location].split('/').last end # List the zones. # @return [Array<GandiV5::LiveDNS::Zone>] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.list _response, data = GandiV5.get url data.map { |item| from_gandi item } end # Get a zone from Gandi. # @param uuid [String, #to_s] the UUID of the zone to fetch. # @return [GandiV5::LiveDNS::Zone] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.fetch(uuid) _response, data = GandiV5.get url(uuid) from_gandi data end private def url "#{BASE}zones/#{CGI.escape uuid}" end def self.url(uuid = nil) BASE + (uuid ? "zones/#{CGI.escape(uuid)}" : 'zones') end private_class_method :url end |
#soa_minimum ⇒ Integer (readonly)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 27 class Zone include GandiV5::Data include GandiV5::LiveDNS::HasZoneRecords members :uuid, :name member :sharing_uuid, gandi_key: 'sharing_id' member :soa_retry, gandi_key: 'retry' member :soa_minimum, gandi_key: 'minimum' member :soa_refresh, gandi_key: 'refresh' member :soa_expire, gandi_key: 'expire' member :soa_serial, gandi_key: 'serial' member :soa_email, gandi_key: 'email' member :soa_primary_ns, gandi_key: 'primary_ns' alias zone_uuid uuid # Generate SOA record for the zone # @return [String] def to_s "@\tIN\tSOA\t#{soa_primary_ns} #{soa_email} (\n" \ "\t#{soa_serial}\t;Serial\n" \ "\t#{soa_refresh}\t\t;Refresh\n" \ "\t#{soa_retry}\t\t;Retry\n" \ "\t#{soa_expire}\t\t;Expire\n" \ "\t#{soa_minimum}\t\t;Minimum & Negative TTL\n" \ ')' end # List the domains that use this zone. # @return [Array<String>] The FQDNs. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def list_domains _response, data = GandiV5.get "#{url}/domains" data.map { |item| item['fqdn'] } end # Attach domain to this zone. # @param fqdn [String, #fqdn, #to_s] the fully qualified domain name # that should start using this zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def attach_domain(fqdn) fqdn = fqdn.fqdn if fqdn.respond_to?(:fqdn) _resp, data = GandiV5.patch "#{BASE}domains/#{CGI.escape fqdn}", { zone_uuid: uuid }.to_json data['message'] end # Get snapshot UUIDs for this zone from Gandi. # @return [Hash{String => Time}] Mapping snapshot UUID to time made. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshots GandiV5::LiveDNS::Zone::Snapshot.list uuid end # Get snapshot from Gandi. # @param uuid [String] the UUID of the snapshot to fetch. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshot(uuid) GandiV5::LiveDNS::Zone::Snapshot.fetch self.uuid, uuid end # Take a snapshot of this zone. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def take_snapshot _response, data = GandiV5.post "#{url}/snapshots" snapshot data['uuid'] end # Update this zone. # @param name [String, #to_s] new name for the zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def update(name:) _response, data = GandiV5.patch url, { name: name }.to_json self.name = name data['message'] end # Delete this zone from Gandi. # @return [nil] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def delete GandiV5.delete url end # Create a new zone. # @param name [String] the name for the created zone. # @param sharing_id [String] the UUID of the account to ceate the zone under. # @return [GandiV5::LiveDNS::Zone] The created zone. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.create(name, sharing_id: nil) params = sharing_id ? { sharing_id: sharing_id } : {} response, _data = GandiV5.post( url, { name: name }.to_json, params: params ) fetch response.headers[:location].split('/').last end # List the zones. # @return [Array<GandiV5::LiveDNS::Zone>] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.list _response, data = GandiV5.get url data.map { |item| from_gandi item } end # Get a zone from Gandi. # @param uuid [String, #to_s] the UUID of the zone to fetch. # @return [GandiV5::LiveDNS::Zone] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.fetch(uuid) _response, data = GandiV5.get url(uuid) from_gandi data end private def url "#{BASE}zones/#{CGI.escape uuid}" end def self.url(uuid = nil) BASE + (uuid ? "zones/#{CGI.escape(uuid)}" : 'zones') end private_class_method :url end |
#soa_primary_ns ⇒ String (readonly)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 27 class Zone include GandiV5::Data include GandiV5::LiveDNS::HasZoneRecords members :uuid, :name member :sharing_uuid, gandi_key: 'sharing_id' member :soa_retry, gandi_key: 'retry' member :soa_minimum, gandi_key: 'minimum' member :soa_refresh, gandi_key: 'refresh' member :soa_expire, gandi_key: 'expire' member :soa_serial, gandi_key: 'serial' member :soa_email, gandi_key: 'email' member :soa_primary_ns, gandi_key: 'primary_ns' alias zone_uuid uuid # Generate SOA record for the zone # @return [String] def to_s "@\tIN\tSOA\t#{soa_primary_ns} #{soa_email} (\n" \ "\t#{soa_serial}\t;Serial\n" \ "\t#{soa_refresh}\t\t;Refresh\n" \ "\t#{soa_retry}\t\t;Retry\n" \ "\t#{soa_expire}\t\t;Expire\n" \ "\t#{soa_minimum}\t\t;Minimum & Negative TTL\n" \ ')' end # List the domains that use this zone. # @return [Array<String>] The FQDNs. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def list_domains _response, data = GandiV5.get "#{url}/domains" data.map { |item| item['fqdn'] } end # Attach domain to this zone. # @param fqdn [String, #fqdn, #to_s] the fully qualified domain name # that should start using this zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def attach_domain(fqdn) fqdn = fqdn.fqdn if fqdn.respond_to?(:fqdn) _resp, data = GandiV5.patch "#{BASE}domains/#{CGI.escape fqdn}", { zone_uuid: uuid }.to_json data['message'] end # Get snapshot UUIDs for this zone from Gandi. # @return [Hash{String => Time}] Mapping snapshot UUID to time made. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshots GandiV5::LiveDNS::Zone::Snapshot.list uuid end # Get snapshot from Gandi. # @param uuid [String] the UUID of the snapshot to fetch. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshot(uuid) GandiV5::LiveDNS::Zone::Snapshot.fetch self.uuid, uuid end # Take a snapshot of this zone. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def take_snapshot _response, data = GandiV5.post "#{url}/snapshots" snapshot data['uuid'] end # Update this zone. # @param name [String, #to_s] new name for the zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def update(name:) _response, data = GandiV5.patch url, { name: name }.to_json self.name = name data['message'] end # Delete this zone from Gandi. # @return [nil] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def delete GandiV5.delete url end # Create a new zone. # @param name [String] the name for the created zone. # @param sharing_id [String] the UUID of the account to ceate the zone under. # @return [GandiV5::LiveDNS::Zone] The created zone. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.create(name, sharing_id: nil) params = sharing_id ? { sharing_id: sharing_id } : {} response, _data = GandiV5.post( url, { name: name }.to_json, params: params ) fetch response.headers[:location].split('/').last end # List the zones. # @return [Array<GandiV5::LiveDNS::Zone>] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.list _response, data = GandiV5.get url data.map { |item| from_gandi item } end # Get a zone from Gandi. # @param uuid [String, #to_s] the UUID of the zone to fetch. # @return [GandiV5::LiveDNS::Zone] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.fetch(uuid) _response, data = GandiV5.get url(uuid) from_gandi data end private def url "#{BASE}zones/#{CGI.escape uuid}" end def self.url(uuid = nil) BASE + (uuid ? "zones/#{CGI.escape(uuid)}" : 'zones') end private_class_method :url end |
#soa_refresh ⇒ Integer (readonly)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 27 class Zone include GandiV5::Data include GandiV5::LiveDNS::HasZoneRecords members :uuid, :name member :sharing_uuid, gandi_key: 'sharing_id' member :soa_retry, gandi_key: 'retry' member :soa_minimum, gandi_key: 'minimum' member :soa_refresh, gandi_key: 'refresh' member :soa_expire, gandi_key: 'expire' member :soa_serial, gandi_key: 'serial' member :soa_email, gandi_key: 'email' member :soa_primary_ns, gandi_key: 'primary_ns' alias zone_uuid uuid # Generate SOA record for the zone # @return [String] def to_s "@\tIN\tSOA\t#{soa_primary_ns} #{soa_email} (\n" \ "\t#{soa_serial}\t;Serial\n" \ "\t#{soa_refresh}\t\t;Refresh\n" \ "\t#{soa_retry}\t\t;Retry\n" \ "\t#{soa_expire}\t\t;Expire\n" \ "\t#{soa_minimum}\t\t;Minimum & Negative TTL\n" \ ')' end # List the domains that use this zone. # @return [Array<String>] The FQDNs. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def list_domains _response, data = GandiV5.get "#{url}/domains" data.map { |item| item['fqdn'] } end # Attach domain to this zone. # @param fqdn [String, #fqdn, #to_s] the fully qualified domain name # that should start using this zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def attach_domain(fqdn) fqdn = fqdn.fqdn if fqdn.respond_to?(:fqdn) _resp, data = GandiV5.patch "#{BASE}domains/#{CGI.escape fqdn}", { zone_uuid: uuid }.to_json data['message'] end # Get snapshot UUIDs for this zone from Gandi. # @return [Hash{String => Time}] Mapping snapshot UUID to time made. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshots GandiV5::LiveDNS::Zone::Snapshot.list uuid end # Get snapshot from Gandi. # @param uuid [String] the UUID of the snapshot to fetch. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshot(uuid) GandiV5::LiveDNS::Zone::Snapshot.fetch self.uuid, uuid end # Take a snapshot of this zone. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def take_snapshot _response, data = GandiV5.post "#{url}/snapshots" snapshot data['uuid'] end # Update this zone. # @param name [String, #to_s] new name for the zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def update(name:) _response, data = GandiV5.patch url, { name: name }.to_json self.name = name data['message'] end # Delete this zone from Gandi. # @return [nil] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def delete GandiV5.delete url end # Create a new zone. # @param name [String] the name for the created zone. # @param sharing_id [String] the UUID of the account to ceate the zone under. # @return [GandiV5::LiveDNS::Zone] The created zone. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.create(name, sharing_id: nil) params = sharing_id ? { sharing_id: sharing_id } : {} response, _data = GandiV5.post( url, { name: name }.to_json, params: params ) fetch response.headers[:location].split('/').last end # List the zones. # @return [Array<GandiV5::LiveDNS::Zone>] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.list _response, data = GandiV5.get url data.map { |item| from_gandi item } end # Get a zone from Gandi. # @param uuid [String, #to_s] the UUID of the zone to fetch. # @return [GandiV5::LiveDNS::Zone] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.fetch(uuid) _response, data = GandiV5.get url(uuid) from_gandi data end private def url "#{BASE}zones/#{CGI.escape uuid}" end def self.url(uuid = nil) BASE + (uuid ? "zones/#{CGI.escape(uuid)}" : 'zones') end private_class_method :url end |
#soa_retry ⇒ Integer (readonly)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 27 class Zone include GandiV5::Data include GandiV5::LiveDNS::HasZoneRecords members :uuid, :name member :sharing_uuid, gandi_key: 'sharing_id' member :soa_retry, gandi_key: 'retry' member :soa_minimum, gandi_key: 'minimum' member :soa_refresh, gandi_key: 'refresh' member :soa_expire, gandi_key: 'expire' member :soa_serial, gandi_key: 'serial' member :soa_email, gandi_key: 'email' member :soa_primary_ns, gandi_key: 'primary_ns' alias zone_uuid uuid # Generate SOA record for the zone # @return [String] def to_s "@\tIN\tSOA\t#{soa_primary_ns} #{soa_email} (\n" \ "\t#{soa_serial}\t;Serial\n" \ "\t#{soa_refresh}\t\t;Refresh\n" \ "\t#{soa_retry}\t\t;Retry\n" \ "\t#{soa_expire}\t\t;Expire\n" \ "\t#{soa_minimum}\t\t;Minimum & Negative TTL\n" \ ')' end # List the domains that use this zone. # @return [Array<String>] The FQDNs. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def list_domains _response, data = GandiV5.get "#{url}/domains" data.map { |item| item['fqdn'] } end # Attach domain to this zone. # @param fqdn [String, #fqdn, #to_s] the fully qualified domain name # that should start using this zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def attach_domain(fqdn) fqdn = fqdn.fqdn if fqdn.respond_to?(:fqdn) _resp, data = GandiV5.patch "#{BASE}domains/#{CGI.escape fqdn}", { zone_uuid: uuid }.to_json data['message'] end # Get snapshot UUIDs for this zone from Gandi. # @return [Hash{String => Time}] Mapping snapshot UUID to time made. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshots GandiV5::LiveDNS::Zone::Snapshot.list uuid end # Get snapshot from Gandi. # @param uuid [String] the UUID of the snapshot to fetch. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshot(uuid) GandiV5::LiveDNS::Zone::Snapshot.fetch self.uuid, uuid end # Take a snapshot of this zone. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def take_snapshot _response, data = GandiV5.post "#{url}/snapshots" snapshot data['uuid'] end # Update this zone. # @param name [String, #to_s] new name for the zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def update(name:) _response, data = GandiV5.patch url, { name: name }.to_json self.name = name data['message'] end # Delete this zone from Gandi. # @return [nil] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def delete GandiV5.delete url end # Create a new zone. # @param name [String] the name for the created zone. # @param sharing_id [String] the UUID of the account to ceate the zone under. # @return [GandiV5::LiveDNS::Zone] The created zone. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.create(name, sharing_id: nil) params = sharing_id ? { sharing_id: sharing_id } : {} response, _data = GandiV5.post( url, { name: name }.to_json, params: params ) fetch response.headers[:location].split('/').last end # List the zones. # @return [Array<GandiV5::LiveDNS::Zone>] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.list _response, data = GandiV5.get url data.map { |item| from_gandi item } end # Get a zone from Gandi. # @param uuid [String, #to_s] the UUID of the zone to fetch. # @return [GandiV5::LiveDNS::Zone] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.fetch(uuid) _response, data = GandiV5.get url(uuid) from_gandi data end private def url "#{BASE}zones/#{CGI.escape uuid}" end def self.url(uuid = nil) BASE + (uuid ? "zones/#{CGI.escape(uuid)}" : 'zones') end private_class_method :url end |
#soa_serial ⇒ Integer (readonly)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 27 class Zone include GandiV5::Data include GandiV5::LiveDNS::HasZoneRecords members :uuid, :name member :sharing_uuid, gandi_key: 'sharing_id' member :soa_retry, gandi_key: 'retry' member :soa_minimum, gandi_key: 'minimum' member :soa_refresh, gandi_key: 'refresh' member :soa_expire, gandi_key: 'expire' member :soa_serial, gandi_key: 'serial' member :soa_email, gandi_key: 'email' member :soa_primary_ns, gandi_key: 'primary_ns' alias zone_uuid uuid # Generate SOA record for the zone # @return [String] def to_s "@\tIN\tSOA\t#{soa_primary_ns} #{soa_email} (\n" \ "\t#{soa_serial}\t;Serial\n" \ "\t#{soa_refresh}\t\t;Refresh\n" \ "\t#{soa_retry}\t\t;Retry\n" \ "\t#{soa_expire}\t\t;Expire\n" \ "\t#{soa_minimum}\t\t;Minimum & Negative TTL\n" \ ')' end # List the domains that use this zone. # @return [Array<String>] The FQDNs. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def list_domains _response, data = GandiV5.get "#{url}/domains" data.map { |item| item['fqdn'] } end # Attach domain to this zone. # @param fqdn [String, #fqdn, #to_s] the fully qualified domain name # that should start using this zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def attach_domain(fqdn) fqdn = fqdn.fqdn if fqdn.respond_to?(:fqdn) _resp, data = GandiV5.patch "#{BASE}domains/#{CGI.escape fqdn}", { zone_uuid: uuid }.to_json data['message'] end # Get snapshot UUIDs for this zone from Gandi. # @return [Hash{String => Time}] Mapping snapshot UUID to time made. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshots GandiV5::LiveDNS::Zone::Snapshot.list uuid end # Get snapshot from Gandi. # @param uuid [String] the UUID of the snapshot to fetch. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshot(uuid) GandiV5::LiveDNS::Zone::Snapshot.fetch self.uuid, uuid end # Take a snapshot of this zone. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def take_snapshot _response, data = GandiV5.post "#{url}/snapshots" snapshot data['uuid'] end # Update this zone. # @param name [String, #to_s] new name for the zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def update(name:) _response, data = GandiV5.patch url, { name: name }.to_json self.name = name data['message'] end # Delete this zone from Gandi. # @return [nil] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def delete GandiV5.delete url end # Create a new zone. # @param name [String] the name for the created zone. # @param sharing_id [String] the UUID of the account to ceate the zone under. # @return [GandiV5::LiveDNS::Zone] The created zone. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.create(name, sharing_id: nil) params = sharing_id ? { sharing_id: sharing_id } : {} response, _data = GandiV5.post( url, { name: name }.to_json, params: params ) fetch response.headers[:location].split('/').last end # List the zones. # @return [Array<GandiV5::LiveDNS::Zone>] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.list _response, data = GandiV5.get url data.map { |item| from_gandi item } end # Get a zone from Gandi. # @param uuid [String, #to_s] the UUID of the zone to fetch. # @return [GandiV5::LiveDNS::Zone] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.fetch(uuid) _response, data = GandiV5.get url(uuid) from_gandi data end private def url "#{BASE}zones/#{CGI.escape uuid}" end def self.url(uuid = nil) BASE + (uuid ? "zones/#{CGI.escape(uuid)}" : 'zones') end private_class_method :url end |
#uuid ⇒ String (readonly) Also known as: zone_uuid
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 27 class Zone include GandiV5::Data include GandiV5::LiveDNS::HasZoneRecords members :uuid, :name member :sharing_uuid, gandi_key: 'sharing_id' member :soa_retry, gandi_key: 'retry' member :soa_minimum, gandi_key: 'minimum' member :soa_refresh, gandi_key: 'refresh' member :soa_expire, gandi_key: 'expire' member :soa_serial, gandi_key: 'serial' member :soa_email, gandi_key: 'email' member :soa_primary_ns, gandi_key: 'primary_ns' alias zone_uuid uuid # Generate SOA record for the zone # @return [String] def to_s "@\tIN\tSOA\t#{soa_primary_ns} #{soa_email} (\n" \ "\t#{soa_serial}\t;Serial\n" \ "\t#{soa_refresh}\t\t;Refresh\n" \ "\t#{soa_retry}\t\t;Retry\n" \ "\t#{soa_expire}\t\t;Expire\n" \ "\t#{soa_minimum}\t\t;Minimum & Negative TTL\n" \ ')' end # List the domains that use this zone. # @return [Array<String>] The FQDNs. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def list_domains _response, data = GandiV5.get "#{url}/domains" data.map { |item| item['fqdn'] } end # Attach domain to this zone. # @param fqdn [String, #fqdn, #to_s] the fully qualified domain name # that should start using this zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def attach_domain(fqdn) fqdn = fqdn.fqdn if fqdn.respond_to?(:fqdn) _resp, data = GandiV5.patch "#{BASE}domains/#{CGI.escape fqdn}", { zone_uuid: uuid }.to_json data['message'] end # Get snapshot UUIDs for this zone from Gandi. # @return [Hash{String => Time}] Mapping snapshot UUID to time made. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshots GandiV5::LiveDNS::Zone::Snapshot.list uuid end # Get snapshot from Gandi. # @param uuid [String] the UUID of the snapshot to fetch. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def snapshot(uuid) GandiV5::LiveDNS::Zone::Snapshot.fetch self.uuid, uuid end # Take a snapshot of this zone. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def take_snapshot _response, data = GandiV5.post "#{url}/snapshots" snapshot data['uuid'] end # Update this zone. # @param name [String, #to_s] new name for the zone. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def update(name:) _response, data = GandiV5.patch url, { name: name }.to_json self.name = name data['message'] end # Delete this zone from Gandi. # @return [nil] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def delete GandiV5.delete url end # Create a new zone. # @param name [String] the name for the created zone. # @param sharing_id [String] the UUID of the account to ceate the zone under. # @return [GandiV5::LiveDNS::Zone] The created zone. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.create(name, sharing_id: nil) params = sharing_id ? { sharing_id: sharing_id } : {} response, _data = GandiV5.post( url, { name: name }.to_json, params: params ) fetch response.headers[:location].split('/').last end # List the zones. # @return [Array<GandiV5::LiveDNS::Zone>] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.list _response, data = GandiV5.get url data.map { |item| from_gandi item } end # Get a zone from Gandi. # @param uuid [String, #to_s] the UUID of the zone to fetch. # @return [GandiV5::LiveDNS::Zone] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.fetch(uuid) _response, data = GandiV5.get url(uuid) from_gandi data end private def url "#{BASE}zones/#{CGI.escape uuid}" end def self.url(uuid = nil) BASE + (uuid ? "zones/#{CGI.escape(uuid)}" : 'zones') end private_class_method :url end |
Class Method Details
.create(name, sharing_id: nil) ⇒ GandiV5::LiveDNS::Zone
Create a new zone.
119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 119 def self.create(name, sharing_id: nil) params = sharing_id ? { sharing_id: sharing_id } : {} response, _data = GandiV5.post( url, { name: name }.to_json, params: params ) fetch response.headers[:location].split('/').last end |
.fetch(uuid) ⇒ GandiV5::LiveDNS::Zone
Get a zone from Gandi.
143 144 145 146 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 143 def self.fetch(uuid) _response, data = GandiV5.get url(uuid) from_gandi data end |
.list ⇒ Array<GandiV5::LiveDNS::Zone>
List the zones.
134 135 136 137 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 134 def self.list _response, data = GandiV5.get url data.map { |item| from_gandi item } end |
Instance Method Details
#attach_domain(fqdn) ⇒ String
Attach domain to this zone.
68 69 70 71 72 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 68 def attach_domain(fqdn) fqdn = fqdn.fqdn if fqdn.respond_to?(:fqdn) _resp, data = GandiV5.patch "#{BASE}domains/#{CGI.escape fqdn}", { zone_uuid: uuid }.to_json data['message'] end |
#delete ⇒ nil
Delete this zone from Gandi.
110 111 112 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 110 def delete GandiV5.delete url end |
#list_domains ⇒ Array<String>
List the domains that use this zone.
58 59 60 61 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 58 def list_domains _response, data = GandiV5.get "#{url}/domains" data.map { |item| item['fqdn'] } end |
#snapshot(uuid) ⇒ GandiV5::LiveDNS::Zone::Snapshot
Get snapshot from Gandi.
85 86 87 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 85 def snapshot(uuid) GandiV5::LiveDNS::Zone::Snapshot.fetch self.uuid, uuid end |
#snapshots ⇒ Hash{String => Time}
Get snapshot UUIDs for this zone from Gandi.
77 78 79 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 77 def snapshots GandiV5::LiveDNS::Zone::Snapshot.list uuid end |
#take_snapshot ⇒ GandiV5::LiveDNS::Zone::Snapshot
Take a snapshot of this zone.
92 93 94 95 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 92 def take_snapshot _response, data = GandiV5.post "#{url}/snapshots" snapshot data['uuid'] end |
#to_s ⇒ String
Generate SOA record for the zone
45 46 47 48 49 50 51 52 53 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 45 def to_s "@\tIN\tSOA\t#{soa_primary_ns} #{soa_email} (\n" \ "\t#{soa_serial}\t;Serial\n" \ "\t#{soa_refresh}\t\t;Refresh\n" \ "\t#{soa_retry}\t\t;Retry\n" \ "\t#{soa_expire}\t\t;Expire\n" \ "\t#{soa_minimum}\t\t;Minimum & Negative TTL\n" \ ')' end |
#update(name:) ⇒ String
Update this zone.
101 102 103 104 105 |
# File 'lib/gandi_v5/live_dns/zone.rb', line 101 def update(name:) _response, data = GandiV5.patch url, { name: name }.to_json self.name = name data['message'] end |