Rhea: ColdFusion Rackspace Cloud API CFC

Written by on March 10, 2010 in ColdFusion, Projects - 8 Comments
Tags: , ,
Short URL: http://www.mattgifford.co.uk/s/1166

Another day, another open-source ColdFusion API released to the community :)

Fuzzy Orange are pleased to announce the release of our first open-source project.

Codenamed Rhea, after the Greek mythologicial figure and mother of Gods and Godesses, the project has been a labour of love for the last few weeks, and one that I’ve certainly enjoyed developing.

What is it?

Naming conventions and codenames aside, Rhea is a ColdFusion CFC package developed specifically to interact with the Rackspace Cloud Server and Cloud Files APIs.

Over at FO Towers, not only are we Rackspace partners, but we’ve been using the Rackspace Cloud services for some time. Having the ability to create a new server in literally seconds is amazing, and the option to store files remotely in custom directories (or ‘Containers’) using the Cloud Files system is fantastic.

Having spoken to other developers and reading through the documentation available, we noticed that although Rackspace provided bindings to support their API in many languages, there was no official ColdFusion binding.

Spotting the gap in the field and wanting to fill the void, Rhea was born.

Bringing Rhea to life

To try to make life easier and simpler for fellow developers and users of the project, Rhea has been developed to be as simple to use as possible. The only file that needs to be instantiated to start working with the object is rackspaceCloud.cfc.

This file acts as a facade (or Service Layer object) to the sub-components and underlying public-facing methods.

Instantiating the rackspaceCloud.cfc is incredibly easy, and only requires two parameters; the Rackspace account username and the API key.

<cffunction name="onApplicationStart" output="false">
	<cfscript>
		strcloudUser = '<enter your cloud api username>';
		strcloudKey  = '<enter your cloud api key>';

		Application.objRackspace = createObject('component',
		        'com.fuzzyorange.rackspaceCloud').
		        init(username=strcloudUser,apiKey=strcloudKey);

	</cfscript>
</cffunction>

Immediately after instantiation, the component runs an authentication method to verify and validate the user details against the API.

If unsuccessful, the API will throw a user-friendly error message and any further processing will abort. If your details are correct and authentication has been successful, you’re ready to go and explore Rhea.

One facade to rule them all…

cloudSofa

As we are dealing with two separate API systems (Cloud Server and Cloud Files), access to the relevant methods for each is obtained through the main rackspaceCloud object.

This file invokes two new objects on run time to act as an interface to the relevant functions.

Although not strictly an Interface pattern in terms of true Object-Oriented Design, the two API interfaces are accessed using the code below:

// store and persist the file interface
Application.objFiles = Application.objRackspace.fileInterface();
// store and persist the server interface
Application.objServer = Application.objRackspace.serverInterface();

Using the fileInterface() and serverInterface() methods from the main object, we are now storing and persisting the relevant objects in the Application scope for use throughout our site.

To access a Server-specific method for example, we would then call code similar to the following:

Application.objServer.methodname(param1, param2…);

What can we do with it?

Quite a lot. Fact.

The official project download contains documentation outlining the installation and implementation of the CFC package, and also contains a comprehensive list of all methods available to interact with the Rackspace Cloud services, for both the server and file APIs.

Here’s a brief summary of some of the functions available:

  • Create a new server using custom images and flavors
  • Back up, restore, reboot and resize a server
  • Upload files to custom Containers
  • View and edit object meta data and contents

Over the next few weeks, I’ll be publishing some posts with code examples covering some of the methods available using Rhea, so make sure you bookmark the site and stay tuned for forthcoming posts.

We hope that you download, have a look through and use the project code. It’s certainly changed the way we operate and deploy our files.
Because of this, we developed the API to pass on the benefits to others in the community.

If you choose to implement or use the code, please feel free to let us know. We’d love to hear from you.

As always, time never stands still. We’ll keep working on Rhea with updates and additions to constantly improve the code where possible and to ensure that you continue to get the best application available.

Where can I get it?

The Rhea project is available for download now from RIA Forge: http://rhea.riaforge.org/

8 Comments on "Rhea: ColdFusion Rackspace Cloud API CFC"

  1. Darren April 13, 2010 at 11:31 pm · Reply

    Thank you so much for this contribution to the community. Looking forward to using it!

  2. Chris September 25, 2010 at 3:03 am · Reply

    Oh man.. this is just what I needed.
    I’m going to have a play around and see how things go.

    Saved me a lot of work here guys, thanks for sharing with the community.

  3. Kevin Fricke October 7, 2010 at 6:43 pm · Reply

    We are looking to use this to manage a number of our members files, primarily their profile photo. For some reason it times out. We don’t get any errors at all it just does not work after 24 hours.

    We are using Mach-ii and coldspring. Any ideas? I thought that it was an application timeout issue but since we are using coldspring i did not think that would be the case.

    Thanks for any response or ideas you may have.

    (by the way…THANK YOU for this. Other than this timeout issue, which I am sure is on our end, this words fantastic)

  4. Matt October 8, 2010 at 10:18 am · Reply

    Hey Kevin

    thanks for the kind words. This open-source release was something I had great fun working on, and I have more works in the pipeline as a result of this initial release.

    The timeout issues sounds incredibly strange. I must admit I haven’t been running the API in such a way that would leave it open indefinitely, and so i haven’t encountered this problem.

    The initial instinct on it is the authentication via the API times out for security reasons (from the Rackspace end). Worth looking into. I’ll have a look and see what I can find out.

  5. Chris October 25, 2010 at 12:12 am · Reply

    Do you have any examples of getting the contents of a file from a NON CDN container that has a pseudo path. I’ve tried a few things and haven’t been able to get any results back, other than an “OK” message.

    Is there anything at all that I can look at it? Thanks.

    Chris

  6. Chris November 17, 2010 at 12:30 am · Reply

    Just after a link to a working example of put and get for CloudFiles.

    • Matt November 17, 2010 at 12:27 pm · Reply

      Hi Chris

      I’ll post an example on this as soon as I can. I’m making some amendments / updates to the API wrapper and will also be releasing an extra tool to complement it.

  7. Chris January 4, 2011 at 6:53 am · Reply

    Happy New Year!
    Any advances on this at all? Is there a new post I should be looking at?

    I’ve made some good progress with this, and would be keen to share and see your ammendments / updates.

    Cheers!

Leave a Comment

Get creative and draw here... Go swirl-y crazy