{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Kinesis.DeregisterStreamConsumer
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- To deregister a consumer, provide its ARN. Alternatively, you can
-- provide the ARN of the data stream and the name you gave the consumer
-- when you registered it. You may also provide all three parameters, as
-- long as they don\'t conflict with each other. If you don\'t know the
-- name or ARN of the consumer that you want to deregister, you can use the
-- ListStreamConsumers operation to get a list of the descriptions of all
-- the consumers that are currently registered with a given data stream.
-- The description of a consumer contains its name and ARN.
--
-- This operation has a limit of five transactions per second per stream.
module Amazonka.Kinesis.DeregisterStreamConsumer
  ( -- * Creating a Request
    DeregisterStreamConsumer (..),
    newDeregisterStreamConsumer,

    -- * Request Lenses
    deregisterStreamConsumer_consumerARN,
    deregisterStreamConsumer_streamARN,
    deregisterStreamConsumer_consumerName,

    -- * Destructuring the Response
    DeregisterStreamConsumerResponse (..),
    newDeregisterStreamConsumerResponse,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Kinesis.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeregisterStreamConsumer' smart constructor.
data DeregisterStreamConsumer = DeregisterStreamConsumer'
  { -- | The ARN returned by Kinesis Data Streams when you registered the
    -- consumer. If you don\'t know the ARN of the consumer that you want to
    -- deregister, you can use the ListStreamConsumers operation to get a list
    -- of the descriptions of all the consumers that are currently registered
    -- with a given data stream. The description of a consumer contains its
    -- ARN.
    DeregisterStreamConsumer -> Maybe Text
consumerARN :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the Kinesis data stream that the consumer is registered with.
    -- For more information, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-kinesis-streams Amazon Resource Names (ARNs) and AWS Service Namespaces>.
    DeregisterStreamConsumer -> Maybe Text
streamARN :: Prelude.Maybe Prelude.Text,
    -- | The name that you gave to the consumer.
    DeregisterStreamConsumer -> Maybe Text
consumerName :: Prelude.Maybe Prelude.Text
  }
  deriving (DeregisterStreamConsumer -> DeregisterStreamConsumer -> Bool
(DeregisterStreamConsumer -> DeregisterStreamConsumer -> Bool)
-> (DeregisterStreamConsumer -> DeregisterStreamConsumer -> Bool)
-> Eq DeregisterStreamConsumer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterStreamConsumer -> DeregisterStreamConsumer -> Bool
$c/= :: DeregisterStreamConsumer -> DeregisterStreamConsumer -> Bool
== :: DeregisterStreamConsumer -> DeregisterStreamConsumer -> Bool
$c== :: DeregisterStreamConsumer -> DeregisterStreamConsumer -> Bool
Prelude.Eq, ReadPrec [DeregisterStreamConsumer]
ReadPrec DeregisterStreamConsumer
Int -> ReadS DeregisterStreamConsumer
ReadS [DeregisterStreamConsumer]
(Int -> ReadS DeregisterStreamConsumer)
-> ReadS [DeregisterStreamConsumer]
-> ReadPrec DeregisterStreamConsumer
-> ReadPrec [DeregisterStreamConsumer]
-> Read DeregisterStreamConsumer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterStreamConsumer]
$creadListPrec :: ReadPrec [DeregisterStreamConsumer]
readPrec :: ReadPrec DeregisterStreamConsumer
$creadPrec :: ReadPrec DeregisterStreamConsumer
readList :: ReadS [DeregisterStreamConsumer]
$creadList :: ReadS [DeregisterStreamConsumer]
readsPrec :: Int -> ReadS DeregisterStreamConsumer
$creadsPrec :: Int -> ReadS DeregisterStreamConsumer
Prelude.Read, Int -> DeregisterStreamConsumer -> ShowS
[DeregisterStreamConsumer] -> ShowS
DeregisterStreamConsumer -> String
(Int -> DeregisterStreamConsumer -> ShowS)
-> (DeregisterStreamConsumer -> String)
-> ([DeregisterStreamConsumer] -> ShowS)
-> Show DeregisterStreamConsumer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterStreamConsumer] -> ShowS
$cshowList :: [DeregisterStreamConsumer] -> ShowS
show :: DeregisterStreamConsumer -> String
$cshow :: DeregisterStreamConsumer -> String
showsPrec :: Int -> DeregisterStreamConsumer -> ShowS
$cshowsPrec :: Int -> DeregisterStreamConsumer -> ShowS
Prelude.Show, (forall x.
 DeregisterStreamConsumer -> Rep DeregisterStreamConsumer x)
-> (forall x.
    Rep DeregisterStreamConsumer x -> DeregisterStreamConsumer)
-> Generic DeregisterStreamConsumer
forall x.
Rep DeregisterStreamConsumer x -> DeregisterStreamConsumer
forall x.
DeregisterStreamConsumer -> Rep DeregisterStreamConsumer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeregisterStreamConsumer x -> DeregisterStreamConsumer
$cfrom :: forall x.
DeregisterStreamConsumer -> Rep DeregisterStreamConsumer x
Prelude.Generic)

