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
23 import Servant.Job.Utils (jsonOptions)
24 import Web.FormUrlEncoded hiding (parseMaybe)
25 import qualified Data.HashMap.Strict as H
27 ------------------------------------------------------------------------
29 data Schedule = Schedule
32 , s_setting :: ![Text]
33 , s_jobid :: !(Maybe Text)
34 , s_version :: !(Maybe Text)
35 , s_extra :: ![(Text,[Text])]
39 data ScheduleResponse = ScheduleResponse
45 instance FromJSON ScheduleResponse where
46 parseJSON = genericParseJSON (jsonOptions "r_")
48 instance ToForm Schedule where
51 [("project", [s_project s])
52 ,("spider", [s_spider s])
53 ,("setting", s_setting s)
54 ,("jobid", s_jobid s ^.. _Just)
55 ,("_version", s_version s ^.. _Just)
59 "schedule.json" :> ReqBody '[FormUrlEncoded] Schedule
60 :> Post '[JSON] ScheduleResponse
62 scrapyAPI :: Proxy Scrapy
65 scrapySchedule :: Schedule -> ClientM ScheduleResponse
66 scrapySchedule = client scrapyAPI