]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/API/Node/Get.hs
Merge branch 'dev' of ssh://gitlab.iscpif.fr:20022/gargantext/haskell-gargantext...
[gargantext.git] / src / Gargantext / API / Node / Get.hs
1 {-|
2 Module : Gargantext.API.Node.Get
3 Description :
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 Polymorphic Get Node API
11
12 -}
13
14 {-# LANGUAGE TemplateHaskell #-}
15 {-# LANGUAGE TypeOperators #-}
16 {-# OPTIONS_GHC -fno-warn-orphans #-}
17
18 module Gargantext.API.Node.Get
19 where
20
21 -- import Gargantext.API.Admin.Settings (HasSettings)
22 -- import Servant.Job.Async (JobFunction(..), serveJobsAPI)
23 -- import Test.QuickCheck (elements)
24 -- import Gargantext.Database.Action.Flow.Types (FlowCmdM)
25 import Data.Aeson
26 import Data.Swagger
27 import GHC.Generics (Generic)
28 import Gargantext.API.Prelude
29 import Gargantext.Database.Admin.Types.Node
30 import Gargantext.Database.Query.Table.Node (JSONB{-, getNodeWith-})
31 import Gargantext.Prelude
32 import Servant
33 import Test.QuickCheck.Arbitrary
34
35 ------------------------------------------------------------------------
36 type API a = Summary "Polymorphic Get Node Endpoint"
37 :> ReqBody '[JSON] GetNodeParams
38 :> Get '[JSON] (Node a)
39
40 ------------------------------------------------------------------------
41 data GetNodeParams = GetNodeParams { node_id :: NodeId
42 , nodetype :: NodeType
43 }
44 deriving (Generic)
45
46 ----------------------------------------------------------------------
47 api :: forall proxy a.
48 ( JSONB a
49 , FromJSON a
50 , ToJSON a
51 ) => proxy a -> UserId -> NodeId -> GargServer (API a)
52 api _p _uId _nId (GetNodeParams _nId' _nt) = undefined
53
54 ------------------------------------------------------------------------
55 instance FromJSON GetNodeParams where
56 parseJSON = genericParseJSON (defaultOptions { sumEncoding = ObjectWithSingleField })
57
58 instance ToJSON GetNodeParams where
59 toJSON = genericToJSON (defaultOptions { sumEncoding = ObjectWithSingleField })
60
61 instance ToSchema GetNodeParams
62 instance Arbitrary GetNodeParams where
63 arbitrary = GetNodeParams <$> arbitrary <*> arbitrary
64
65 ------------------------------------------------------------------------