Class: Fog::DNS::Linode::Real
- Inherits:
-
Object
- Object
- Fog::DNS::Linode::Real
- Defined in:
- lib/fog/linode/dns.rb,
lib/fog/linode/requests/dns/domain_list.rb,
lib/fog/linode/requests/dns/domain_create.rb,
lib/fog/linode/requests/dns/domain_delete.rb,
lib/fog/linode/requests/dns/domain_update.rb,
lib/fog/linode/requests/dns/domain_resource_list.rb,
lib/fog/linode/requests/dns/domain_resource_create.rb,
lib/fog/linode/requests/dns/domain_resource_delete.rb,
lib/fog/linode/requests/dns/domain_resource_update.rb
Instance Method Summary collapse
-
#domain_create(domain, type, options = {}) ⇒ Object
Creates a domain record.
-
#domain_delete(domain_id) ⇒ Object
Delete the given domain from the list Linode hosts.
-
#domain_list(domain_id = nil) ⇒ Object
List of domains (you have access to).
-
#domain_resource_create(domain_id, type, options = {}) ⇒ Object
Creates a resource record in a domain.
-
#domain_resource_delete(domain_id, resource_id) ⇒ Object
Delete the given resource from a domain.
-
#domain_resource_list(domain_id, resource_id = nil) ⇒ Object
List of resource records for a domain.
-
#domain_resource_update(domain_id, resource_id, options = {}) ⇒ Object
Updates a resource record in a domain.
-
#domain_update(domain_id, options = {}) ⇒ Object
Update a domain record.
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #reload ⇒ Object
- #request(params) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fog/linode/dns.rb', line 55 def initialize(={}) require 'multi_json' @connection_options = [:connection_options] || {} @host = [:host] || "api.linode.com" @linode_api_key = [:linode_api_key] @persistent = [:persistent] || false @port = [:port] || 443 @scheme = [:scheme] || 'https' @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end |
Instance Method Details
#domain_create(domain, type, options = {}) ⇒ Object
Creates a domain record
Parameters
-
domain<~String>: The zone’s name. Note, if master zone, SOA_email is required and if slave
master_ips is/are required
-
type<~String>: master or slave
-
options<~Hash>
-
description<~String> Currently undisplayed
-
SOA_email<~String> Required when type=master
-
refresh_sec<~Integer> numeric, default: ‘0’
-
retry_sec<~Integer> numeric, default: ‘0’
-
expire_sec<~Integer> numeric, default: ‘0’
-
ttl_sec<~String> numeric, default: ‘0’
-
status<~Integer> 0, 1, or 2 (disabled, active, edit mode), default: 1
-
master_ips<~String> When type=slave, the zone’s master DNS servers list, semicolon separated
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
DATA<~Hash>:
-
‘DomainID’<~Integer>: domain ID
-
-
-
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fog/linode/requests/dns/domain_create.rb', line 27 def domain_create(domain, type, = {}) query= {} request( :expects => 200, :method => 'GET', :query => { :api_action => 'domain.create', :domain => domain, :type => type }.merge!( ) ) end |
#domain_delete(domain_id) ⇒ Object
Delete the given domain from the list Linode hosts
Parameters
-
domain_id<~Integer>: id of domain to delete
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
DATA<~Hash>:
-
-
TODO: docs
16 17 18 19 20 21 22 |
# File 'lib/fog/linode/requests/dns/domain_delete.rb', line 16 def domain_delete(domain_id) request( :expects => 200, :method => 'GET', :query => { :api_action => 'domain.delete', :domainId => domain_id } ) end |
#domain_list(domain_id = nil) ⇒ Object
List of domains (you have access to)
Parameters
-
domain_id<~Integer>: limit the list to the domain ID specified
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
DATA<~Array>
-
‘DOMAINID’<~Interger>
-
‘SOA_EMAIL’<~String>
-
‘DESCRIPTION’<~String>
-
‘TTL_SEC’<~String>
-
‘EXPIRE_SEC’<~Integer>
-
‘RETRY_SEC’<~Integer>
-
‘DOMAIN’<~String>
-
‘STATUS’<~Integer>
-
‘MASTER_IPS’<~String>
-
‘REFRESH_SEC’<~Integer>
-
‘TYPE’<~String>
-
-
-
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fog/linode/requests/dns/domain_list.rb', line 26 def domain_list(domain_id = nil) = {} if domain_id .merge!(:domainId => domain_id) end request( :expects => 200, :method => 'GET', :query => { :api_action => 'domain.list' }.merge!() ) end |
#domain_resource_create(domain_id, type, options = {}) ⇒ Object
Creates a resource record in a domain
Parameters
-
domain_id<~Integer>: limit the list to the domain ID specified
-
type<~String>: One of: NS, MX, A, AAAA, CNAME, TXT, or SRV
-
options<~Hash>
-
name<~String>: The hostname or FQDN. When Type=MX the subdomain to delegate to the
Target MX server
-
target<~String> When Type=MX the hostname. When Type=CNAME the target of the alias.
When Type=TXT the value of the record. When Type=A or AAAA the token of '[remote_addr]' will be substituted with the IP address of the request.
-
priority<~Integer>: priority for MX and SRV records, 0-255 - default: 10
-
weight<~Integer>: default: 5
-
port<~Integer>: default: 80
-
protocol<~String>: The protocol to append to an SRV record. Ignored on other record
types. default: udp
-
ttl_sec<~Integer>: note, Linode will round the input to set values (300, 3600, 7200, etc)
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
DATA<~Hash>:
-
‘ResourceID’<~Integer>: ID of the resource record created
-
-
-
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fog/linode/requests/dns/domain_resource_create.rb', line 28 def domain_resource_create(domain_id, type, = {}) query= {} request( :expects => 200, :method => 'GET', :query => { :api_action => 'domain.resource.create', :domainID => domain_id, :type => type }.merge!( ) ) end |
#domain_resource_delete(domain_id, resource_id) ⇒ Object
Delete the given resource from a domain
Parameters
-
domain_id<~Integer>: id of domain resource belongs to
-
resource_id<~Integer>: id of resouce to delete
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
DATA<~Hash>:
-
resource_id<~Integer>: resource id that was deleted
-
-
-
17 18 19 20 21 22 23 |
# File 'lib/fog/linode/requests/dns/domain_resource_delete.rb', line 17 def domain_resource_delete(domain_id, resource_id) request( :expects => 200, :method => 'GET', :query => { :api_action => 'domain.resource.delete', :domainId => domain_id, :resourceID => resource_id } ) end |
#domain_resource_list(domain_id, resource_id = nil) ⇒ Object
List of resource records for a domain
Parameters
-
domain_id<~Integer>: limit the list to the domain ID specified
-
resource_id<~Integer>: optional. use if want only a specific resource record
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
DATA<~Array>
-
‘PROTOCOL’<~String>: for SRV records. default is UDP
-
‘TTL_SEC’<~Interger>:
-
‘PRIORITY’<~Interger>: for MX and SRV records
-
‘TYPE’<~String>: One of: NS, MX, A, AAAA, CNAME, TXT, or SRV
-
‘TARGET’<~String>: When Type=MX the hostname. When Type=CNAME the target of the alias.
When Type=TXT the value of the record. When Type=A or AAAA the token of '[remote_addr]' will be substituted with the IP address of the request.
-
‘WEIGHT’<~Interger>:
-
‘RESOURCEID’<~Interger>: ID of the resource record
-
‘PORT’<~Interger>:
-
‘DOMAINID’<~Interger>: ID of the domain that this record belongs to
-
‘NAME’<~Interger>: The hostname or FQDN. When Type=MX, the subdomain to delegate to
-
-
-
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fog/linode/requests/dns/domain_resource_list.rb', line 28 def domain_resource_list(domain_id, resource_id = nil) query = { :api_action => 'domain.resource.list', :domainID => domain_id } if resource_id query[:resourceID] = resource_id end request( :expects => 200, :method => 'GET', :query => query ) end |
#domain_resource_update(domain_id, resource_id, options = {}) ⇒ Object
Updates a resource record in a domain
Parameters
-
domain_id<~Integer>: limit the list to the domain ID specified
-
resource_id<~Integer>: id of resouce to delete
-
options<~Hash>
-
type<~String>: One of: NS, MX, A, AAAA, CNAME, TXT, or SRV
-
name<~String>: The hostname or FQDN. When Type=MX the subdomain to delegate to the
Target MX server
-
target<~String> When Type=MX the hostname. When Type=CNAME the target of the alias.
When Type=TXT the value of the record. When Type=A or AAAA the token of '[remote_addr]' will be substituted with the IP address of the request.
-
priority<~Integer>: priority for MX and SRV records, 0-255 - default: 10
-
weight<~Integer>: default: 5
-
port<~Integer>: default: 80
-
protocol<~String>: The protocol to append to an SRV record. Ignored on other record
types. default: udp
-
ttl_sec<~Integer>: note, Linode will round the input to set values (300, 3600, 7200, etc)
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
DATA<~Hash>:
-
‘ResourceID’<~Integer>: ID of the resource record updated
-
-
-
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fog/linode/requests/dns/domain_resource_update.rb', line 29 def domain_resource_update(domain_id, resource_id, = {}) query= {} request( :expects => 200, :method => 'GET', :query => { :api_action => 'domain.resource.update', :domainID => domain_id, :resourceID => resource_id, }.merge!( ) ) end |
#domain_update(domain_id, options = {}) ⇒ Object
Update a domain record
Parameters
-
domain_id<~Integer>: The ID to identify the zone
-
options<~Hash>
-
domain<~String>: The zone’s name.
-
type<~String>: master or slave
-
description<~String> Currently undisplayed
-
SOA_email<~String> Required when type=master
-
refresh_sec<~Integer> numeric, default: ‘0’
-
retry_sec<~Integer> numeric, default: ‘0’
-
expire_sec<~Integer> numeric, default: ‘0’
-
ttl_sec<~String> numeric, default: ‘0’
-
status<~Integer> 0, 1, or 2 (disabled, active, edit mode), default: 1
-
master_ips<~String> When type=slave, the zone’s master DNS servers list, semicolon separated
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
DATA<~Hash>:
-
‘DomainID’<~Integer>: domain ID
-
-
-
27 28 29 30 31 32 33 34 35 |
# File 'lib/fog/linode/requests/dns/domain_update.rb', line 27 def domain_update(domain_id, = {}) request( :expects => 200, :method => 'GET', :query => { :api_action => 'domain.update', :domainId => domain_id }.merge!() ) end |
#reload ⇒ Object
66 67 68 |
# File 'lib/fog/linode/dns.rb', line 66 def reload @connection.reset end |
#request(params) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/fog/linode/dns.rb', line 70 def request(params) params[:query] ||= {} params[:query].merge!(:api_key => @linode_api_key) response = @connection.request(params.merge!({:host => @host})) unless response.body.empty? response.body = MultiJson.decode(response.body) if data = response.body['ERRORARRAY'].first error = case data['ERRORCODE'] when 5 Fog::DNS::Linode::NotFound else Fog::DNS::Linode::Error end raise error.new(data['ERRORMESSAGE']) end end response end |