dnsmadeeasy 0.4.0 → 1.0.1

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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +5 -10
  3. data/.gitignore +2 -0
  4. data/.rubocop.yml +5 -4
  5. data/.rubocop_todo.yml +251 -143
  6. data/CLAUDE.md +67 -0
  7. data/Gemfile +9 -1
  8. data/README.md +858 -0
  9. data/Rakefile +4 -4
  10. data/dnsmadeeasy.gemspec +42 -26
  11. data/docs/badges/coverage_badge.svg +21 -0
  12. data/docs/dry-cli-based-tools.webloc +8 -0
  13. data/docs/plan-zone-management.md +756 -0
  14. data/docs/plans/01-plan-ruby4-baseline.md +38 -0
  15. data/docs/plans/02-plan-dry-cli-launcher.md +44 -0
  16. data/docs/plans/03-plan-account-command.md +43 -0
  17. data/docs/plans/04-plan-zone-record-model.md +48 -0
  18. data/docs/plans/05-plan-zone-parser.md +41 -0
  19. data/docs/plans/06-plan-zone-formatter.md +43 -0
  20. data/docs/plans/07-plan-zone-export.md +58 -0
  21. data/docs/plans/08-plan-zone-diff.md +42 -0
  22. data/docs/plans/09-plan-zone-apply.md +69 -0
  23. data/docs/plans/10-plan-docs-cleanup.md +55 -0
  24. data/docs/spec-zone-management.md +242 -0
  25. data/exe/dme +13 -2
  26. data/exe/dmez +6 -0
  27. data/lib/dme.rb +7 -2
  28. data/lib/dnsmadeeasy/api/client.rb +32 -26
  29. data/lib/dnsmadeeasy/cli/box_output.rb +9 -0
  30. data/lib/dnsmadeeasy/cli/commands/account.rb +222 -0
  31. data/lib/dnsmadeeasy/cli/commands/base.rb +119 -0
  32. data/lib/dnsmadeeasy/cli/commands/legacy_operation.rb +30 -0
  33. data/lib/dnsmadeeasy/cli/commands/version.rb +22 -0
  34. data/lib/dnsmadeeasy/cli/commands/zone.rb +326 -0
  35. data/lib/dnsmadeeasy/cli/commands.rb +19 -0
  36. data/lib/dnsmadeeasy/cli/input.rb +14 -0
  37. data/lib/dnsmadeeasy/cli/launcher.rb +53 -0
  38. data/lib/dnsmadeeasy/cli/message_helpers.rb +81 -0
  39. data/lib/dnsmadeeasy/cli/reported_error.rb +10 -0
  40. data/lib/dnsmadeeasy/credentials/api_keys.rb +11 -9
  41. data/lib/dnsmadeeasy/credentials.rb +0 -1
  42. data/lib/dnsmadeeasy/runner.rb +24 -24
  43. data/lib/dnsmadeeasy/types.rb +19 -0
  44. data/lib/dnsmadeeasy/version.rb +2 -1
  45. data/lib/dnsmadeeasy/zone/aname_flattener.rb +63 -0
  46. data/lib/dnsmadeeasy/zone/apply_executor.rb +189 -0
  47. data/lib/dnsmadeeasy/zone/apply_result.rb +22 -0
  48. data/lib/dnsmadeeasy/zone/diff.rb +152 -0
  49. data/lib/dnsmadeeasy/zone/file.rb +26 -0
  50. data/lib/dnsmadeeasy/zone/parser.rb +172 -0
  51. data/lib/dnsmadeeasy/zone/plan.rb +28 -0
  52. data/lib/dnsmadeeasy/zone/plan_action.rb +29 -0
  53. data/lib/dnsmadeeasy/zone/plan_renderer.rb +91 -0
  54. data/lib/dnsmadeeasy/zone/provider_record.rb +18 -0
  55. data/lib/dnsmadeeasy/zone/record.rb +44 -0
  56. data/lib/dnsmadeeasy/zone/record_set.rb +23 -0
  57. data/lib/dnsmadeeasy/zone/remote_adapter.rb +94 -0
  58. data/lib/dnsmadeeasy/zone/remote_records.rb +26 -0
  59. data/lib/dnsmadeeasy/zone/serializer.rb +115 -0
  60. data/lib/dnsmadeeasy.rb +61 -27
  61. metadata +184 -25
  62. data/.dme-help.png +0 -0
  63. data/README.adoc +0 -690
