class Dennis::Nameserver
Public Class Methods
all(client)
click to toggle source
# File lib/dennis/nameserver.rb, line 8 def all(client) nameservers = client.api.perform(:get, 'nameservers') nameservers.hash['nameservers'].map { |hash| new(client, hash) } end
create(client, name:, server: nil)
click to toggle source
# File lib/dennis/nameserver.rb, line 21 def create(client, name:, server: nil) request = client.api.create_request(:post, 'nameservers') request.arguments[:properties] = { name: name, server: server } new(client, request.perform.hash['nameserver']) rescue ApiaClient::RequestError => e raise ValidationError, e.detail['errors'] if e.code == 'validation_error' raise end
find_by(client, field, value)
click to toggle source
# File lib/dennis/nameserver.rb, line 13 def find_by(client, field, value) request = client.api.create_request(:get, 'nameservers/:nameserver') request.arguments[:nameserver] = { field => value } new(client, request.perform.hash['nameserver']) rescue ApiaClient::RequestError => e e.code == 'nameserver_not_found' ? nil : raise end
new(client, hash)
click to toggle source
# File lib/dennis/nameserver.rb, line 33 def initialize(client, hash) @client = client @hash = hash end
Public Instance Methods
created_at()
click to toggle source
# File lib/dennis/nameserver.rb, line 50 def created_at return nil if @hash['created_at'].nil? return @hash['created_at'] if @hash['created_at'].is_a?(Time) Time.at(@hash['created_at']) end
delete()
click to toggle source
# File lib/dennis/nameserver.rb, line 76 def delete req = @client.api.create_request(:delete, 'nameservers/:nameserver') req.arguments['nameserver'] = { id: id } req.perform true end
id()
click to toggle source
# File lib/dennis/nameserver.rb, line 38 def id @hash['id'] end
name()
click to toggle source
# File lib/dennis/nameserver.rb, line 42 def name @hash['name'] end
server()
click to toggle source
# File lib/dennis/nameserver.rb, line 46 def server @hash['server'] end
update(properties)
click to toggle source
# File lib/dennis/nameserver.rb, line 64 def update(properties) req = @client.api.create_request(:patch, 'nameservers/:nameserver') req.arguments['nameserver'] = { id: id } req.arguments['properties'] = properties @hash = req.perform.hash['nameserver'] true rescue ApiaClient::RequestError => e raise ValidationError, e.detail['errors'] if e.code == 'validation_error' raise end
updated_at()
click to toggle source
# File lib/dennis/nameserver.rb, line 57 def updated_at return nil if @hash['updated_at'].nil? return @hash['updated_at'] if @hash['updated_at'].is_a?(Time) Time.at(@hash['updated_at']) end