Skip to content

Instantly share code, notes, and snippets.

@jeremyd
Created December 30, 2010 18:07
Show Gist options
  • Save jeremyd/760069 to your computer and use it in GitHub Desktop.
Save jeremyd/760069 to your computer and use it in GitHub Desktop.
use rest_connection w/out a config file
## One way to change the rest_connection settings using Ruby code.
RightScale::Api::BaseExtend.class_eval <<-EOF
@@connection.settings = {
:user => "someuser@rightscale.com",
:pass => "test1234_",
:api_url => "https://my.rightscale.com/api/acct/12345",
:common_headers => {
"X_API_VERSION" => "1.0"
}
}
EOF
@mcg
Copy link

mcg commented Mar 8, 2011

This didn't work as is, I had to add:
RightScale::Api::BaseExtend.class_eval <<-EOF
+@@connection ||= RestConnection::Connection.new
@@connection.settings = {

@mcg
Copy link

mcg commented Mar 17, 2011

Yet another follow up for this. Some calls continue to fail using original fix. You need to override connection settings in the Base class as well. The full "fix" seems to be:
RightScale::Api::BaseExtend.class_eval <<-EOF
@@connection ||= RestConnection::Connection.new
@@connection.settings = {
:user => "someuser@rightscale.com",
:pass => "test1234_",
:api_url => "https://my.rightscale.com/api/acct/12345",
:common_headers => {
"X_API_VERSION" => "1.0"
}
}
EOF
RightScale::Api::Base.class_eval <<-EOF
@@connection ||= RestConnection::Connection.new
@@connection.settings = {
:user => "someuser@rightscale.com",
:pass => "test1234_",
:api_url => "https://my.rightscale.com/api/acct/12345",
:common_headers => {
"X_API_VERSION" => "1.0"
}
}
EOF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment