Class: Dnsimple::Client::RecordsService

Inherits:
ClientService show all
Defined in:
lib/dnsimple/client/records_service.rb

Instance Attribute Summary

Attributes inherited from ClientService

#client

Instance Method Summary collapse

Instance Method Details

#create(domain, attributes = {}) ⇒ 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:



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

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

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

#delete(domain, record) ⇒ void

This method returns an undefined value.

Deletes a record for a domain.

WARNING: this cannot be undone.

Parameters:

  • domain (#to_s)

    The domain id or domain name.

  • record (Fixnum)

    The record id.

Raises:

See Also:



85
86
87
# File 'lib/dnsimple/client/records_service.rb', line 85

def delete(domain, record)
  client.delete("v1/domains/#{domain}/records/#{record}")
end

#find(domain, record) ⇒ 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:



49
50
51
52
53
# File 'lib/dnsimple/client/records_service.rb', line 49

def find(domain, record)
  response = client.get("v1/domains/#{domain}/records/#{record}")

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

#list(domain, options = {}) ⇒ Array<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/records_service.rb', line 15

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

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

#update(domain, record, attributes = {}) ⇒ 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:



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

def update(domain, record, attributes = {})
  options  = { record: attributes }
  response = client.put("v1/domains/#{domain}/records/#{record}", options)

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