module Network.Nakadi.EventTypes.EventType
( eventTypeGet
, eventTypeGetR
, eventTypeUpdate
, eventTypeUpdateR
, eventTypeDelete
, eventTypeDeleteR
) where
import Network.Nakadi.Internal.Prelude
import Control.Lens
import Network.Nakadi.Internal.Http
import qualified Network.Nakadi.Internal.Lenses as L
path :: EventTypeName -> ByteString
path eventTypeName = "/event-types/" <> encodeUtf8 (unEventTypeName eventTypeName)
eventTypeGet ::
MonadNakadi m
=> Config
-> EventTypeName
-> m EventType
eventTypeGet config eventTypeName =
httpJsonBody config ok200 [(status404, errorEventTypeNotFound)]
(setRequestMethod "GET"
. setRequestPath (path eventTypeName))
eventTypeGetR ::
MonadNakadiEnv r m
=> EventTypeName
-> m EventType
eventTypeGetR eventTypeName = do
config <- asks (view L.nakadiConfig)
eventTypeGet config eventTypeName
eventTypeUpdate ::
MonadNakadi m
=> Config
-> EventTypeName
-> EventType
-> m ()
eventTypeUpdate config eventTypeName eventType =
httpJsonNoBody config ok200 []
(setRequestMethod "PUT"
. setRequestPath (path eventTypeName)
. setRequestBodyJSON eventType)
eventTypeUpdateR ::
MonadNakadiEnv r m
=> EventTypeName
-> EventType
-> m ()
eventTypeUpdateR eventTypeName eventType = do
config <- asks (view L.nakadiConfig)
eventTypeUpdate config eventTypeName eventType
eventTypeDelete ::
MonadNakadi m
=> Config
-> EventTypeName
-> m ()
eventTypeDelete config eventTypeName =
httpJsonNoBody config ok200 [(status404, errorEventTypeNotFound)]
(setRequestMethod "DELETE" . setRequestPath (path eventTypeName))
eventTypeDeleteR ::
MonadNakadiEnv r m
=> EventTypeName
-> m ()
eventTypeDeleteR eventTypeName = do
config <- asks (view L.nakadiConfig)
eventTypeDelete config eventTypeName