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 DataKinds #-}
13 {-# LANGUAGE DeriveGeneric #-}
14 {-# LANGUAGE OverloadedStrings #-}
15 {-# LANGUAGE TypeOperators #-}
17 module Gargantext.API.Admin.Orchestrator.Scrapy.Schedule
22 import Data.Text (Text)
26 import Servant.Job.Utils (jsonOptions)
27 import Web.FormUrlEncoded hiding (parseMaybe)
28 import qualified Data.HashMap.Strict as H
30 ------------------------------------------------------------------------
32 data Schedule = Schedule
35 , s_setting :: ![Text]
36 , s_jobid :: !(Maybe Text)
37 , s_version :: !(Maybe Text)
38 , s_extra :: ![(Text,[Text])]
42 data ScheduleResponse = ScheduleResponse
48 instance FromJSON ScheduleResponse where
49 parseJSON = genericParseJSON (jsonOptions "r_")
51 instance ToForm Schedule where
54 [("project", [s_project s])
55 ,("spider", [s_spider s])
56 ,("setting", s_setting s)
57 ,("jobid", s_jobid s ^.. _Just)
58 ,("_version", s_version s ^.. _Just)
62 "schedule.json" :> ReqBody '[FormUrlEncoded] Schedule
63 :> Post '[JSON] ScheduleResponse
65 scrapyAPI :: Proxy Scrapy
68 scrapySchedule :: Schedule -> ClientM ScheduleResponse
69 scrapySchedule = client scrapyAPI