]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/API/Node/Get.hs
[Folder view API] Don't return parent folder in teams
[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 Data.Aeson
22 import Data.Swagger
23 import GHC.Generics (Generic)
24 import Servant
25 import Test.QuickCheck.Arbitrary
26
27 import Gargantext.API.Prelude
28 import Gargantext.Database.Admin.Types.Node
29 import Gargantext.Database.Prelude (JSONB)
30 import Gargantext.Prelude
31
32 ------------------------------------------------------------------------
33 type API a = Summary "Polymorphic Get Node Endpoint"
34 :> ReqBody '[JSON] GetNodeParams
35 :> Get '[JSON] (Node a)
36
37 ------------------------------------------------------------------------
38 data GetNodeParams = GetNodeParams { node_id :: NodeId
39 , nodetype :: NodeType
40 }
41 deriving (Generic)
42
43 ----------------------------------------------------------------------
44 api :: forall proxy a.
45 ( JSONB a
46 , FromJSON a
47 , ToJSON a
48 ) => proxy a -> UserId -> NodeId -> GargServer (API a)
49 api _p _uId _nId (GetNodeParams _nId' _nt) = undefined
50
51 ------------------------------------------------------------------------
52 instance FromJSON GetNodeParams where
53 parseJSON = genericParseJSON (defaultOptions { sumEncoding = ObjectWithSingleField })
54
55 instance ToJSON GetNodeParams where
56 toJSON = genericToJSON (defaultOptions { sumEncoding = ObjectWithSingleField })
57
58 instance ToSchema GetNodeParams
59 instance Arbitrary GetNodeParams where
60 arbitrary = GetNodeParams <$> arbitrary <*> arbitrary
61
62 ------------------------------------------------------------------------