module Network.Nakadi.Subscriptions.Subscription
( subscriptionGet
, subscriptionGetR
, subscriptionDelete
, subscriptionDeleteR
) where
import Network.Nakadi.Internal.Prelude
import Control.Lens
import Network.Nakadi.Internal.Conversions
import Network.Nakadi.Internal.Http
import qualified Network.Nakadi.Internal.Lenses as L
path :: SubscriptionId -> ByteString
path subscriptionId =
"/subscriptions/"
<> subscriptionIdToByteString subscriptionId
subscriptionGet ::
MonadNakadi m
=> Config
-> SubscriptionId
-> m Subscription
subscriptionGet config subscriptionId =
httpJsonBody config ok200 [(status404, errorSubscriptionNotFound)]
(setRequestMethod "GET" . setRequestPath (path subscriptionId))
subscriptionGetR ::
MonadNakadiEnv r m
=> SubscriptionId
-> m Subscription
subscriptionGetR subscriptionId = do
config <- asks (view L.nakadiConfig)
subscriptionGet config subscriptionId
subscriptionDelete ::
MonadNakadi m
=> Config
-> SubscriptionId
-> m ()
subscriptionDelete config subscriptionId =
httpJsonNoBody config status204 [(status404, errorSubscriptionNotFound)]
(setRequestMethod "DELETE" . setRequestPath (path subscriptionId))
subscriptionDeleteR ::
MonadNakadiEnv r m
=> SubscriptionId
-> m ()
subscriptionDeleteR subscriptionId = do
config <- asks (view L.nakadiConfig)
subscriptionDelete config subscriptionId