Class: OVH::Provisioner::APIObject::DomainZone
- Defined in:
- lib/ovh/provisioner/api_object/domain_zone.rb
Overview
Represent a Domain
Instance Attribute Summary collapse
-
#dnssec ⇒ Object
readonly
Returns the value of attribute dnssec.
-
#dnssec_supported ⇒ Object
readonly
Returns the value of attribute dnssec_supported.
-
#nameservers ⇒ Object
readonly
Returns the value of attribute nameservers.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Attributes inherited from APIObject
Instance Method Summary collapse
- #add_record(subdomain, type, target, ttl = 0) ⇒ Object
- #details(record_lists = records) ⇒ Object
- #filter_records(config) ⇒ Object
- #rm_record(record) ⇒ Object
- #rm_records(records) ⇒ Object
- #to_s ⇒ Object
Methods inherited from APIObject
#<=>, attr_reader, attributes, #attributes, classname, #config, #delete, entrypoint, #get, #init_properties, #initialize, #post, underscore
Constructor Details
This class inherits a constructor from OVH::Provisioner::APIObject::APIObject
Instance Attribute Details
#dnssec ⇒ Object (readonly)
Returns the value of attribute dnssec.
24 25 26 |
# File 'lib/ovh/provisioner/api_object/domain_zone.rb', line 24 def dnssec @dnssec end |
#dnssec_supported ⇒ Object (readonly)
Returns the value of attribute dnssec_supported.
24 25 26 |
# File 'lib/ovh/provisioner/api_object/domain_zone.rb', line 24 def dnssec_supported @dnssec_supported end |
#nameservers ⇒ Object (readonly)
Returns the value of attribute nameservers.
24 25 26 |
# File 'lib/ovh/provisioner/api_object/domain_zone.rb', line 24 def nameservers @nameservers end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
24 25 26 |
# File 'lib/ovh/provisioner/api_object/domain_zone.rb', line 24 def records @records end |
Instance Method Details
#add_record(subdomain, type, target, ttl = 0) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ovh/provisioner/api_object/domain_zone.rb', line 35 def add_record(subdomain, type, target, ttl = 0) body = { 'fieldType' => type.upcase, 'target' => target, 'ttl' => ttl.to_i } sub = subdomain body['subDomain'] = sub unless sub.nil? || sub.empty? answer = post('record', body) post('refresh') format(answer) end |
#details(record_lists = records) ⇒ Object
30 31 32 33 |
# File 'lib/ovh/provisioner/api_object/domain_zone.rb', line 30 def details(record_lists = records) "#{id} - dnssec: #{dnssec_to_s}\n"\ "#{(record_lists.format('type').lines[1..-1] || []).join('')}" end |
#filter_records(config) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/ovh/provisioner/api_object/domain_zone.rb', line 59 def filter_records(config) filter = generate_filter( config['subdomain'] || '', config['type'] || '', config['target'] || '', config['ttl'] || '' ) targets = records.list.dup.keep_if do |record| filter.call(record) end.map(&:id) Actor[Spawner::NAME].get('Record', *targets, parent: @url) end |
#rm_record(record) ⇒ Object
48 49 50 51 52 |
# File 'lib/ovh/provisioner/api_object/domain_zone.rb', line 48 def rm_record(record) out = delete("record/#{record.id}") post('refresh') " #{record}#{out.nil? ? '' : ": #{out}"}" end |
#rm_records(records) ⇒ Object
54 55 56 57 |
# File 'lib/ovh/provisioner/api_object/domain_zone.rb', line 54 def rm_records(records) outputs = records.parallel_map(:rm_record, [], Actor.current) (["#{id}, remove records:"] + outputs.sort).join("\n") end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/ovh/provisioner/api_object/domain_zone.rb', line 26 def to_s "#{id}, dnssec #{dnssec_to_s}, #{records.list.size} records" end |