Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
121 lines (74 sloc) 3.47 KB


Dynectastic is a nice wrapper for Dynect's REST API. Use it to manage Zones, Records and Nodes on your Dynect account.


gem install dynectastic


HTTParty 0.6.1


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.


You can always access most recent request of a resource by calling last_request on it:

zone.last_request # => #<Dynectastic::Request:...>

Every request store it's response:

zone.last_request.response # => #<HTTParty::Response:...>


Every request to Dynect has a special Job assigned to it. You can access it like this:

zone.publish                    # => true        # => 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        # => 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:
  :name    => "",
  :contact => "",
  :ttl     => 1800


zone = dynect.zones.find_by_name("")




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:
  :zone => "",
  :node => "", # will be created automatically
  :ttl  => 1800,
  :rdata => {
    :cname => ""

dynect.records.cname.find_all(:zone => "", :node => "")

record = dynect.records.cname.find_by_id(0, :zone => "", :node => "")

record.rdata['cname'] = ""


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("", "")

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 © 2010 Ilya Sabanin. See LICENSE for details.