Class: Njalla::V1::Domain
- Inherits:
-
Object
- Object
- Njalla::V1::Domain
- Defined in:
- lib/njalla/v1/domain.rb
Overview
Implement domain method APIv1
Instance Attribute Summary collapse
- #client ⇒ Njalla::V1::Client readonly
- #domain ⇒ String readonly
Instance Method Summary collapse
-
#add_record(content:, name: '@', ttl: 60, type: 'A') ⇒ Njalla::V1::Schemas::Record
Adds a record.
-
#initialize(client:, domain:) ⇒ Domain
constructor
A new instance of Domain.
-
#remove_record(id:) ⇒ Boolean
Remove a record by its ID.
Constructor Details
#initialize(client:, domain:) ⇒ Domain
Returns a new instance of Domain.
18 19 20 21 |
# File 'lib/njalla/v1/domain.rb', line 18 def initialize(client:, domain:) @client = client @domain = domain end |
Instance Attribute Details
#client ⇒ Njalla::V1::Client (readonly)
12 13 14 |
# File 'lib/njalla/v1/domain.rb', line 12 def client @client end |
#domain ⇒ String (readonly)
14 15 16 |
# File 'lib/njalla/v1/domain.rb', line 14 def domain @domain end |
Instance Method Details
#add_record(content:, name: '@', ttl: 60, type: 'A') ⇒ Njalla::V1::Schemas::Record
Adds a record
30 31 32 33 34 |
# File 'lib/njalla/v1/domain.rb', line 30 def add_record(content:, name: '@', ttl: 60, type: 'A') record = Schemas::AddRecord.new.call(domain: domain, content: content, name: name, type: type, ttl: ttl) Schemas::Record.new.call(**client.post('add-record', record).dig('result')) end |
#remove_record(id:) ⇒ Boolean
Remove a record by its ID
40 41 42 43 44 45 |
# File 'lib/njalla/v1/domain.rb', line 40 def remove_record(id:) record = Schemas::RemoveRecord.new.call(domain: domain, id: id) result = client.post('remove-record', record).dig('result') !result.nil? && result.empty? end |