Module: Dnsimple::Client::DomainsRecords

Included in:
DomainsService
Defined in:
lib/dnsimple/client/domains_records.rb

Instance Method Summary collapse

Instance Method Details

#create_record(domain, attributes = {}, options = {}) ⇒ Struct::Record

Creates a record for a domain.

Parameters:

  • domain (#to_s)

    The domain id or domain name.

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

Returns:

Raises:

See Also:



32
33
34
35
36
37
38
# File 'lib/dnsimple/client/domains_records.rb', line 32

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

  Struct::Record.new(response["record"])
end

#delete_record(domain, record, options = {}) ⇒ void

This method returns an undefined value.

Deletes a record for a domain.

Parameters:

  • domain (#to_s)

    The domain id or domain name.

  • record (Fixnum)

    The record id.

Raises:

See Also:



84
85
86
# File 'lib/dnsimple/client/domains_records.rb', line 84

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

#record(domain, record, options = {}) ⇒ Struct::Record

Gets a record for a domain.

Parameters:

  • domain (#to_s)

    The domain id or domain name.

  • record (Fixnum)

    The record id.

Returns:

Raises:

See Also:



50
51
52
53
54
# File 'lib/dnsimple/client/domains_records.rb', line 50

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

  Struct::Record.new(response["record"])
end

#records(domain, options = {}) ⇒ Array<Struct::Record> Also known as: list_record

Lists the records for a domain.

Parameters:

  • domain (#to_s)

    The domain id or domain name.

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

Returns:

Raises:

See Also:



15
16
17
18
19
# File 'lib/dnsimple/client/domains_records.rb', line 15

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

  response.map { |r| Struct::Record.new(r["record"]) }
end

#update_record(domain, record, attributes = {}, options = {}) ⇒ Struct::Record

Updates a record for a domain.

Parameters:

  • domain (#to_s)

    The domain id or domain name.

  • record (Fixnum)

    The record id.

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

Returns:

Raises:

See Also:



67
68
69
70
71
72
# File 'lib/dnsimple/client/domains_records.rb', line 67

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

  Struct::Record.new(response["record"])
end