   (GET- "/host/machine/:host" [^:string host] {:nickname "getHostMachine" :summary "Get Host machine"}
         (success (p/host host)))
 
-  (POST- "/host/machine" [& ^:system props] {:nickname "addHostMachine" :summary "Add Host machine"}
+  (POST- "/host/machine" [& ^:system props] {:nickname "addHostMachine" :summary "Add Host machine" 
+                                             :errorResponses (errors {:conflict "Host already exists" :bad-req "Missing host type"})}
          (let [host (get-in props [:machine :hostname])]
            (if (p/host-exists? host)
              (conflict {:msg "Host aleady exists, use PUT /host/machine instead"}) 

                 (bad-req  {:msg (<< "Cannot create machine with missing type ~(e :t)}")}))) 
             )))

  (PUT- "/host/machine" [& ^:system props] {:nickname "updateHostMachine" :summary "Add Host machine"}
        (let [host  (get-in props [:machine :hostname])]
          (when-not (p/host-exists? host)
            (conflict {:msg "Host does not exists, use POST /host/machine first"})) 
          (p/register-host props) 
          (success {:msg "new host saved" :host host :props props})))

  (DELETE- "/host/machine/:host" [^:string host] {:nickname "deleteHost" :summary "Delete Host"}
           (if (p/host-exists? host)
             (do (p/delete-host host) (success {:msg "Host deleted"}))
             (bad-req {:msg "Host does not exist"})))

        [ring.middleware.format-response :only [wrap-restful-response]]
        [ring.middleware.params :only (wrap-params)]
        [metrics.ring.instrument :only  (instrument)]
        [swag.core :only (swagger-routes http-codes GET- POST- PUT- DELETE- defroutes- errors)]
        [swag.model :only (defmodel wrap-swag defv defc)]
        [celestial.common :only (import-logging)])
  (:require 
    [celestial.security :as sec]
    [celestial.persistency :as p]
