Module: Dnsimple::Client::TemplatesRecords
- Included in:
- TemplatesService
- Defined in:
- lib/dnsimple/client/templates_records.rb
Instance Method Summary collapse
-
#all_records(account_id, template_id, options = {}) ⇒ Dnsimple::CollectionResponse<Dnsimple::Struct::TemplateRecord>
Lists ALL the records in the template.
-
#create_record(account_id, template_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::TemplateRecord>
Creates a record in the template.
-
#delete_record(account_id, template_id, record_id, options = {}) ⇒ Dnsimple::Response<nil>
Deletes a record from the template.
-
#record(account_id, template_id, record_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::TemplateRecord>
Gets a record from the template.
-
#records(account_id, template_id, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::TemplateRecord>
(also: #list_records)
Lists the records in the template.
Instance Method Details
#all_records(account_id, template_id, options = {}) ⇒ Dnsimple::CollectionResponse<Dnsimple::Struct::TemplateRecord>
Lists ALL the records in the template.
This method is similar to #records, 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.
63 64 65 |
# File 'lib/dnsimple/client/templates_records.rb', line 63 def all_records(account_id, template_id, = {}) paginate(:records, account_id, template_id, ) end |
#create_record(account_id, template_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::TemplateRecord>
Creates a record in the template.
82 83 84 85 86 87 88 |
# File 'lib/dnsimple/client/templates_records.rb', line 82 def create_record(account_id, template_id, attributes, = {}) Extra.validate_mandatory_attributes(attributes, [:type, :name, :content]) endpoint = Client.versioned("/%s/templates/%s/records" % [account_id, template_id]) response = client.post(endpoint, attributes, ) Dnsimple::Response.new(response, Struct::TemplateRecord.new(response["data"])) end |
#delete_record(account_id, template_id, record_id, options = {}) ⇒ Dnsimple::Response<nil>
Deletes a record from the template.
WARNING: this cannot be undone.
129 130 131 132 133 134 |
# File 'lib/dnsimple/client/templates_records.rb', line 129 def delete_record(account_id, template_id, record_id, = {}) endpoint = Client.versioned("/%s/templates/%s/records/%s" % [account_id, template_id, record_id]) response = client.delete(endpoint, ) Dnsimple::Response.new(response, nil) end |
#record(account_id, template_id, record_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::TemplateRecord>
Gets a record from the template.
105 106 107 108 109 110 |
# File 'lib/dnsimple/client/templates_records.rb', line 105 def record(account_id, template_id, record_id, = {}) endpoint = Client.versioned("/%s/templates/%s/records/%s" % [account_id, template_id, record_id]) response = client.get(endpoint, ) Dnsimple::Response.new(response, Struct::TemplateRecord.new(response["data"])) end |
#records(account_id, template_id, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::TemplateRecord> Also known as: list_records
Lists the records in the template.
31 32 33 34 35 36 |
# File 'lib/dnsimple/client/templates_records.rb', line 31 def records(account_id, template_id, = {}) endpoint = Client.versioned("/%s/templates/%s/records" % [account_id, template_id]) response = client.get(endpoint, Options::ListOptions.new()) Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::TemplateRecord.new(r) }) end |