-
Notifications
You must be signed in to change notification settings - Fork 1
/
zone.clj
43 lines (36 loc) · 1.17 KB
/
zone.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
(ns exoscale.compute.api.zone
"Higher order functions to manipulate keypairs.
In addition to standard facilities, this also
bundles an opt-in atom-backed store for private keys
created here."
(:refer-clojure :exclude [list])
(:require [exoscale.compute.api.client :as client]
[exoscale.compute.api.meta :as meta]
[qbits.auspex :as auspex]
[exoscale.compute.api.spec]))
(defn sanitize
[z]
(meta/describe {:id (client/parse-uuid (:id z))
:name (:name z)}
:exoscale.compute/zone
z))
(defn by-name
[config zname]
(auspex/chain (client/api-call config :list-zones {:name (name zname)})
(fn [resp]
(when-not (= 1 (count resp))
(throw (IllegalArgumentException.
"cannot resolve zone")))
(sanitize (first resp)))))
(defn list
"List virtual machines"
[config]
(auspex/chain (client/api-call config :list-zones)
#(mapv sanitize %)))
(comment
@(list config)
@(by-name config :ch-dk-2)
@(list config)
@(delete config :kp1)
@(list config)
)