{-# 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.QLDB.Types.KinesisConfiguration
-- 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.QLDB.Types.KinesisConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The configuration settings of the Amazon Kinesis Data Streams
-- destination for an Amazon QLDB journal stream.
--
-- /See:/ 'newKinesisConfiguration' smart constructor.
data KinesisConfiguration = KinesisConfiguration'
  { -- | Enables QLDB to publish multiple data records in a single Kinesis Data
    -- Streams record, increasing the number of records sent per API call.
    --
    -- /This option is enabled by default./ Record aggregation has important
    -- implications for processing records and requires de-aggregation in your
    -- stream consumer. To learn more, see
    -- <https://docs.aws.amazon.com/streams/latest/dev/kinesis-kpl-concepts.html KPL Key Concepts>
    -- and
    -- <https://docs.aws.amazon.com/streams/latest/dev/kinesis-kpl-consumer-deaggregation.html Consumer De-aggregation>
    -- in the /Amazon Kinesis Data Streams Developer Guide/.
    KinesisConfiguration -> Maybe Bool
aggregationEnabled :: Prelude.Maybe Prelude.Bool,
    -- | The Amazon Resource Name (ARN) of the Kinesis Data Streams resource.
    KinesisConfiguration -> Text
streamArn :: Prelude.Text
  }
  deriving (KinesisConfiguration -> KinesisConfiguration -> Bool
(KinesisConfiguration -> KinesisConfiguration -> Bool)
-> (KinesisConfiguration -> KinesisConfiguration -> Bool)
-> Eq KinesisConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KinesisConfiguration -> KinesisConfiguration -> Bool
$c/= :: KinesisConfiguration -> KinesisConfiguration -> Bool
== :: KinesisConfiguration -> KinesisConfiguration -> Bool
$c== :: KinesisConfiguration -> KinesisConfiguration -> Bool
Prelude.Eq, ReadPrec [KinesisConfiguration]
ReadPrec KinesisConfiguration
Int -> ReadS KinesisConfiguration
ReadS [KinesisConfiguration]
(Int -> ReadS KinesisConfiguration)
-> ReadS [KinesisConfiguration]
-> ReadPrec KinesisConfiguration
-> ReadPrec [KinesisConfiguration]
-> Read KinesisConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KinesisConfiguration]
$creadListPrec :: ReadPrec [KinesisConfiguration]
readPrec :: ReadPrec KinesisConfiguration
$creadPrec :: ReadPrec KinesisConfiguration
readList :: ReadS [KinesisConfiguration]
$creadList :: ReadS [KinesisConfiguration]
readsPrec :: Int -> ReadS KinesisConfiguration
$creadsPrec :: Int -> ReadS KinesisConfiguration
Prelude.Read, Int -> KinesisConfiguration -> ShowS
[KinesisConfiguration] -> ShowS
KinesisConfiguration -> String
(Int -> KinesisConfiguration -> ShowS)
-> (KinesisConfiguration -> String)
-> ([KinesisConfiguration] -> ShowS)
-> Show KinesisConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KinesisConfiguration] -> ShowS
$cshowList :: [KinesisConfiguration] -> ShowS
show :: KinesisConfiguration -> String
$cshow :: KinesisConfiguration -> String
showsPrec :: Int -> KinesisConfiguration -> ShowS
$cshowsPrec :: Int -> KinesisConfiguration -> ShowS
Prelude.Show, (forall x. KinesisConfiguration -> Rep KinesisConfiguration x)
-> (forall x. Rep KinesisConfiguration x -> KinesisConfiguration)
-> Generic KinesisConfiguration
forall x. Rep KinesisConfiguration x -> KinesisConfiguration
forall x. KinesisConfiguration -> Rep KinesisConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KinesisConfiguration x -> KinesisConfiguration
$cfrom :: forall x. KinesisConfiguration -> Rep KinesisConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'KinesisConfiguration' 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:
--
-- 'aggregationEnabled', 'kinesisConfiguration_aggregationEnabled' - Enables QLDB to publish multiple data records in a single Kinesis Data
-- Streams record, increasing the number of records sent per API call.
--
-- /This option is enabled by default./ Record aggregation has important
-- implications for processing records and requires de-aggregation in your
-- stream consumer. To learn more, see
-- <https://docs.aws.amazon.com/streams/latest/dev/kinesis-kpl-concepts.html KPL Key Concepts>
-- and
-- <https://docs.aws.amazon.com/streams/latest/dev/kinesis-kpl-consumer-deaggregation.html Consumer De-aggregation>
-- in the /Amazon Kinesis Data Streams Developer Guide/.
--
-- 'streamArn', 'kinesisConfiguration_streamArn' - The Amazon Resource Name (ARN) of the Kinesis Data Streams resource.
newKinesisConfiguration ::
  -- | 'streamArn'
  Prelude.Text ->
  KinesisConfiguration
