{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.ConsumerDescription
-- 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)
module Amazonka.Kinesis.Types.ConsumerDescription where

import qualified Amazonka.Core as Core
import Amazonka.Kinesis.Types.ConsumerStatus
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that represents the details of a registered consumer. This
-- type of object is returned by DescribeStreamConsumer.
--
-- /See:/ 'newConsumerDescription' smart constructor.
data ConsumerDescription = ConsumerDescription'
  { -- | The name of the consumer is something you choose when you register the
    -- consumer.
    ConsumerDescription -> Text
consumerName :: Prelude.Text,
    -- | When you register a consumer, Kinesis Data Streams generates an ARN for
    -- it. You need this ARN to be able to call SubscribeToShard.
    --
    -- If you delete a consumer and then create a new one with the same name,
    -- it won\'t have the same ARN. That\'s because consumer ARNs contain the
    -- creation timestamp. This is important to keep in mind if you have IAM
    -- policies that reference consumer ARNs.
    ConsumerDescription -> Text
consumerARN :: Prelude.Text,
    -- | A consumer can\'t read data while in the @CREATING@ or @DELETING@
    -- states.
    ConsumerDescription -> ConsumerStatus
consumerStatus :: ConsumerStatus,
    ConsumerDescription -> POSIX
consumerCreationTimestamp :: Core.POSIX,
    -- | The ARN of the stream with which you registered the consumer.
    ConsumerDescription -> Text
streamARN :: Prelude.Text
  }
  deriving (ConsumerDescription -> ConsumerDescription -> Bool
(ConsumerDescription -> ConsumerDescription -> Bool)
-> (ConsumerDescription -> ConsumerDescription -> Bool)
-> Eq ConsumerDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConsumerDescription -> ConsumerDescription -> Bool
$c/= :: ConsumerDescription -> ConsumerDescription -> Bool
== :: ConsumerDescription -> ConsumerDescription -> Bool
$c== :: ConsumerDescription -> ConsumerDescription -> Bool
Prelude.Eq, ReadPrec [ConsumerDescription]
ReadPrec ConsumerDescription
Int -> ReadS ConsumerDescription
ReadS [ConsumerDescription]
(Int -> ReadS ConsumerDescription)
-> ReadS [ConsumerDescription]
-> ReadPrec ConsumerDescription
-> ReadPrec [ConsumerDescription]
-> Read ConsumerDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConsumerDescription]
$creadListPrec :: ReadPrec [ConsumerDescription]
readPrec :: ReadPrec ConsumerDescription
$creadPrec :: ReadPrec ConsumerDescription
readList :: ReadS [ConsumerDescription]
$creadList :: ReadS [ConsumerDescription]
readsPrec :: Int -> ReadS ConsumerDescription
$creadsPrec :: Int -> ReadS ConsumerDescription
Prelude.Read, Int -> ConsumerDescription -> ShowS
[ConsumerDescription] -> ShowS
ConsumerDescription -> String
(Int -> ConsumerDescription -> ShowS)
-> (ConsumerDescription -> String)
-> ([ConsumerDescription] -> ShowS)
-> Show ConsumerDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConsumerDescription] -> ShowS
$cshowList :: [ConsumerDescription] -> ShowS
show :: ConsumerDescription -> String
$cshow :: ConsumerDescription -> String
showsPrec :: Int -> ConsumerDescription -> ShowS
$cshowsPrec :: Int -> ConsumerDescription -> ShowS
Prelude.Show, (forall x. ConsumerDescription -> Rep ConsumerDescription x)
-> (forall x. Rep ConsumerDescription x -> ConsumerDescription)
-> Generic ConsumerDescription
forall x. Rep ConsumerDescription x -> ConsumerDescription
forall x. ConsumerDescription -> Rep ConsumerDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConsumerDescription x -> ConsumerDescription
$cfrom :: forall x. ConsumerDescription -> Rep ConsumerDescription x
Prelude.Generic)

