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