Class: Fog::DNS::DNSMadeEasy::Real

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/dnsmadeeasy/dns.rb,
lib/fog/dnsmadeeasy/requests/dns/get_domain.rb,
lib/fog/dnsmadeeasy/requests/dns/get_record.rb,
lib/fog/dnsmadeeasy/requests/dns/list_domains.rb,
lib/fog/dnsmadeeasy/requests/dns/list_records.rb,
lib/fog/dnsmadeeasy/requests/dns/create_domain.rb,
lib/fog/dnsmadeeasy/requests/dns/create_record.rb,
lib/fog/dnsmadeeasy/requests/dns/delete_domain.rb,
lib/fog/dnsmadeeasy/requests/dns/delete_record.rb,
lib/fog/dnsmadeeasy/requests/dns/get_secondary.rb,
lib/fog/dnsmadeeasy/requests/dns/update_record.rb,
lib/fog/dnsmadeeasy/requests/dns/list_secondary.rb,
lib/fog/dnsmadeeasy/requests/dns/create_secondary.rb,
lib/fog/dnsmadeeasy/requests/dns/delete_secondary.rb,
lib/fog/dnsmadeeasy/requests/dns/update_secondary.rb,
lib/fog/dnsmadeeasy/requests/dns/delete_all_domains.rb,
lib/fog/dnsmadeeasy/requests/dns/delete_all_secondary.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Real

Initialize connection to DNS Made Easy

Notes

options parameter must include values for :dnsmadeeasy_api_key and :dnsmadeeasy_secret_key in order to create a connection

Examples

dns = Fog::DNSMadeEasy::DNS.new(
  :dnsmadeeasy_api_key => your_dnsmadeeasy_api_key,
  :dnsmadeeasy_secret_key => your_dnsmadeeasy_secret_key
)

Parameters

  • options<~Hash> - config arguments for connection. Defaults to {}.

Returns

  • dns object with connection to aws.



81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/fog/dnsmadeeasy/dns.rb', line 81

def initialize(options={})
  require 'fog/core/parser'
  require 'multi_json'

  @dnsmadeeasy_api_key = options[:dnsmadeeasy_api_key]
  @dnsmadeeasy_secret_key = options[:dnsmadeeasy_secret_key]
  @connection_options = options[:connection_options] || {}
  @host       = options[:host]        || 'api.dnsmadeeasy.com'
  @persistent = options[:persistent]  || true
  @port       = options[:port]        || 80 #443 Not yet
  @scheme     = options[:scheme]      || 'http' #'https Not yet
  @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end

Instance Method Details

#create_domain(domain) ⇒ Object

Creates a domain entry with the specified name. Returns errors if name is not valid or conflicts with another domain.

Parameters

  • domain<~String> - domain name

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • name<~String> The domain name.

      • nameServer<~Array> List of strings, Name servers associated with this domain e.g. [“ns1.dnsmadeeasy.com”, “ns2.dnsmadeeasy.com”]

      • gtdEnabled<~Boolean> true | false - Indicator of whether or not this domain uses the Global Traffic Director.

    • status<~Integer> - 201 - domain successfully created, 400 - domain name not valid, see errors in response content



18
19
20
21
22
23
24
# File 'lib/fog/dnsmadeeasy/requests/dns/create_domain.rb', line 18

def create_domain(domain)
  request(
    :expects  => 201,
    :method   => 'PUT',
    :path     => "/V1.2/domains/#{domain}"
  )
end

#create_record(domain, name, type, data, options = {}) ⇒ Object

Creates a record with the representation specified in the request content. Returns errors if record is not valid. Note that a record ID will be generated by the system with this request and any ID that is sent will be ignored. Records are not modifiable for domains that are locked to a template.

Parameters

  • domain<~String> Domain name.

  • name<~String> Record name.

  • type<~String> Record type. Values: A, AAAA, CNAME, HTTPRED, MX, NS, PTR, SRV, TXT

  • data<~String> Record data

  • options<~Hash> - optional

    • ttl<~Integer> Time to live. The amount of time a record will be cached before being refreshed. Default: 1800 (30 mins)

    • gtdLocation<~String> Global Traffic Director location. Values: DEFAULT, US_EAST, US_WEST, EUROPE

    • password<~String> For A records. Password used to authenticate for dynamic DNS.

    • description<~String> For HTTPRED records. A description of the HTTPRED record.

    • keywords<~String> For HTTPRED records. Keywords associated with the HTTPRED record.

    • title<~String> For HTTPRED records. The title of the HTTPRED record.

    • redirectType<~String> For HTTPRED records. Type of redirection performed. Values: Hidden Frame Masked, Standard - 302, Standard - 301

    • hardLink<~Boolean> For HTTPRED records.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • id<~Integer> Unique record identifier

      • name<~String>

      • type<~String>

      • data<~String>

      • ttl<~Integer>

      • gtdLocation<~String>

      • password<~String>

      • description<~String>

      • keywords<~String>

      • title<~String>

      • redirectType<~String>

      • hardLink<~Boolean>

    • ‘status’<~Integer> - 201 - record successfully created, 400 - record not valid, see errors in response content, 404 - domain not found



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/fog/dnsmadeeasy/requests/dns/create_record.rb', line 40

