{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
module Network.Livy.Client.Batch.GetBatches
(
GetBatches (..)
, getBatches
, gbsFrom
, gbsSize
, GetBatchesResponse (..)
, gbsrFrom
, gbsrSize
, gbsrSessions
) where
import Control.Lens
import Data.Aeson.TH
import qualified Data.ByteString.Char8 as C
import Data.Maybe (isJust)
import Data.Typeable
import Network.Livy.Client.Internal.JSON
import Network.Livy.Client.Types.Batch
import Network.Livy.Request
import Network.Livy.Types
data GetBatches = GetBatches
{ _gbsFrom :: Maybe Int
, _gbsSize :: Maybe Int
} deriving (Eq, Show, Typeable)
makeLenses ''GetBatches
instance ToPath GetBatches where
toPath = const "batches"
instance ToQuery GetBatches where
toQueryString r = filter (isJust . snd)
[ ("from", C.pack . show <$> r ^. gbsFrom)
, ("size", C.pack . show <$> r ^. gbsSize)
]
instance LivyRequest GetBatches where
request = getQuery
getBatches :: GetBatches
getBatches = GetBatches Nothing Nothing
data GetBatchesResponse = GetBatchesResponse
{ _gbsrFrom :: !Int
, _gbsrSize :: !(Maybe Int)
, _gbsrSessions :: ![Batch]
} deriving (Eq, Show, Typeable)
makeLenses ''GetBatchesResponse
deriveFromJSON (recordPrefixOptions 5) ''GetBatchesResponse
type instance LivyResponse GetBatches = GetBatchesResponse