Class: Vinyldns::API::Zone
- Inherits:
-
Object
- Object
- Vinyldns::API::Zone
show all
- Defined in:
- lib/vinyldns/api/zone/zone.rb
Defined Under Namespace
Classes: BatchRecordChanges, RecordSet
Class Method Summary
collapse
-
.connect(name, distribution_email, group_id = nil, group_name_filter = nil) ⇒ Object
-
.delete(id) ⇒ Object
-
.get(id) ⇒ Object
-
.list_changes(id, max_items = 5, start_from = nil) ⇒ Object
Warning: Being deprecated, use list_changes def self.history(id) api_request_object = Vinyldns::API.new(‘get’) Vinyldns::API.make_request(api_request_object, “#@api_uri/#id/history”) end.
-
.search(name_filter = nil, max_items = 5, start_from = nil) ⇒ Object
-
.sync(id) ⇒ Object
-
.update(id, request_params) ⇒ Object
Class Method Details
.connect(name, distribution_email, group_id = nil, group_name_filter = nil) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/vinyldns/api/zone/zone.rb', line 15
def self.connect(name, distribution_email, group_id = nil, group_name_filter = nil)
if (group_id.nil? || group_id.empty?) && (!group_name_filter.nil? && !group_name_filter.empty?)
group_object = Vinyldns::API::Group.list_my_groups(group_name_filter)['groups']
raise(StandardError, 'Parameter group_object returned nil. This is a problem with the make_request or list_my_groups methods.') if group_object.nil?
raise(ArgumentError, 'No group found for your group_name_filter. Please re-check the spelling so it\'s exact.') if group_object.empty?
raise(ArgumentError, 'Your group_name_filter used returned more than one group. Please re-check the spelling so it\'s exact.') if group_object.count > 1
group_id = group_object.first['id']
elsif (group_id.nil? || group_id.empty?) && (group_name_filter.nil? || group_name_filter.empty?)
raise(ArgumentError, 'You must include a group_id or group_name_filter.')
end
api_request_object = Vinyldns::API.new('post')
Vinyldns::API.make_request(api_request_object, @api_uri, { adminGroupId: group_id, name: name, email: distribution_email })
end
|
.delete(id) ⇒ Object
42
43
44
45
|
# File 'lib/vinyldns/api/zone/zone.rb', line 42
def self.delete(id)
api_request_object = Vinyldns::API.new('delete')
Vinyldns::API.make_request(api_request_object, "#{@api_uri}/#{id}")
end
|
.get(id) ⇒ Object
47
48
49
50
|
# File 'lib/vinyldns/api/zone/zone.rb', line 47
def self.get(id)
api_request_object = Vinyldns::API.new('get')
Vinyldns::API.make_request(api_request_object, "#{@api_uri}/#{id}")
end
|
.list_changes(id, max_items = 5, start_from = nil) ⇒ Object
Warning: Being deprecated, use list_changes def self.history(id)
api_request_object = Vinyldns::API.new('get')
Vinyldns::API.make_request(api_request_object, "#{@api_uri}/#{id}/history")
end
69
70
71
72
73
|
# File 'lib/vinyldns/api/zone/zone.rb', line 69
def self.list_changes(id, max_items = 5, start_from = nil)
api_request_object = Vinyldns::API.new('get')
Vinyldns::API.make_request(api_request_object, "#{@api_uri}/#{id}/changes?maxItems=#{max_items}#{start_from.nil? ? '' : "&startFrom=#{start_from}"}")
end
|
.search(name_filter = nil, max_items = 5, start_from = nil) ⇒ Object
52
53
54
55
56
|
# File 'lib/vinyldns/api/zone/zone.rb', line 52
def self.search(name_filter = nil, max_items = 5, start_from = nil)
api_request_object = Vinyldns::API.new('get')
Vinyldns::API.make_request(api_request_object, "#{@api_uri}?#{URI.encode_www_form([['nameFilter', name_filter], ['maxItems', max_items], ['startFrom', start_from]])}")
end
|
.sync(id) ⇒ Object
58
59
60
61
|
# File 'lib/vinyldns/api/zone/zone.rb', line 58
def self.sync(id)
api_request_object = Vinyldns::API.new('post')
Vinyldns::API.make_request(api_request_object, "#{@api_uri}/#{id}/sync")
end
|
.update(id, request_params) ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/vinyldns/api/zone/zone.rb', line 34
def self.update(id, request_params)
raise(ArgumentError, 'Request Parameters must be a Hash') unless request_params.is_a? Hash
api_request_object = Vinyldns::API.new('put')
Vinyldns::API.make_request(api_request_object, "#{@api_uri}/#{id}", request_params)
end
|