Module: Dnsimple::Client::Domains
- Included in:
- DomainsService
- Defined in:
- lib/dnsimple/client/domains.rb
Instance Method Summary collapse
-
#all_domains(account_id, options = {}) ⇒ Dnsimple::CollectionResponse<Dnsimple::Struct::Domain>
Lists ALL the domains in the account.
-
#create_domain(account_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Domain>
Creates a domain in the account.
-
#delete_domain(account_id, domain_id, options = {}) ⇒ Dnsimple::Response<nil>
Deletes a domain from the account.
-
#domain(account_id, domain_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Domain>
Gets a domain from the account.
-
#domains(account_id, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::Domain>
(also: #list_domains)
Lists the domains in the account.
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.
60 61 62 |
# File 'lib/dnsimple/client/domains.rb', line 60 def all_domains(account_id, = {}) paginate(:domains, account_id, ) end |
#create_domain(account_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Domain>
Creates a domain in the account.
77 78 79 80 81 82 83 |
# File 'lib/dnsimple/client/domains.rb', line 77 def create_domain(account_id, attributes, = {}) Extra.validate_mandatory_attributes(attributes, [:name]) = .merge(attributes) response = client.post(Client.versioned("/%s/domains" % [account_id]), attributes, ) 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.
126 127 128 129 130 |
# File 'lib/dnsimple/client/domains.rb', line 126 def delete_domain(account_id, domain_id, = {}) response = client.delete(Client.versioned("/%s/domains/%s" % [account_id, domain_id]), nil, ) Dnsimple::Response.new(response, nil) end |
#domain(account_id, domain_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Domain>
Gets a domain from the account.
102 103 104 105 106 |
# File 'lib/dnsimple/client/domains.rb', line 102 def domain(account_id, domain_id, = {}) response = client.get(Client.versioned("/%s/domains/%s" % [account_id, domain_id]), ) 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.
33 34 35 36 37 |
# File 'lib/dnsimple/client/domains.rb', line 33 def domains(account_id, = {}) response = client.get(Client.versioned("/%s/domains" % [account_id]), Options::ListOptions.new()) Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::Domain.new(r) }) end |