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> Also known as: all

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 (Fixnum)

    the account ID

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

    the filtering and sorting option

Returns:

Raises:

See Also:



45
46
47
# File 'lib/dnsimple/client/domains.rb', line 45

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

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

Creates a domain in the account.

Parameters:

  • account_id (Fixnum)

    the account ID

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

Returns:

Raises:

See Also:



60
61
62
63
64
65
66
# File 'lib/dnsimple/client/domains.rb', line 60

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> Also known as: delete

Deletes a domain from the account.

WARNING: this cannot be undone.

Parameters:

  • account_id (Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT)

    the account ID or wildcard

  • domain_id (#to_s)

    The domain ID or domain name

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

Returns:

Raises:

See Also:



99
100
101
102
103
# File 'lib/dnsimple/client/domains.rb', line 99

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.

Parameters:

  • account_id (Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT)

    the account ID or wildcard

  • domain_id (#to_s)

    The domain ID or domain name

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

Returns:

Raises:

See Also:



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

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, list_domains

Lists the domains in the account.

Examples:

List domains in the first page

client.domains.list(1010)

List domains, provide a specific page

client.domains.list(1010, query: { page: 2 })

Parameters:

  • account_id (Fixnum)

    the account ID

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

    the filtering and sorting option

Returns:

Raises:

See Also:



21
22
23
24
25
# File 'lib/dnsimple/client/domains.rb', line 21

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

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

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

Resets the domain token.

Parameters:

  • account_id (Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT)

    the account ID or wildcard

  • domain_id (#to_s)

    The domain ID or domain name

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

Returns:

Raises:

See Also:



117
118
119
120
121
# File 'lib/dnsimple/client/domains.rb', line 117

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

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