From 2198d8990da4535b6d81cf7008b85e5c14c3e0f3 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Sat, 17 Feb 2018 16:03:31 -0200 Subject: Adds service endpoints --- src/clj/queue_api/routes/services.clj | 74 +++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 33 deletions(-) (limited to 'src/clj/queue_api/routes/services.clj') 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)))))) -- cgit v1.2.3