Class: Varanus::Domain
- Inherits:
-
RestResource
- Object
- RestResource
- Varanus::Domain
- Defined in:
- lib/varanus/domain.rb
Overview
A connection to the Domain API
Instance Method Summary collapse
-
#create(domain, delegations, opts = {}) ⇒ Object
Create a new domain.
-
#info(id) ⇒ Object
Return info on domain.
- #list(opts = {}) ⇒ Object
- #list_with_info(opts = {}) ⇒ Object
- #report ⇒ Object
Methods inherited from RestResource
Constructor Details
This class inherits a constructor from Varanus::RestResource
Instance Method Details
#create(domain, delegations, opts = {}) ⇒ Object
Create a new domain. The domain may need to be manually approved after this is called. name
is the domain delegations
is an Array of Hashes. Each Hash should have an ‘orgId’ and
'certTypes' key
opts may include the following keys:
- :description - optional - String
- :active - optional - Boolean (defaults to +true+)
- :allow_subdomains - optional - set to +false+ if you don't want to allow sub
domains for this entry
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/varanus/domain.rb', line 17 def create domain, delegations, opts = {} opts = opts.dup allow_subdomains = opts.delete(:allow_subdomains) domain = "*.#{domain}" if allow_subdomains != false && !domain.start_with?('*.') result = @varanus.connection.post('domain/v1', opts.merge(name: domain, delegations: delegations)) check_result result result.headers['Location'] end |
#info(id) ⇒ Object
Return info on domain. id
must be the id returned by #list
29 30 31 |
# File 'lib/varanus/domain.rb', line 29 def info id get("domain/v1/#{id}") end |
#list(opts = {}) ⇒ Object
33 34 35 |
# File 'lib/varanus/domain.rb', line 33 def list opts = {} get_with_size_and_position('domain/v1', opts) end |
#list_with_info(opts = {}) ⇒ Object
37 38 39 40 41 |
# File 'lib/varanus/domain.rb', line 37 def list_with_info opts = {} domains = list(opts) domains.map! { |domain| info(domain['id']) } domains end |
#report ⇒ Object
43 44 45 |
# File 'lib/varanus/domain.rb', line 43 def report post('report/v1/domains', {})['reports'] end |