newKinesisConfiguration :: Text -> KinesisConfiguration
newKinesisConfiguration Text
pStreamArn_ =
  KinesisConfiguration' :: Maybe Bool -> Text -> KinesisConfiguration
KinesisConfiguration'
    { $sel:aggregationEnabled:KinesisConfiguration' :: Maybe Bool
aggregationEnabled =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:streamArn:KinesisConfiguration' :: Text
streamArn = Text
pStreamArn_
    }

-- | Enables QLDB to publish multiple data records in a single Kinesis Data
-- Streams record, increasing the number of records sent per API call.
--
-- /This option is enabled by default./ Record aggregation has important
-- implications for processing records and requires de-aggregation in your
-- stream consumer. To learn more, see
-- <https://docs.aws.amazon.com/streams/latest/dev/kinesis-kpl-concepts.html KPL Key Concepts>
-- and
-- <https://docs.aws.amazon.com/streams/latest/dev/kinesis-kpl-consumer-deaggregation.html Consumer De-aggregation>
-- in the /Amazon Kinesis Data Streams Developer Guide/.
kinesisConfiguration_aggregationEnabled :: Lens.Lens' KinesisConfiguration (Prelude.Maybe Prelude.Bool)
kinesisConfiguration_aggregationEnabled :: (Maybe Bool -> f (Maybe Bool))
-> KinesisConfiguration -> f KinesisConfiguration
kinesisConfiguration_aggregationEnabled = (KinesisConfiguration -> Maybe Bool)
-> (KinesisConfiguration -> Maybe Bool -> KinesisConfiguration)
-> Lens
     KinesisConfiguration KinesisConfiguration (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KinesisConfiguration' {Maybe Bool
aggregationEnabled :: Maybe Bool
$sel:aggregationEnabled:KinesisConfiguration' :: KinesisConfiguration -> Maybe Bool
aggregationEnabled} -> Maybe Bool
aggregationEnabled) (\s :: KinesisConfiguration
s@KinesisConfiguration' {} Maybe Bool
a -> KinesisConfiguration
s {$sel:aggregationEnabled:KinesisConfiguration' :: Maybe Bool
aggregationEnabled = Maybe Bool
a} :: KinesisConfiguration)

-- | The Amazon Resource Name (ARN) of the Kinesis Data Streams resource.
kinesisConfiguration_streamArn :: Lens.Lens' KinesisConfiguration Prelude.Text
kinesisConfiguration_streamArn :: (Text -> f Text) -> KinesisConfiguration -> f KinesisConfiguration
kinesisConfiguration_streamArn = (KinesisConfiguration -> Text)
-> (KinesisConfiguration -> Text -> KinesisConfiguration)
-> Lens KinesisConfiguration KinesisConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KinesisConfiguration' {Text
streamArn :: Text
$sel:streamArn:KinesisConfiguration' :: KinesisConfiguration -> Text
streamArn} -> Text
streamArn) (\s :: KinesisConfiguration
s@KinesisConfiguration' {} Text
a -> KinesisConfiguration
s {$sel:streamArn:KinesisConfiguration' :: Text
streamArn = Text
a} :: KinesisConfiguration)

instance Core.FromJSON KinesisConfiguration where
  parseJSON :: Value -> Parser KinesisConfiguration
parseJSON =
    String
-> (Object -> Parser KinesisConfiguration)
-> Value
-> Parser KinesisConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"KinesisConfiguration"
      ( \Object
x ->
          Maybe Bool -> Text -> KinesisConfiguration
KinesisConfiguration'
            (Maybe Bool -> Text -> KinesisConfiguration)
-> Parser (Maybe Bool) -> Parser (Text -> KinesisConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AggregationEnabled")
            Parser (Text -> KinesisConfiguration)
-> Parser Text -> Parser KinesisConfiguration
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 KinesisConfiguration

instance Prelude.NFData KinesisConfiguration

instance Core.ToJSON KinesisConfiguration where
  toJSON :: KinesisConfiguration -> Value
toJSON KinesisConfiguration' {Maybe Bool
Text
streamArn :: Text
aggregationEnabled :: Maybe Bool
$sel:streamArn:KinesisConfiguration' :: KinesisConfiguration -> Text
$sel:aggregationEnabled:KinesisConfiguration' :: KinesisConfiguration -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AggregationEnabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
aggregationEnabled,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"StreamArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
streamArn)
          ]
      )