Class: Dennis::Client
- Inherits:
-
Object
- Object
- Dennis::Client
- Defined in:
- lib/dennis/client.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
Instance Method Summary collapse
- #create_group(**opts) ⇒ Object
- #create_nameserver(**opts) ⇒ Object
- #group(id, field: :id) ⇒ Object
- #groups(**opts) ⇒ Object
-
#initialize(hostname, api_key, **options) ⇒ Client
constructor
A new instance of Client.
- #nameserver(id, field: :id) ⇒ Object
- #nameservers ⇒ Object
- #record(id, field: :id) ⇒ Object
- #record_types ⇒ Object
- #tagged_records(tags, group: nil) ⇒ Object
- #zone(id, field: :id) ⇒ Object
- #zones(**opts) ⇒ Object
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, **) @hostname = hostname @api_key = api_key @api = ApiaClient.load(hostname, namespace: 'api/v1', **) @api.headers['Authorization'] = "Bearer #{api_key}" end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
15 16 17 |
# File 'lib/dennis/client.rb', line 15 def api @api end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
14 15 16 |
# File 'lib/dennis/client.rb', line 14 def api_key @api_key end |
#hostname ⇒ Object (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 |
#nameservers ⇒ Object
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_types ⇒ Object
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(, group: nil) Record.all_by_tag(self, , 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 |