-- |
-- Create a value of 'ConsumerDescription' 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:
--
-- 'consumerName', 'consumerDescription_consumerName' - The name of the consumer is something you choose when you register the
-- consumer.
--
-- 'consumerARN', 'consumerDescription_consumerARN' - When you register a consumer, Kinesis Data Streams generates an ARN for
-- it. You need this ARN to be able to call SubscribeToShard.
--
-- If you delete a consumer and then create a new one with the same name,
-- it won\'t have the same ARN. That\'s because consumer ARNs contain the
-- creation timestamp. This is important to keep in mind if you have IAM
-- policies that reference consumer ARNs.
--
-- 'consumerStatus', 'consumerDescription_consumerStatus' - A consumer can\'t read data while in the @CREATING@ or @DELETING@
-- states.
--
-- 'consumerCreationTimestamp', 'consumerDescription_consumerCreationTimestamp' -
--
-- 'streamARN', 'consumerDescription_streamARN' - The ARN of the stream with which you registered the consumer.
newConsumerDescription ::
  -- | 'consumerName'
  Prelude.Text ->
  -- | 'consumerARN'
  Prelude.Text ->
  -- | 'consumerStatus'
  ConsumerStatus ->
  -- | 'consumerCreationTimestamp'
  Prelude.UTCTime ->
  -- | 'streamARN'
  Prelude.Text ->
  ConsumerDescription
newConsumerDescription :: Text
-> Text -> ConsumerStatus -> UTCTime -> Text -> ConsumerDescription
newConsumerDescription
  Text
pConsumerName_
  Text
pConsumerARN_
  ConsumerStatus
pConsumerStatus_
  UTCTime
pConsumerCreationTimestamp_
  Text
pStreamARN_ =
    ConsumerDescription' :: Text
-> Text -> ConsumerStatus -> POSIX -> Text -> ConsumerDescription
ConsumerDescription'
      { $sel:consumerName:ConsumerDescription' :: Text
consumerName = Text
pConsumerName_,
        $sel:consumerARN:ConsumerDescription' :: Text
consumerARN = Text
pConsumerARN_,
        $sel:consumerStatus:ConsumerDescription' :: ConsumerStatus
consumerStatus = ConsumerStatus
pConsumerStatus_,
        $sel:consumerCreationTimestamp:ConsumerDescription' :: POSIX
consumerCreationTimestamp =
          Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pConsumerCreationTimestamp_,
        $sel:streamARN:ConsumerDescription' :: Text
streamARN = Text
pStreamARN_
      }

-- | The name of the consumer is something you choose when you register the
-- consumer.
consumerDescription_consumerName :: Lens.Lens' ConsumerDescription Prelude.Text
consumerDescription_consumerName :: (Text -> f Text) -> ConsumerDescription -> f ConsumerDescription
consumerDescription_consumerName = (ConsumerDescription -> Text)
-> (ConsumerDescription -> Text -> ConsumerDescription)
-> Lens ConsumerDescription ConsumerDescription Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConsumerDescription' {Text
consumerName :: Text
$sel:consumerName:ConsumerDescription' :: ConsumerDescription -> Text
consumerName} -> Text
consumerName) (\s :: ConsumerDescription
s@ConsumerDescription' {} Text
a -> ConsumerDescription
s {$sel:consumerName:ConsumerDescription' :: Text
consumerName = Text
a} :: ConsumerDescription)

-- | When you register a consumer, Kinesis Data Streams generates an ARN for
-- it. You need this ARN to be able to call SubscribeToShard.
--
-- If you delete a consumer and then create a new one with the same name,
-- it won\'t have the same ARN. That\'s because consumer ARNs contain the
-- creation timestamp. This is important to keep in mind if you have IAM
-- policies that reference consumer ARNs.
consumerDescription_consumerARN :: Lens.Lens' ConsumerDescription Prelude.Text
consumerDescription_consumerARN :: (Text -> f Text) -> ConsumerDescription -> f ConsumerDescription
consumerDescription_consumerARN = (ConsumerDescription -> Text)
-> (ConsumerDescription -> Text -> ConsumerDescription)
-> Lens ConsumerDescription ConsumerDescription Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConsumerDescription' {Text
consumerARN :: Text
$sel:consumerARN:ConsumerDescription' :: ConsumerDescription -> Text
consumerARN} -> Text
consumerARN) (\s :: ConsumerDescription
s@ConsumerDescription' {} Text
a -> ConsumerDescription
s {$sel:consumerARN:ConsumerDescription' :: Text
consumerARN = Text
a} :: ConsumerDescription)