def create_record(domain, name, type, data, options = {})

  body = {
    "name" => name,
    "type" => type,
    "data" => data,
    "ttl"  => 1800
  }

  body.merge!(options)

  request(
    :expects  => 201,
    :method   => "POST",
    :path     => "/V1.2/domains/#{domain}/records",
    :body     => MultiJson.encode(body)
  )
end

#create_secondary(secondary_name, ip_addresses) ⇒ Object

Creates a secondary entry with the specified name. Returns errors if name is not valid or conflicts with another domain.

Parameters

  • secondary_name<~String> - secondary name

  • ip_addresses<~Array> - List of secondary ip addresses

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • name<~String> Secondary name.

      • ip<~Array> List of strings, IP addresses for your master nameserver associated with this secondary entry. e.g. [“10.10.10.10”, “10.10.10.11”]

      • gtdLocation<~String> Global Traffic Director location. Values: DEFAULT, US_EAST, US_WEST, EUROPE

    • status<~Integer> - 201 - secondary entry successfully created or modified, 400 - secondary entry name or IP addresses not valid, see errors in response content



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/dnsmadeeasy/requests/dns/create_secondary.rb', line 19

def create_secondary(secondary_name, ip_addresses)
  
  body = {
    "ip" => [*ip_addresses]
  }
  
  request(
    :expects  => 201,
    :method   => 'PUT',
    :path     => "/V1.2/secondary/#{secondary_name}",
    :body     => MultiJson.encode(body)
  )
end

#delete_all_domainsObject

Deletes all domains for your account.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • status<~Integer> - 200 - OK



12
13
14
15
16
17
18
# File 'lib/fog/dnsmadeeasy/requests/dns/delete_all_domains.rb', line 12

def delete_all_domains
  request(
    :expects  => 200,
    :method   => 'DELETE',
    :path     => '/V1.2/domains'
  )
end

#delete_all_secondaryObject

Deletes all secondary entries for your account.

Returns

  • response<~Excon::Response>:

    • status<~Integer> 200 - OK



11
12
13
14
15
16
17
# File 'lib/fog/dnsmadeeasy/requests/dns/delete_all_secondary.rb', line 11

def delete_all_secondary
  request(
    :expects  => 200,
    :method   => 'DELETE',
    :path     => '/V1.2/secondary'
  )
end

#delete_domain(domain) ⇒ Object

Delete the given domain from your account.

Parameters

  • domain<~String> - domain name

Returns

  • response<~Excon::Response>:

    • status<~Integer> 200 - OK, 404 - specified domain name is not found



14
15
16
17
18
19
20
# File 'lib/fog/dnsmadeeasy/requests/dns/delete_domain.rb', line 14

def delete_domain(domain)
  request(
    :expects  => 200,
    :method   => 'DELETE',
    :path     => "/V1.2/domains/#{domain}"
  )
end

#delete_record(domain, record_id) ⇒ Object

Deletes the record with the specified id. Note that records are not modifiable for domains that are locked to a template.

Parameters

  • domain<~String> - domain name

  • record_id<~String> - record id

Returns

  • response<~Excon::Response>:

    • status<~Integer> 200 - OK, 404 - specified domain name or record id is not found



15
16
17
18
19
20
21
# File 'lib/fog/dnsmadeeasy/requests/dns/delete_record.rb', line 15

def delete_record(domain, record_id)
  request(
    :expects  => 200,
    :method   => 'DELETE',
    :path     => "/V1.2/domains/#{domain}/records/#{record_id}"
  )
end

#delete_secondary(secondary_name) ⇒ Object

Deletes the specified secondary entry.

Parameters

  • secondary_name<~String> - secondary domain name

Returns

  • response<~Excon::Response>:

    • status<~Integer> 200 - OK, 404 - specified secondary entry name is not found



14
15
16
17
18
19
20
# File 'lib/fog/dnsmadeeasy/requests/dns/delete_secondary.rb', line 14

def delete_secondary(secondary_name)
  request(
    :expects  => 200,
    :method   => 'DELETE',
    :path     => "/V1.2/secondary/#{secondary_name}"
  )
