Module: Dnsimple::Client::ZonesRecords
- Included in:
- ZonesService
- Defined in:
- lib/dnsimple/client/zones_records.rb
Instance Method Summary collapse
-
#all_records(account_id, zone_id, options = {}) ⇒ Dnsimple::CollectionResponse<Dnsimple::Struct::ZoneRecord>
(also: #all)
Lists ALL the zone records in the account.
-
#create_record(account_id, zone_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::ZoneRecord>
(also: #create)
Creates a zone record in the account.
-
#delete_record(account_id, zone_id, record_id, options = {}) ⇒ Dnsimple::Response<nil>
(also: #delete)
Deletes a zone record from the account.
-
#record(account_id, zone_id, record_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::ZoneRecord>
Gets a zone record from the account.
-
#records(account_id, zone_id, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::ZoneRecord>
(also: #list, #list_records)
Lists the zone records in the account.
-
#update_record(account_id, zone_id, record_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::ZoneRecord>
(also: #update)
Updates a zone record in the account.
Instance Method Details
#all_records(account_id, zone_id, options = {}) ⇒ Dnsimple::CollectionResponse<Dnsimple::Struct::ZoneRecord> Also known as: all
Lists ALL the zone records in the account.
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.
66 67 68 |
# File 'lib/dnsimple/client/zones_records.rb', line 66 def all_records(account_id, zone_id, = {}) paginate(:records, account_id, zone_id, ) end |
#create_record(account_id, zone_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::ZoneRecord> Also known as: create
Creates a zone record in the account.
86 87 88 89 90 91 |
# File 'lib/dnsimple/client/zones_records.rb', line 86 def create_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_record(account_id, zone_id, record_id, options = {}) ⇒ Dnsimple::Response<nil> Also known as: delete
Deletes a zone record from the account.
WARNING: this cannot be undone.
155 156 157 158 159 |
# File 'lib/dnsimple/client/zones_records.rb', line 155 def delete_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 |
#record(account_id, zone_id, record_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::ZoneRecord>
Gets a zone record from the account.
109 110 111 112 113 |
# File 'lib/dnsimple/client/zones_records.rb', line 109 def 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 |
#records(account_id, zone_id, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::ZoneRecord> Also known as: list, list_records
Lists the zone records in the account.
33 34 35 36 37 |
# File 'lib/dnsimple/client/zones_records.rb', line 33 def 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 |
#update_record(account_id, zone_id, record_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::ZoneRecord> Also known as: update
Updates a zone record in the account.
131 132 133 134 135 |
# File 'lib/dnsimple/client/zones_records.rb', line 131 def update_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 |