class Vinyldns::API::Zone

Public Class Methods

connect(name, distribution_email, group_id = nil, group_name_filter = nil, **optional_args) click to toggle source
# File lib/vinyldns/api/zone/zone.rb, line 16
def self.connect(name, distribution_email, group_id = nil, group_name_filter = nil, **optional_args)
  # Find the group ID using the group_name
  if (group_id.nil? || group_id.empty?) && (!group_name_filter.nil? && !group_name_filter.empty?)
    # Obtain admin group ID for body
    group_object = Vinyldns::API::Group.list_my_groups(group_name_filter)['groups']
    ## Validation
    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 # Else, we just use the group_id
  parameters = { adminGroupId: group_id, name: name, email: distribution_email}
  parameters.merge!(optional_args)
  # Post to API
  api_request_object = Vinyldns::API.new('post')
  Vinyldns::API.make_request(api_request_object, @api_uri, parameters)
end
delete(id) click to toggle source
# File lib/vinyldns/api/zone/zone.rb, line 44
def self.delete(id)
  api_request_object = Vinyldns::API.new('delete')
  Vinyldns::API.make_request(api_request_object, "#{@api_uri}/#{id}")
end
get(id) click to toggle source
# File lib/vinyldns/api/zone/zone.rb, line 49
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) click to toggle source

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

# File lib/vinyldns/api/zone/zone.rb, line 71
def self.list_changes(id, max_items = 5, start_from = nil)
  api_request_object = Vinyldns::API.new('get')
  # UNI.encode matches all symbols that must be replaced with codes
  Vinyldns::API.make_request(api_request_object, "#{@api_uri}/#{id}/changes?maxItems=#{max_items}#{start_from.nil? ? '' : "&startFrom=#{start_from}"}")
end
sync(id) click to toggle source
# File lib/vinyldns/api/zone/zone.rb, line 60
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) click to toggle source
# File lib/vinyldns/api/zone/zone.rb, line 36
def self.update(id, request_params)
  # We use request_params here as values required by create may differ from update
  # Validations
  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