end

#get_domain(domain) ⇒ Object

Get the details for a specific domain in your account.

Parameters

  • domain<~String> - domain name

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • name<~String> The domain name.

      • nameServer<~Array> List of strings, Name servers associated with this domain e.g. [“ns1.dnsmadeeasy.com”, “ns2.dnsmadeeasy.com”]

      • gtdEnabled<~Boolean> Indicator of whether or not this domain uses the Global Traffic Director.

    • status<~Integer> 200 - OK, 404 - specified domain name is not found



18
19
20
21
22
23
24
# File 'lib/fog/dnsmadeeasy/requests/dns/get_domain.rb', line 18

def get_domain(domain)
  request(
    :expects  => 200,
    :method   => "GET",
    :path     => "/V1.2/domains/#{domain}"
  )
end

#get_record(domain, record_id) ⇒ Object

Returns a record object representing the record with the specified id.

Parameters

  • domain<~String>

  • record_id<~Integer>

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • id<~Integer> Unique record identifier

      • name<~String> Record name.

      • type<~String> Record type. Values: A, AAAA, CNAME, HTTPRED, MX, NS, PTR, SRV, TXT

      • data<~String> Record data

      • ttl<~Integer> Time to live. The amount of time a record will be cached before being refreshed. Default: 1800

      • gtdLocation<~String> Global Traffic Director location. Values: DEFAULT, US_EAST, US_WEST, EUROPE

      • password<~String> For A records. Password used to authenticate for dynamic DNS.

      • description<~String> For HTTPRED records. A description of the HTTPRED record.

      • keywords<~String> For HTTPRED records. Keywords associated with the HTTPRED record.

      • title<~String> For HTTPRED records. The title of the HTTPRED record.

      • redirectType<~String> For HTTPRED records. Type of redirection performed. Values: Hidden Frame Masked, Standard - 302, Standard - 301

      • hardLink<~Boolean> For HTTPRED records.

    • status<~Integer> - 200 - OK, 404 - specified domain name or record id is not found



27
28
29
30
31
32
33
# File 'lib/fog/dnsmadeeasy/requests/dns/get_record.rb', line 27

def get_record(domain, record_id)
  request(
    :expects  => 200,
    :method   => "GET",
    :path     => "/V1.2/domains/#{domain}/records/#{record_id}"
  )
end

#get_secondary(secondary_name) ⇒ Object

Returns the secondary entry object representation of the specified secondary entry.

Parameters

  • secondary_name<~String> - secondary name

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • name<~String> Secondary name.

      • ip<~Array> List of strings, IP addresses for your master nameserver associated with this secondary entry. e.g. [“10.10.10.10”, “10.10.10.11”]

      • gtdLocation<~String> Global Traffic Director location. Values: DEFAULT, US_EAST, US_WEST, EUROPE

    • status<~Integer> - 200 - OK, 404 - specified secondary entry name is not found



18
19
20
21
22
23
24
# File 'lib/fog/dnsmadeeasy/requests/dns/get_secondary.rb', line 18

def get_secondary(secondary_name)
  request(
    :expects  => 200,
    :method   => "GET",
    :path     => "/V1.2/secondary/#{secondary_name}"
  )
end

#list_domainsObject

Returns a list of all domain names for your account.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • list<~Array> e.g. [“domain1.com”,“domain2.com”, “domain3.com”]

    • status<~Integer> - 200 - OK



13
14
15
16
17
18
19
# File 'lib/fog/dnsmadeeasy/requests/dns/list_domains.rb', line 13

def list_domains
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => '/V1.2/domains'
  )
end

#list_records(domain, options = {}) ⇒ Object

Returns a list of record objects containing all records for the specified domain

Parameters

  • domain<~String>

  • options<~Hash>

    • gtdLocation<~String> Global Traffic Director location. Values: DEFAULT, US_EAST, US_WEST, EUROPE

    • type<~String> Record type. Values: A, AAAA, CNAME, HTTPRED, MX, NS, PTR, SRV, TXT

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • id<~Integer> Unique record identifier

      • name<~String> Record name.

      • type<~String> Record type. Values: A, AAAA, CNAME, HTTPRED, MX, NS, PTR, SRV, TXT

      • data<~String>

      • ttl<~Integer> Time to live. The amount of time a record will be cached before being refreshed.

      • gtdLocation<~String> Global Traffic Director location. Values: DEFAULT, US_EAST, US_WEST, EUROPE

      • password<~String> For A records. Password used to authenticate for dynamic DNS.

      • description<~String> For HTTPRED records. A description of the HTTPRED record.

      • keywords<~String> For HTTPRED records. Keywords associated with the HTTPRED record.

      • title<~String> For HTTPRED records. The title of the HTTPRED record.

      • redirectType<~String> For HTTPRED records. Type of redirection performed. Values: Hidden Frame Masked, Standard - 302, Standard - 301

      • hardLink<~Boolean> For HTTPRED records.

    • status<~Integer> - 200 - OK, 404 - specified domain name is not found



