aboutsummaryrefslogtreecommitdiff
path: root/src/clj/queue_api/routes
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2018-02-17 16:03:31 -0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2018-02-17 16:03:31 -0200
commit2198d8990da4535b6d81cf7008b85e5c14c3e0f3 (patch)
tree11a10f78a7b50fead0d66ed757a063b6f1d21e9d /src/clj/queue_api/routes
parent6f30892a02a3feff164b1c26805cb35a54475726 (diff)
downloadqueue-api-2198d8990da4535b6d81cf7008b85e5c14c3e0f3.tar.gz
queue-api-2198d8990da4535b6d81cf7008b85e5c14c3e0f3.tar.bz2
queue-api-2198d8990da4535b6d81cf7008b85e5c14c3e0f3.zip
Adds service endpoints
Diffstat (limited to 'src/clj/queue_api/routes')
-rw-r--r--src/clj/queue_api/routes/services.clj74
1 files changed, 41 insertions, 33 deletions
diff --git a/src/clj/queue_api/routes/services.clj b/src/clj/queue_api/routes/services.clj
index cc8ac04..326ee68 100644
--- a/src/clj/queue_api/routes/services.clj
+++ b/src/clj/queue_api/routes/services.clj
@@ -1,44 +1,52 @@
(ns queue-api.routes.services
(:require [ring.util.http-response :refer :all]
[compojure.api.sweet :refer :all]
- [schema.core :as s]))
+ [schema.core :as s]
+ [queue-api.db.core :as db]))
(defapi service-routes
- {:swagger {:ui "/swagger-ui"
+ {:swagger {:ui "/swagger-ui"
:spec "/swagger.json"
- :data {:info {:version "1.0.0"
- :title "Sample API"
- :description "Sample Services"}}}}
-
- (context "/api" []
- :tags ["thingie"]
+ :data {:info {:version "1.0.0"
+ :title "Job Queue API"
+ :description "Manages agent resources"}}}}
- (GET "/plus" []
- :return Long
- :query-params [x :- Long, {y :- Long 1}]
- :summary "x+y with query-parameters. y defaults to 1."
- (ok (+ x y)))
+ (context "/agent" []
+ (PUT "/" []
+ :body-params [id :- String, name :- String, primary_skillset :- [String], secondary_skillset :- [String]]
+ :summary "Add a new agent"
+ (db/add-agent
+ {:id id
+ :name name
+ :primary-skillset primary_skillset
+ :secondary-skillset secondary_skillset})
+ (ok))
+ (POST "/" []
+ :return [{:type String :jobs s/Int}]
+ :body-params [agent_id :- String]
+ :summary "Get a summary of an agent"
+ (ok (db/get-agent agent_id))))
- (POST "/minus" []
- :return Long
- :body-params [x :- Long, y :- Long]
- :summary "x-y with body-parameters."
- (ok (- x y)))
+ (context "/job" []
+ (PUT "/" []
+ :body-params [id :- String, type :- String, urgent :- Boolean]
+ :summary "Add a new job"
+ (db/add-job {:id id
+ :type type
+ :urgent urgent})
+ (ok))
+ (POST "/" []
+ :return {:job_request {:job_id String :agent_id String}}
+ :body-params [agent_id :- String]
+ :summary "Request a job for a agent"
+ (ok (db/request-job agent_id))))
- (GET "/times/:x/:y" []
- :return Long
- :path-params [x :- Long, y :- Long]
- :summary "x*y with path-parameters"
- (ok (* x y)))
+ (context "/queue" []
+ (GET "/" []
+ :return {:completed [String]
+ :in_process[String]
+ :waiting [String]}
+ :summary "Get a summary of an agent"
+ (ok (db/get-queue)))))
- (POST "/divide" []
- :return Double
- :form-params [x :- Long, y :- Long]
- :summary "x/y with form-parameters"
- (ok (/ x y)))
- (GET "/power" []
- :return Long
- :header-params [x :- Long, y :- Long]
- :summary "x^y with header-parameters"
- (ok (long (Math/pow x y))))))