-- |
-- Create a value of 'DeregisterStreamConsumer' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'consumerARN', 'deregisterStreamConsumer_consumerARN' - The ARN returned by Kinesis Data Streams when you registered the
-- consumer. If you don\'t know the ARN of the consumer that you want to
-- deregister, you can use the ListStreamConsumers operation to get a list
-- of the descriptions of all the consumers that are currently registered
-- with a given data stream. The description of a consumer contains its
-- ARN.
--
-- 'streamARN', 'deregisterStreamConsumer_streamARN' - The ARN of the Kinesis data stream that the consumer is registered with.
-- For more information, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-kinesis-streams Amazon Resource Names (ARNs) and AWS Service Namespaces>.
--
-- 'consumerName', 'deregisterStreamConsumer_consumerName' - The name that you gave to the consumer.
newDeregisterStreamConsumer ::
  DeregisterStreamConsumer
newDeregisterStreamConsumer :: DeregisterStreamConsumer
newDeregisterStreamConsumer =
  DeregisterStreamConsumer' :: Maybe Text -> Maybe Text -> Maybe Text -> DeregisterStreamConsumer
DeregisterStreamConsumer'
    { $sel:consumerARN:DeregisterStreamConsumer' :: Maybe Text
consumerARN =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:streamARN:DeregisterStreamConsumer' :: Maybe Text
streamARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:consumerName:DeregisterStreamConsumer' :: Maybe Text
consumerName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN returned by Kinesis Data Streams when you registered the
-- consumer. If you don\'t know the ARN of the consumer that you want to
-- deregister, you can use the ListStreamConsumers operation to get a list
-- of the descriptions of all the consumers that are currently registered
-- with a given data stream. The description of a consumer contains its
-- ARN.
deregisterStreamConsumer_consumerARN :: Lens.Lens' DeregisterStreamConsumer (Prelude.Maybe Prelude.Text)
deregisterStreamConsumer_consumerARN :: (Maybe Text -> f (Maybe Text))
-> DeregisterStreamConsumer -> f DeregisterStreamConsumer
deregisterStreamConsumer_consumerARN = (DeregisterStreamConsumer -> Maybe Text)
-> (DeregisterStreamConsumer
    -> Maybe Text -> DeregisterStreamConsumer)
-> Lens
     DeregisterStreamConsumer
     DeregisterStreamConsumer
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterStreamConsumer' {Maybe Text
consumerARN :: Maybe Text
$sel:consumerARN:DeregisterStreamConsumer' :: DeregisterStreamConsumer -> Maybe Text
consumerARN} -> Maybe Text
consumerARN) (\s :: DeregisterStreamConsumer
s@DeregisterStreamConsumer' {} Maybe Text
a -> DeregisterStreamConsumer
s {$sel:consumerARN:DeregisterStreamConsumer' :: Maybe Text
consumerARN = Maybe Text
a} :: DeregisterStreamConsumer)

-- | The ARN of the Kinesis data stream that the consumer is registered with.
-- For more information, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-kinesis-streams Amazon Resource Names (ARNs) and AWS Service Namespaces>.
deregisterStreamConsumer_streamARN :: Lens.Lens' DeregisterStreamConsumer (Prelude.Maybe Prelude.Text)
deregisterStreamConsumer_streamARN :: (Maybe Text -> f (Maybe Text))
-> DeregisterStreamConsumer -> f DeregisterStreamConsumer
deregisterStreamConsumer_streamARN = (DeregisterStreamConsumer -> Maybe Text)
-> (DeregisterStreamConsumer
    -> Maybe Text -> DeregisterStreamConsumer)