30
31
32
33
34
35
36
37
# File 'lib/fog/dnsmadeeasy/requests/dns/list_records.rb', line 30

def list_records(domain, options = {})
  request(
    :expects  => 200,
    :method   => "GET",
    :path     => "/V1.2/domains/#{domain}/records",
    :query    => options
  )
end

#list_secondaryObject

Returns a list of all secondary entry names for your account.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • list<~Array> e.g. [“xxx.domain.com”, “xxx.domain.com”]

    • status<~Integer> 200 - OK



13
14
15
16
17
18
19
# File 'lib/fog/dnsmadeeasy/requests/dns/list_secondary.rb', line 13

def list_secondary
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => '/V1.2/secondary'
  )
end

#reloadObject



95
96
97
# File 'lib/fog/dnsmadeeasy/dns.rb', line 95

def reload
  @connection.reset
end

#update_record(domain, record_id, options = {}) ⇒ Object

Updates a record with the representation specified in the request content. Returns errors if record is not valid. Note that a record ID will be generated by the system with this request and any ID that is sent will be ignored. Records are not modifiable for domains that are locked to a template.

DNS Made Easy has no update record method but they plan to add it in the next update! They sent a reponse suggesting, there going to internaly delete/create a new record when we make update record call, so I’ve done the same here for now! If want to update a record, it might be better to manually destroy and then create a new record

Parameters

  • domain<~String> Domain name.

  • record_id<~Integer> Record id.

  • options<~Hash>

    • name<~String> Record name.

    • type<~String> Record type. Values: A, AAAA, CNAME, HTTPRED, MX, NS, PTR, SRV, TXT

    • ttl<~Integer> Time to live. The amount of time a record will be cached before being refreshed. Default: 1800 (30 mins)

    • gtdLocation<~String> Global Traffic Director location. Values: DEFAULT, US_EAST, US_WEST, EUROPE

    • password<~String> For A records. Password used to authenticate for dynamic DNS.

    • description<~String> For HTTPRED records. A description of the HTTPRED record.

    • keywords<~String> For HTTPRED records. Keywords associated with the HTTPRED record.

    • title<~String> For HTTPRED records. The title of the HTTPRED record.

    • redirectType<~String> For HTTPRED records. Type of redirection performed. Values: Hidden Frame Masked, Standard - 302, Standard - 301

    • hardLink<~Boolean> For HTTPRED records.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • id<~Integer> Unique record identifier

      • name<~String>

      • type<~String>

      • data<~String>

      • ttl<~Integer>

      • gtdLocation<~String>

      • password<~String>

      • description<~String>

      • keywords<~String>

      • title<~String>

      • redirectType<~String>

      • hardLink<~Boolean>

    • ‘status’<~Integer> - 201 - record successfully created, 400 - record not valid, see errors in response content, 404 - domain not found



44
45
46
47
48
49
50
51
# File 'lib/fog/dnsmadeeasy/requests/dns/update_record.rb', line 44

def update_record(domain, record_id, options = {})
  request(
    :expects  => 200,
    :method   => "PUT",
    :path     => "/V1.2/domains/#{domain}/records/#{record_id}",
    :body     => MultiJson.encode(options)
  )
end

#update_secondary(secondary_name, ip_addresses) ⇒ Object

Modifies a secondary entry with the specified name. Returns errors if name is not valid or conflicts with another domain.

Parameters

  • secondary_name<~String> - secondary name

  • ip_addresses<~Array> - List of secondary ip addresses

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • name<~String> Secondary name.

      • ip<~Array> List of strings, IP addresses for your master nameserver associated with this secondary entry. e.g. [“10.10.10.10”, “10.10.10.11”]

      • gtdLocation<~String> Global Traffic Director location. Values: DEFAULT, US_EAST, US_WEST, EUROPE

    • status<~Integer> - 201 - secondary entry successfully created or modified, 400 - secondary entry name or IP addresses not valid, see errors in response content



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/dnsmadeeasy/requests/dns/update_secondary.rb', line 19

def update_secondary(secondary_name, ip_addresses)

  body = {
    "ip" => [*ip_addresses]
  }

  request(
    :expects  => 201,
    :method   => 'PUT',
    :path     => "/V1.2/secondary/#{secondary_name}",
    :body     => MultiJson.encode(body)
  )
end