{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
module Network.Livy.Client.Interactive.GetSessionLogs
(
GetSessionLogs (..)
, getSessionLogs
, gslFrom
, gslSize
, GetSessionLogsResponse (..)
, gslrId
, gslrFrom
, gslrSize
, gslrLog
) where
import Control.Lens
import Data.Aeson.TH
import qualified Data.ByteString.Char8 as C
import Data.Maybe (isJust)
import Data.Text (Text)
import Data.Typeable
import Network.Livy.Client.Internal.JSON
import Network.Livy.Client.Types.Session
import Network.Livy.Internal.Text
import Network.Livy.Request
import Network.Livy.Types
data GetSessionLogs = GetSessionLogs
{ _gslSessionId :: SessionId
, _gslFrom :: Maybe Int
, _gslSize :: Maybe Int
} deriving (Eq, Show, Typeable)
makeLenses ''GetSessionLogs
instance ToPath GetSessionLogs where
toPath r = toPath ["sessions", toText $ r ^. gslSessionId, "log"]
instance ToQuery GetSessionLogs where
toQueryString r = filter (isJust . snd)
[ ("from", C.pack . show <$> r ^. gslFrom)
, ("size", C.pack . show <$> r ^. gslSize)
]
instance LivyRequest GetSessionLogs where
request = getQuery
getSessionLogs :: SessionId -> GetSessionLogs
getSessionLogs n = GetSessionLogs n Nothing Nothing
data GetSessionLogsResponse = GetSessionLogsResponse
{ _gslrId :: !Int
, _gslrFrom :: !Int
, _gslrSize :: !(Maybe Int)
, _gslrLog :: ![Text]
} deriving (Eq, Show, Typeable)
makeLenses ''GetSessionLogsResponse
deriveFromJSON (recordPrefixOptions 5) ''GetSessionLogsResponse
type instance LivyResponse GetSessionLogs = GetSessionLogsResponse