]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/API/Node/Get.hs
[VERSION] +1 to 0.0.6.1
[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.Types (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 Servant
29 import Test.QuickCheck.Arbitrary
30
31 import Gargantext.API.Prelude
32 import Gargantext.Database.Admin.Types.Node
33 import Gargantext.Database.Prelude (JSONB{-, getNodeWith-})
34 import Gargantext.Prelude
35
36 ------------------------------------------------------------------------
37 type API a = Summary "Polymorphic Get Node Endpoint"
38 :> ReqBody '[JSON] GetNodeParams
39 :> Get '[JSON] (Node a)
40
41 ------------------------------------------------------------------------
42 data GetNodeParams = GetNodeParams { node_id :: NodeId
43 , nodetype :: NodeType
44 }
45 deriving (Generic)
46
47 ----------------------------------------------------------------------
48 api :: forall proxy a.
49 ( JSONB a
50 , FromJSON a
51 , ToJSON a
52 ) => proxy a -> UserId -> NodeId -> GargServer (API a)
53 api _p _uId _nId (GetNodeParams _nId' _nt) = undefined
54
55 ------------------------------------------------------------------------
56 instance FromJSON GetNodeParams where
57 parseJSON = genericParseJSON (defaultOptions { sumEncoding = ObjectWithSingleField })
58
59 instance ToJSON GetNodeParams where
60 toJSON = genericToJSON (defaultOptions { sumEncoding = ObjectWithSingleField })
61
62 instance ToSchema GetNodeParams
63 instance Arbitrary GetNodeParams where
64 arbitrary = GetNodeParams <$> arbitrary <*> arbitrary
65
66 ------------------------------------------------------------------------