Module: Dnsimple::Client::TemplatesRecords

Included in:
TemplatesService
Defined in:
lib/dnsimple/client/templates_records.rb

Instance Method Summary collapse

Instance Method Details

#create_record(template, attributes = {}, options = {}) ⇒ Struct::TemplateRecord

Creates a record for a template.

Parameters:

  • template (#to_s)

    The template id or short-name.

  • attributes (Hash) (defaults to: {})

Returns:

Raises:

See Also:



30
31
32
33
34
35
36
# File 'lib/dnsimple/client/templates_records.rb', line 30

def create_record(template, attributes = {}, options = {})
  Extra.validate_mandatory_attributes(attributes, [:name, :record_type, :content])
  options  = options.merge({ dns_template_record: attributes })
  response = client.post(Client.versioned("/templates/#{template}/records"), options)

  Struct::TemplateRecord.new(response["dns_template_record"])
end

#delete_record(template, record, options = {}) ⇒ Template

Deletes a record for a template.

Parameters:

  • template (#to_s)

    The template id or short-name.

  • record (Fixnum)

    The record id.

Returns:

  • (Template)

Raises:

See Also:



82
83
84
# File 'lib/dnsimple/client/templates_records.rb', line 82

def delete_record(template, record, options = {})
  client.delete(Client.versioned("/templates/#{template}/records/#{record}"), options)
end

#record(template, record, options = {}) ⇒ Struct::TemplateRecord

Gets a record for a template.

Parameters:

  • template (#to_s)

    The template id or short-name.

  • record (Fixnum)

    The record id.

Returns:

Raises:

See Also:



48
49
50
51
52
# File 'lib/dnsimple/client/templates_records.rb', line 48

def record(template, record, options = {})
  response = client.get(Client.versioned("/templates/#{template}/records/#{record}"), options)

  Struct::TemplateRecord.new(response["dns_template_record"])
end

#records(template, options = {}) ⇒ Array<Struct::TemplateRecord>

Lists the records for a template.

Parameters:

  • template (#to_s)

    The template id or short-name.

Returns:

Raises:

See Also:



14
15
16
17
18
# File 'lib/dnsimple/client/templates_records.rb', line 14

def records(template, options = {})
  response = client.get(Client.versioned("/templates/#{template}/records"), options)

  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.

Parameters:

  • template (#to_s)

    The template id or short-name.

  • record (Fixnum)

    The record id.

  • attributes (Hash) (defaults to: {})

Returns:

Raises:

See Also:



65
66
67
68
69
70
# File 'lib/dnsimple/client/templates_records.rb', line 65

def update_record(template, record, attributes = {}, options = {})
  options  = options.merge({ dns_template_record: attributes })
  response = client.put(Client.versioned("/templates/#{template}/records/#{record}"), options)

  Struct::TemplateRecord.new(response["dns_template_record"])
end