dynect_rest icon indicating copy to clipboard operation
dynect_rest copied to clipboard

Access the Dynect REST API from Ruby

= dynect-rest

Interact with the Dynect REST API.

== Resource Records

Since this is 90% of what you'll be doing, we make it easy.

require 'dynect_rest' dyn = DynectRest.new("CUSTOMER", "USERNAME", "PASSWORD", "ZONE") dyn.a.fqdn("sunshine.example.com").ttl(3600).address("192.168.1.1").save dyn.cname.fqdn("something.example.com").cname("ec2-10-10-10-10.amazonaws.com").save dyn.publish

Will add an A record and a CNAME. You can use the chained method syntax for every resource record - we map unknown methods to the resource data you make in the call. See link: (example.rb)[https://github.com/adamhjk/dynect_rest/blob/master/example.rb] for an executable example using environment variables.

== GSLB

Create a new GSLB:

require 'dynect_rest' dyn = DynectRest.new("CUSTOMER", "USERNAME", "PASSWORD", "ZONE") gslb = dyn.gslb() gslb.fqdn("sunshine.example.com").ttl(30).region_code("global") gslb.min_healthy(1).serve_count(2) gslb.monitor(:protocol => "HTTP", :interval => 1, :port => 8000, :path => "/healthcheck", :host => "sunshine.example.com") gslb.add_host(:address => "1.1.1.1", :label => "friendly_name", :weight => 10, :serve_mode => "obey") gslb.add_host(:address => "1.1.1.2", :label => "friendly_name2", :weight => 10, :serve_mode => "obey") gslb.save

This will create a GSLB with hosts 1.1.1.1 and 1.1.1.2 in the global region. The parameters are self-explanatory.

Add a host to an existing GSLB:

require 'dynect_rest' dyn = DynectRest.new("CUSTOMER", "USERNAME", "PASSWORD", "ZONE") gslb = dyn.gslb.get("sunshine.example.com") gslb.add_host(:address => "1.1.1.3", :label => "friendly_name3", :weight => 10, :serve_mode => "obey") gslb.save(:replace)

This will fetch the GSLB object for "sunshine.example.com", add the host 1.1.1.3, and save the updated configuration back to dynect.

== Everything else

We wrap up the lower-level functionality of the API, so you can focus on just making the calls. For example, to get a list of contacts:

dyn = DynectRest.new("CUSTOMER", "USERNAME", "PASSWORD", "ZONE") dyn.get('Contact')

To create a new contact:

dyn = DynectRest.new("CUSTOMER", "USERNAME", "PASSWORD", "ZONE") dyn.post('Contact', { "first_name" => "Bobo", "last_name" => "Clown", "organization" => 'The Circus', "email" => "[email protected]" })

== Use the API docs

For more - you should be able to find the latest at:

https://manage.dynect.net/help/docs/api2/rest/resources/

If you are a Dynect customer.

== Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • 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 (c) 2010 Opscode, Inc. See LICENSE for details.