dns_made_easy 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +4 -0
- data/LICENSE.md +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/dns_made_easy.gemspec +25 -0
- data/lib/dns_made_easy/api.rb +93 -0
- data/lib/dns_made_easy/version.rb +3 -0
- data/lib/dns_made_easy.rb +8 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 126ab6b813acd7a762a777e84d2d3a2c7255d3a0
|
4
|
+
data.tar.gz: 5a8a85f3596ddd60d9f733188decbc77870e3963
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 79230a58a1ff1ac607f70df9c8f0daa1cae26d95eabc002f33b47ab6819c165fca80949c5e9fd46c1eac9cbaef484c3903d32b0dea91500f28a69bce32f14f25
|
7
|
+
data.tar.gz: 8d618200cd20093c954193d752f0c40086545fe5d71d91f3358aa63c5694b41fd55d31a6c7a4af52a75d72e2d98cfb32cd1d3bb4564d84f308d49a38810a204a
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 unformatt
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# DnsMadeEasy
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'dns_made_easy'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install dns_made_easy
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( http://github.com/<my-github-username>/dns_made_easy/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'dns_made_easy/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "dns_made_easy"
|
8
|
+
s.version = DnsMadeEasy::VERSION
|
9
|
+
s.authors = ["Matias Hick"]
|
10
|
+
s.email = ["me@unformatt.com.ar"]
|
11
|
+
s.summary = "Interacts dns made easy API"
|
12
|
+
s.description = "Interacts to dns made easy API"
|
13
|
+
s.homepage = "https://github.com/unformattmh/dns_made_easy"
|
14
|
+
s.license = "MIT"
|
15
|
+
|
16
|
+
s.files = `git ls-files -z`.split("\x0")
|
17
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
s.test_files = s.files.grep(%r{^(test|s|features)/})
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
s.add_development_dependency "rake"
|
23
|
+
|
24
|
+
s.add_runtime_dependency "rest-client", "~> 1.6.7"
|
25
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module DnsMadeEasy
|
2
|
+
class Api
|
3
|
+
def initialize(api_key, api_secret)
|
4
|
+
@api_key = api_key
|
5
|
+
@api_secret = api_secret
|
6
|
+
@endpoint = 'https://api.dnsmadeeasy.com/V2.0'
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_domains
|
10
|
+
get_request('/dns/managed/')[:body]
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_domain(domain_name)
|
14
|
+
get_request("/dns/managed/id/#{domain_name}")[:body]
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_domain_records(domain_name, filters={})
|
18
|
+
domain = get_domain(domain_name)
|
19
|
+
response = get_request("/dns/managed/#{domain['id']}/records")[:body]['data']
|
20
|
+
|
21
|
+
response.find_all { |x|
|
22
|
+
filters.all? { |k,v| x[k.to_s] == v }
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_domain_record(domain_name, type, name)
|
27
|
+
get_domain_records(domain_name, { type: type, name: name }).first
|
28
|
+
end
|
29
|
+
|
30
|
+
def update_domain_record(domain_name, type, name, value)
|
31
|
+
domain = get_domain(domain_name)
|
32
|
+
record = get_domain_record(domain_name, type, name)
|
33
|
+
attributes = record.merge({ 'value' => value }).to_json
|
34
|
+
|
35
|
+
response = put_request("/dns/managed/#{domain['id']}/records/#{record['id']}", attributes)
|
36
|
+
response[:status_code] == 200
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def get_request(action, params={})
|
42
|
+
begin
|
43
|
+
parse_response(RestClient.get("#{@endpoint}#{action}", {params: params}.merge(build_headers)))
|
44
|
+
rescue => e
|
45
|
+
parse_response(e.response)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def post_request(action, params={})
|
50
|
+
begin
|
51
|
+
parse_response(RestClient.post("#{@endpoint}#{action}", params, build_headers))
|
52
|
+
rescue => e
|
53
|
+
parse_response(e.response)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def put_request(action, params={})
|
58
|
+
begin
|
59
|
+
parse_response(RestClient.put("#{@endpoint}#{action}", params, build_headers))
|
60
|
+
rescue => e
|
61
|
+
parse_response(e.response)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def delete_request(action, params={})
|
66
|
+
begin
|
67
|
+
parse_response(RestClient.delete("#{@endpoint_url}#{action}", params, build_headers))
|
68
|
+
rescue => e
|
69
|
+
parse_response(e.response)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def build_headers
|
74
|
+
request_date = Time.now.httpdate
|
75
|
+
hmac = OpenSSL::HMAC.hexdigest('sha1', @api_secret, request_date)
|
76
|
+
|
77
|
+
{
|
78
|
+
'Accept' => 'application/json',
|
79
|
+
'x-dnsme-apiKey' => @api_key,
|
80
|
+
'x-dnsme-requestDate' => request_date,
|
81
|
+
'x-dnsme-hmac' => hmac
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
def parse_response(response)
|
86
|
+
{
|
87
|
+
headers: response.headers,
|
88
|
+
body: (JSON.parse(response.body) rescue response.body),
|
89
|
+
status_code: response.code
|
90
|
+
}
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dns_made_easy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matias Hick
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rest-client
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.6.7
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.6.7
|
55
|
+
description: Interacts to dns made easy API
|
56
|
+
email:
|
57
|
+
- me@unformatt.com.ar
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- CHANGELOG.md
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.md
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- dns_made_easy.gemspec
|
69
|
+
- lib/dns_made_easy.rb
|
70
|
+
- lib/dns_made_easy/api.rb
|
71
|
+
- lib/dns_made_easy/version.rb
|
72
|
+
homepage: https://github.com/unformattmh/dns_made_easy
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.2.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Interacts dns made easy API
|
96
|
+
test_files: []
|