Module: Dnsimple::Client::Templates
- Included in:
- TemplatesService
- Defined in:
- lib/dnsimple/client/templates.rb
Instance Method Summary collapse
-
#create_template(attributes = {}, options = {}) ⇒ Struct::Template
(also: #create)
Creates a template in the account.
-
#delete_template(template, options = {}) ⇒ void
(also: #delete)
Deletes a template from the account.
-
#template(template, options = {}) ⇒ Struct::Template
Gets a template from the account.
-
#templates(options = {}) ⇒ Array<Struct::Template>
(also: #list, #list_templates)
Lists the templates in the account.
-
#update_template(template, attributes = {}, options = {}) ⇒ Struct::Template
(also: #update)
Updates a template in the account.
Instance Method Details
#create_template(attributes = {}, options = {}) ⇒ Struct::Template Also known as: create
Creates a template in the account.
28 29 30 31 32 33 34 |
# File 'lib/dnsimple/client/templates.rb', line 28 def create_template(attributes = {}, = {}) Extra.validate_mandatory_attributes(attributes, [:name, :short_name]) = .merge({ dns_template: attributes }) response = client.post(Client.versioned("templates"), ) Struct::Template.new(response["dns_template"]) end |
#delete_template(template, options = {}) ⇒ void Also known as: delete
This method returns an undefined value.
Deletes a template from the account.
WARNING: this cannot be undone.
81 82 83 |
# File 'lib/dnsimple/client/templates.rb', line 81 def delete_template(template, = {}) client.delete(Client.versioned("templates/#{template}"), ) end |
#template(template, options = {}) ⇒ Struct::Template
Gets a template from the account.
46 47 48 49 50 |
# File 'lib/dnsimple/client/templates.rb', line 46 def template(template, = {}) response = client.get(Client.versioned("templates/#{template}"), ) Struct::Template.new(response["dns_template"]) end |
#templates(options = {}) ⇒ Array<Struct::Template> Also known as: list, list_templates
Lists the templates in the account.
12 13 14 15 16 |
# File 'lib/dnsimple/client/templates.rb', line 12 def templates( = {}) response = client.get(Client.versioned("templates"), ) response.map { |r| Struct::Template.new(r["dns_template"]) } end |
#update_template(template, attributes = {}, options = {}) ⇒ Struct::Template Also known as: update
Updates a template in the account.
62 63 64 65 66 67 |
# File 'lib/dnsimple/client/templates.rb', line 62 def update_template(template, attributes = {}, = {}) = .merge({ dns_template: attributes }) response = client.put(Client.versioned("templates/#{template}"), ) Struct::Template.new(response["dns_template"]) end |