Module: Dnsimple::Client::TemplatesRecords
- Included in:
- TemplatesService
- Defined in:
- lib/dnsimple/client/templates_records.rb
Instance Method Summary collapse
-
#create_record(template, attributes = {}, options = {}) ⇒ Struct::TemplateRecord
Creates a record for a template.
-
#delete_record(template, record, options = {}) ⇒ Template
Deletes a record for a template.
-
#record(template, record, options = {}) ⇒ Struct::TemplateRecord
Gets a record for a template.
-
#records(template, options = {}) ⇒ Array<Struct::TemplateRecord>
Lists the records for a template.
-
#update_record(template, record, attributes = {}, options = {}) ⇒ Struct::TemplateRecord
Updates a record for a template.
Instance Method Details
#create_record(template, attributes = {}, options = {}) ⇒ Struct::TemplateRecord
Creates a record for a template.
30 31 32 33 34 35 36 |
# File 'lib/dnsimple/client/templates_records.rb', line 30 def create_record(template, attributes = {}, = {}) Extra.validate_mandatory_attributes(attributes, [:name, :record_type, :content]) = .merge({ dns_template_record: attributes }) response = client.post(Client.versioned("/templates/#{template}/records"), ) Struct::TemplateRecord.new(response["dns_template_record"]) end |
#delete_record(template, record, options = {}) ⇒ Template
Deletes a record for a template.
82 83 84 |
# File 'lib/dnsimple/client/templates_records.rb', line 82 def delete_record(template, record, = {}) client.delete(Client.versioned("/templates/#{template}/records/#{record}"), ) end |
#record(template, record, options = {}) ⇒ Struct::TemplateRecord
Gets a record for a template.
48 49 50 51 52 |
# File 'lib/dnsimple/client/templates_records.rb', line 48 def record(template, record, = {}) response = client.get(Client.versioned("/templates/#{template}/records/#{record}"), ) Struct::TemplateRecord.new(response["dns_template_record"]) end |
#records(template, options = {}) ⇒ Array<Struct::TemplateRecord>
Lists the records for a template.
14 15 16 17 18 |
# File 'lib/dnsimple/client/templates_records.rb', line 14 def records(template, = {}) response = client.get(Client.versioned("/templates/#{template}/records"), ) response.map { |r| Struct::TemplateRecord.new(r["dns_template_record"]) } end |
#update_record(template, record, attributes = {}, options = {}) ⇒ Struct::TemplateRecord
Updates a record for a template.
65 66 67 68 69 70 |
# File 'lib/dnsimple/client/templates_records.rb', line 65 def update_record(template, record, attributes = {}, = {}) = .merge({ dns_template_record: attributes }) response = client.put(Client.versioned("/templates/#{template}/records/#{record}"), ) Struct::TemplateRecord.new(response["dns_template_record"]) end |