Overview

ops-ruby is a Ruby library to interface with Tucows OpenSRS service. It condenses their rambling and badly-designed API into a coherent and simple one, working around the implementation problems as best it can to present an easy-to-use interface.

The interface is implemented in three main libraries:

1. the lowest layer (ops.rb) implements the XML<->Perl types layer which is used to build up the messages needed to exchange data with the OpenSRS servers. 2. the middle layer (rpc.rb) is provides the API call framework, presenting a generic Ruby interface onto any OpenSRS-documented call. 3. the top layer (rpc_quick.rb) is the sanitised API which presents many of the OpenSRS API calls in a way that fits the way you expect it to work.

There is also a cache utility class to speed up queries on lists of domains, and a crummy shell program which was originally used for testing all the features by hand, but now handles an embarrassing number of actual queries for Bytemark customers.

See OpenSRSsuck? for why you want to choose a different reseller for your domains. This library has to jump through too many hoops to work in a sensible fashion, and I don't like it!

Example code

rpc = OpenSRS::RPCQuick.live(username, password, key, true,
  OpenSRS::BasicDomainCache.new("/tmp/domain-cache", 864000)
)

# returns ["foo.com", "bar.com", "abc.co.uk" ... ]
all_my_domains = rpc.get_domain_list

# some default contact information
BYTEMARK_DEFAULT_CONTACT = {
  :first_name => "Bytemark",
  :last_name => "Hostmaster",
  :org_name => "Bytemark Hosting",
  :address1 => "The Raylor Centre",
  :address2 => "James Street",
  :city => "York",
  :state => "North Yorkshire",
  :country => "GB",
  :postal_code => "YO10 3DW",
  :email => "hostmaster@bytemark.co.uk",
  :phone => "+44.8450043004",
  :fax => "+44.8707622253",
  :url => "http://www.bytemark.co.uk/"
}

BYTEMARK_CONTACT_SET = {
  :owner   => BYTEMARK_DEFAULT_CONTACT,
  :admin   => BYTEMARK_DEFAULT_CONTACT,
  :tech    => BYTEMARK_DEFAULT_CONTACT,
  :billing => BYTEMARK_DEFAULT_CONTACT
}

# register a domain, throws exception if it doesn't work
rpc.register_domain(
  "mysupernewdomain.com", 
  BYTEMARK_CONTACT_SET,
  2,    # years
  true, # lock domain?
  ["a.ns.bytemark.co.uk",
   "b.ns.bytemark.co.uk",
   "c.ns.bytemark.co.uk"]
)

# renew another domain for 10 years
rpc.renew_domain("myolddomain.com", 10)

# OpenSRS UK integration is terrible, send it to a normal registrar
rpc.set_uk_domain_tag("mydomain.co.uk", "BYTEMARK")

# Bytemark suck too!  I want my auth code!
p rpc.get_domain_auth_info("myotherdomain.org")

Download

Sorry not got around to releases yet, but you can do:

darcs get http://src.bytemark.co.uk/ops-ruby/

to get the latest version.