A Clojure HTTP Client for Exoscale (actually, it's just clj-http with a middleware).
In your deps.edn:
aplumez/exo-http {:git/url "git@github.com:aplumez/exo-http.git"
:git/sha "53f3cbb6df4db04f6a9cf0bd14ebaf9c0ccb1248"}Each request is made of a verb (GET, POST, PUT, DELETE), the credentials to use (api-key + api-secret), the zone ${"ch-gva-2" "ch-dk-2" "at-vie-1" "de-fra-1" "bg-sof-1" "de-muc-1" "at-vie-2"}, an URI (starting with "/v2/") and a body made of a Clojure map if it is needed.
When the response is an Operation, the response will automatically be polled until completion and then return the result. This behaviour is customizable with the following keys in every request:
:fetch-reference?defines if the reference should be requested once the operation is successfully completed:poll-intervaldefines the delay in ms between each poll, defaults toexo-http.core/default-poll-interval:poll-max-iterationsdefines the maximum number of polling iterations to realize, defaults toexo-http.core/default-poll-max-iterations
Get the list of API Keys:
@(get {:api-key (System/getenv "EXO_API_KEY")
:api-secret (System/getenv "EXO_API_SECRET")
:uri "/v2/api-key"
:zone "ch-gva-2"})Create a new API Key:
@(post {:api-key (System/getenv "EXO_API_KEY")
:api-secret (System/getenv "EXO_API_SECRET")
:uri "/v2/api-key"
:zone "ch-gva-2"
:body {:role-id (parse-uuid "be5f08ed-0298-4bad-b741-cb435968409d")
:name "delete-me"}})Delete an API Key:
@(delete {:api-key (System/getenv "EXO_API_KEY")
:api-secret (System/getenv "EXO_API_SECRET")
:uri (str "/v2/api-key/EXO08251e09c7bddcdb9dbe1d9a")
:zone "ch-gva-2"})Catch the errors:
(try
@(delete {:api-key (System/getenv "EXO_API_KEY")
:api-secret (System/getenv "EXO_API_SECRET")
:uri (str "/v2/api-key/EXOnotexisting")
:zone "ch-gva-2"})
(catch Exception e
(ex-data e)))