-> Lens
     DeregisterStreamConsumer
     DeregisterStreamConsumer
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterStreamConsumer' {Maybe Text
streamARN :: Maybe Text
$sel:streamARN:DeregisterStreamConsumer' :: DeregisterStreamConsumer -> Maybe Text
streamARN} -> Maybe Text
streamARN) (\s :: DeregisterStreamConsumer
s@DeregisterStreamConsumer' {} Maybe Text
a -> DeregisterStreamConsumer
s {$sel:streamARN:DeregisterStreamConsumer' :: Maybe Text
streamARN = Maybe Text
a} :: DeregisterStreamConsumer)

-- | The name that you gave to the consumer.
deregisterStreamConsumer_consumerName :: Lens.Lens' DeregisterStreamConsumer (Prelude.Maybe Prelude.Text)
deregisterStreamConsumer_consumerName :: (Maybe Text -> f (Maybe Text))
-> DeregisterStreamConsumer -> f DeregisterStreamConsumer
deregisterStreamConsumer_consumerName = (DeregisterStreamConsumer -> Maybe Text)
-> (DeregisterStreamConsumer
    -> Maybe Text -> DeregisterStreamConsumer)
-> Lens
     DeregisterStreamConsumer
     DeregisterStreamConsumer
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterStreamConsumer' {Maybe Text
consumerName :: Maybe Text
$sel:consumerName:DeregisterStreamConsumer' :: DeregisterStreamConsumer -> Maybe Text
consumerName} -> Maybe Text
consumerName) (\s :: DeregisterStreamConsumer
s@DeregisterStreamConsumer' {} Maybe Text
a -> DeregisterStreamConsumer
s {$sel:consumerName:DeregisterStreamConsumer' :: Maybe Text
consumerName = Maybe Text
a} :: DeregisterStreamConsumer)

instance Core.AWSRequest DeregisterStreamConsumer where
  type
    AWSResponse DeregisterStreamConsumer =
      DeregisterStreamConsumerResponse
  request :: DeregisterStreamConsumer -> Request DeregisterStreamConsumer
request = Service
-> DeregisterStreamConsumer -> Request DeregisterStreamConsumer
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeregisterStreamConsumer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeregisterStreamConsumer)))
response =
    AWSResponse DeregisterStreamConsumer
-> Logger
-> Service
-> Proxy DeregisterStreamConsumer
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeregisterStreamConsumer)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse DeregisterStreamConsumer
DeregisterStreamConsumerResponse
DeregisterStreamConsumerResponse'

instance Prelude.Hashable DeregisterStreamConsumer

instance Prelude.NFData DeregisterStreamConsumer

instance Core.ToHeaders DeregisterStreamConsumer where
  toHeaders :: DeregisterStreamConsumer -> [Header]
toHeaders =
    [Header] -> DeregisterStreamConsumer -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"Kinesis_20131202.DeregisterStreamConsumer" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DeregisterStreamConsumer where
  toJSON :: DeregisterStreamConsumer -> Value
toJSON DeregisterStreamConsumer' {Maybe Text
consumerName :: Maybe Text
streamARN :: Maybe Text
consumerARN :: Maybe Text
$sel:consumerName:DeregisterStreamConsumer' :: DeregisterStreamConsumer -> Maybe Text
$sel:streamARN:DeregisterStreamConsumer' :: DeregisterStreamConsumer -> Maybe Text
$sel:consumerARN:DeregisterStreamConsumer' :: DeregisterStreamConsumer -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ConsumerARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
consumerARN,
            (Text
"StreamARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
streamARN,
            (Text
"ConsumerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
consumerName
          ]
      )

instance Core.ToPath DeregisterStreamConsumer where
  toPath :: DeregisterStreamConsumer -> ByteString
toPath = ByteString -> DeregisterStreamConsumer -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery DeregisterStreamConsumer where
  toQuery :: DeregisterStreamConsumer -> QueryString
