Module: Dnsimple::Client::ZonesRecords
- Included in:
- ZonesService
- Defined in:
- lib/dnsimple/client/zones_records.rb
Instance Method Summary collapse
-
#all_zone_records(account_id, zone_id, options = {}) ⇒ Dnsimple::CollectionResponse<Dnsimple::Struct::ZoneRecord>
Lists ALL the zone records in the account.
-
#batch_change_zone_records(account_id, zone_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::ZoneRecordsBatchChange>
Updates a zone with a set of records (records to be created, edited or deleted), as an atomic batch operation.
-
#create_zone_record(account_id, zone_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::ZoneRecord>
Creates a zone record in the account.
-
#delete_zone_record(account_id, zone_id, record_id, options = {}) ⇒ Dnsimple::Response<nil>
Deletes a zone record from the account.
-
#update_zone_record(account_id, zone_id, record_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::ZoneRecord>
Updates a zone record in the account.
-
#zone_record(account_id, zone_id, record_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::ZoneRecord>
Gets a zone record from the account.
-
#zone_records(account_id, zone_id, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::ZoneRecord>
(also: #list_zone_records)
Lists the zone records in the account.
Instance Method Details
#all_zone_records(account_id, zone_id, options = {}) ⇒ Dnsimple::CollectionResponse<Dnsimple::Struct::ZoneRecord>
Lists ALL the zone records in the account.
This method is similar to #zone_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.
66 67 68 |
# File 'lib/dnsimple/client/zones_records.rb', line 66 def all_zone_records(account_id, zone_id, = {}) paginate(:list_zone_records, account_id, zone_id, ) end |
#batch_change_zone_records(account_id, zone_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::ZoneRecordsBatchChange>
Updates a zone with a set of records (records to be created, edited or deleted), as an atomic batch operation.
176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/dnsimple/client/zones_records.rb', line 176 def batch_change_zone_records(account_id, zone_id, attributes, = {}) response = client.post(Client.versioned("/%s/zones/%s/batch" % [account_id, zone_id]), attributes, ) creates, updates, deletes = [] if response["data"] creates_data = response["data"]["creates"] || [] creates = creates_data.map { |r| Struct::ZoneRecord.new(r) } updates_data = response["data"]["updates"] || [] updates = updates_data.map { |r| Struct::ZoneRecord.new(r) } deletes_data = response["data"]["deletes"] || [] deletes = deletes_data.map { |r| Struct::ZoneRecordId.new(r) } end Dnsimple::Response.new(response, Struct::ZoneRecordsBatchChange.new({ creates:, updates:, deletes: })) end |
#create_zone_record(account_id, zone_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::ZoneRecord>
Creates a zone record in the account.
85 86 87 88 89 90 |
# File 'lib/dnsimple/client/zones_records.rb', line 85 def create_zone_record(account_id, zone_id, attributes, = {}) Extra.validate_mandatory_attributes(attributes, [:type, :name, :content]) response = client.post(Client.versioned("/%s/zones/%s/records" % [account_id, zone_id]), attributes, ) Dnsimple::Response.new(response, Struct::ZoneRecord.new(response["data"])) end |
#delete_zone_record(account_id, zone_id, record_id, options = {}) ⇒ Dnsimple::Response<nil>
Deletes a zone record from the account.
WARNING: this cannot be undone.
152 153 154 155 156 |
# File 'lib/dnsimple/client/zones_records.rb', line 152 def delete_zone_record(account_id, zone_id, record_id, = {}) response = client.delete(Client.versioned("/%s/zones/%s/records/%s" % [account_id, zone_id, record_id]), nil, ) Dnsimple::Response.new(response, nil) end |
#update_zone_record(account_id, zone_id, record_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::ZoneRecord>
Updates a zone record in the account.
129 130 131 132 133 |
# File 'lib/dnsimple/client/zones_records.rb', line 129 def update_zone_record(account_id, zone_id, record_id, attributes, = {}) response = client.patch(Client.versioned("/%s/zones/%s/records/%s" % [account_id, zone_id, record_id]), attributes, ) Dnsimple::Response.new(response, Struct::ZoneRecord.new(response["data"])) end |
#zone_record(account_id, zone_id, record_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::ZoneRecord>
Gets a zone record from the account.
107 108 109 110 111 |
# File 'lib/dnsimple/client/zones_records.rb', line 107 def zone_record(account_id, zone_id, record_id, = {}) response = client.get(Client.versioned("/%s/zones/%s/records/%s" % [account_id, zone_id, record_id]), ) Dnsimple::Response.new(response, Struct::ZoneRecord.new(response["data"])) end |
#zone_records(account_id, zone_id, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::ZoneRecord> Also known as: list_zone_records
Lists the zone records in the account.
34 35 36 37 38 |
# File 'lib/dnsimple/client/zones_records.rb', line 34 def zone_records(account_id, zone_id, = {}) response = client.get(Client.versioned("/%s/zones/%s/records" % [account_id, zone_id]), Options::ListOptions.new()) Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::ZoneRecord.new(r) }) end |