Skip to content

aplumez/exo-http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

exo-http

A Clojure HTTP Client for Exoscale (actually, it's just clj-http with a middleware).

Installation

In your deps.edn:

aplumez/exo-http {:git/url "git@github.com:aplumez/exo-http.git"
                  :git/sha "53f3cbb6df4db04f6a9cf0bd14ebaf9c0ccb1248"}

Usage

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-interval defines the delay in ms between each poll, defaults to exo-http.core/default-poll-interval
  • :poll-max-iterations defines the maximum number of polling iterations to realize, defaults to exo-http.core/default-poll-max-iterations

Examples

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)))

About

A Clojure HTTP Client for Exoscale (actually, it's just clj-http with a middleware)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors