{-# 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.SecurityHub.Types.AwsDynamoDbTableStreamSpecification
-- 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.SecurityHub.Types.AwsDynamoDbTableStreamSpecification where

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

-- | The current DynamoDB Streams configuration for the table.
--
-- /See:/ 'newAwsDynamoDbTableStreamSpecification' smart constructor.
data AwsDynamoDbTableStreamSpecification = AwsDynamoDbTableStreamSpecification'
  { -- | Determines the information that is written to the table.
    AwsDynamoDbTableStreamSpecification -> Maybe Text
streamViewType :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether DynamoDB Streams is enabled on the table.
    AwsDynamoDbTableStreamSpecification -> Maybe Bool
streamEnabled :: Prelude.Maybe Prelude.Bool
  }
  deriving (AwsDynamoDbTableStreamSpecification
-> AwsDynamoDbTableStreamSpecification -> Bool
(AwsDynamoDbTableStreamSpecification
 -> AwsDynamoDbTableStreamSpecification -> Bool)
-> (AwsDynamoDbTableStreamSpecification
    -> AwsDynamoDbTableStreamSpecification -> Bool)
-> Eq AwsDynamoDbTableStreamSpecification
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsDynamoDbTableStreamSpecification
-> AwsDynamoDbTableStreamSpecification -> Bool
$c/= :: AwsDynamoDbTableStreamSpecification
-> AwsDynamoDbTableStreamSpecification -> Bool
== :: AwsDynamoDbTableStreamSpecification
-> AwsDynamoDbTableStreamSpecification -> Bool
$c== :: AwsDynamoDbTableStreamSpecification
-> AwsDynamoDbTableStreamSpecification -> Bool
Prelude.Eq, ReadPrec [AwsDynamoDbTableStreamSpecification]
ReadPrec AwsDynamoDbTableStreamSpecification
Int -> ReadS AwsDynamoDbTableStreamSpecification
ReadS [AwsDynamoDbTableStreamSpecification]
(Int -> ReadS AwsDynamoDbTableStreamSpecification)
-> ReadS [AwsDynamoDbTableStreamSpecification]
-> ReadPrec AwsDynamoDbTableStreamSpecification
-> ReadPrec [AwsDynamoDbTableStreamSpecification]
-> Read AwsDynamoDbTableStreamSpecification
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsDynamoDbTableStreamSpecification]
$creadListPrec :: ReadPrec [AwsDynamoDbTableStreamSpecification]
readPrec :: ReadPrec AwsDynamoDbTableStreamSpecification
$creadPrec :: ReadPrec AwsDynamoDbTableStreamSpecification
readList :: ReadS [AwsDynamoDbTableStreamSpecification]
$creadList :: ReadS [AwsDynamoDbTableStreamSpecification]
readsPrec :: Int -> ReadS AwsDynamoDbTableStreamSpecification
$creadsPrec :: Int -> ReadS AwsDynamoDbTableStreamSpecification
Prelude.Read, Int -> AwsDynamoDbTableStreamSpecification -> ShowS
[AwsDynamoDbTableStreamSpecification] -> ShowS
AwsDynamoDbTableStreamSpecification -> String
(Int -> AwsDynamoDbTableStreamSpecification -> ShowS)
-> (AwsDynamoDbTableStreamSpecification -> String)
-> ([AwsDynamoDbTableStreamSpecification] -> ShowS)
-> Show AwsDynamoDbTableStreamSpecification
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsDynamoDbTableStreamSpecification] -> ShowS
$cshowList :: [AwsDynamoDbTableStreamSpecification] -> ShowS
show :: AwsDynamoDbTableStreamSpecification -> String
$cshow :: AwsDynamoDbTableStreamSpecification -> String
showsPrec :: Int -> AwsDynamoDbTableStreamSpecification -> ShowS
$cshowsPrec :: Int -> AwsDynamoDbTableStreamSpecification -> ShowS
Prelude.Show, (forall x.
 AwsDynamoDbTableStreamSpecification
 -> Rep AwsDynamoDbTableStreamSpecification x)
-> (forall x.
    Rep AwsDynamoDbTableStreamSpecification x
    -> AwsDynamoDbTableStreamSpecification)
-> Generic AwsDynamoDbTableStreamSpecification
forall x.
Rep AwsDynamoDbTableStreamSpecification x
-> AwsDynamoDbTableStreamSpecification
forall x.
AwsDynamoDbTableStreamSpecification
-> Rep AwsDynamoDbTableStreamSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsDynamoDbTableStreamSpecification x
-> AwsDynamoDbTableStreamSpecification
$cfrom :: forall x.
AwsDynamoDbTableStreamSpecification
-> Rep AwsDynamoDbTableStreamSpecification x
Prelude.Generic)

