A little client for talking to edda
Include in your project.clj
[mixradio/mr-edda "0.1.0"]
(require '[mr-edda.core :as edda]) ;;query
(require '[mr-edda.http :as edda-http]) ;;http client
(require '[mr-edda.collection :as edda-coll]) ;;collection resources
(require '[mr-edda.view :as edda-view]) ;;view resources
(require '[mr-edda.group :as edda-group]) ;;group resources
(def client (edda-http/client "http://localhost:8080"))
(edda/query client edda-coll/images
{:filters {:imageOwnerAlias "amazon"
:public true})
;; => a seq of maps representing the images matching the filters
:expand?
if true returns the entire document describing the resources
rather than just its id.
:filters
a map containing field -> value pairs which will be restrict the result set of a query. Can specify sub fields using dot notation.
e.g
(query client edda-coll/auto-scaling-groups
{:filters {:instances.availabilityZone "eu-west-1b"}})
:fields
expands out to field notation. In clojure this is represented as vectors and maps. If fields is passed, :expand?
is implicitly passed (as otherwise it would have no effect).
(query client edda-coll/auto-scaling-groups
{:fields [:status {:instances [:availabilityZone :healthStatus]}]})
:limit
simply limits the result set
:id
instead of filtering and returning a sequence, if you know the id of the resource, you can returning it directly.
(query client edda-coll/images {:id "some-image"})
;; => either a singleton sequence with the full document describing the
;; resource, or an empty sequence if the id didn't match any thing.
Copyright © 2015 MixRadio
mr-edda is released under the 3-clause license ("New BSD License" or "Modified BSD License").