dynectastic¶ ↑
Dynectastic is a nice wrapper for Dynect’s REST API. Use it to manage Zones, Records and Nodes on your Dynect account.
Installation¶ ↑
gem install dynectastic
Requirements¶ ↑
HTTParty 0.6.1
Usage¶ ↑
First you need to create new Dynect session:
dynect = Dynectastic.session("dynect_customer_name", "dynect_login", "dynect_password")
Make sure to create a separate login/password pair for your API client or it will interfere with your web interface browsing.
Now you can use this “dynect” object to call various API methods.
Requests¶ ↑
You can always access most recent request of a resource by calling last_request on it:
zone.freeze zone.last_request # => #<Dynectastic::Request:...>
Every request store it’s response:
zone.last_request.response # => #<HTTParty::Response:...>
Jobs¶ ↑
Every request to Dynect has a special Job assigned to it. You can access it like this:
zone.publish # => true zone.last_request.job.id # => 343245 zone.last_request.job.complete? # => true
Sometimes a long running job can not be completed in time, so Dynectastic returns false as a result of your request:
zone.publish # => false zone.last_request.job.id # => 342626 zone.last_request.job.complete? # => false
Since Dynect does not allow you to run several jobs simultaneously, sometimes your requests will return Dynectastic::SessionBusy exception. Luckily there is a built-in retry cycle for such exceptions: Dynectastic will sleep for a few seconds and retry your request 5 more times.
Zone examples¶ ↑
With Dynectastic you can find, create, freeze, unfreeze, publish and destroy zones:
dynect.zones.build( :name => "newfancyzone.com", :contact => "stalin@communismwilleventuallywin.com", :ttl => 1800 ).save dynect.zones.find_all zone = dynect.zones.find_by_name("newfancyzone.com") zone.freeze zone.frozen? zone.unfreeze zone.publish zone.published? zone.destroy
Don’t forget that you have to publish a zone every time you make any changes to it (for example when you add new record).
Record examples¶ ↑
For now it’s possible to find, create, update and delete records:
dynect.records.cname.build( :zone => "newfancyzone.com", :node => "new_node.newfancyzone.com", # will be created automatically :ttl => 1800, :rdata => { :cname => "something.somewhere.com" } ).save dynect.records.cname.find_all(:zone => "newfancyzone.com", :node => "new_node.newfancyzone.com") record = dynect.records.cname.find_by_id(0, :zone => "newfancyzone.com", :node => "new_node.newfancyzone.com") record.rdata['cname'] = "some_other_thing.somewhere.com" record.save record.destroy
Dynect will automatically create Node for your record if it’s missing.
You can use all other record types instead of “cname” such as “txt” or “a” or anything else.
Node examples¶ ↑
The API only allow us to delete nodes, nothing else:
dynect.nodes.destroy("newfancyzone.com", "new_node.newfancyzone.com")
Note on Patches/Pull Requests¶ ↑
-
Fork the project.
-
Make your feature addition or bug fix.
-
Add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-
Send me a pull request. Bonus points for topic branches.
Copyright¶ ↑
Copyright © 2010 Ilya Sabanin. See LICENSE for details.