dnsmadeeasy 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.travis.yml +26 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +218 -0
- data/Rakefile +26 -0
- data/bin/console +6 -0
- data/bin/setup +8 -0
- data/dnsmadeeasy.gemspec +44 -0
- data/exe/dme +6 -0
- data/lib/dnsmadeeasy.rb +39 -0
- data/lib/dnsmadeeasy/api/client.rb +274 -0
- data/lib/dnsmadeeasy/version.rb +3 -0
- metadata +184 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a097d8e189dfd1af0b1e67e8c5dd6a2f3ef1f5e8
|
4
|
+
data.tar.gz: 1fe1562800afd9096af3ab76c447e62892c1db82
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0b72394aa5432cd4cd0377b69ea325f486569ab42805286d6ec356fbdfc425efb550d7fd89c9c5db4f87ab8b26fd58a07a9fc0a64acea649b3b62c21e3a1da20
|
7
|
+
data.tar.gz: fadef2632686a40a0ac0dbf9d6f60822e191d7c6c1322aff1702a308d47c4a0f4a458167e2182a379eebfe23cd08e06738161bc152c48a98e08e6ce5421bf043
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
env:
|
2
|
+
global:
|
3
|
+
- CC_TEST_REPORTER_ID=f8f229bdf1f374a3a9227d3bef6f57b78f88c73a2d4705c9de5852bb484eaaef
|
4
|
+
sudo: false
|
5
|
+
language: ruby
|
6
|
+
cache: bundler
|
7
|
+
rvm:
|
8
|
+
- 2.4.1
|
9
|
+
- 2.3.5
|
10
|
+
before_install: gem install bundler -v 1.15.4
|
11
|
+
before_script:
|
12
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
|
13
|
+
> ./cc-test-reporter
|
14
|
+
- chmod +x ./cc-test-reporter
|
15
|
+
- "./cc-test-reporter before-build"
|
16
|
+
script:
|
17
|
+
- bundle exec rspec
|
18
|
+
after_script:
|
19
|
+
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
20
|
+
notifications:
|
21
|
+
webhooks:
|
22
|
+
urls:
|
23
|
+
- secure: fgpv34jAm3rDNjiWuQtuijE0p9B2bpsCWdoCQ82pDZwktSITmNjanYCoZC0hlEw/kqMBDKRN78HfIIidy8dS664sLz8KyaFXq7RWAFsMP9fn/GMG/r9B+S3YumifQ/Zy+3OGa+0Qz76075q291QfNSPv0Y5QDMoAU5VljIVashC/qJS6DRO+vekDaDKIhi4Dr/+JpHPnjchqS4VaMB8gEIrDpeSYNlhrj1oAI/8GwgqZ8UR4sZGxNpIzUg+XGJSYz5/cAB3P18ENSQvOwaNefJa7qIVNjMD7YwXKmfX9cyr5RHM5sibq/S5fHH/N7pig+aveTquGGVxInJr1IEDiyr2TsFARjPitp9KJSFLHLsA2jm1cZfNW0/d6ii+51HdLPKorHom3fPjb0jkIe1LPa9CrrjnfSrAE9a/w4qpSnDv7OjAzkieepz+VQCtpQGIzQxJcHWaFX32iZ6RQ6pmKc/22E0OZwsNM2FHrB5V1b+rfczl8Ej7/R1wAOtHWkbLbfwZ9Ux2N0N0EKW8r8cOjEbsxmN8FFQubTwl68uqjJLhEtrOUbM28JM/NkX+Ue1KRw+NJAdMFEZQKPb/b/X6s3nwPD4/4yLyUDCGyr8aGpzSBD5uIu5uSJNiWdNDjcnXtJJ6TlGGZqj91r7FckjA8FuSA6S3yA8epMNG3FTUxPVE=
|
24
|
+
on_success: always
|
25
|
+
on_failure: onchange
|
26
|
+
on_start: never
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Konstantin Gredeskoul
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,218 @@
|
|
1
|
+
[](https://badge.fury.io/rb/dnsmadeeasy)
|
2
|
+
[](https://travis-ci.org/kigster/dnsmadeeasy)
|
3
|
+
[](https://codeclimate.com/github/kigster/dnsmadeeasy/maintainability)
|
4
|
+
[](https://codeclimate.com/github/kigster/dnsmadeeasy/test_coverage)
|
5
|
+
|
6
|
+
DnsMadeEasy — Ruby Client API (Supporting SDK V2.0)
|
7
|
+
==============
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'dnsmadeeasy'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
```
|
20
|
+
$ bundle
|
21
|
+
```
|
22
|
+
|
23
|
+
Or install it yourself:
|
24
|
+
|
25
|
+
```
|
26
|
+
$ gem install dnsmadeeasy
|
27
|
+
```
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
After requiring `dnsmadeeasy` you can either:
|
32
|
+
|
33
|
+
* directly instantiate a new instance of the `DnsMadeEasy::Api::Client` class,
|
34
|
+
by passing your API key and API secret, OR:
|
35
|
+
|
36
|
+
* you can use the `DnsMadeEasy.client` method after configuring the key and the secret.
|
37
|
+
|
38
|
+
### Recommended Usage
|
39
|
+
|
40
|
+
If you are not planning on accessing more than one DnsMadeEasy account from the same Ruby VM, you might prefer the following usage since it's a bit simpler:
|
41
|
+
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
require 'dnsmadeeasy'
|
45
|
+
DnsMadeEasy.configure do |config|
|
46
|
+
config.api_key = 'XXXX'
|
47
|
+
config.api_secret = 'YYYY'
|
48
|
+
end
|
49
|
+
|
50
|
+
@client = ::DnsMadeEasy.client
|
51
|
+
@client.domain('test.io')
|
52
|
+
# => Domain Object
|
53
|
+
```
|
54
|
+
|
55
|
+
### Advanced Usage
|
56
|
+
|
57
|
+
You can also instantiate a `Client` object with a different set of API key and secret, should you need to manage multiple accounts from within the same Ruby VM. The `DnsMadeEasy.configure` method is not used in this case, and the values passed to the constructor will be used instead.
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
require 'dnsmadeeasy/api/client'
|
61
|
+
|
62
|
+
api_key = 'XXXX'
|
63
|
+
api_secret = 'YYYY'
|
64
|
+
|
65
|
+
@client = ::DnsMadeEasy::Api::Client.new(api_key, api_secret)
|
66
|
+
```
|
67
|
+
|
68
|
+
#### Module Level Access
|
69
|
+
|
70
|
+
All return values are the direct JSON responses from DNS Made Easy converted into a Hash.
|
71
|
+
|
72
|
+
For more information on the actual JSON API, please refer to the [following PDF document](http://www.dnsmadeeasy.com/integration/pdf/API-Docv2.pdf).
|
73
|
+
|
74
|
+
### Managing Domains
|
75
|
+
|
76
|
+
To retrieve all domains:
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
@client.domains
|
80
|
+
```
|
81
|
+
|
82
|
+
To retreive the id of a domain by the domain name:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
@client.get_id_by_domain('test.io')
|
86
|
+
```
|
87
|
+
|
88
|
+
To retrieve the full domain record by domain name:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
@client.domain('test.io')
|
92
|
+
```
|
93
|
+
|
94
|
+
To create a domain:
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
@client.create_domain('test.io')
|
98
|
+
|
99
|
+
# Multiple domains can be created by:
|
100
|
+
@client.create_domains(%w[test.io moo.re])
|
101
|
+
```
|
102
|
+
|
103
|
+
To delete a domain:
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
@client.delete_domain ('test.io')
|
107
|
+
```
|
108
|
+
|
109
|
+
### Managing Records
|
110
|
+
|
111
|
+
To retrieve all records for a given domain name:
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
@client.records_for ('test.io')
|
115
|
+
```
|
116
|
+
|
117
|
+
To find the record id for a given domain, name, and type:
|
118
|
+
|
119
|
+
This finds the id of the A record 'woah.test.io'.
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
@client.find_record_id ('test.io', 'woah', 'A')
|
123
|
+
```
|
124
|
+
|
125
|
+
To delete a record by domain name and record id (the record id can be retrieved from `find_record_id`:
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
@client.delete_record ('test.io', 123)
|
129
|
+
|
130
|
+
# To delete multiple records:
|
131
|
+
|
132
|
+
@client.delete_records ('test.io', [123, 143])
|
133
|
+
|
134
|
+
# To delete all records in the domain:
|
135
|
+
|
136
|
+
@client.delete_all_records ('test.io')
|
137
|
+
```
|
138
|
+
|
139
|
+
To create a record:
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
@client.create_record ('test.io', 'woah', 'A', '127.0.0.1', { 'ttl' => '60' })
|
143
|
+
@client.create_a_record ('test.io', 'woah', '127.0.0.1', {})
|
144
|
+
@client.create_aaaa_record ('test.io', 'woah', '127.0.0.1', {})
|
145
|
+
@client.create_ptr_record ('test.io', 'woah', '127.0.0.1', {})
|
146
|
+
@client.create_txt_record ('test.io', 'woah', '127.0.0.1', {})
|
147
|
+
@client.create_cname_record ('test.io', 'woah', '127.0.0.1', {})
|
148
|
+
@client.create_ns_record ('test.io', 'woah', '127.0.0.1', {})
|
149
|
+
@client.create_spf_record ('test.io', 'woah', '127.0.0.1', {})
|
150
|
+
# Arguments are: domain_name, name, priority, value, options = {}
|
151
|
+
@client.create_mx_record ('test.io', 'woah', 5, '127.0.0.1', {})
|
152
|
+
# Arguments are: domain_name, name, priority, weight, port, value, options = {}
|
153
|
+
@client.create_srv_record ('test.io', 'woah', 1, 5, 80, '127.0.0.1', {})
|
154
|
+
# Arguments are: domain_name, name, value, redirectType, description, keywords, title, options = {}
|
155
|
+
@client.create_httpred_record('test.io', 'woah', '127.0.0.1', 'STANDARD - 302',
|
156
|
+
'a description', 'keywords', 'a title', {})
|
157
|
+
```
|
158
|
+
|
159
|
+
To update a record:
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
@client.update_record ('test.io', 123, 'woah', 'A', '127.0.1.1',
|
163
|
+
{ 'ttl' => '60' })
|
164
|
+
```
|
165
|
+
|
166
|
+
To update several records:
|
167
|
+
|
168
|
+
```ruby
|
169
|
+
@client.update_records('test.io',
|
170
|
+
[
|
171
|
+
{ 'id' => 123,
|
172
|
+
'name' => 'buddy',
|
173
|
+
'type' => 'A',
|
174
|
+
'value'=> '127.0.0.1'
|
175
|
+
}
|
176
|
+
], { 'ttl' => '60' })
|
177
|
+
|
178
|
+
```
|
179
|
+
|
180
|
+
To get the number of API requests remaining after a call:
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
@client.requests_remaining
|
184
|
+
#=> 19898
|
185
|
+
```
|
186
|
+
> NOTE: Information is not available until an API call has been made
|
187
|
+
|
188
|
+
To get the API request total limit after a call:
|
189
|
+
|
190
|
+
```ruby
|
191
|
+
@client.request_limit
|
192
|
+
#=> 2342
|
193
|
+
```
|
194
|
+
>Information is not available until an API call has been made
|
195
|
+
|
196
|
+
|
197
|
+
## Development
|
198
|
+
|
199
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exe rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
200
|
+
|
201
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, up date the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
202
|
+
|
203
|
+
## Acknowledgements
|
204
|
+
|
205
|
+
The current maintainer [Konstantin Gredeskoul](https://github.com/kigster) wishes to thank:
|
206
|
+
|
207
|
+
* Arnoud Vermeer for the original `dnsmadeeasy-rest-api` gem
|
208
|
+
* Andre Arko, Paul Henry, James Hart formerly of [Wanelo](wanelo.com) fame, for bringing the REST API gem up to the level.
|
209
|
+
* Phil Cohen, who graciously transferred the ownership of this gem on RubyGems to the current maintainer.
|
210
|
+
|
211
|
+
|
212
|
+
## Contributing
|
213
|
+
|
214
|
+
Bug reports and pull requests are welcome on GitHub at [https://github.com/kigster/dnsmadeeasy](https://github.com/kigster/dnsmadeeasy).
|
215
|
+
|
216
|
+
## License
|
217
|
+
|
218
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'yard'
|
4
|
+
|
5
|
+
def shell(*args)
|
6
|
+
puts "running: #{args.join(' ')}"
|
7
|
+
system(args.join(' '))
|
8
|
+
end
|
9
|
+
|
10
|
+
task :permissions do
|
11
|
+
shell('rm -rf pkg/ tmp/' )
|
12
|
+
shell("chmod -v o+r,g+r * */* */*/* */*/*/* */*/*/*/* */*/*/*/*/*")
|
13
|
+
shell("find . -type d -exec chmod o+x,g+x {} \\;")
|
14
|
+
end
|
15
|
+
|
16
|
+
task :build => :permissions
|
17
|
+
|
18
|
+
YARD::Rake::YardocTask.new(:doc) do |t|
|
19
|
+
t.files = %w(lib/**/*.rb exe/*.rb - README.md LICENSE.txt)
|
20
|
+
t.options.unshift('--title','DNS Client for DnsMadeEasy')
|
21
|
+
t.after = ->() { exec('open doc/index.html') }
|
22
|
+
end
|
23
|
+
|
24
|
+
RSpec::Core::RakeTask.new(:spec)
|
25
|
+
|
26
|
+
task :default => :spec
|
data/bin/console
ADDED
data/bin/setup
ADDED
data/dnsmadeeasy.gemspec
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'dnsmadeeasy/version'
|
6
|
+
|
7
|
+
DnsMadeEasy::DESCRIPTION = <<-eof
|
8
|
+
This is a fully-featured DNS API client for DnsMadeEasy.com, that includes
|
9
|
+
both the Ruby API and (soon to follow – a CLI). This gem used to be called
|
10
|
+
dnsmadeeasy-rest-api, but the original author Phil Cohen kindly passed on
|
11
|
+
the RubyGems namespace, and now you can install just plane simple "dnsmadeeasy".
|
12
|
+
eof
|
13
|
+
|
14
|
+
Gem::Specification.new do |spec|
|
15
|
+
spec.name = 'dnsmadeeasy'
|
16
|
+
spec.version = DnsMadeEasy::VERSION
|
17
|
+
spec.authors = ['Konstantin Gredeskoul', 'Arnoud Vermeer', 'Paul Henry', 'James Hart', 'Phil Cohen']
|
18
|
+
spec.email = %w(kigster@gmail.com letuboy@gmail.com hjhart@gmail.com)
|
19
|
+
spec.summary = DnsMadeEasy::DESCRIPTION
|
20
|
+
spec.description = DnsMadeEasy::DESCRIPTION
|
21
|
+
|
22
|
+
spec.homepage = 'https://github.com/kigster/dnsmadeeasy'
|
23
|
+
spec.license = 'MIT'
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
|
29
|
+
spec.bindir = 'exe'
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ['lib']
|
32
|
+
|
33
|
+
|
34
|
+
spec.add_development_dependency 'yard'
|
35
|
+
spec.add_development_dependency 'simplecov'
|
36
|
+
spec.add_development_dependency 'webmock'
|
37
|
+
spec.add_development_dependency 'bundler'
|
38
|
+
spec.add_development_dependency 'rake'
|
39
|
+
spec.add_development_dependency 'rspec'
|
40
|
+
spec.add_development_dependency 'rspec-its'
|
41
|
+
spec.add_development_dependency 'rubocop'
|
42
|
+
|
43
|
+
# spec.add_development_dependency 'aruba'
|
44
|
+
end
|
data/exe/dme
ADDED
data/lib/dnsmadeeasy.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module DnsMadeEasy
|
2
|
+
API_BASE_URL_PRODUCTION = 'https://api.dnsmadeeasy.com/V2.0'
|
3
|
+
API_BASE_URL_SANDBOX = 'https://sandboxapi.dnsmadeeasy.com/V2.0'
|
4
|
+
end
|
5
|
+
|
6
|
+
require_relative 'dnsmadeeasy/api/client'
|
7
|
+
|
8
|
+
module DnsMadeEasy
|
9
|
+
class Error < StandardError; end
|
10
|
+
class APIKeyAndSecretMissingError < Error; end
|
11
|
+
|
12
|
+
class << self
|
13
|
+
attr_accessor :api_key, :api_secret
|
14
|
+
|
15
|
+
|
16
|
+
def configure
|
17
|
+
yield(self) if block_given?
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def client(**options)
|
22
|
+
@client ||= create_client(false, **options)
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def sandbox_client(**options)
|
27
|
+
@sandbox_client ||= create_client(true, **options)
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def create_client(sandbox = false, **options)
|
34
|
+
raise APIKeyAndSecretMissingError, 'Please set #api_key and #api_secret' unless api_key && api_secret
|
35
|
+
::DnsMadeEasy::Api::Client.new(api_key, api_secret, sandbox, **options)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,274 @@
|
|
1
|
+
require 'time'
|
2
|
+
require 'openssl'
|
3
|
+
require 'json'
|
4
|
+
require 'uri'
|
5
|
+
require 'net/http'
|
6
|
+
|
7
|
+
module DnsMadeEasy
|
8
|
+
module Api
|
9
|
+
class Client
|
10
|
+
|
11
|
+
attr_accessor :base_uri
|
12
|
+
attr_reader :requests_remaining
|
13
|
+
attr_reader :request_limit
|
14
|
+
|
15
|
+
|
16
|
+
def initialize(api_key, api_secret, sandbox = false, options = {})
|
17
|
+
fail 'api_key is undefined' unless api_key
|
18
|
+
fail 'api_secret is undefined' unless api_secret
|
19
|
+
|
20
|
+
@api_key = api_key
|
21
|
+
@api_secret = api_secret
|
22
|
+
@options = options
|
23
|
+
@requests_remaining = -1
|
24
|
+
@request_limit = -1
|
25
|
+
|
26
|
+
self.base_uri = sandbox ? API_BASE_URL_SANDBOX : API_BASE_URL_PRODUCTION
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
# -----------------------------------
|
31
|
+
# ------------- DOMAINS -------------
|
32
|
+
# -----------------------------------
|
33
|
+
|
34
|
+
def get_id_by_domain(domain_name)
|
35
|
+
get("/dns/managed/id/#{domain_name}")['id']
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def domains
|
40
|
+
get '/dns/managed/'
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
def domain(domain_name)
|
45
|
+
get "/dns/managed/#{get_id_by_domain(domain_name)}"
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
def delete_domain(domain_name)
|
50
|
+
delete "/dns/managed/#{get_id_by_domain(domain_name)}"
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def create_domains(names)
|
55
|
+
post('/dns/managed/', names: names)
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def create_domain(domain_name)
|
60
|
+
create_domains([domain_name])
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
# -----------------------------------
|
65
|
+
# ------------- RECORDS -------------
|
66
|
+
# -----------------------------------
|
67
|
+
|
68
|
+
def records_for(domain_name)
|
69
|
+
get "/dns/managed/#{get_id_by_domain(domain_name)}/records"
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def find(domain_name, name, type)
|
74
|
+
records = records_for(domain_name)
|
75
|
+
records['data'].detect { |r| r['name'] == name && r['type'] == type }
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
def find_record_id(domain_name, name, type)
|
80
|
+
records = records_for(domain_name)
|
81
|
+
|
82
|
+
records['data'].select { |r| r['name'] == name && r['type'] == type }.map { |r| r['id'] }
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
def delete_record(domain_name, record_id)
|
87
|
+
delete "/dns/managed/#{get_id_by_domain(domain_name)}/records/#{record_id}/"
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
def delete_records(domain_name, ids = [])
|
92
|
+
return if ids.empty?
|
93
|
+
domain_id = get_id_by_domain(domain_name)
|
94
|
+
|
95
|
+
delete "/dns/managed/#{domain_id}/records?ids=#{ids.join(',')}"
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
def delete_all_records(domain_name)
|
100
|
+
domain_id = get_id_by_domain(domain_name)
|
101
|
+
delete "/dns/managed/#{domain_id}/records"
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
def create_record(domain_name, name, type, value, options = {})
|
106
|
+
body = { 'name' => name, 'type' => type, 'value' => value, 'ttl' => 3600, 'gtdLocation' => 'DEFAULT' }
|
107
|
+
post "/dns/managed/#{get_id_by_domain(domain_name)}/records/", body.merge(options)
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
def create_a_record(domain_name, name, value, options = {})
|
112
|
+
# TODO: match IPv4 for value
|
113
|
+
create_record domain_name, name, 'A', value, options
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
def create_aaaa_record(domain_name, name, value, options = {})
|
118
|
+
# TODO: match IPv6 for value
|
119
|
+
create_record domain_name, name, 'AAAA', value, options
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
def create_ptr_record(domain_name, name, value, options = {})
|
124
|
+
# TODO: match PTR value
|
125
|
+
create_record domain_name, name, 'PTR', value, options
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
def create_txt_record(domain_name, name, value, options = {})
|
130
|
+
# TODO: match TXT value
|
131
|
+
create_record domain_name, name, 'TXT', value, options
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
def create_cname_record(domain_name, name, value, options = {})
|
136
|
+
# TODO: match CNAME value
|
137
|
+
create_record domain_name, name, 'CNAME', value, options
|
138
|
+
end
|
139
|
+
|
140
|
+
|
141
|
+
def create_ns_record(domain_name, name, value, options = {})
|
142
|
+
# TODO: match domainname for value
|
143
|
+
create_record domain_name, name, 'NS', value, options
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
def create_spf_record(domain_name, name, value, options = {})
|
148
|
+
create_record domain_name, name, 'SPF', value, options
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
def create_mx_record(domain_name, name, priority, value, options = {})
|
153
|
+
options.merge!('mxLevel' => priority)
|
154
|
+
|
155
|
+
create_record domain_name, name, 'MX', value, options
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
def create_srv_record(domain_name, name, priority, weight, port, value, options = {})
|
160
|
+
options.merge!('priority' => priority, 'weight' => weight, 'port' => port)
|
161
|
+
create_record domain_name, name, 'SRV', value, options
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
def create_httpred_record(domain_name, name, value, redirectType = 'STANDARD - 302', description = '', keywords = '', title = '', options = {})
|
166
|
+
options.merge!('redirectType' => redirectType, 'description' => description, 'keywords' => keywords, 'title' => title)
|
167
|
+
create_record domain_name, name, 'HTTPRED', value, options
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
def update_record(domain, record_id, name, type, value, options = {})
|
172
|
+
body = { 'name' => name, 'type' => type, 'value' => value, 'ttl' => 3600, 'gtdLocation' => 'DEFAULT', 'id' => record_id }
|
173
|
+
put "/dns/managed/#{get_id_by_domain(domain)}/records/#{record_id}/", body.merge(options)
|
174
|
+
end
|
175
|
+
|
176
|
+
|
177
|
+
def update_records(domain, records, options = {})
|
178
|
+
body = records.map do |record|
|
179
|
+
{
|
180
|
+
'id' => record['id'],
|
181
|
+
'name' => record['name'],
|
182
|
+
'type' => record['type'],
|
183
|
+
'value' => record['value'],
|
184
|
+
'gtdLocation' => record['gtdLocation'],
|
185
|
+
'ttl' => record['ttl']
|
186
|
+
}.merge(options)
|
187
|
+
end
|
188
|
+
put "/dns/managed/#{get_id_by_domain(domain)}/records/updateMulti/", body
|
189
|
+
end
|
190
|
+
|
191
|
+
|
192
|
+
private
|
193
|
+
|
194
|
+
def get(path)
|
195
|
+
request(path) do |uri|
|
196
|
+
Net::HTTP::Get.new(uri)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
|
201
|
+
def delete(path, body = nil)
|
202
|
+
request(path) do |uri|
|
203
|
+
req = Net::HTTP::Delete.new(uri)
|
204
|
+
req.body = body.to_json if body
|
205
|
+
req
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
|
210
|
+
def put(path, body = nil)
|
211
|
+
request(path) do |uri|
|
212
|
+
req = Net::HTTP::Put.new(uri)
|
213
|
+
req.body = body.to_json if body
|
214
|
+
req
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
|
219
|
+
def post(path, body)
|
220
|
+
request(path) do |uri|
|
221
|
+
req = Net::HTTP::Post.new(uri)
|
222
|
+
req.body = body.to_json
|
223
|
+
req
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
|
228
|
+
def request(path)
|
229
|
+
uri = URI("#{base_uri}#{path}")
|
230
|
+
|
231
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
232
|
+
http.use_ssl = true
|
233
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @options.key?(:ssl_verify_none)
|
234
|
+
http.open_timeout = @options[:open_timeout] if @options.key?(:open_timeout)
|
235
|
+
http.read_timeout = @options[:read_timeout] if @options.key?(:read_timeout)
|
236
|
+
|
237
|
+
request = yield(uri)
|
238
|
+
|
239
|
+
request_headers.each do |key, value|
|
240
|
+
request[key] = value
|
241
|
+
end
|
242
|
+
|
243
|
+
response = http.request(request)
|
244
|
+
response.value # raise Net::HTTPServerException unless response was 2xx
|
245
|
+
|
246
|
+
process_rate_limits(response)
|
247
|
+
|
248
|
+
unparsed_json = response.body.to_s.empty? ? '{}' : response.body
|
249
|
+
|
250
|
+
JSON.parse(unparsed_json)
|
251
|
+
end
|
252
|
+
|
253
|
+
|
254
|
+
def process_rate_limits(response)
|
255
|
+
response.each_header do |header, value|
|
256
|
+
@requests_remaining = value.to_i if header == 'x-dnsme-requestsremaining'
|
257
|
+
@request_limit = value.to_i if header == 'x-dnsme-requestlimit'
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
|
262
|
+
def request_headers
|
263
|
+
request_date = Time.now.httpdate
|
264
|
+
hmac = OpenSSL::HMAC.hexdigest('sha1', @api_secret, request_date)
|
265
|
+
{
|
266
|
+
'Accept' => 'application/json',
|
267
|
+
'x-dnsme-apiKey' => @api_key,
|
268
|
+
'x-dnsme-requestDate' => request_date,
|
269
|
+
'x-dnsme-hmac' => hmac
|
270
|
+
}
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
metadata
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dnsmadeeasy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Konstantin Gredeskoul
|
8
|
+
- Arnoud Vermeer
|
9
|
+
- Paul Henry
|
10
|
+
- James Hart
|
11
|
+
- Phil Cohen
|
12
|
+
autorequire:
|
13
|
+
bindir: exe
|
14
|
+
cert_chain: []
|
15
|
+
date: 2017-12-09 00:00:00.000000000 Z
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: yard
|
19
|
+
requirement: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '0'
|
24
|
+
type: :development
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: simplecov
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: webmock
|
47
|
+
requirement: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
type: :development
|
53
|
+
prerelease: false
|
54
|
+
version_requirements: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: bundler
|
61
|
+
requirement: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: rake
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
type: :development
|
81
|
+
prerelease: false
|
82
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: rspec
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
type: :development
|
95
|
+
prerelease: false
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: rspec-its
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
type: :development
|
109
|
+
prerelease: false
|
110
|
+
version_requirements: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: rubocop
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
description: |
|
130
|
+
This is a fully-featured DNS API client for DnsMadeEasy.com, that includes
|
131
|
+
both the Ruby API and (soon to follow – a CLI). This gem used to be called
|
132
|
+
dnsmadeeasy-rest-api, but the original author Phil Cohen kindly passed on
|
133
|
+
the RubyGems namespace, and now you can install just plane simple "dnsmadeeasy".
|
134
|
+
email:
|
135
|
+
- kigster@gmail.com
|
136
|
+
- letuboy@gmail.com
|
137
|
+
- hjhart@gmail.com
|
138
|
+
executables:
|
139
|
+
- dme
|
140
|
+
extensions: []
|
141
|
+
extra_rdoc_files: []
|
142
|
+
files:
|
143
|
+
- ".gitignore"
|
144
|
+
- ".rspec"
|
145
|
+
- ".travis.yml"
|
146
|
+
- Gemfile
|
147
|
+
- LICENSE.txt
|
148
|
+
- README.md
|
149
|
+
- Rakefile
|
150
|
+
- bin/console
|
151
|
+
- bin/setup
|
152
|
+
- dnsmadeeasy.gemspec
|
153
|
+
- exe/dme
|
154
|
+
- lib/dnsmadeeasy.rb
|
155
|
+
- lib/dnsmadeeasy/api/client.rb
|
156
|
+
- lib/dnsmadeeasy/version.rb
|
157
|
+
homepage: https://github.com/kigster/dnsmadeeasy
|
158
|
+
licenses:
|
159
|
+
- MIT
|
160
|
+
metadata: {}
|
161
|
+
post_install_message:
|
162
|
+
rdoc_options: []
|
163
|
+
require_paths:
|
164
|
+
- lib
|
165
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
requirements: []
|
176
|
+
rubyforge_project:
|
177
|
+
rubygems_version: 2.6.13
|
178
|
+
signing_key:
|
179
|
+
specification_version: 4
|
180
|
+
summary: This is a fully-featured DNS API client for DnsMadeEasy.com, that includes
|
181
|
+
both the Ruby API and (soon to follow – a CLI). This gem used to be called dnsmadeeasy-rest-api,
|
182
|
+
but the original author Phil Cohen kindly passed on the RubyGems namespace, and
|
183
|
+
now you can install just plane simple "dnsmadeeasy".
|
184
|
+
test_files: []
|