              (catch [:type :celestial.persistency/missing-system] e 
                (bad-req {:msg "System does not exist"}))))
 
-  (GET- "/host/type/:id" [^:int id] {:nickname "getSystemType" :summary "Fetch type of provided system id"}
+  (GET- "/systems/:id/type" [^:int id] {:nickname "getSystemType" :summary "Fetch type of provided system id"}
         (success (p/get-type (:type (p/get-system id))))) 
   )
 
 
-(defroutes- types {:path "/type" :description "Operations on types"}
+(defroutes- type {:path "/type" :description "Operations on types"}
 
-  (GET- "/type/:type" [^:string type] {:nickname "getType" :summary "Get type"}
+  (GET- "/types/:type" [^:string type] {:nickname "getType" :summary "Get type"}
         (success (p/get-type type)))
 
-  (POST- "/type" [& ^:type props] {:nickname "addType" :summary "Add type"}
+  (POST- "/types" [& ^:type props] {:nickname "addType" :summary "Add type"}
          (wrap-errors 
            (p/add-type props)
            (success {:msg "new type saved"})))
 
-  (PUT- "/type" [& ^:type props] {:nickname "updateType" :summary "Update type"}
+  (PUT- "/types" [& ^:type props] {:nickname "updateType" :summary "Update type"}
         (wrap-errors
           (if-not (p/type-exists? (props :type))
             (conflict {:msg "Type does not exists, use POST /type first"}) 
             (do (p/update-type props) 
                 (success {:msg "type updated"})))))
 
-  (DELETE- "/type/:type" [^:string type] {:nickname "deleteType" :summary "Delete type" 
+  (DELETE- "/types/:type" [^:string type] {:nickname "deleteType" :summary "Delete type" 
                                           :errorResponses (errors {:bad-req "Type does not exist"})}
            (if (p/type-exists? type)
              (do (p/delete-type type) 

             (success {:msg "system cloned" :id id}))
           (conflict {:msg "System does not exists, use POST /host/system to create it first"})))

  (PUT- "/host/system/:id" [^:int id & ^:system system] {:nickname "updateSystem" :summary "Update system" 
                                                         :errorResponses (errors {:conflict "System does not exist"}) }
        (if-not (p/system-exists? id)
          (conflict {:msg "System does not exists, use POST /host/system first"}) 


(set-base "")

(defroutes- system {:path "/host" :description "Operations on hosts"}

  (GET- "/systems" [] {:nickname "getSystems" :summary "Get all systems"}
        (success (map #(p/get-system %) (p/all-systems))))

  (GET- "/systems/:id" [^:int id] {:nickname "getSystem" :summary "Get system by id"}
        (success (p/get-system id)))

  (GET- "/system-by/:type" [^:string type] {:nickname "getSystemsByType" :summary "Get systems by type"}
        (success {:ids (p/get-system-index :type type)}))

  (POST- "/system" [& ^:system spec] {:nickname "addSystem" :summary "Add system" 
                                           :errorResponses (errors {:bad-req "Missing system type"})}
         (wrap-errors
           (p/with-quota (p/add-system spec) spec
             (success {:msg "new system saved" :id id}))))

  (POST- "/system-clone/:id/:hostname" [^:int id ^:string hostname] 
         {:nickname "cloneSystem" :summary "Clone an existing system " 
          :notes "Clones a system replacing unique identifiers along the way,
                 the only user provided value is the dest hostname"
