{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Kinesis.Types.ConsumerDescription where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Kinesis.Types.ConsumerStatus
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 :: Data.POSIX,
    -- | The ARN of the stream with which you registered the consumer.
    ConsumerDescription -> Text
streamARN :: Prelude.Text
  }
  deriving (ConsumerDescription -> ConsumerDescription -> Bool
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]
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
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. 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'
      { $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 =
          forall (a :: Format). Iso' (Time a) UTCTime
Data._Time 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 :: Lens' ConsumerDescription Text
consumerDescription_consumerName = 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 :: Lens' ConsumerDescription Text
consumerDescription_consumerARN = 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 :: Lens' ConsumerDescription ConsumerStatus
consumerDescription_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 :: Lens' ConsumerDescription UTCTime
consumerDescription_consumerCreationTimestamp = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The ARN of the stream with which you registered the consumer.
consumerDescription_streamARN :: Lens.Lens' ConsumerDescription Prelude.Text
consumerDescription_streamARN :: Lens' ConsumerDescription Text
consumerDescription_streamARN = 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 Data.FromJSON ConsumerDescription where
  parseJSON :: Value -> Parser ConsumerDescription
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ConsumerDescription"
      ( \Object
x ->
          Text
-> Text -> ConsumerStatus -> POSIX -> Text -> ConsumerDescription
ConsumerDescription'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ConsumerName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ConsumerARN")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ConsumerStatus")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ConsumerCreationTimestamp")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"StreamARN")
      )

instance Prelude.Hashable ConsumerDescription where
  hashWithSalt :: Int -> ConsumerDescription -> Int
hashWithSalt Int
_salt ConsumerDescription' {Text
POSIX
ConsumerStatus
streamARN :: Text
consumerCreationTimestamp :: POSIX
consumerStatus :: ConsumerStatus
consumerARN :: Text
consumerName :: Text
$sel:streamARN:ConsumerDescription' :: ConsumerDescription -> Text
$sel:consumerCreationTimestamp:ConsumerDescription' :: ConsumerDescription -> POSIX
$sel:consumerStatus:ConsumerDescription' :: ConsumerDescription -> ConsumerStatus
$sel:consumerARN:ConsumerDescription' :: ConsumerDescription -> Text
$sel:consumerName:ConsumerDescription' :: ConsumerDescription -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
consumerName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
consumerARN
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ConsumerStatus
consumerStatus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
consumerCreationTimestamp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
streamARN

instance Prelude.NFData ConsumerDescription where
  rnf :: ConsumerDescription -> ()
rnf ConsumerDescription' {Text
POSIX
ConsumerStatus
streamARN :: Text
consumerCreationTimestamp :: POSIX
consumerStatus :: ConsumerStatus
consumerARN :: Text
consumerName :: Text
$sel:streamARN:ConsumerDescription' :: ConsumerDescription -> Text
$sel:consumerCreationTimestamp:ConsumerDescription' :: ConsumerDescription -> POSIX
$sel:consumerStatus:ConsumerDescription' :: ConsumerDescription -> ConsumerStatus
$sel:consumerARN:ConsumerDescription' :: ConsumerDescription -> Text
$sel:consumerName:ConsumerDescription' :: ConsumerDescription -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
consumerName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
consumerARN
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ConsumerStatus
consumerStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
consumerCreationTimestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
streamARN