module Network.Nakadi.EventTypes.Partitions
( eventTypePartitions
, eventTypePartition
) where
import Network.Nakadi.Internal.Http
import Network.Nakadi.Internal.Prelude
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 b m
=> EventTypeName
-> m [Partition]
eventTypePartitions eventTypeName = do
config <- nakadiAsk
httpJsonBody ok200 [(status404, errorEventTypeNotFound)] $
(includeFlowId config
. setRequestPath (path eventTypeName Nothing))
eventTypePartition
:: MonadNakadi b m
=> EventTypeName
-> PartitionName
-> m Partition
eventTypePartition eventTypeName partitionName = do
config <- nakadiAsk
httpJsonBody ok200 [] $
(includeFlowId config
. setRequestPath (path eventTypeName (Just partitionName)))