data/README.adoc DELETED
@@ -1,690 +0,0 @@
1
- :doctype: book
2
-
3
- :toc:
4
- = DnsMadeEasy -- Ruby Client API Library
5
-
6
- == Supporting Rest API SDK V2.0
7
-
8
- NOTE: image:https://badge.fury.io/rb/dnsmadeeasy@2x.png["Gem Version", link="https://badge.fury.io/rb/dnsmadeeasy"]
9
-
10
- image:https://img.shields.io/gem/dt/dnsmadeeasy?style=for-the-badge[Downloads,link="https://rubygems.org/gems/dnsmadeeasy"]
11
- image:https://img.shields.io/github/issues/kigster/dnsmadeeasy?style=for-the-badge&logo=appveyor[Github Issues,link="https://github.com/kigster/dnsmadeeasy/issues"]
12
- image:https://img.shields.io/github/forks/kigster/dnsmadeeasy?style=for-the-badge&logo=appveyor[Forks,link="https://github.com/kigster/dnsmadeeasy/network/members"]
13
- image:https://img.shields.io/github/stars/kigster/dnsmadeeasy?style=for-the-badge&logo=appveyor[Stars,link="https://github.com/kigster/dnsmadeeasy/stargazers"]
14
- image:https://img.shields.io/github/license/kigster/dnsmadeeasy?style=for-the-badge&logo=appveyor[License,link="https://github.com/kigster/dnsmadeeasy/blob/master/LICENSE.txt"]
15
-
16
-
17
- image:https://github.com/kigster/dnsmadeeasy/workflows/Ruby/badge.svg?branch=master[Github Build,link=https://github.com/kigster/dnsmadeeasy/actions?query=workflow%3ARuby]
18
- image:https://travis-ci.org/kigster/dnsmadeeasy.svg?branch=master[Build Status,link=https://travis-ci.org/kigster/dnsmadeeasy]
19
-
20
- image:https://api.codeclimate.com/v1/badges/7a48648b482b5a5c9257/maintainability[Maintainability,link=https://codeclimate.com/github/kigster/dnsmadeeasy/maintainability]
21
- image:https://api.codeclimate.com/v1/badges/7a48648b482b5a5c9257/test_coverage[Test Coverage,link=https://codeclimate.com/github/kigster/dnsmadeeasy/test_coverage]
22
-
23
- This is a fully featured REST API client for DnsMadeEasy provider. DME is an *excellent* provider, and is highly recommended for their ease of use, very solid API, and great customer support. They also offer free DNS failover with business accounts, which is highly recommended for the arrays of load balancers in front of your app.
24
-
25
- == Usage
26
-
27
- *DnsMadeEasy* allows you to fetch, create, update DNS records, as long as you know your API key and the secret.
28
-
29
- === Setting up Credentials
30
-
31
- You can find your API Key and Secret on the https://cp.dnsmadeeasy.com/account/info[Account Settings Page] of their UI.
32
-
33
- Once you have the key and the secret, you have several choices:
34
-
35
- * You can directly instantiate a new instance of the `Client` class, by passing your API key and API secrets as arguments:
36
-
37
- +
38
- [source,ruby]
39
- ----
40
- require 'dnsmadeeasy'
41
- @client = DnsMadeEasy::Api::Client.new(api_key, api_secret)
42
- ----
43
-
44
- . Or, you can use the `DnsMadeEasy.configure` method to configure the key/secret pair, and then use `DnsMadeEasy` namespace to call the methods:
45
- +
46
- [source,ruby]
47
- ----
48
- require 'dnsmadeeasy'
49
-
50
- DnsMadeEasy.configure do |config|
51
- config.api_key = 'XXXX'
52
- config.api_secret = 'YYYY'
53
- end
54
-
55
- DnsMadeEasy.domains.data.first.name #=> 'moo.gamespot.com'
56
- ----
57
-
58
- . Configuring API keys as above is easy, and can be done using environment variables. Alternatively, it may be convenient to store credentials in a YAML file.
59
-
60
- ....
61
- * If filename is not specified, there is default location where this file is searched, which is `~/.dnsmadeeasy/credentials.yml`.
62
- * If filename is provided, it will be read, and must conform to the following format:
63
- ....
64
-
65
- *Simple Credentials Format*
66
-
67
- [source,yaml]
68
- ----
69
- # file: ~/.dnsmadeeasy/credentials.yml
70
- credentials:
71
- api_key: 2062259f-f666b17-b1fa3b48-042ad4030
72
- api_secret: 2265bc3-e31ead-95b286312e-c215b6a0
73
- ----
74
-
75
- *Multi-Account Credentials Format*
76
-
77
- Below you see two accounts, with production key and secret being encrypted. See <<encryption,further below>> about encrypting your key and secrets.
78
-
79
- [source,yaml]
80
- ----
81
- accounts:
82
- - name: development
83
- default_account: true
84
- credentials:
85
- api_key: 12345678-a8f8-4466-ffff-2324aaaa9098
86
- api_secret: 43009899-abcc-ffcc-eeee-09f809808098
87
- - name: production
88
- credentials:
89
- api_key: "BAhTOh1TeW06OkRhdGE6OldyYXBwZXJT............"
90
- api_secret: "BAhTOh1TeW06OkRhdGE6OldyYXBwZ............"
91
- encryption_key: spec/fixtures/sym.key
92
- ----
93
-
94
- You can use the following method to access both simple and multi-account YAML configurations:
95
-
96
- [source,ruby]
97
- ----
98
- require 'dnsmadeeasy'
99
- DnsMadeEasy.configure_from_file(file, account = nil, encryption_key = nil)
100
-
101
- # for example:
102
- DnsMadeEasy.configure_from_file('config/dme.yaml', 'production')
103
- DnsMadeEasy.domains #=> [ ... ]
104
-
105
- # or with encrypted key passed as an argument to decrypt YAML values:
106
- DnsMadeEasy.configure_from_file(
107
- 'config/dme.yaml',
108
- 'production',
109
- ENV['PRODUCTION_KEY'])
110
- ----
111
-
112
- . Finally, you can use `DME.credentials_from_file` method that, unlike the method above, uses hash arguments:
113
-
114
- [source,ruby]
115
- ----
116
- @creds = DnsMadeEasy.credentials_from_file(file: 'my-creds.yml',
117
- account: 'production',
118
- encryption_key: 'MY_KEY')
119
- @creds.api_key # => ...
120
- @creds.api_secret # => ...
121
- ----
122
-
123
- Method above simply returns the credentials instance, but does not "save" it as the default credentials like `configure_from_file`. Therefore, if you need to access multiple accounts at the same time, this method will help you maintain multiple credentials at the same time.
124
-
125
-
126
- Once you configure the keys, you can also use the shortcut module to save you some typing:
127
-
128
- [source,ruby]
129
- ----
130
- require 'dnsmadeeasy/dme'
131
- DME.domains.data.first.name #=> 'moo.gamespot.com'
132
- ----
133
-
134
- This has the advantage of being much shorter, but might conflict with existing modules in your Ruby VM.
135
- In this case, just do not require `dnsmadeeasy/dme` and only require `dnsmadeeasy`, and you'll be fine.
136
- Otherwise, using `DME` is identical to using `DnsMadeEasy`, assuming you required `dnsmadeeasy/dme` file.
137
-
138
- === Which Namespace to Use? What is `DME` versus `DnsMadeEasy`?
139
-
140
- Since `DnsMadeEasy` is a bit of a mouthful, we decided to offer (in addition to the standard `DnsMadeEasy` namespace) the abbreviated module `DME` that simply forwards all messages to the module `DnsMadeEasy`. If in your Ruby VM there is no conflicting top-level class `DME`, then you can `require 'dnsmadeeasy/dme'` to get all of the DnsMadeEasy client library functionality without having to type the full name once. You can even do `require 'dme'`.
141
-
142
- Whenever you require `dme` you also import the `DnsMadeEasy` namespace. *The opposite is not true.*
143
-
144
- So if you DO have a name clash with another top-level module `DME`, simply do `require 'dnsmadeeasy'` and none of the `DME` module namespace will be loaded.
145
-
146
- In a nutshell you have three ways to access all methods provided by the http://www.rubydoc.info/gems/dnsmadeeasy/DnsMadeEasy/Api/Client[`DnsMadeEasy::Api::Client`] class:
147
-
148
- . Instantiate and use the client class directly,
149
- . Use the top-level module `DnsMadeEasy` with `require 'dnsmadeeasy'`
150
- . Use the shortened top-level module `DME` with `require 'dnsmadeeasy/dme'`
151
-
152
- === Examples
153
-
154
- Whether or not you are accessing a single account or multiple, it is recommended that you save your credentials (the API key and the secret) encrypted in the above mentioned file `~/.dnsmadeeasy/credentials.yml` (or any file of you preference).
155
-
156
- WARNING: **DO NOT check that file into your repo! If you use encryption, do not check in your key!**
157
-
158
- The examples that follow assume credentials have already been configured, and so we explore the API.
159
-
160
- Using the `DME` module (or `DnsMadeEasy` if you prefer) you can access all of your records through the available API method calls, for example:
161
-
162
- [source, ruby]
163
- ----
164
- IRB > require 'dme' #=> true
165
- # Or you can also do
166
- IRB > require 'dnsmadeeasy/dme' #=> true
167
- IRB > DME.domains.data.map(&:name)
168
- ⤷ ["demo.gamespot.systems",
169
- "dev.gamespot.systems",
170
- "gamespot.live",
171
- "gamespot.systems",
172
- "prod.gamespot.systems"
173
- ]
174
-
175
- # These have been read from the file ~/.dnsmadeeasy/credentials.yml
176
- IRB > DME.api_key
177
- ⤷ "2062259f-f666b17-b1fa3b48-042ad4030"
178
-
179
- IRB > DME.api_secret
180
- ⤷ "2265bc3-e31ead-95b286312e-c215b6a0"
181
-
182
- IRB > DME.domain('gamespot.live').delegateNameServers
183
- ⤷ #<Hashie::Array ["ns-125-c.gandi.net.", "ns-129-a.gandi.net.", "ns-94-b.gandi.net."]>
184
-
185
- # Let's inspect the Client — after all, all methods are simply delegated to it:
186
- IRB > @client = DME.client
187
- ⤷ #<DnsMadeEasy::Api::Client:0x00007fb6b416a4c8
188
- @api_key="2062259f-f666b17-b1fa3b48-042ad4030",
189
- @api_secret="2265bc3-e31ead-95b286312e-c215b6a0",
190
- @options={},
191
- @requests_remaining=149,
192
- @request_limit=150,
193
- @base_uri="https://api.dnsmadeeasy.com/V2.0">
194
- ----
195
-
196
- Next, let's fetch a particular domain, get it's records and compute the counts for each record type, such as 'A', 'NS', etc.
197
-
198
- [source,ruby]
199
- ----
200
- IRB > records = DME.records_for('gamespot.com')
201
- IRB > [ records.totalPages, records.totalRecords ]
202
- ⤷ [1, 33]
203
- IRB > records.data.select{|f| f.type == 'A' }.map(&:name)
204
- ⤷ ["www", "vpn-us-east1", "vpn-us-east2", "staging", "yourmom"]
205
- IRB > types = records.data.map(&:type)
206
- ⤷ [....]
207
- IRB > require 'awesome_print'
208
- IRB > ap Hash[types.group_by {|x| x}.map {|k,v| [k,v.count]}]
209
- {
210
- "MX" => 2,
211
- "TXT" => 1,
212
- "CNAME" => 3,
213
- "NS" => 22,
214
- "A" => 5
215
- }
216
- ----
217
-
218
- === Return Value Types
219
-
220
- All public methods of this library return a Hash-like object, that is actually an instance of the class https://github.com/intridea/hashie[`Hashie::Mash`]. `Hashie::Mash` supports the very useful ability to reach deeply nested hash values via a chain of method calls instead of using a train of square brackets. You can always convert it to a regular hash either `to_hash` or `to_h` on an instance of a `Hashie::Mash` to get a pure hash representation.
221
-
222
- ____
223
- NOTE: `to_hash` converts the entire object to a regular hash, including the deeply nested hashes, while `to_h` only converts the primary object, but not the nested hashes. Here is an example below -- in the first instance where we call `to_h` we are still able to call `.value` on the nested object, because only the top-level `Mash` has been converted into a `Hash`. In the second example, this call fails, because this method does not exist, and the value must be accessed via the square brackets:
224
- ____
225
-
226
- [source,ruby]
227
- ----
228
- IRB > recs.to_h['data'].last.value
229
- ⤷ "54.200.26.233"
230
- IRB > recs.to_hash['data'].last.value
231
- "NoMethodError: undefined method `value` for #<Hash:0x00007fe36fab0f68>"
232
- IRB > recs.to_hash['data'].last['value']
233
- ⤷ "54.200.26.233"
234
- ----
235
-
236
- For more information on the actual JSON API, please refer to the http://www.dnsmadeeasy.com/integration/pdf/API-Docv2.pdf[following PDF document].
237
-
238
- == Available Actions
239
-
240
- Here is the complete of all methods supported by the `DnsMadeEasy::Api::Client`:
241
-
242
- ==== Domains
243
-
244
- * `create_domain`
245
- * `create_domains`
246
- * `delete_domain`
247
- * `domain`
248
- * `domains`
249
- * `get_id_by_domain`
250
-
251
- [discrete]
252
- ==== Records
253
-
254
- * `records_for`
255
- * `all`
256
- * `base_uri`
257
- * `create_a_record`
258
- * `create_aaaa_record`
259
- * `create_cname_record`
260
- * `create_httpred_record`
261
- * `create_mx_record`
262
- * `create_ns_record`
263
- * `create_ptr_record`
264
- * `create_record`
265
- * `create_spf_record`
266
- * `create_srv_record`
267
- * `create_txt_record`
268
- * `delete_all_records`
269
- * `delete_record`
270
- * `delete_records`
271
- * `find_all`
272
- * `find_first`
273
- * `find_record_ids`
274
-
275
- [discrete]
276
- ==== Secondary Domains
277
-
278
- * `secondary_domain`
279
- * `secondary_domains`
280
- * `get_id_by_secondary_domain`
281
- * `create_secondary_domain`
282
- * `create_secondary_domains`
283
- * `update_secondary_domains`
284
- * `delete_secondary_domain`
285
-
286
- [discrete]
287
- ==== Secondary IpSets
288
-
289
- * `secondary_ip_set`
290
- * `secondary_ip_sets`
291
- * `create_secondary_ip_set`
292
- * `update_secondary_ip_set`
293
- * `delete_secondary_ip_set`
294
-
295
- +++<a name="encryption">++++++</a>+++
296
-
297
- === Encryption
298
-
299
- It was mentioned above that the credentials YAML file may contain encrypted values. This facility is provided by the encryption gem https://github.com/kigster/sym[Sym].
300
-
301
- In order to encrypt your values, you need to perform the following steps:
302
-
303
- [source,bash]
304
- ----
305
- gem install sym
306
-
307
- # let's generate a new key and save it to a file:
308
- sym -g -o my.key
309
-
310
- # if you are on Mac OS-X, you can import the key into the KeyChain.
311
- # this creates an entry in the keychain named 'my.key' that can be used later.
312
- sym -g -x my.key
313
- ----
314
-
315
- Once you have the key generated, first, *make sure to never commit this to any repo!*. You can use 1Password for it, or something like that.
316
-
317
- Let's encrypt our actual API key:
318
-
319
- [source,bash]
320
- ----
321
- api_key="12345678-a8f8-4466-ffff-2324aaaa9098"
322
- api_secret="43009899-abcc-ffcc-eeee-09f809808098"
323
- sym -ck my.key -e -s "${api_key}"
324
- # => prints the encrypted value
325
-
326
- # On a mac, you can copy it to clipboard:
327
- sym -ck my.key -e -s "${api_secret}" | pbcopy
328
- ----
329
-
330
- Now, you place the encrypted values in the YAML file, and you can save "my.key" as the value against `encryption_key:` at the same level as the `api_key` and `api_secret` in the YAML file. This value can either point to a file path, or be a keychain name, or even a name of an environment variable. For full details, please see https://github.com/kigster/sym#using-sym-with-the-command-line[sym documentation].
331
-
332
- == CLI Client
333
-
334
- This library offers a simple CLI client `dme` that maps the command line arguments to method arguments for corresponding actions:
335
-
336
- image:.dme-help.png[Usage,width="80%",border="2"]
337
-
338
- You can run `dme operations` to see the supported list of operations:
339
-
340
- [source,bash]
341
- ----
342
- ❯ dme op
343
- Actions:
344
- Checkout the README and RubyDoc for the arguments to each operation,
345
- which is basically a method on a DnsMadeEasy::Api::Client instance.
346
- http://www.rubydoc.info/gems/dnsmadeeasy/DnsMadeEasy/Api/Client
347
-
348
- Valid Operations Are:
349
- all
350
- base_uri
351
- create_a_record
352
- create_aaaa_record
353
- create_cname_record
354
- create_domain
355
- create_domains
356
- create_httpred_record
357
- create_mx_record
358
- create_ns_record
359
- create_ptr_record
360
- create_record
361
- create_secondary_domain
362
- create_secondary_domains
363
- create_secondary_ip_set
364
- create_spf_record
365
- create_srv_record
366
- create_txt_record
367
- delete_all_records
368
- delete_domain
369
- delete_record
370
- delete_records
371
- delete_secondary_domain
372
- delete_secondary_ip_set
373
- domain
374
- domains
375
- find_all
376
- find_first
377
- find_record_ids
378
- get_id_by_domain
379
- get_id_by_secondary_domain
380
- records_for
381
- secondary_domain
382
- secondary_domains
383
- secondary_ip_set
384
- secondary_ip_sets
385
- update_record
386
- update_records
387
- update_secondary_domains
388
- update_secondary_ip_set
389
- ----
390
-
391
- For example:
392
-
393
- [source,bash]
394
- ----
395
- ❯ dme domains moo.com
396
- ----
397
-
398
- is equivalent to `DME.domains("moo.com")`. You can use any operation listed above, and output the result in either `YAML` or `JSON` (in addition to the default "awesome_print"), for example:
399
-
400
- [source,bash]
401
- ----
402
- ❯ dme --yaml find_all moo.com www CNAME
403
- ---
404
- - dynamicDns: false
405
- failed: false
406
- gtdLocation: DEFAULT
407
- hardLink: false
408
- ttl: 60
409
- failover: false
410
- monitor: false
411
- sourceId: 5861234
412
- source: 1
413
- name: www
414
- value: ec2-54-202-251-7.us-west-2.compute.amazonaws.com
415
- id: 43509989
416
- type: CNAME
417
- ----
418
-
419
- === Managing Domains
420
-
421
- NOTE: below we can be using `@client` instantiated with given key and secret, or
422
- `DME` or `DnsMadeEasy` module.
423
-
424
- To retrieve all domains:
425
-
426
- [source,ruby]
427
- ----
428
- require 'dnsmadeeasy/dme'
429
- DME.domains
430
- ----
431
-
432
- To retreive the id of a domain by the domain name:
433
-
434
- [source,ruby]
435
- ----
436
- DME.get_id_by_domain('test.io')
437
- ----
438
-
439
- To retrieve the full domain record by domain name:
440
-
441
- [source,ruby]
442
- ----
443
- DME.domain('test.io')
444
- ----
445
-
446
- To create a domain:
447
-
448
- [source,ruby]
449
- ----
450
- DME.create_domain('test.io')
451
- # Multiple domains can be created by:
452
- DME.create_domains(%w[test.io moo.re])
453
- ----
454
-
455
- To delete a domain:
456
-
457
- [source,ruby]
458
- ----
459
- DME.delete_domain ('test.io')
460
- ----
461
-
462
- === Managing Secondary Domains
463
-
464
- To retrieve all secondary domains:
465
-
466
- [source,ruby]
467
- ----
468
- DME.secondary_domains
469
- ----
470
-
471
- To retrieve secondary domain by id:
472
-
473
- [source,ruby]
474
- ----
475
- DME.secondary_domain(domain_id)
476
- ----
477
-
478
- To retrieve the id of a domain by the secondary domain name:
479
-
480
- [source,ruby]
481
- ----
482
- DME.get_id_by_secondary_domain('test.io')
483
- ----
484
-
485
- To create a secondary domain:
486
-
487
- [source,ruby]
488
- ----
489
- # IP_SET_ID is id of ip_set you want to associate domain with
490
- DME.create_secondary_domain('test.io', IP_SET_ID)
491
-
492
- # Multiple domains can be created by:
493
- DME.create_secondary_domains(%w[test.io moo.re], IP_SET_ID)
494
- ----
495
-
496
- To update a secondary domain:
497
-
498
- [source,ruby]
499
- ----
500
- # IP_SET_ID is id of ip_set you want to associate
501
- # DOMAIN_ID is id of domain
502
- DME.update_secondary_domains([DOMAIN_ID], IP_SET_ID)
503
- ----
504
-
505
- To delete a secondary domain:
506
-
507
- [source,ruby]
508
- ----
509
- DME.delete_secondary_domain('test.io')
510
- ----
511
-
512
- === Managing Secondary IpSets
513
-
514
- To retrieve all secondary IpSets:
515
-
516
- [source,ruby]
517
- ----
518
- DME.secondary_ip_sets
519
- ----
520
-
521
- To retrieve single ipSet:
522
-
523
- [source,ruby]
524
- ----
525
- DME.secondary_ip_set(IP_SET_ID)
526
- ----
527
-
528
- To create an ipSet:
529
-
530
- [source,ruby]
531
- ----
532
- # IP_LIST is list of ips to be associated with this ip_set, like %w[8.8.8.8, 1.1.1.1]
533
- DME.create_secondary_ip_set('ip-set-name', IP_LIST)
534
- ----
535
-
536
- To update an ipSet:
537
-
538
- [source,ruby]
539
- ----
540
- DME.update_secondary_ip_set(IP_SET_ID, 'ip-list-name', IP_LIST)
541
- ----
542
-
543
- To delete an ipSet:
544
-
545
- [source,ruby]
546
- ----
547
- DME.delete_secondary_ip_set(IP_SET_ID)
548
- ----
549
-
550
- === Managing Records
551
-
552
- To retrieve all records for a given domain name:
553
-
554
- [source,ruby]
555
- ----
556
- DME.all('test.io')
557
- ----
558
-
559
- To find the record id for a given domain, name, and type:
560
-
561
- This finds all of the IDs matching 'woah.test.io' type 'A':
562
-
563
- [source,ruby]
564
- ----
565
- DME.find_record_ids ('test.io', 'woah', 'A')
566
- # => [ 234234, 2342345 ]
567
- ----
568
-
569
- [source,ruby]
570
- ----
571
- # To delete a record by domain name and record id (the record id can be retrieved from `find_record_id`:
572
- DME.delete_record ('test.io', 123)
573
- # To delete multiple records:
574
- DME.delete_records ('test.io', [123, 143])
575
- # To delete all records in the domain:
576
- DME.delete_all_records ('test.io')
577
- ----
578
-
579
- To create records of various types:
580
-
581
- [source,ruby]
582
- ----
583
- # The generic method:
584
- DME.create_record ('test.io', 'woah', 'A', '127.0.0.1', { 'ttl' => '60' })
585
-
586
- # Specialized methods:
587
- DME.create_a_record ('test.io', 'woah', '127.0.0.1', {})
588
- DME.create_aaaa_record ('test.io', 'woah', '127.0.0.1', {})
589
- DME.create_ptr_record ('test.io', 'woah', '127.0.0.1', {})
590
- DME.create_txt_record ('test.io', 'woah', '127.0.0.1', {})
591
- DME.create_cname_record ('test.io', 'woah', '127.0.0.1', {})
592
- DME.create_ns_record ('test.io', 'woah', '127.0.0.1', {})
593
- DME.create_spf_record ('test.io', 'woah', '127.0.0.1', {})
594
- ----
595
-
596
- ==== Specialized Record Types
597
-
598
- Below are the method calls for `MX`, `SRV`, and `HTTPRED` types:
599
-
600
- [source,ruby]
601
- ----
602
- # Arguments are: domain_name, name, priority, value, options = {}
603
- DME.create_mx_record ('test.io', 'woah', 5, '127.0.0.1', {})
604
- # Arguments are: domain_name, name, priority, weight, port, value, options = {}
605
- DME.create_srv_record ('test.io', 'woah', 1, 5, 80, '127.0.0.1', {})
606
- # Arguments are: domain_name, name, value, redirectType,
607
- DME.create_httpred_record('test.io', 'woah', '127.0.0.1', 'STANDARD - 302',
608
- # description, keywords, title, options = {}
609
- 'a description', 'keywords', 'a title', {})
610
- ----
611
-
612
- To update a record:
613
-
614
- [source,ruby]
615
- ----
616
- DME.update_record('test.io', 123, 'woah', 'A', '127.0.1.1', { 'ttl' => '60' })
617
- ----
618
-
619
- To update several records:
620
-
621
- [source,ruby]
622
- ----
623
- DME.update_records('test.io',
624
- [
625
- { 'id' => 123,
626
- 'name' => 'buddy',
627
- 'type' => 'A',
628
- 'value'=> '127.0.0.1'
629
- }
630
- ], { 'ttl' => '60' })
631
- ----
632
-
633
- To get the number of API requests remaining after a call:
634
-
635
- [source,ruby]
636
- ----
637
- DME.requests_remaining
638
- #=> 19898
639
- ----
640
-
641
- NOTE: Information is not available until an API call has been made
642
-
643
- To get the API request total limit after a call:
644
-
645
- [source,ruby]
646
- ----
647
- DME.request_limit
648
- #=> 2342
649
- ----
650
-
651
- NOTE: Information is not available until an API call has been made
652
-
653
- == Installation
654
-
655
- Add this line to your application's Gemfile:
656
-
657
- [source,ruby]
658
- ----
659
- gem 'dnsmadeeasy'
660
- ----
661
-
662
- And then execute:
663
-
664
- $ bundle
665
-
666
- Or install it yourself:
667
-
668
- $ gem install dnsmadeeasy
669
-
670
- == Development
671
-
672
- 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.
673
-
674
- 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 https://rubygems.org[rubygems.org].
675
-
676
- == Acknowledgements
677
-
678
- The current maintainer https://github.com/kigster[Konstantin Gredeskoul] wishes to thank:
679
-
680
- * Arnoud Vermeer for the original `dnsmadeeasy-rest-api` gem
681
- * Andre Arko, Paul Henry, James Hart formerly of link:wanelo.com[Wanelo] fame, for bringing the REST API gem up to the level.
682
- * Phil Cohen, who graciously transferred the ownership of the name of this gem on RubyGems.org to the current maintainer.
683
-
684
- == Contributing
685
-
686
- Bug reports and pull requests are welcome on GitHub at https://github.com/kigster/dnsmadeeasy.
687
-
688
- == License
689
-
690
- The gem is available as open source under the terms of the http://opensource.org/licenses/MIT[MIT License].