module Network.Nakadi.EventTypes.Schemas
( eventTypeSchemasGet
, eventTypeSchema
) where
import Network.Nakadi.Internal.Prelude
import Network.Nakadi.Internal.Http
path :: EventTypeName -> Maybe SchemaVersion -> ByteString
path eventTypeName maybeSchemaVersion =
"/event-types/"
<> encodeUtf8 (unEventTypeName eventTypeName)
<> "/schemas"
<> case maybeSchemaVersion of
Just schemaVersion -> "/" <> encodeUtf8 (unSchemaVersion schemaVersion)
Nothing -> ""
eventTypeSchemasGet ::
MonadNakadi b m
=> EventTypeName
-> Maybe Offset
-> Maybe Limit
-> m EventTypeSchemasResponse
eventTypeSchemasGet eventTypeName offset limit =
httpJsonBody ok200 []
(setRequestMethod "GET"
. setRequestPath (path eventTypeName Nothing)
. setRequestQueryParameters [ ("offset", offset')
, ("limit", limit') ])
where offset' = encodeUtf8 (tshow (maybe defaultOffset unOffset offset))
limit' = encodeUtf8 (tshow (maybe defaultLimit unLimit limit))
defaultOffset = 0
defaultLimit = 20
eventTypeSchema ::
MonadNakadi b m
=> EventTypeName
-> SchemaVersion
-> m EventTypeSchema
eventTypeSchema eventTypeName schemaVersion =
httpJsonBody ok200 []
(setRequestMethod "GET"
. setRequestPath (path eventTypeName (Just schemaVersion)))