-- | A consumer can\'t read data while in the @CREATING@ or @DELETING@
-- states.
consumerDescription_consumerStatus :: Lens.Lens' ConsumerDescription ConsumerStatus
consumerDescription_consumerStatus :: (ConsumerStatus -> f ConsumerStatus)
-> ConsumerDescription -> f ConsumerDescription
consumerDescription_consumerStatus = (ConsumerDescription -> ConsumerStatus)
-> (ConsumerDescription -> ConsumerStatus -> ConsumerDescription)
-> Lens
     ConsumerDescription
     ConsumerDescription
     ConsumerStatus
     ConsumerStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConsumerDescription' {ConsumerStatus
consumerStatus :: ConsumerStatus
$sel:consumerStatus:ConsumerDescription' :: ConsumerDescription -> ConsumerStatus
consumerStatus} -> ConsumerStatus
consumerStatus) (\s :: ConsumerDescription
s@ConsumerDescription' {} ConsumerStatus
a -> ConsumerDescription
s {$sel:consumerStatus:ConsumerDescription' :: ConsumerStatus
consumerStatus = ConsumerStatus
a} :: ConsumerDescription)

-- |
consumerDescription_consumerCreationTimestamp :: Lens.Lens' ConsumerDescription Prelude.UTCTime
consumerDescription_consumerCreationTimestamp :: (UTCTime -> f UTCTime)
-> ConsumerDescription -> f ConsumerDescription
consumerDescription_consumerCreationTimestamp = (ConsumerDescription -> POSIX)
-> (ConsumerDescription -> POSIX -> ConsumerDescription)
-> Lens ConsumerDescription ConsumerDescription POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConsumerDescription' {POSIX
consumerCreationTimestamp :: POSIX
$sel:consumerCreationTimestamp:ConsumerDescription' :: ConsumerDescription -> POSIX
consumerCreationTimestamp} -> POSIX
consumerCreationTimestamp) (\s :: ConsumerDescription
s@ConsumerDescription' {} POSIX
a -> ConsumerDescription
s {$sel:consumerCreationTimestamp:ConsumerDescription' :: POSIX
consumerCreationTimestamp = POSIX
a} :: ConsumerDescription) ((POSIX -> f POSIX)
 -> ConsumerDescription -> f ConsumerDescription)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ConsumerDescription
-> f ConsumerDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The ARN of the stream with which you registered the consumer.
consumerDescription_streamARN :: Lens.Lens' ConsumerDescription Prelude.Text
consumerDescription_streamARN :: (Text -> f Text) -> ConsumerDescription -> f ConsumerDescription
consumerDescription_streamARN = (ConsumerDescription -> Text)
-> (ConsumerDescription -> Text -> ConsumerDescription)
-> Lens ConsumerDescription ConsumerDescription Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConsumerDescription' {Text
streamARN :: Text
$sel:streamARN:ConsumerDescription' :: ConsumerDescription -> Text
streamARN} -> Text
streamARN) (\s :: ConsumerDescription
s@ConsumerDescription' {} Text
a -> ConsumerDescription
s {$sel:streamARN:ConsumerDescription' :: Text
streamARN = Text
a} :: ConsumerDescription)

instance Core.FromJSON ConsumerDescription where
  parseJSON :: Value -> Parser ConsumerDescription
parseJSON =
    String
-> (Object -> Parser ConsumerDescription)
-> Value
-> Parser ConsumerDescription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ConsumerDescription"
      ( \Object
x ->
          Text
-> Text -> ConsumerStatus -> POSIX -> Text -> ConsumerDescription
ConsumerDescription'
            (Text
 -> Text -> ConsumerStatus -> POSIX -> Text -> ConsumerDescription)
-> Parser Text
-> Parser
     (Text -> ConsumerStatus -> POSIX -> Text -> ConsumerDescription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ConsumerName")
            Parser
  (Text -> ConsumerStatus -> POSIX -> Text -> ConsumerDescription)
-> Parser Text
-> Parser (ConsumerStatus -> POSIX -> Text -> ConsumerDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ConsumerARN")
            Parser (ConsumerStatus -> POSIX -> Text -> ConsumerDescription)
-> Parser ConsumerStatus
-> Parser (POSIX -> Text -> ConsumerDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ConsumerStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ConsumerStatus")
            Parser (POSIX -> Text -> ConsumerDescription)
-> Parser POSIX -> Parser (Text -> ConsumerDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ConsumerCreationTimestamp")
            Parser (Text -> ConsumerDescription)
-> Parser Text -> Parser ConsumerDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"StreamARN")
      )

instance Prelude.Hashable ConsumerDescription

instance Prelude.NFData ConsumerDescription