Skip to content

Instantly share code, notes, and snippets.

@ahonor
Created December 17, 2013 16:10
Show Gist options
  • Save ahonor/8007472 to your computer and use it in GitHub Desktop.
Save ahonor/8007472 to your computer and use it in GitHub Desktop.
Node get(String href, Map params) {
if (null == href) throw new IllegalAccessException("href cannot be null")
if (!href.endsWith('.xml')) {
href= href+'.xml'
}
System.out.println("DEBUG: RightscaleAPIRequest.RestClient: Getting resource by href: ${href}")
/**
* Request the servers data as XML
*/
def request = href as Rest;
request.addFilter(new LoggingFilter(System.out)); // debug output
def ClientResponse response = request.get([:], params); // instance_detail contains extra info
if (response.status.equals(200)) {
// yay
} else if (response.status.equals(403)) {
authenticate()
} else {
throw new ResourceModelSourceException("RightScale ${href} request error ${response.status}. " + response)
}
requests.inc()
return response.XML
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment