Class: GandiV5::LiveDNS::Zone::Snapshot
- Inherits:
-
Object
- Object
- GandiV5::LiveDNS::Zone::Snapshot
- Includes:
- Data
- Defined in:
- lib/gandi_v5/live_dns/zone/snapshot.rb
Overview
A snapshot (backup) of a zone.
Instance Attribute Summary collapse
- #created_at ⇒ Time readonly
- #records ⇒ Array<GandiV5::LiveDNS::RecordSet> readonly
- #uuid ⇒ String (also: #snapshot_uuid) readonly
- #zone_uuid ⇒ String readonly
Class Method Summary collapse
-
.fetch(zone_uuid, snapshot_uuid) ⇒ GandiV5::LiveDNS::Zone::Snapshot
Get snapshot from Gandi.
-
.list(zone_uuid) ⇒ Hash{String => Time}
Get snapshot UUIDs for this zone from Gandi.
Instance Method Summary collapse
-
#delete ⇒ String
Delete this snapshot.
- #fetch_zone ⇒ Object
-
#zone ⇒ GandiV5::LiveDNS::Zone
The snapshot’s zone (fetching from Gandi if required).
Methods included from Data
#from_gandi, included, #initialize, #to_gandi, #to_h, #values_at
Instance Attribute Details
#created_at ⇒ Time (readonly)
15 16 17 18 19 20 21 22 23 24 25 26 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 |
# File 'lib/gandi_v5/live_dns/zone/snapshot.rb', line 15 class Snapshot include GandiV5::Data members :uuid, :zone_uuid member :created_at, gandi_key: 'date_created', converter: GandiV5::Data::Converter::Time member( :records, gandi_key: 'zone_data', converter: GandiV5::LiveDNS::RecordSet, array: true ) alias snapshot_uuid uuid # Delete this snapshot. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def delete _response, data = GandiV5.delete url data['message'] end # @see GandiV5::LiveDNS::Zone.fetch def fetch_zone GandiV5::LiveDNS::Zone.fetch zone_uuid end # The snapshot's zone (fetching from Gandi if required). # @return [GandiV5::LiveDNS::Zone] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def zone @zone ||= fetch_zone end # Get snapshot UUIDs for this zone from Gandi. # @return [Hash{String => Time}] Mapping UUID to time made. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.list(zone_uuid) _response, data = GandiV5.get url(zone_uuid) Hash[data.map { |snapshot| [snapshot['uuid'], Time.parse(snapshot['date_created'])] }] end # Get snapshot from Gandi. # @param zone_uuid [String, #to_s] the UUID of the zone the snapshot was made of. # @param snapshot_uuid [String, #to_s] the UUID of the snapshot to fetch. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.fetch(zone_uuid, snapshot_uuid) _response, data = GandiV5.get url(zone_uuid, snapshot_uuid) from_gandi data end private def url "#{BASE}zones/#{CGI.escape zone_uuid}/snapshots/#{CGI.escape uuid}" end def self.url(zone_uuid, snapshot_uuid = nil) "#{BASE}zones/#{CGI.escape zone_uuid}/snapshots" + (snapshot_uuid ? "/#{CGI.escape snapshot_uuid}" : '') end private_class_method :url end |
#records ⇒ Array<GandiV5::LiveDNS::RecordSet> (readonly)
15 16 17 18 19 20 21 22 23 24 25 26 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 |
# File 'lib/gandi_v5/live_dns/zone/snapshot.rb', line 15 class Snapshot include GandiV5::Data members :uuid, :zone_uuid member :created_at, gandi_key: 'date_created', converter: GandiV5::Data::Converter::Time member( :records, gandi_key: 'zone_data', converter: GandiV5::LiveDNS::RecordSet, array: true ) alias snapshot_uuid uuid # Delete this snapshot. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def delete _response, data = GandiV5.delete url data['message'] end # @see GandiV5::LiveDNS::Zone.fetch def fetch_zone GandiV5::LiveDNS::Zone.fetch zone_uuid end # The snapshot's zone (fetching from Gandi if required). # @return [GandiV5::LiveDNS::Zone] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def zone @zone ||= fetch_zone end # Get snapshot UUIDs for this zone from Gandi. # @return [Hash{String => Time}] Mapping UUID to time made. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.list(zone_uuid) _response, data = GandiV5.get url(zone_uuid) Hash[data.map { |snapshot| [snapshot['uuid'], Time.parse(snapshot['date_created'])] }] end # Get snapshot from Gandi. # @param zone_uuid [String, #to_s] the UUID of the zone the snapshot was made of. # @param snapshot_uuid [String, #to_s] the UUID of the snapshot to fetch. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.fetch(zone_uuid, snapshot_uuid) _response, data = GandiV5.get url(zone_uuid, snapshot_uuid) from_gandi data end private def url "#{BASE}zones/#{CGI.escape zone_uuid}/snapshots/#{CGI.escape uuid}" end def self.url(zone_uuid, snapshot_uuid = nil) "#{BASE}zones/#{CGI.escape zone_uuid}/snapshots" + (snapshot_uuid ? "/#{CGI.escape snapshot_uuid}" : '') end private_class_method :url end |
#uuid ⇒ String (readonly) Also known as: snapshot_uuid
15 16 17 18 19 20 21 22 23 24 25 26 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 |
# File 'lib/gandi_v5/live_dns/zone/snapshot.rb', line 15 class Snapshot include GandiV5::Data members :uuid, :zone_uuid member :created_at, gandi_key: 'date_created', converter: GandiV5::Data::Converter::Time member( :records, gandi_key: 'zone_data', converter: GandiV5::LiveDNS::RecordSet, array: true ) alias snapshot_uuid uuid # Delete this snapshot. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def delete _response, data = GandiV5.delete url data['message'] end # @see GandiV5::LiveDNS::Zone.fetch def fetch_zone GandiV5::LiveDNS::Zone.fetch zone_uuid end # The snapshot's zone (fetching from Gandi if required). # @return [GandiV5::LiveDNS::Zone] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def zone @zone ||= fetch_zone end # Get snapshot UUIDs for this zone from Gandi. # @return [Hash{String => Time}] Mapping UUID to time made. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.list(zone_uuid) _response, data = GandiV5.get url(zone_uuid) Hash[data.map { |snapshot| [snapshot['uuid'], Time.parse(snapshot['date_created'])] }] end # Get snapshot from Gandi. # @param zone_uuid [String, #to_s] the UUID of the zone the snapshot was made of. # @param snapshot_uuid [String, #to_s] the UUID of the snapshot to fetch. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.fetch(zone_uuid, snapshot_uuid) _response, data = GandiV5.get url(zone_uuid, snapshot_uuid) from_gandi data end private def url "#{BASE}zones/#{CGI.escape zone_uuid}/snapshots/#{CGI.escape uuid}" end def self.url(zone_uuid, snapshot_uuid = nil) "#{BASE}zones/#{CGI.escape zone_uuid}/snapshots" + (snapshot_uuid ? "/#{CGI.escape snapshot_uuid}" : '') end private_class_method :url end |
#zone_uuid ⇒ String (readonly)
15 16 17 18 19 20 21 22 23 24 25 26 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 |
# File 'lib/gandi_v5/live_dns/zone/snapshot.rb', line 15 class Snapshot include GandiV5::Data members :uuid, :zone_uuid member :created_at, gandi_key: 'date_created', converter: GandiV5::Data::Converter::Time member( :records, gandi_key: 'zone_data', converter: GandiV5::LiveDNS::RecordSet, array: true ) alias snapshot_uuid uuid # Delete this snapshot. # @return [String] The confirmation message from Gandi. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def delete _response, data = GandiV5.delete url data['message'] end # @see GandiV5::LiveDNS::Zone.fetch def fetch_zone GandiV5::LiveDNS::Zone.fetch zone_uuid end # The snapshot's zone (fetching from Gandi if required). # @return [GandiV5::LiveDNS::Zone] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def zone @zone ||= fetch_zone end # Get snapshot UUIDs for this zone from Gandi. # @return [Hash{String => Time}] Mapping UUID to time made. # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.list(zone_uuid) _response, data = GandiV5.get url(zone_uuid) Hash[data.map { |snapshot| [snapshot['uuid'], Time.parse(snapshot['date_created'])] }] end # Get snapshot from Gandi. # @param zone_uuid [String, #to_s] the UUID of the zone the snapshot was made of. # @param snapshot_uuid [String, #to_s] the UUID of the snapshot to fetch. # @return [GandiV5::LiveDNS::Zone::Snapshot] # @raise [GandiV5::Error::GandiError] if Gandi returns an error. def self.fetch(zone_uuid, snapshot_uuid) _response, data = GandiV5.get url(zone_uuid, snapshot_uuid) from_gandi data end private def url "#{BASE}zones/#{CGI.escape zone_uuid}/snapshots/#{CGI.escape uuid}" end def self.url(zone_uuid, snapshot_uuid = nil) "#{BASE}zones/#{CGI.escape zone_uuid}/snapshots" + (snapshot_uuid ? "/#{CGI.escape snapshot_uuid}" : '') end private_class_method :url end |
Class Method Details
.fetch(zone_uuid, snapshot_uuid) ⇒ GandiV5::LiveDNS::Zone::Snapshot
Get snapshot from Gandi.
62 63 64 65 |
# File 'lib/gandi_v5/live_dns/zone/snapshot.rb', line 62 def self.fetch(zone_uuid, snapshot_uuid) _response, data = GandiV5.get url(zone_uuid, snapshot_uuid) from_gandi data end |
.list(zone_uuid) ⇒ Hash{String => Time}
Get snapshot UUIDs for this zone from Gandi.
52 53 54 55 |
# File 'lib/gandi_v5/live_dns/zone/snapshot.rb', line 52 def self.list(zone_uuid) _response, data = GandiV5.get url(zone_uuid) Hash[data.map { |snapshot| [snapshot['uuid'], Time.parse(snapshot['date_created'])] }] end |
Instance Method Details
#delete ⇒ String
Delete this snapshot.
32 33 34 35 |
# File 'lib/gandi_v5/live_dns/zone/snapshot.rb', line 32 def delete _response, data = GandiV5.delete url data['message'] end |
#fetch_zone ⇒ Object
38 39 40 |
# File 'lib/gandi_v5/live_dns/zone/snapshot.rb', line 38 def fetch_zone GandiV5::LiveDNS::Zone.fetch zone_uuid end |
#zone ⇒ GandiV5::LiveDNS::Zone
The snapshot’s zone (fetching from Gandi if required).
45 46 47 |
# File 'lib/gandi_v5/live_dns/zone/snapshot.rb', line 45 def zone @zone ||= fetch_zone end |