aboutsummaryrefslogtreecommitdiff
path: root/src/clj/queue_api/routes
diff options
context:
space:
mode:
Diffstat (limited to 'src/clj/queue_api/routes')
-rw-r--r--src/clj/queue_api/routes/services.clj31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/clj/queue_api/routes/services.clj b/src/clj/queue_api/routes/services.clj
index 9b8cc91..01937c1 100644
--- a/src/clj/queue_api/routes/services.clj
+++ b/src/clj/queue_api/routes/services.clj
@@ -8,9 +8,9 @@
(s/defschema new-agent
- {:id s/Str
- :name s/Str
- :primary_skillset [s/Str]
+ {:id s/Str
+ :name s/Str
+ :primary_skillset [s/Str]
:secondary_skillset [s/Str]})
(s/defschema new-job
@@ -55,21 +55,24 @@
(if (nil? (db/agent (:id body)))
(do (db/add-agent body)
{:status 201})
- (bad-request {:message "Agent id already exists"})))}
- :post {:summary "Get summary of an agent"
- :parameters {:body-params agent-id}
+ (bad-request {:message "Agent id already exists"})))}}))
+
+ (context "/agent/:id" []
+ (resource
+ {:tags ["agent"]
+ :get {:summary "Get summary of an agent"
+ :parameters {:path-params {:id s/Str}}
:responses {http-status/ok {:schema agent-sum
:description "Fetched correctly"}
http-status/not-found {:schema error-message
:description "Agent not found"}}
- :handler (fn [{body :body-params}]
- (let [a (:agent_id body)]
- (if-not (nil? (db/agent a))
- (let [jobs (db/sum-agent a)]
- (ok (map (fn [x]
- {:type (first x)
- :jobs (last x)}) jobs)))
- (not-found {:message "Agent does not exist"}))))}}))
+ :handler (fn [{{:keys [id]} :path-params}]
+ (if-not (nil? (db/agent id))
+ (let [jobs (db/sum-agent id)]
+ (ok (map (fn [x]
+ {:type (first x)
+ :jobs (last x)}) jobs)))
+ (not-found {:message "Agent does not exist"})))}}))
(context "/job" []