{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
module Network.Livy.Client.Batch.CreateBatch
(
CreateBatch (..)
, createBatch
, cbFile
, cbProxyUser
, cbClassName
, cbArgs
, cbJars
, cbPyFiles
, cbFiles
, cbDriverMemory
, cbDriverCores
, cbExecutorMemory
, cbExecutorCores
, cbNumExecutors
, cbArchives
, cbQueue
, cbName
, cbConf
, cbHeartbeatTimeoutInSecond
, CreateBatchResponse (..)
, cbrBatch
) where
import Control.Lens
import Data.Aeson.TH
import qualified Data.HashMap.Strict as Map
import Data.Text (Text)
import Data.Typeable
import Network.Livy.Client.Internal.JSON
import Network.Livy.Client.Types.Batch
import Network.Livy.Request
import Network.Livy.Types
data CreateBatch = CreateBatch
{ _cbFile :: Text
, _cbProxyUser :: Maybe Text
, _cbClassName :: Maybe Text
, _cbArgs :: Maybe [Text]
, _cbJars :: Maybe [Text]
, _cbPyFiles :: Maybe [Text]
, _cbFiles :: Maybe [Text]
, _cbDriverMemory :: Maybe Text
, _cbDriverCores :: Maybe Int
, _cbExecutorMemory :: Maybe Text
, _cbExecutorCores :: Maybe Int
, _cbNumExecutors :: Maybe Int
, _cbArchives :: Maybe [Text]
, _cbQueue :: Maybe Text
, _cbName :: Maybe Text
, _cbConf :: Maybe (Map.HashMap Text Text)
, _cbHeartbeatTimeoutInSecond :: Maybe Int
} deriving (Eq, Show, Typeable)
makeLenses ''CreateBatch
deriveToJSON ((recordPrefixOptions 3) { omitNothingFields = True }) ''CreateBatch
instance ToPath CreateBatch where
toPath = const "batches"
instance LivyRequest CreateBatch where
request = postJSON
createBatch :: Text -> CreateBatch
createBatch f = CreateBatch
{ _cbFile = f
, _cbProxyUser = Nothing
, _cbClassName = Nothing
, _cbArgs = Nothing
, _cbJars = Nothing
, _cbPyFiles = Nothing
, _cbFiles = Nothing
, _cbDriverMemory = Nothing
, _cbDriverCores = Nothing
, _cbExecutorMemory = Nothing
, _cbExecutorCores = Nothing
, _cbNumExecutors = Nothing
, _cbArchives = Nothing
, _cbQueue = Nothing
, _cbName = Nothing
, _cbConf = Nothing
, _cbHeartbeatTimeoutInSecond = Nothing
}
newtype CreateBatchResponse = CreateBatchResponse
{ _cbrBatch :: Batch
} deriving (Eq, Show, Typeable)
makeLenses ''CreateBatchResponse
deriveFromJSON (defaultOptions { unwrapUnaryRecords = True }) ''CreateBatchResponse
type instance LivyResponse CreateBatch = CreateBatchResponse