Class: Dennis::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/dennis/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hostname, api_key, **options) ⇒ Client

Returns a new instance of Client.



17
18
19
20
21
22
23
# File 'lib/dennis/client.rb', line 17

def initialize(hostname, api_key, **options)
  @hostname = hostname
  @api_key = api_key

  @api = ApiaClient.load(hostname, namespace: 'api/v1', **options)
  @api.headers['Authorization'] = "Bearer #{api_key}"
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api.



15
16
17
# File 'lib/dennis/client.rb', line 15

def api
  @api
end

#api_keyObject (readonly)

Returns the value of attribute api_key.



14
15
16
# File 'lib/dennis/client.rb', line 14

def api_key
  @api_key
end

#hostnameObject (readonly)

Returns the value of attribute hostname.



13
14
15
# File 'lib/dennis/client.rb', line 13

def hostname
  @hostname
end

Instance Method Details

#create_group(**opts) ⇒ Object



37
38
39
# File 'lib/dennis/client.rb', line 37

def create_group(**opts)
  Group.create(self, **opts)
end

#create_nameserver(**opts) ⇒ Object



65
66
67
# File 'lib/dennis/client.rb', line 65

def create_nameserver(**opts)
  Nameserver.create(self, **opts)
end

#group(id, field: :id) ⇒ Object



33
34
35
# File 'lib/dennis/client.rb', line 33

def group(id, field: :id)
  Group.find_by(self, field, id)
end

#groups(**opts) ⇒ Object



29
30
31
# File 'lib/dennis/client.rb', line 29

def groups(**opts)
  Group.all(self, **opts)
end

#nameserver(id, field: :id) ⇒ Object



61
62
63
# File 'lib/dennis/client.rb', line 61

def nameserver(id, field: :id)
  Nameserver.find_by(self, field, id)
end

#nameserversObject



57
58
59
# File 'lib/dennis/client.rb', line 57

def nameservers
  Nameserver.all(self)
end

#record(id, field: :id) ⇒ Object



49
50
51
# File 'lib/dennis/client.rb', line 49

def record(id, field: :id)
  Record.find_by(self, field, id)
end

#record_typesObject



25
26
27
# File 'lib/dennis/client.rb', line 25

def record_types
  RecordType.all(self)
end

#tagged_records(tags, group: nil) ⇒ Object



53
54
55
# File 'lib/dennis/client.rb', line 53

def tagged_records(tags, group: nil)
  Record.all_by_tag(self, tags, group: group)
end

#zone(id, field: :id) ⇒ Object



45
46
47
# File 'lib/dennis/client.rb', line 45

def zone(id, field: :id)
  Zone.find_by(self, field, id)
end

#zones(**opts) ⇒ Object



41
42
43
# File 'lib/dennis/client.rb', line 41

def zones(**opts)
  Zone.all(self, **opts)
end