Module: NSOne::API::Zones
- Defined in:
- lib/nsone/api/zones.rb
Instance Method Summary collapse
-
#create_zone(zone, params = {}) ⇒ NSOne::Response
Create a new DNS zone.
-
#delete_zone(zone) ⇒ NSOne::Response
Destroys an existing DNS zone and all records in the zone.
-
#modify_zone(zone, params = {}) ⇒ NSOne::Response
Modifies basic details of a DNS zone.
-
#search(string, params = {}) ⇒ NSOne::Response
Returns all zones and records that match the given ‘string`.
-
#zone(zone) ⇒ NSOne::Response
Returns a single active Zone and its basic configuration details including all the zones records in a “records” array.
-
#zones ⇒ NSOne::Response
Returns all active zones and basic zone configuration details for each.
Instance Method Details
#create_zone(zone, params = {}) ⇒ NSOne::Response
Create a new DNS zone. You must include a JSON body in the request with basic details of the zone. The only required element in the body is zone.
For all the zone options @see [NSOne API - create-a-new-dns-zone](jsapi.apiary.io/apis/ns1api/reference/zones-and-records/zone/create-a-new-dns-zone.html)
39 40 41 42 43 |
# File 'lib/nsone/api/zones.rb', line 39 def create_zone(zone, params = {}) raise NSOne::MissingParameter, "zone cannot be blank" if blank?(zone) params = params.merge(zone: zone) perform_request(HTTP_PUT, "/v1/zones/#{zone}", params) end |
#delete_zone(zone) ⇒ NSOne::Response
Destroys an existing DNS zone and all records in the zone
68 69 70 71 |
# File 'lib/nsone/api/zones.rb', line 68 def delete_zone(zone) raise NSOne::MissingParameter, "zone cannot be blank" if blank?(zone) perform_request(HTTP_DELETE, "/v1/zones/#{zone}") end |
#modify_zone(zone, params = {}) ⇒ NSOne::Response
Modifies basic details of a DNS zone. You must include a JSON body in the request, in which you may include ttl (SOA record TTL), refresh, retry, expiry, or nx_ttl values, as in a SOA record. You may not change the zone name or other details.
55 56 57 58 59 |
# File 'lib/nsone/api/zones.rb', line 55 def modify_zone(zone, params = {}) raise NSOne::MissingParameter, "zone cannot be blank" if blank?(zone) raise NSOne::MissingParameter, "params hash must contain valid zone settings" if !params.is_a?(Hash) || params.empty? perform_request(HTTP_POST, "/v1/zones/#{zone}", params) end |
#search(string, params = {}) ⇒ NSOne::Response
Returns all zones and records that match the given ‘string`. You can limit the max number of results and you can restrict the type of results to zone, record, or all. Entries in the response without domain/type are zones, and those with domain/type are records.
86 87 88 89 90 |
# File 'lib/nsone/api/zones.rb', line 86 def search(string, params = {}) raise NSOne::MissingParameter, "search string cannot be blank" if blank?(string) params = params.merge(q: string) perform_request(HTTP_GET, "/v1/search", params) end |
#zone(zone) ⇒ NSOne::Response
Returns a single active Zone and its basic configuration details including all the zones records in a “records” array.
23 24 25 26 |
# File 'lib/nsone/api/zones.rb', line 23 def zone(zone) raise NSOne::MissingParameter, "zone cannot be blank" if blank?(zone) perform_request(HTTP_GET, "/v1/zones/#{zone}") end |
#zones ⇒ NSOne::Response
Returns all active zones and basic zone configuration details for each
12 13 14 |
# File 'lib/nsone/api/zones.rb', line 12 def zones perform_request(HTTP_GET, "/v1/zones") end |