   (clojure.core/get-in (parse-string (:body (client/get (str (base-url) "/keys/" key)))) ["node" "value"]))
 
 (defn delete
+  "Deletes a value"
   [key]
   (parse-string (:body (client/delete (str (base-url) "/keys/" key)))))
 
 (defn delete-dir
+  "Deletes a dir"
   [key]
   (parse-string (:body (client/delete (str (base-url) "/keys/" key "?dir=true")))))
 
 (defn delete-dir-recur
+  "Deletes a directory recursively"
   [key]
   (parse-string (:body (client/delete (str (base-url) "/keys/" key "?dir=true&recursive=true")))))
+
+(defn create-in-order
+  "Creates in order"
+  [key value]
+  (let [url (str (base-url) "/keys/" key)]
+    (clojure.core/get-in (parse-string (:body (client/post url {:form-params {:value value}}))) ["node" "value"])))
+
+(defn list
+  "Lists the content of a directory"
+  [key & {:keys [recursive]}]
+  (let [url (str (base-url) "/keys/" key "?recursive=" recursive)]
+    (clojure.core/get-in (parse-string (:body (client/get url ))) ["node"])))
+
+(defn list-in-order
+  "Lists the content of a directory recursively and in order"
+  [key]
+  (let [url (str (base-url) "/keys/" key "?recursive=true&sorted=true")]
+    (map #(clojure.core/get % "value") (clojure.core/get-in (parse-string (:body (client/get url ))) ["node" "nodes"]))))
+
+(defn create-dir
+  "Creates a dir"
+  [key & {:keys [ttl]}]
+  (let [data {:value val :dir true}
+        url (str (base-url) "/keys/" key)]
+    (if ttl
+      (clojure.core/get-in (parse-string (:body (client/put url {:form-params (assoc data :ttl ttl)}))) ["node" "key"])
+      (clojure.core/get-in (parse-string (:body (client/put url {:form-params data}))) ["node" "key"]))))
 
 (defn watch
   [key callback]

    (when-done f #(callback %)) f))

(defn stats
  ""
  []
  (parse-string (:body (client/get (str (base-url) "/stats/leader")))))

(defn self-stats
  ""
  []
  (parse-string(:body (client/get (str (base-url) "/stats/self")))))

(defn store-stats
  ""
  []
  (parse-string (:body (client/get (str (base-url) "/stats/store")))))

(defn machines
  []
  (println (str (admin-base-url) api-version "/admin/machines"))
  (parse-string (:body (client/get (str (admin-base-url) "/admin/machines")))))

(defn get-config
  ""
  []
  (parse-string (:body (client/get (str (admin-base-url) "/admin/config")))))

(defn get-version
  ""
  []
  (:body (client/get (str @endpoint "/version"))))

  (reset! endpoint (format "http://%s:4001" etcd-server-host))
  (reset! admin-endpoint (format "http://%s:7001" etcd-server-host)))

(defn- when-done [future-to-watch function-to-call]
  (future (function-to-call @future-to-watch)))