toQuery = QueryString -> DeregisterStreamConsumer -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newDeregisterStreamConsumerResponse' smart constructor.
data DeregisterStreamConsumerResponse = DeregisterStreamConsumerResponse'
  {
  }
  deriving (DeregisterStreamConsumerResponse
-> DeregisterStreamConsumerResponse -> Bool
(DeregisterStreamConsumerResponse
 -> DeregisterStreamConsumerResponse -> Bool)
-> (DeregisterStreamConsumerResponse
    -> DeregisterStreamConsumerResponse -> Bool)
-> Eq DeregisterStreamConsumerResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterStreamConsumerResponse
-> DeregisterStreamConsumerResponse -> Bool
$c/= :: DeregisterStreamConsumerResponse
-> DeregisterStreamConsumerResponse -> Bool
== :: DeregisterStreamConsumerResponse
-> DeregisterStreamConsumerResponse -> Bool
$c== :: DeregisterStreamConsumerResponse
-> DeregisterStreamConsumerResponse -> Bool
Prelude.Eq, ReadPrec [DeregisterStreamConsumerResponse]
ReadPrec DeregisterStreamConsumerResponse
Int -> ReadS DeregisterStreamConsumerResponse
ReadS [DeregisterStreamConsumerResponse]
(Int -> ReadS DeregisterStreamConsumerResponse)
-> ReadS [DeregisterStreamConsumerResponse]
-> ReadPrec DeregisterStreamConsumerResponse
-> ReadPrec [DeregisterStreamConsumerResponse]
-> Read DeregisterStreamConsumerResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterStreamConsumerResponse]
$creadListPrec :: ReadPrec [DeregisterStreamConsumerResponse]
readPrec :: ReadPrec DeregisterStreamConsumerResponse
$creadPrec :: ReadPrec DeregisterStreamConsumerResponse
readList :: ReadS [DeregisterStreamConsumerResponse]
$creadList :: ReadS [DeregisterStreamConsumerResponse]
readsPrec :: Int -> ReadS DeregisterStreamConsumerResponse
$creadsPrec :: Int -> ReadS DeregisterStreamConsumerResponse
Prelude.Read, Int -> DeregisterStreamConsumerResponse -> ShowS
[DeregisterStreamConsumerResponse] -> ShowS
DeregisterStreamConsumerResponse -> String
(Int -> DeregisterStreamConsumerResponse -> ShowS)
-> (DeregisterStreamConsumerResponse -> String)
-> ([DeregisterStreamConsumerResponse] -> ShowS)
-> Show DeregisterStreamConsumerResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterStreamConsumerResponse] -> ShowS
$cshowList :: [DeregisterStreamConsumerResponse] -> ShowS
show :: DeregisterStreamConsumerResponse -> String
$cshow :: DeregisterStreamConsumerResponse -> String
showsPrec :: Int -> DeregisterStreamConsumerResponse -> ShowS
$cshowsPrec :: Int -> DeregisterStreamConsumerResponse -> ShowS
Prelude.Show, (forall x.
 DeregisterStreamConsumerResponse
 -> Rep DeregisterStreamConsumerResponse x)
-> (forall x.
    Rep DeregisterStreamConsumerResponse x
    -> DeregisterStreamConsumerResponse)
-> Generic DeregisterStreamConsumerResponse
forall x.
Rep DeregisterStreamConsumerResponse x
-> DeregisterStreamConsumerResponse
forall x.
DeregisterStreamConsumerResponse
-> Rep DeregisterStreamConsumerResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeregisterStreamConsumerResponse x
-> DeregisterStreamConsumerResponse
$cfrom :: forall x.
DeregisterStreamConsumerResponse
-> Rep DeregisterStreamConsumerResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeregisterStreamConsumerResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
newDeregisterStreamConsumerResponse ::
  DeregisterStreamConsumerResponse
newDeregisterStreamConsumerResponse :: DeregisterStreamConsumerResponse
newDeregisterStreamConsumerResponse =
  DeregisterStreamConsumerResponse
DeregisterStreamConsumerResponse'

instance
  Prelude.NFData
    DeregisterStreamConsumerResponse