Class: Fog::HP::DNS::Real
- Inherits:
-
Object
- Object
- Fog::HP::DNS::Real
- Defined in:
- lib/fog/hp/requests/dns/get_domain.rb,
lib/fog/hp/dns.rb,
lib/fog/hp/requests/dns/get_record.rb,
lib/fog/hp/requests/dns/list_domains.rb,
lib/fog/hp/requests/dns/create_domain.rb,
lib/fog/hp/requests/dns/create_record.rb,
lib/fog/hp/requests/dns/delete_domain.rb,
lib/fog/hp/requests/dns/delete_record.rb,
lib/fog/hp/requests/dns/update_domain.rb,
lib/fog/hp/requests/dns/update_record.rb,
lib/fog/hp/requests/dns/list_records_in_a_domain.rb,
lib/fog/hp/requests/dns/get_servers_hosting_domain.rb
Overview
Create a new DNS domain
Parameters
-
‘name’<~String> - Name of the domain
-
‘email’<~String> - Email for the domain
-
options<~Hash>:
-
‘description’<~String> - Description for the domain
-
‘ttl’<~String> - TTL for the domain
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘id’<~String> - UUID of the domain
-
‘name’<~String> - Name of the domain
-
‘description’<~String> - Description for the domain
-
‘ttl’<~Integer> - TTL for the domain
-
‘email’<~String> - Email for the domain
-
‘serial’<~Integer> - Serial number for the domain
-
‘created_at’<~String> - created date time stamp
-
-
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
Instance Method Summary collapse
- #create_domain(name, email, options = {}) ⇒ Object
-
#create_record(domain_id, name, type, data, options = {}) ⇒ Object
Create a new DNS record.
-
#delete_domain(domain_id) ⇒ Object
Delete a DNS domain.
-
#delete_record(domain_id, record_id) ⇒ Object
Delete a DNS Record.
- #get_domain(domain_id) ⇒ Object
-
#get_record(domain_id, record_id) ⇒ Object
Get details of an existing DNS record.
-
#get_servers_hosting_domain(domain_id) ⇒ Object
Get authoritative nameservers for existing DNS domain.
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
-
#list_domains ⇒ Object
Returns * response<~Excon::Response>: * body<~Hash>: * ‘domains’<~Array>: * ‘id’<~String> - UUID of the domain * ‘name’<~String> - Name of the domain * ‘ttl’<~Integer> - TTL for the domain * ‘email’<~String> - Email for the domain * ‘serial’<~Integer> - Serial number for the domain * ‘created_at’<~String> - created date time stamp.
-
#list_records_in_a_domain(domain_id) ⇒ Object
List DNS records for a given domain.
- #reload ⇒ Object
- #request(params, parse_json = true, &block) ⇒ Object
-
#update_domain(domain_id, options = {}) ⇒ Object
Update an existing DNS domain.
-
#update_record(domain_id, record_id, options = {}) ⇒ Object
Update an existing DNS record.
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/fog/hp/dns.rb', line 65 def initialize(={}) @hp_access_key = [:hp_access_key] @hp_secret_key = [:hp_secret_key] @hp_auth_uri = [:hp_auth_uri] @connection_options = [:connection_options] || {} ### Set an option to use the style of authentication desired; :v1 or :v2 (default) auth_version = [:hp_auth_version] || :v2 ### Pass the service name for object storage to the authentication call [:hp_service_type] ||= "DNS" @hp_tenant_id = [:hp_tenant_id] @hp_avl_zone = [:hp_avl_zone] ### Make the authentication call if (auth_version == :v2) # Call the control services authentication credentials = Fog::HP.authenticate_v2(, @connection_options) # the CS service catalog returns the block storage endpoint @hp_block_uri = credentials[:endpoint_url] @credentials = credentials else # Call the legacy v1.0/v1.1 authentication credentials = Fog::HP.authenticate_v1(, @connection_options) # the user sends in the block storage endpoint @hp_block_uri = [:hp_auth_uri] end @auth_token = credentials[:auth_token] @persistent = [:persistent] || false uri = URI.parse(@hp_block_uri) @host = uri.host @path = uri.path @port = uri.port @scheme = uri.scheme @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
63 64 65 |
# File 'lib/fog/hp/dns.rb', line 63 def credentials @credentials end |
Instance Method Details
#create_domain(name, email, options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fog/hp/requests/dns/create_domain.rb', line 25 def create_domain(name, email, ={}) data = { :name => name, :email => email } = [:description, :ttl] .select{|o| [o]}.each do |key| data[key] = [key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'POST', :path => 'domains' ) end |
#create_record(domain_id, name, type, data, options = {}) ⇒ Object
Create a new DNS record
Parameters
-
‘domain_id’<~String> - UUId of the domain
-
‘name’<~String> - Name of record
-
‘type’<~String> - Type of the record i.e. ‘A’
-
‘data’<~String> - Data required by the record
-
options<~Hash>:
-
‘description’<~String> - Description for the record
-
‘priority’<~Integer> - Priority
-
‘ttl’<~Integer> - TTL of the record
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘id’<~String> - UUID of the record
-
‘name’<~String> - Name of the record
-
‘description’<~String> - Description for the record
-
‘type’<~String> - Type of the record
-
‘domain_id’<~String> - UUID of the domain
-
‘ttl’<~Integer> - TTL of the record
-
‘data’<~String> - Data required by the record
-
‘priority’<~Integer> - Priority for the record
-
‘created_at’<~String> - created date time stamp
-
‘updated_at’<~String> - updated date time stamp
-
-
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fog/hp/requests/dns/create_record.rb', line 31 def create_record(domain_id, name, type, data, ={}) data = { :name => name, :type => type, :data => data } = [:description, :priority, :ttl] .select{|o| [o]}.each do |key| data[key] = [key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'POST', :path => "domains/#{domain_id}/records" ) end |
#delete_domain(domain_id) ⇒ Object
Delete a DNS domain
Parameters
-
domain_id<~String> - UUId of domain to delete
12 13 14 15 16 17 18 |
# File 'lib/fog/hp/requests/dns/delete_domain.rb', line 12 def delete_domain(domain_id) request( :expects => 200, :method => 'DELETE', :path => "domains/#{domain_id}" ) end |
#delete_record(domain_id, record_id) ⇒ Object
Delete a DNS Record
Parameters
-
‘domain_id’<~String> - UUId of domain for record
-
‘record_id’<~String> - UUId of record to delete
11 12 13 14 15 16 17 |
# File 'lib/fog/hp/requests/dns/delete_record.rb', line 11 def delete_record(domain_id, record_id) request( :expects => 200, :method => 'DELETE', :path => "domains/#{domain_id}/records/#{record_id}" ) end |
#get_domain(domain_id) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/fog/hp/requests/dns/get_domain.rb', line 20 def get_domain(domain_id) request( :expects => 200, :method => 'GET', :path => "domains/#{domain_id}" ) end |
#get_record(domain_id, record_id) ⇒ Object
Get details of an existing DNS record
Parameters
-
‘domain_id’<~String> - UUId of domain for record
-
‘record_id’<~String> - UUId of record to get
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘id’<~String> - UUID of the record
-
‘name’<~String> - Name of the record
-
‘description’<~String> - Description for the record
-
‘type’<~String> - Type of the record
-
‘domain_id’<~String> - UUId of the domain
-
‘ttl’<~Integer> - TTL of the record
-
‘data’<~String> - Data required by the record
-
‘priority’<~Integer> - Priority for the record
-
‘created_at’<~String> - created date time stamp
-
‘updated_at’<~String> - updated date time stamp
-
-
25 26 27 28 29 30 31 |
# File 'lib/fog/hp/requests/dns/get_record.rb', line 25 def get_record(domain_id, record_id) request( :expects => 200, :method => 'GET', :path => "domains/#{domain_id}/records/#{record_id}" ) end |
#get_servers_hosting_domain(domain_id) ⇒ Object
Get authoritative nameservers for existing DNS domain
Parameters
-
domain_id<~String> - UUId of the domain to get nameservers for
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘nameservers’<~Array>:
-
‘id’<~String> - UUID of the domain
-
‘name’<~String> - Name of the domain
-
‘ttl’<~Integer> - TTL for the domain
-
‘email’<~String> - Email for the domain
-
‘serial’<~Integer> - Serial number for the domain
-
‘created_at’<~String> - created date time stamp
-
-
-
20 21 22 23 24 25 26 |
# File 'lib/fog/hp/requests/dns/get_servers_hosting_domain.rb', line 20 def get_servers_hosting_domain(domain_id) request( :expects => 200, :method => 'GET', :path => "domains/#{domain_id}/servers" ) end |
#list_domains ⇒ Object
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘domains’<~Array>:
-
‘id’<~String> - UUID of the domain
-
‘name’<~String> - Name of the domain
-
‘ttl’<~Integer> - TTL for the domain
-
‘email’<~String> - Email for the domain
-
‘serial’<~Integer> - Serial number for the domain
-
‘created_at’<~String> - created date time stamp
-
-
-
16 17 18 19 20 21 22 |
# File 'lib/fog/hp/requests/dns/list_domains.rb', line 16 def list_domains request( :expects => 200, :method => 'GET', :path => 'domains' ) end |
#list_records_in_a_domain(domain_id) ⇒ Object
List DNS records for a given domain
Parameters
-
‘domain_id’<~String> - UUId of domain for record
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘records’<~Array>:
-
‘id’<~String> - UUID of the record
-
‘name’<~String> - Name of the record
-
‘description’<~String> - Description for the record
-
‘type’<~String> - Type of the record
-
‘domain_id’<~String> - UUID of the domain
-
‘ttl’<~Integer> - TTL of the record
-
‘data’<~String> - Data required by the record
-
‘priority’<~Integer> - Priority for the record
-
‘created_at’<~String> - created date time stamp
-
‘updated_at’<~String> - updated date time stamp
-
-
-
24 25 26 27 28 29 30 |
# File 'lib/fog/hp/requests/dns/list_records_in_a_domain.rb', line 24 def list_records_in_a_domain(domain_id) request( :expects => 200, :method => 'GET', :path => "domains/#{domain_id}/records" ) end |
#reload ⇒ Object
103 104 105 |
# File 'lib/fog/hp/dns.rb', line 103 def reload @connection.reset end |
#request(params, parse_json = true, &block) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/fog/hp/dns.rb', line 107 def request(params, parse_json = true, &block) begin response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :path => "#{@path}/#{params[:path]}", }), &block) rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::HP::DNS::NotFound.slurp(error) else error end end if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %r{application/json} response.body = Fog::JSON.decode(response.body) end response end |
#update_domain(domain_id, options = {}) ⇒ Object
Update an existing DNS domain
Parameters
-
domain_id<~String> - UUId of domain to delete
-
options<~Hash>:
-
‘name’<~String> - Name of domain
-
‘description’<~String> - Description for the domain
-
‘ttl’<~String> - TTL for the domain
-
‘email’<~String> - email for the domain
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘id’<~String> - UUID of the domain
-
‘name’<~String> - Name of the domain
-
‘description’<~String> - Description for the domain
-
‘ttl’<~Integer> - TTL for the domain
-
‘email’<~String> - Email for the domain
-
‘serial’<~Integer> - Serial number for the domain
-
‘created_at’<~String> - created date time stamp
-
-
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fog/hp/requests/dns/update_domain.rb', line 26 def update_domain(domain_id, ={}) data = {} = [:name, :description, :ttl, :email] .select{|o| [o]}.each do |key| data[key] = [key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "domains/#{domain_id}" ) end |
#update_record(domain_id, record_id, options = {}) ⇒ Object
Update an existing DNS record
Parameters
-
‘domain_id’<~String> - UUId of domain of record
-
‘record_id’<~String> - UUId of record to update
-
options<~Hash>:
-
‘name’<~String> - Name of record
-
‘description’<~String> - Description for the record
-
‘type’<~String> - Type of the record i.e. ‘A’
-
‘data’<~String> - Data required by the record
-
‘priority’<~Integer> - Priority
-
‘ttl’<~Integer> - TTL of the record
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘id’<~String> - UUID of the record
-
‘name’<~String> - Name of the record
-
‘description’<~String> - Description for the record
-
‘type’<~String> - Type of the record
-
‘domain_id’<~String> - UUID of the domain
-
‘ttl’<~Integer> - TTL of the record
-
‘data’<~String> - Data required by the record
-
‘priority’<~Integer> - Priority for the record
-
‘created_at’<~String> - created date time stamp
-
‘updated_at’<~String> - updated date time stamp
-
-
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fog/hp/requests/dns/update_record.rb', line 32 def update_record(domain_id, record_id, ={}) data = {} = [:name, :description, :type, :data, :priority, :ttl] .select{|o| [o]}.each do |key| data[key] = [key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "domains/#{domain_id}/records/#{record_id}" ) end |