{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
module Network.Livy.Client.Interactive.RunStatement
(
RunStatement (..)
, runStatement
, rsSessionId
, rsCode
, rsKind
, RunStatementResponse (..)
, rsrStatement
) where
import Control.Lens
import Data.Aeson
import Data.Aeson.TH
import Data.Text (Text)
import Data.Typeable
import Network.Livy.Client.Types.Session
import Network.Livy.Client.Types.Statement
import Network.Livy.Internal.Text
import Network.Livy.Request
import Network.Livy.Types
data RunStatement = RunStatement
{ _rsSessionId :: SessionId
, _rsCode :: Text
, _rsKind :: SessionKind
} deriving (Eq, Show, Typeable)
makeLenses ''RunStatement
instance ToPath RunStatement where
toPath r = toPath ["sessions", toText $ r ^. rsSessionId, "statements"]
instance LivyRequest RunStatement where
request r = postBody r [("code", r ^. rsCode), ("kind", toText $ r ^. rsKind)]
runStatement :: SessionId -> Text -> SessionKind -> RunStatement
runStatement = RunStatement
newtype RunStatementResponse = RunStatementResponse
{ _rsrStatement :: Statement
} deriving (Eq, Show, Typeable)
makeLenses ''RunStatementResponse
deriveFromJSON (defaultOptions { unwrapUnaryRecords = True }) ''RunStatementResponse
type instance LivyResponse RunStatement = RunStatementResponse