2 Module : Gargantext.API.Admin.Orchestartor.Scrapy.Schedule
3 Description : Server API Auth Module
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
12 {-# LANGUAGE TypeOperators #-}
14 module Gargantext.API.Admin.Orchestrator.Scrapy.Schedule
19 import Data.Text (Text)
24 import Servant.Job.Utils (jsonOptions)
25 import Web.FormUrlEncoded hiding (parseMaybe)
26 import qualified Data.HashMap.Strict as H
28 ------------------------------------------------------------------------
30 data Schedule = Schedule
33 , s_setting :: ![Text]
34 , s_jobid :: !(Maybe Text)
35 , s_version :: !(Maybe Text)
36 , s_extra :: ![(Text,[Text])]
40 data ScheduleResponse = ScheduleResponse
46 instance FromJSON ScheduleResponse where
47 parseJSON = genericParseJSON (jsonOptions "r_")
49 instance ToForm Schedule where
52 [("project", [s_project s])
53 ,("spider", [s_spider s])
54 ,("setting", s_setting s)
55 ,("jobid", s_jobid s ^.. _Just)
56 ,("_version", s_version s ^.. _Just)
60 "schedule.json" :> ReqBody '[FormUrlEncoded] Schedule
61 :> Post '[JSON] ScheduleResponse
63 scrapyAPI :: Proxy Scrapy
66 scrapySchedule :: Schedule -> ClientM ScheduleResponse
67 scrapySchedule = client scrapyAPI