Class: CloudParty::Nodes::Zones
- Inherits:
-
Object
- Object
- CloudParty::Nodes::Zones
- Includes:
- Context, HTTParty
- Defined in:
- lib/cloud_party/nodes/zones.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_record(type, name, content, opts, zone:) ⇒ Object
- #get(id) ⇒ Object
-
#initialize(options = {}) ⇒ Zones
constructor
A new instance of Zones.
- #list ⇒ Object
Methods included from Context
Constructor Details
#initialize(options = {}) ⇒ Zones
Returns a new instance of Zones.
30 31 32 33 |
# File 'lib/cloud_party/nodes/zones.rb', line 30 def initialize( = {}) super() = end |
Class Method Details
.set_id_by_name(zone) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cloud_party/nodes/zones.rb', line 16 def self.set_id_by_name(zone) = { match: 'all', name: zone, order: 'name' } if .nil? = else .merge!() end @@zone = CloudParty::Responses::Zones.new(:get, '/zones', get('/zones', query: ), ).result.first.fetch(:id, nil) end |
Instance Method Details
#add_record(type, name, content, opts, zone:) ⇒ Object
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 |
# File 'lib/cloud_party/nodes/zones.rb', line 43 def add_record(type, name, content, opts, zone:) zone_id = nil = { type: type, name: name, content: content } ttl = opts.fetch('ttl', nil) priority = opts.fetch('priority', nil) proxied = opts.fetch('proxied', nil) .merge!(ttl: ttl) unless ttl.nil? .merge!(priority: priority) unless priority.nil? .merge!(proxied: proxied) unless proxied.nil? if zone = { match: 'all', name: zone, order: 'name' } zone_id = CloudParty::Responses::Zones.new(:get, '/zones', get('/zones', query: ), ).result.first.fetch(:id, nil) end CloudParty::Responses::Zones.new( :post, '/zones/', self.class.get("/zones/#{@@zone || zone_id}/dns_records", ), ) end |
#get(id) ⇒ Object
39 40 41 |
# File 'lib/cloud_party/nodes/zones.rb', line 39 def get(id) CloudParty::Responses::Zones.new(:get, '/zones/:id', self.class.get("/zones/#{id}"), ) end |
#list ⇒ Object
35 36 37 |
# File 'lib/cloud_party/nodes/zones.rb', line 35 def list CloudParty::Responses::Zones.new(:get, '/zones', self.class.get('/zones'), ) end |