Module: Dnsimple::Client::Domains

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

Instance Method Summary collapse

Instance Method Details

#all_domains(account_id, options = {}) ⇒ Dnsimple::CollectionResponse<Dnsimple::Struct::Domain>

Lists ALL the domains in the account.

This method is similar to #domains, but instead of returning the results of a specific page it iterates all the pages and returns the entire collection.

Please use this method carefully, as fetching the entire collection will increase the number of requests you send to the API server and you may eventually risk to hit the throttle limit.

Parameters:

  • account_id (Integer)

    the account ID

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

    the filtering and sorting option

Options Hash (options):

  • :page (Integer)

    current page (pagination)

  • :per_page (Integer)

    number of entries to return (pagination)

  • :sort (String)

    sorting policy

  • :filter (Hash)

    filtering policy

Returns:

Raises:

See Also:



60
61
62
# File 'lib/dnsimple/client/domains.rb', line 60

def all_domains(, options = {})
  paginate(:domains, , options)
end

#create_domain(account_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Domain>

Creates a domain in the account.

Examples:

Creating a domain in a specific account. Does not register the domain

client.domains.create_domain(1010, name: "example.com")

Parameters:

  • account_id (Integer)

    the account ID

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

Returns:

Raises:

See Also:



77
78
79
80
81
82
83
# File 'lib/dnsimple/client/domains.rb', line 77

def create_domain(, attributes, options = {})
  Extra.validate_mandatory_attributes(attributes, [:name])
  options  = options.merge(attributes)
  response = client.post(Client.versioned("/%s/domains" % []), attributes, options)

  Dnsimple::Response.new(response, Struct::Domain.new(response["data"]))
end

#delete_domain(account_id, domain_id, options = {}) ⇒ Dnsimple::Response<nil>

Deletes a domain from the account.

WARNING: this cannot be undone.

Examples:

Deleting a domain in a specific account, by domain id

client.domains.delete_domain(1010, 12345)

Deleting a domain in a specific account, by domain name

client.domains.delete_domain(1010, "example.com")

Parameters:

  • account_id (Integer)

    the account ID

  • domain_id (#to_s)

    The domain ID or domain name

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

Returns:

Raises:

See Also:



126
127
128
129
130
# File 'lib/dnsimple/client/domains.rb', line 126

def delete_domain(, domain_id, options = {})
  response = client.delete(Client.versioned("/%s/domains/%s" % [, domain_id]), nil, options)

  Dnsimple::Response.new(response, nil)
end

#domain(account_id, domain_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Domain>

Gets a domain from the account.

Examples:

Getting a domain in a specific account, by domain id

client.domains.domain(1010, 12345)

Getting a domain in a specific account, by domain name

client.domains.domain(1010, "example.com")

Parameters:

  • account_id (Integer)

    the account ID

  • domain_id (#to_s)

    The domain ID or domain name

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

Returns:

Raises:

See Also:



102
103
104
105
106
# File 'lib/dnsimple/client/domains.rb', line 102

def domain(, domain_id, options = {})
  response = client.get(Client.versioned("/%s/domains/%s" % [, domain_id]), options)

  Dnsimple::Response.new(response, Struct::Domain.new(response["data"]))
end

#domains(account_id, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::Domain> Also known as: list_domains

Lists the domains in the account.

Examples:

List domains in the first page

client.domains.domains(1010)

List domains, provide a specific page

client.domains.domains(1010, page: 2)

List domains, provide a sorting policy

client.domains.domains(1010, sort: "expiration:asc")

List domains, provide a filtering policy

client.domains.domains(1010, filter: { name_like: "example" })

Parameters:

  • account_id (Integer)

    the account ID

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

    the filtering and sorting options

Options Hash (options):

  • :page (Integer)

    current page (pagination)

  • :per_page (Integer)

    number of entries to return (pagination)

  • :sort (String)

    sorting policy

  • :filter (Hash)

    filtering policy

Returns:

Raises:

See Also:



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

def domains(, options = {})
  response = client.get(Client.versioned("/%s/domains" % []), Options::ListOptions.new(options))

  Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::Domain.new(r) })
end