Class: Fog::DNS::Rage4::Real
- Inherits:
-
Object
- Object
- Fog::DNS::Rage4::Real
- Defined in:
- lib/fog/rage4/dns.rb,
lib/fog/rage4/requests/dns/get_domain.rb,
lib/fog/rage4/requests/dns/list_domains.rb,
lib/fog/rage4/requests/dns/list_records.rb,
lib/fog/rage4/requests/dns/create_domain.rb,
lib/fog/rage4/requests/dns/create_record.rb,
lib/fog/rage4/requests/dns/delete_domain.rb,
lib/fog/rage4/requests/dns/delete_record.rb,
lib/fog/rage4/requests/dns/update_domain.rb,
lib/fog/rage4/requests/dns/update_record.rb,
lib/fog/rage4/requests/dns/list_geo_regions.rb,
lib/fog/rage4/requests/dns/list_record_types.rb,
lib/fog/rage4/requests/dns/show_global_usage.rb,
lib/fog/rage4/requests/dns/get_domain_by_name.rb,
lib/fog/rage4/requests/dns/show_current_usage.rb,
lib/fog/rage4/requests/dns/set_record_failover.rb,
lib/fog/rage4/requests/dns/create_domain_vanity.rb,
lib/fog/rage4/requests/dns/create_reverse_domain_4.rb
Instance Method Summary collapse
-
#create_domain(name, options = {}) ⇒ Object
Create a domain.
-
#create_domain_vanity(name, nsname, options = {}) ⇒ Object
Create a domain with a vanity name server.
- #create_record(domain_id, name, content, type, options = {}) ⇒ Object
-
#create_reverse_domain_4(name, subnet, options = {}) ⇒ Object
Create a reverse domain for an ipv4 address .
-
#delete_domain(id) ⇒ Object
Delete a specific domain ==== Parameters * id<~Integer> - numeric ID.
-
#delete_record(id) ⇒ Object
Delete a specific record ==== Parameters * id<~Integer> - numeric record ID.
-
#get_domain(id) ⇒ Object
Get the details for a specific domain in your account.
-
#get_domain_by_name(name) ⇒ Object
Get the details for a specific domain in your account.
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
-
#list_domains ⇒ Object
Get the lsit of all domains for your account.
-
#list_geo_regions ⇒ Object
List all the geo regions available ==== Parameters.
-
#list_record_types ⇒ Object
List all the record types available ==== Parameters.
-
#list_records(id) ⇒ Object
Get the list of records for the specific domain.
- #reload ⇒ Object
- #request(params) ⇒ Object
-
#set_record_failover(id, active, failover) ⇒ Object
Set a failover to on or off ==== Parameters * id<~Integer> - numeric ID.
-
#show_current_usage(id) ⇒ Object
Shows current usage for a single domain ==== Parameters * id<~Integer> - domain name numeric ID.
-
#show_global_usage ⇒ Object
Shows global usage for all domains ==== Parameters.
-
#update_domain(id, options = {}) ⇒ Object
Update an existing domain ==== Parameters * id<~Integer> - domain integer value * email <~String> - email of domain owner * nsprefix<~String> - vanity ns prefix (nullable) * nsname<~String> - vanity ns domain name (nullable) * enablevanity<~String> - activate/deactivate * failover<~Boolean> - failover enable.
- #update_record(record_id, name, content, type, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fog/rage4/dns.rb', line 35 def initialize(={}) @rage4_email = [:rage4_email] @rage4_password = [:rage4_api_key] @connection_options = [:connection_options] || {} if [:rage4_url] uri = URI.parse([:rage4_url]) [:host] = uri.host [:port] = uri.port [:scheme] = uri.scheme end @host = [:host] || "secure.rage4.com" @persistent = [:persistent] || false @port = [:port] || 443 @scheme = [:scheme] || 'https' @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end |
Instance Method Details
#create_domain(name, options = {}) ⇒ Object
Create a domain.
Parameters
-
name<~String> - domain name
-
email<~String> - email of owner of domain, defaults to email of credentials
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
* 'status'<~Boolean> * 'id'<~Integer> * 'error'<~String>
-
18 19 20 21 22 23 24 25 |
# File 'lib/fog/rage4/requests/dns/create_domain.rb', line 18 def create_domain(name, = {}) email = [:email] || @rage4_email request( :expects => 200, :method => 'GET', :path => "/rapi/createregulardomain/?name=#{name}&email=#{email}" ) end |
#create_domain_vanity(name, nsname, options = {}) ⇒ Object
Create a domain with a vanity name server.
Parameters
-
name<~String> - domain name
-
nsname<~String> - vanity ns domain name
-
nsprefix<~String> - prefix for the domain name, defaults to ‘ns’
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
* 'status'<~Boolean> * 'id'<~Integer> * 'error'<~String>
-
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fog/rage4/requests/dns/create_domain_vanity.rb', line 17 def create_domain_vanity(name, nsname, = {}) email = [:email] || @rage4_email nsprefix = [:nsprefix] || 'ns' request( :expects => 200, :method => 'GET', :path => "/rapi/createregulardomainext/?name=#{name}&email=#{email}" + "&nsname=#{nsname}&nsprefix=#{nsprefix}" ) end |
#create_record(domain_id, name, content, type, options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fog/rage4/requests/dns/create_record.rb', line 30 def create_record(domain_id, name, content, type, = {}) path = "/rapi/createrecord/#{domain_id}" path << "?name=#{name}&content=#{content}&type=#{type}" path << "&priority=#{[:priority]}" if [:priority] failover = [:failover] || 'false' path << "&failover=#{failover}" path << "&failovercontent=#{[:failovercontent]}" if [:failovercontent] ttl = [:ttl] || 3600 path << "&ttl=#{ttl}" path << "&geozone=#{[:geozone]}" if [:geozone] path << "&geolock=#{[:geolock]}" if [:geolock] path << "&geolat=#{[:geolat]}" if [:geolat] path << "&geolong=#{[:geolong]}" if [:geolong] path << "&udplimit=#{[:udplimit]}" if [:udplimit] request( :expects => 200, :method => 'GET', :path => path ) end |
#create_reverse_domain_4(name, subnet, options = {}) ⇒ Object
Create a reverse domain for an ipv4 address .
Parameters
-
name<~String> - expects an ipv5 address
-
subnet<~Integer> - subnet ie: 9 for /9, range is /8 to /30
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
* 'status'<~Boolean> * 'id'<~Integer> * 'error'<~String>
-
16 17 18 19 20 21 22 23 24 |
# File 'lib/fog/rage4/requests/dns/create_reverse_domain_4.rb', line 16 def create_reverse_domain_4(name, subnet, = {}) email = [:email] || @rage4_email request( :expects => 200, :method => 'GET', :path => "/rapi/createreversedomain4/?name=#{name}&email=#{email}" + "&subnet=#{subnet}" ) end |
#delete_domain(id) ⇒ Object
Delete a specific domain
Parameters
-
id<~Integer> - numeric ID
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
* 'status'<~Boolean> * 'id'<~Integer> * 'error'<~String>
-
15 16 17 18 19 20 |
# File 'lib/fog/rage4/requests/dns/delete_domain.rb', line 15 def delete_domain(id) request( :expects => 200, :method => 'GET', :path => "/rapi/deletedomain/#{id}" ) end |
#delete_record(id) ⇒ Object
Delete a specific record
Parameters
-
id<~Integer> - numeric record ID
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
* 'status'<~Boolean> * 'id'<~Integer> * 'error'<~String>
-
15 16 17 18 19 20 |
# File 'lib/fog/rage4/requests/dns/delete_record.rb', line 15 def delete_record(id) request( :expects => 200, :method => 'GET', :path => "/rapi/deleterecord/#{id}" ) end |
#get_domain(id) ⇒ Object
Get the details for a specific domain in your account.
Parameters
-
id<~Integer> - numeric ID
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
* 'id'<~Integer> * 'name'<~String> * 'owner_email'<~String> * 'type'<~Integer> * 'subnet_mask'<~Integer>
-
17 18 19 20 21 22 |
# File 'lib/fog/rage4/requests/dns/get_domain.rb', line 17 def get_domain(id) request( :expects => 200, :method => 'GET', :path => "/rapi/getdomain/#{id}" ) end |
#get_domain_by_name(name) ⇒ Object
Get the details for a specific domain in your account.
Parameters
-
name<~String> - name of domain
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
* 'id'<~Integer> * 'name'<~String> * 'owner_email'<~String> * 'type'<~Integer> * 'subnet_mask'<~Integer>
-
17 18 19 20 21 22 |
# File 'lib/fog/rage4/requests/dns/get_domain_by_name.rb', line 17 def get_domain_by_name(name) request( :expects => 200, :method => 'GET', :path => "/rapi/getdomainbyname/?name=#{name}") end |
#list_domains ⇒ Object
Get the lsit of all domains for your account.
Parameters
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
‘domains’<~Hash>
-
‘id’<~Integer>
-
‘name’<~String>
-
‘owner_email’<~String>
-
‘type’<~Integer>
-
‘subnet_mask’<~Integer>
-
-
-
17 18 19 20 21 22 23 |
# File 'lib/fog/rage4/requests/dns/list_domains.rb', line 17 def list_domains request( :expects => 200, :method => 'GET', :path => '/rapi/getdomains' ) end |
#list_geo_regions ⇒ Object
List all the geo regions available
Parameters
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
‘record types’<~Hash> *‘name’ <~String> geo record name *‘value’ <~Integer> Integer value of the type
-
-
15 16 17 18 19 20 21 |
# File 'lib/fog/rage4/requests/dns/list_geo_regions.rb', line 15 def list_geo_regions request( :expects => 200, :method => 'GET', :path => '/rapi/listgeoregions' ) end |
#list_record_types ⇒ Object
List all the record types available
Parameters
Returns
-
response<~Excon::Response>:
-
body<~Array>:
-
‘record types’<~Hash> *‘name’ <~String> record type name *‘value’ <~Integer> Integer value of the type
-
-
14 15 16 17 18 19 20 |
# File 'lib/fog/rage4/requests/dns/list_record_types.rb', line 14 def list_record_types request( :expects => 200, :method => 'GET', :path => '/rapi/listrecordtypes' ) end |
#list_records(id) ⇒ Object
Get the list of records for the specific domain.
Parameters
-
id<~Integer>
Returns
-
response<~Excon::Response>:
-
records<Array~>
-
name<~String>
-
ttl<~Integer>
-
updated_at<~String>
-
domain_id<~Integer>
-
id<~Integer>
-
content<~String>
-
record_type<~String>
-
priority<~Integer>
-
-
20 21 22 23 24 |
# File 'lib/fog/rage4/requests/dns/list_records.rb', line 20 def list_records(id) request( :expects => 200, :method => "GET", :path => "/rapi/getrecords/#{id}" ) end |
#reload ⇒ Object
52 53 54 |
# File 'lib/fog/rage4/dns.rb', line 52 def reload @connection.reset end |
#request(params) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/fog/rage4/dns.rb', line 56 def request(params) params[:headers] ||= {} key = "#{@rage4_email}:#{@rage4_password}" params[:headers].merge!({ "Authorization" => "Basic " + Base64.encode64(key).gsub("\n",'')}) response = @connection.request(params) unless response.body.empty? response.body = Fog::JSON.decode(response.body) end response end |
#set_record_failover(id, active, failover) ⇒ Object
Set a failover to on or off
Parameters
-
id<~Integer> - numeric ID
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
* 'status'<~Boolean> * 'id'<~Integer> * 'error'<~String>
-
15 16 17 18 19 20 21 |
# File 'lib/fog/rage4/requests/dns/set_record_failover.rb', line 15 def set_record_failover(id, active, failover) request( :expects => 200, :method => 'GET', :path => "/rapi/setrecordfailover/#{id}&active=#{active}&failover=#{failover}" ) end |
#show_current_usage(id) ⇒ Object
Shows current usage for a single domain
Parameters
-
id<~Integer> - domain name numeric ID
Returns
-
response<~Excon::Response>:
-
body<~Array>
-
12 13 14 15 16 17 |
# File 'lib/fog/rage4/requests/dns/show_current_usage.rb', line 12 def show_current_usage(id) request( :expects => 200, :method => 'GET', :path => "/rapi/showcurrentusage/#{id}" ) end |
#show_global_usage ⇒ Object
Shows global usage for all domains
Parameters
Returns
-
response<~Excon::Response>:
-
body<~Array>
-
12 13 14 15 16 17 |
# File 'lib/fog/rage4/requests/dns/show_global_usage.rb', line 12 def show_global_usage request( :expects => 200, :method => 'GET', :path => "/rapi/showcurrentglobalusage/" ) end |
#update_domain(id, options = {}) ⇒ Object
Update an existing domain
Parameters
-
id<~Integer> - domain integer value
-
email <~String> - email of domain owner
-
nsprefix<~String> - vanity ns prefix (nullable)
-
nsname<~String> - vanity ns domain name (nullable)
-
enablevanity<~String> - activate/deactivate
-
failover<~Boolean> - failover enable
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
* 'status'<~Boolean> * 'id'<~Integer> * 'error'<~String>
-
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fog/rage4/requests/dns/update_domain.rb', line 20 def update_domain(id, = {}) email = [:email] || @rage4_email path = "/rapi/updatedomain/#{id}?email=#{email}" path << "&nsname=#{[:nsname]}" if [:nsname] path << "&nsprefix=#{[:nsprefix]}" if [:nsprefix] path << "&enablevanity=#{[:enablevanity]}" if [:enablevanity] path << "&failover=#{[:failover]}" if [:failover] request( :expects => 200, :method => 'GET', :path => path ) end |
#update_record(record_id, name, content, type, options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fog/rage4/requests/dns/update_record.rb', line 30 def update_record(record_id, name, content, type, = {}) path = "/rapi/updaterecord/#{record_id}" path << "?name=#{name}&content=#{content}&type=#{type}" path << "&priority=#{[:priority]}" if [:priority] failover = [:failover] || 'false' path << "&failover=#{failover}" path << "&failovercontent=#{[:failovercontent]}" if [:failovercontent] ttl = [:ttl] || 3600 path << "&ttl=#{ttl}" path << "&geozone=#{[:geozone]}" if [:geozone] path << "&geolock=#{[:geolock]}" if [:geolock] path << "&geolat=#{[:geolat]}" if [:geolat] path << "&geolong=#{[:geolong]}" if [:geolong] path << "&udplimit=#{[:udplimit]}" if [:udplimit] request( :expects => 200, :method => 'GET', :path => path ) end |