
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
cloudstack_client
Advanced tools
A CloudStack API client written in Ruby.
Install the cloudstack_client gem:
$ gem install cloudstack_client
cloudstack_client consolerequire "cloudstack_client"
cs = CloudstackClient::Client.new(
"https://cloudstack.local/client/api",
"API_KEY",
"SECRET_KEY"
)
cs.list_virtual_machines(state: "running").each do |vm|
puts vm["name"]
end
Load API definition file from an alternative path and set the version:
cs = CloudstackClient::Client.new(
"https://cloudstack.local/client/api",
"API_KEY",
"SECRET_KEY",
{
api_path: "~/cloudstack",
api_version: "4.15"
}
)
...or load the API definition directly from a file:
cs = CloudstackClient::Client.new(
"https://cloudstack.local/client/api",
"API_KEY",
"API_SECRET",
{ api_file: "~/cloudstack/4.15.json.gz" }
)
When working with paginated responses, you can include the total count in the API response:
# Get paginated results with count information
vms = cs.list_virtual_machines({ page: 1, pagesize: 10 }, { include_count: true })
total_count = vms[:count]
items = vms[:virtualmachine]
# Default behavior (without count)
vms = cs.list_virtual_machines(page: 1, pagesize: 10)
# Returns just the items array
The configuration module of CloudstackClient makes it easy to load CloudStack API settings from configuration files.
require "cloudstack_client"
require "cloudstack_client/configuration"
# looks for ~/.cloudstack.yml per default
config = CloudstackClient::Configuration.load
cs = CloudstackClient::Client.new(config[:url], config[:api_key], config[:secret_key])
Configuration files support multiple environments (i.e. ~/.cloudstack.yml):
# default environment
:default: production
# production environment
production:
:url: "https://my-cloudstack-server/client/api/"
:api_key: "cloudstack-api-key"
:secret_key: "cloudstack-api-secret"
# test environment
test:
:url: "http://my-cloudstack-testserver/client/api/"
:api_key: "cloudstack-api-key"
:secret_key: "cloudstack-api-secret"
You can pass options as 4th argument in CloudstackClient::Client.new. All its keys are optional.
options = {
symbolize_keys: true, # pass symbolize_names: true in JSON#parse for Cloudstack responses, default: false
host: 'localhost', # custom host header to be used in Net::Http. May be useful when Cloudstack is set up locally via docker (i.e. Cloudstack-simulator), default: parsed from config[:url] via Net::Http
read_timeout: 10 # timeout in seconds of a connection to the Cloudstack, default: 60
}
cs = CloudstackClient::Client.new(config[:url], config[:api_key], config[:secret_key], options)
cloudstack_client comes with an interactive console.
$ cloudstack_client console -e prod
prod >> list_virtual_machines
New API definitions can be generated using the list_apis command.
# running against a CloudStack 4.15 API endpoint:
$ cloudstack_client list_apis > data/4.15.json
$ gzip data/4.15.json
git checkout -b my-new-feature)git commit -am 'Add some feature')git push origin my-new-feature)Released under the MIT License. See the LICENSE file for further details.
FAQs
Unknown package
We found that cloudstack_client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.