A simple clojure cloudstack client.
This client provides two ways to query the cloudstack HTTP API.
Client are created with the http-client
which takes an optional
argument map:
config
: a map of three keys:
api-key
: cloustack api keyapi-secret
: cloustack api secretendpoint
: URL where cloudstack livespage-size
: page size (by default 500)The api-key
, api-secret
and endpoint
may also be fetched from the environment
or a configuration file.
The environment takes precedence over the configuration file. When looking for environment variables, both actual environment variables and JVM system properties will be looked up.
The following system properties or environment variables can be used to provide settings:
Property | Environment | Description |
---|---|---|
clostack.api.key | CLOSTACK_API_KEY | Cloudstack API key |
clostack.api.secret | CLOSTACK_API_SECRET | Cloudstack API secret |
clostack.endpoint | CLOSTACK_ENDPOINT | Cloudstack API endpoint |
The configuration file allows for different profiles, two additional relevant variables may be set:
Property | Environment | Description |
---|---|---|
clostack.profile | CLOSTACK_PROFILE | Configuration profile name |
clostack.config.file | CLOSTACK_CONFIG_FILE | Configuration file location |
A typical configuration will have the following aspect:
{:default :prod
:prod {:api-key "xxxx"
:api-secret "xxxx"
:endpoint "https://..."}
:staging {:api-key "xxxx"
:api-secret "xxxx"
:endpoint "https://..."}}
In this configuration, we define two cloudstack installations, by default the production credentials will
be used, setting clostack.profile to staging
would switch this mode of operation.
The easiest way to use clostack in your own projects is via Leiningen. Add the following dependency to your project.clj file:
[exoscale/clostack "0.2.14"]
https://exoscale.github.io/clostack
(def client (http-client {}))
;; Simple requests
(request client :list-virtual-machines {})
(request client :list-zones {})
;; Provide a callback to execute when response comes back
(async-request client :list-service-offerings {} (fn [resp] ...))
;; Page through all records and return a consistent lazy map
(paging-request client :list-events {})
;; Execute body when response comes back
(with-response [resp client :list-events]
(println (pr-str resp)))
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close