{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Network.Nakadi.EventTypes.EventType
( eventTypeGet
, eventTypeUpdate
, eventTypeDelete
)
where
import Network.Nakadi.Internal.Prelude
import Network.Nakadi.Internal.Http
path :: EventTypeName -> ByteString
path eventTypeName = "/event-types/" <> encodeUtf8 (unEventTypeName eventTypeName)
eventTypeGet
:: MonadNakadi b m
=> EventTypeName
-> m EventType
eventTypeGet eventTypeName = do
config <- nakadiAsk
httpJsonBody
ok200
[(status404, errorEventTypeNotFound)]
(setRequestMethod "GET" . includeFlowId config . setRequestPath (path eventTypeName))
eventTypeUpdate
:: MonadNakadi b m
=> EventTypeName
-> EventType
-> m ()
eventTypeUpdate eventTypeName eventType = do
config <- nakadiAsk
httpJsonNoBody
ok200
[]
( setRequestMethod "PUT"
. includeFlowId config
. setRequestPath (path eventTypeName)
. setRequestBodyJSON eventType
)
eventTypeDelete
:: MonadNakadi b m
=> EventTypeName
-> m ()
eventTypeDelete eventTypeName = do
config <- nakadiAsk
httpJsonNoBody
ok200
[(status404, errorEventTypeNotFound)]
(setRequestMethod "DELETE" . includeFlowId config . setRequestPath (path eventTypeName))