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.
62 63 64 |
# File 'lib/dnsimple/client/templates_records.rb', line 62 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.
81 82 83 84 85 86 87 |
# File 'lib/dnsimple/client/templates_records.rb', line 81 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.
128 129 130 131 132 133 |
# File 'lib/dnsimple/client/templates_records.rb', line 128 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.
104 105 106 107 108 109 |
# File 'lib/dnsimple/client/templates_records.rb', line 104 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.
30 31 32 33 34 35 |
# File 'lib/dnsimple/client/templates_records.rb', line 30 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 |