module Network.Nakadi.EventTypes.Partitions
( eventTypePartitions
, eventTypePartitionsR
, eventTypePartition
, eventTypePartitionR
) where
import Network.Nakadi.Internal.Prelude
import Control.Lens
import Network.Nakadi.Internal.Http
import qualified Network.Nakadi.Internal.Lenses as L
path :: EventTypeName -> Maybe PartitionName -> ByteString
path eventTypeName maybePartitionName =
"/event-types/"
<> encodeUtf8 (unEventTypeName eventTypeName)
<> "/partitions"
<> (case maybePartitionName of
Just partitionName -> "/" <> encodeUtf8 (unPartitionName partitionName)
Nothing -> "")
eventTypePartitions ::
MonadNakadi m
=> Config
-> EventTypeName
-> m [Partition]
eventTypePartitions config eventTypeName =
httpJsonBody config ok200 [(status404, errorEventTypeNotFound)]
(setRequestPath (path eventTypeName Nothing))
eventTypePartitionsR ::
MonadNakadiEnv r m
=> EventTypeName
-> m [Partition]
eventTypePartitionsR eventTypeName = do
config <- asks (view L.nakadiConfig)
eventTypePartitions config eventTypeName
eventTypePartition ::
MonadNakadi m
=> Config
-> EventTypeName
-> PartitionName
-> m Partition
eventTypePartition config eventTypeName partitionName =
httpJsonBody config ok200 []
(setRequestPath (path eventTypeName (Just partitionName)))
eventTypePartitionR ::
MonadNakadiEnv r m
=> EventTypeName
-> PartitionName
-> m Partition
eventTypePartitionR eventTypeName partitionName = do
config <- asks (view L.nakadiConfig)
eventTypePartition config eventTypeName partitionName