Module: Dnsimple::Client::Templates
- Included in:
- TemplatesService
- Defined in:
- lib/dnsimple/client/templates.rb
Instance Method Summary collapse
-
#all_templates(account_id, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::Template>
Lists ALL the templates in the account.
-
#create_template(account_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Template>
Creates a template in the account.
-
#delete_template(account_id, template_id, options = {}) ⇒ Dnsimple::Response<nil>
Deletes a template from the account.
-
#template(account_id, template_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Template>
Gets the template with specified ID.
-
#templates(account_id, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::Template>
(also: #list_templates)
Lists the templates in the account.
-
#update_template(account_id, template_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Template>
Updates template with specified ID with provided data.
Instance Method Details
#all_templates(account_id, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::Template>
Lists ALL the templates in the account.
This method is similar to #templates, 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.
58 59 60 |
# File 'lib/dnsimple/client/templates.rb', line 58 def all_templates(account_id, = {}) paginate(:templates, account_id, ) end |
#create_template(account_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Template>
Creates a template in the account.
75 76 77 78 79 80 |
# File 'lib/dnsimple/client/templates.rb', line 75 def create_template(account_id, attributes, = {}) endpoint = Client.versioned("/%s/templates" % [account_id]) response = client.post(endpoint, attributes, ) Dnsimple::Response.new(response, Struct::Template.new(response["data"])) end |
#delete_template(account_id, template_id, options = {}) ⇒ Dnsimple::Response<nil>
Deletes a template from the account.
WARNING: this cannot be undone.
139 140 141 142 143 144 |
# File 'lib/dnsimple/client/templates.rb', line 139 def delete_template(account_id, template_id, = {}) endpoint = Client.versioned("/%s/templates/%s" % [account_id, template_id]) response = client.delete(endpoint, ) Dnsimple::Response.new(response, nil) end |
#template(account_id, template_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Template>
Gets the template with specified ID.
95 96 97 98 99 100 |
# File 'lib/dnsimple/client/templates.rb', line 95 def template(account_id, template_id, = {}) endpoint = Client.versioned("/%s/templates/%s" % [account_id, template_id]) response = client.get(endpoint, ) Dnsimple::Response.new(response, Struct::Template.new(response["data"])) end |
#templates(account_id, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::Template> Also known as: list_templates
Lists the templates in the account.
28 29 30 31 32 33 |
# File 'lib/dnsimple/client/templates.rb', line 28 def templates(account_id, = {}) endpoint = Client.versioned("/%s/templates" % [account_id]) response = client.get(endpoint, Options::ListOptions.new()) Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::Template.new(r) }) end |
#update_template(account_id, template_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Template>
Updates template with specified ID with provided data.
116 117 118 119 120 121 |
# File 'lib/dnsimple/client/templates.rb', line 116 def update_template(account_id, template_id, attributes, = {}) endpoint = Client.versioned("/%s/templates/%s" % [account_id, template_id]) response = client.patch(endpoint, attributes, ) Dnsimple::Response.new(response, Struct::Template.new(response["data"])) end |