aboutsummaryrefslogtreecommitdiff
path: root/src
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
parent6f30892a02a3feff164b1c26805cb35a54475726 (diff)
downloadqueue-api-2198d8990da4535b6d81cf7008b85e5c14c3e0f3.tar.gz
queue-api-2198d8990da4535b6d81cf7008b85e5c14c3e0f3.tar.bz2
queue-api-2198d8990da4535b6d81cf7008b85e5c14c3e0f3.zip
Adds service endpoints
Diffstat (limited to 'src')
-rw-r--r--src/clj/queue_api/db/core.clj20
-rw-r--r--src/clj/queue_api/routes/services.clj74
2 files changed, 61 insertions, 33 deletions
diff --git a/src/clj/queue_api/db/core.clj b/src/clj/queue_api/db/core.clj
new file mode 100644
index 0000000..2d32736
--- /dev/null
+++ b/src/clj/queue_api/db/core.clj
@@ -0,0 +1,20 @@
+(ns queue-api.db.core)
+
+
+(defn add-agent [{:keys [id name primary-skillset secondary-skillset]}]
+ (println (str "Dummy " name)))
+
+(defn add-job [{:keys [id type urgent]}]
+ (println (str "Dummy " type)))
+
+(defn request-job [id]
+ {:job_request {:job_id "Dummy" :agent_id "Dummy"}})
+
+(defn get-agent [id]
+ [{:type "reward_question" :jobs 2}
+ {:type "bills_question" :jobs 3}])
+
+(defn get-queue []
+ {:completed ["1" "2" "3"]
+ :in_process["2" "3" "4"]
+ :waiting ["2" "5" "6"]}) \ No newline at end of file
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))))))