-- |
-- Create a value of 'AwsDynamoDbTableStreamSpecification' 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:
--
-- 'streamViewType', 'awsDynamoDbTableStreamSpecification_streamViewType' - Determines the information that is written to the table.
--
-- 'streamEnabled', 'awsDynamoDbTableStreamSpecification_streamEnabled' - Indicates whether DynamoDB Streams is enabled on the table.
newAwsDynamoDbTableStreamSpecification ::
  AwsDynamoDbTableStreamSpecification
newAwsDynamoDbTableStreamSpecification :: AwsDynamoDbTableStreamSpecification
newAwsDynamoDbTableStreamSpecification =
  AwsDynamoDbTableStreamSpecification' :: Maybe Text -> Maybe Bool -> AwsDynamoDbTableStreamSpecification
AwsDynamoDbTableStreamSpecification'
    { $sel:streamViewType:AwsDynamoDbTableStreamSpecification' :: Maybe Text
streamViewType =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:streamEnabled:AwsDynamoDbTableStreamSpecification' :: Maybe Bool
streamEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Determines the information that is written to the table.
awsDynamoDbTableStreamSpecification_streamViewType :: Lens.Lens' AwsDynamoDbTableStreamSpecification (Prelude.Maybe Prelude.Text)
awsDynamoDbTableStreamSpecification_streamViewType :: (Maybe Text -> f (Maybe Text))
-> AwsDynamoDbTableStreamSpecification
-> f AwsDynamoDbTableStreamSpecification
awsDynamoDbTableStreamSpecification_streamViewType = (AwsDynamoDbTableStreamSpecification -> Maybe Text)
-> (AwsDynamoDbTableStreamSpecification
    -> Maybe Text -> AwsDynamoDbTableStreamSpecification)
-> Lens
     AwsDynamoDbTableStreamSpecification
     AwsDynamoDbTableStreamSpecification
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsDynamoDbTableStreamSpecification' {Maybe Text
streamViewType :: Maybe Text
$sel:streamViewType:AwsDynamoDbTableStreamSpecification' :: AwsDynamoDbTableStreamSpecification -> Maybe Text
streamViewType} -> Maybe Text
streamViewType) (\s :: AwsDynamoDbTableStreamSpecification
s@AwsDynamoDbTableStreamSpecification' {} Maybe Text
a -> AwsDynamoDbTableStreamSpecification
s {$sel:streamViewType:AwsDynamoDbTableStreamSpecification' :: Maybe Text
streamViewType = Maybe Text
a} :: AwsDynamoDbTableStreamSpecification)

-- | Indicates whether DynamoDB Streams is enabled on the table.
awsDynamoDbTableStreamSpecification_streamEnabled :: Lens.Lens' AwsDynamoDbTableStreamSpecification (Prelude.Maybe Prelude.Bool)
awsDynamoDbTableStreamSpecification_streamEnabled :: (Maybe Bool -> f (Maybe Bool))
-> AwsDynamoDbTableStreamSpecification
-> f AwsDynamoDbTableStreamSpecification
awsDynamoDbTableStreamSpecification_streamEnabled = (AwsDynamoDbTableStreamSpecification -> Maybe Bool)
-> (AwsDynamoDbTableStreamSpecification
    -> Maybe Bool -> AwsDynamoDbTableStreamSpecification)
-> Lens
     AwsDynamoDbTableStreamSpecification
     AwsDynamoDbTableStreamSpecification
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsDynamoDbTableStreamSpecification' {Maybe Bool
streamEnabled :: Maybe Bool
$sel:streamEnabled:AwsDynamoDbTableStreamSpecification' :: AwsDynamoDbTableStreamSpecification -> Maybe Bool
streamEnabled} -> Maybe Bool
streamEnabled) (\s :: AwsDynamoDbTableStreamSpecification
s@AwsDynamoDbTableStreamSpecification' {} Maybe Bool
a -> AwsDynamoDbTableStreamSpecification
s {$sel:streamEnabled:AwsDynamoDbTableStreamSpecification' :: Maybe Bool
streamEnabled = Maybe Bool
a} :: AwsDynamoDbTableStreamSpecification)

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

instance
  Prelude.Hashable
    AwsDynamoDbTableStreamSpecification

instance
  Prelude.NFData
    AwsDynamoDbTableStreamSpecification

instance
  Core.ToJSON
    AwsDynamoDbTableStreamSpecification
  where
  toJSON :: AwsDynamoDbTableStreamSpecification -> Value
toJSON AwsDynamoDbTableStreamSpecification' {Maybe Bool
Maybe Text
streamEnabled :: Maybe Bool
streamViewType :: Maybe Text
$sel:streamEnabled:AwsDynamoDbTableStreamSpecification' :: AwsDynamoDbTableStreamSpecification -> Maybe Bool
$sel:streamViewType:AwsDynamoDbTableStreamSpecification' :: AwsDynamoDbTableStreamSpecification -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"StreamViewType" 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
streamViewType,
            (Text
"StreamEnabled" 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
streamEnabled
          ]
      )