Created
December 17, 2013 16:10
-
-
Save ahonor/8007472 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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