{-# 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 #-}
module Amazonka.DynamoDB.Types.StreamSpecification where
import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.StreamViewType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data StreamSpecification = StreamSpecification'
{
StreamSpecification -> Maybe StreamViewType
streamViewType :: Prelude.Maybe StreamViewType,
StreamSpecification -> Bool
streamEnabled :: Prelude.Bool
}
deriving (StreamSpecification -> StreamSpecification -> Bool
(StreamSpecification -> StreamSpecification -> Bool)
-> (StreamSpecification -> StreamSpecification -> Bool)
-> Eq StreamSpecification
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StreamSpecification -> StreamSpecification -> Bool
$c/= :: StreamSpecification -> StreamSpecification -> Bool
== :: StreamSpecification -> StreamSpecification -> Bool
$c== :: StreamSpecification -> StreamSpecification -> Bool
Prelude.Eq, ReadPrec [StreamSpecification]
ReadPrec StreamSpecification
Int -> ReadS StreamSpecification
ReadS [StreamSpecification]
(Int -> ReadS StreamSpecification)
-> ReadS [StreamSpecification]
-> ReadPrec StreamSpecification
-> ReadPrec [StreamSpecification]
-> Read StreamSpecification
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StreamSpecification]
$creadListPrec :: ReadPrec [StreamSpecification]
readPrec :: ReadPrec StreamSpecification
$creadPrec :: ReadPrec StreamSpecification
readList :: ReadS [StreamSpecification]
$creadList :: ReadS [StreamSpecification]
readsPrec :: Int -> ReadS StreamSpecification
$creadsPrec :: Int -> ReadS StreamSpecification
Prelude.Read, Int -> StreamSpecification -> ShowS
[StreamSpecification] -> ShowS
StreamSpecification -> String
(Int -> StreamSpecification -> ShowS)
-> (StreamSpecification -> String)
-> ([StreamSpecification] -> ShowS)
-> Show StreamSpecification
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StreamSpecification] -> ShowS
$cshowList :: [StreamSpecification] -> ShowS
show :: StreamSpecification -> String
$cshow :: StreamSpecification -> String
showsPrec :: Int -> StreamSpecification -> ShowS
$cshowsPrec :: Int -> StreamSpecification -> ShowS
Prelude.Show, (forall x. StreamSpecification -> Rep StreamSpecification x)
-> (forall x. Rep StreamSpecification x -> StreamSpecification)
-> Generic StreamSpecification
forall x. Rep StreamSpecification x -> StreamSpecification
forall x. StreamSpecification -> Rep StreamSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StreamSpecification x -> StreamSpecification
$cfrom :: forall x. StreamSpecification -> Rep StreamSpecification x
Prelude.Generic)
newStreamSpecification ::
Prelude.Bool ->
StreamSpecification
newStreamSpecification :: Bool -> StreamSpecification
newStreamSpecification Bool
pStreamEnabled_ =
StreamSpecification' :: Maybe StreamViewType -> Bool -> StreamSpecification
StreamSpecification'
{ $sel:streamViewType:StreamSpecification' :: Maybe StreamViewType
streamViewType =
Maybe StreamViewType
forall a. Maybe a
Prelude.Nothing,
$sel:streamEnabled:StreamSpecification' :: Bool
streamEnabled = Bool
pStreamEnabled_
}
streamSpecification_streamViewType :: Lens.Lens' StreamSpecification (Prelude.Maybe StreamViewType)
streamSpecification_streamViewType :: (Maybe StreamViewType -> f (Maybe StreamViewType))
-> StreamSpecification -> f StreamSpecification
streamSpecification_streamViewType = (StreamSpecification -> Maybe StreamViewType)
-> (StreamSpecification
-> Maybe StreamViewType -> StreamSpecification)
-> Lens
StreamSpecification
StreamSpecification
(Maybe StreamViewType)
(Maybe StreamViewType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamSpecification' {Maybe StreamViewType
streamViewType :: Maybe StreamViewType
$sel:streamViewType:StreamSpecification' :: StreamSpecification -> Maybe StreamViewType
streamViewType} -> Maybe StreamViewType
streamViewType) (\s :: StreamSpecification
s@StreamSpecification' {} Maybe StreamViewType
a -> StreamSpecification
s {$sel:streamViewType:StreamSpecification' :: Maybe StreamViewType
streamViewType = Maybe StreamViewType
a} :: StreamSpecification)
streamSpecification_streamEnabled :: Lens.Lens' StreamSpecification Prelude.Bool
streamSpecification_streamEnabled :: (Bool -> f Bool) -> StreamSpecification -> f StreamSpecification
streamSpecification_streamEnabled = (StreamSpecification -> Bool)
-> (StreamSpecification -> Bool -> StreamSpecification)
-> Lens StreamSpecification StreamSpecification Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StreamSpecification' {Bool
streamEnabled :: Bool
$sel:streamEnabled:StreamSpecification' :: StreamSpecification -> Bool
streamEnabled} -> Bool
streamEnabled) (\s :: StreamSpecification
s@StreamSpecification' {} Bool
a -> StreamSpecification
s {$sel:streamEnabled:StreamSpecification' :: Bool
streamEnabled = Bool
a} :: StreamSpecification)
instance Core.FromJSON StreamSpecification where
parseJSON :: Value -> Parser StreamSpecification
parseJSON =
String
-> (Object -> Parser StreamSpecification)
-> Value
-> Parser StreamSpecification
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"StreamSpecification"
( \Object
x ->
Maybe StreamViewType -> Bool -> StreamSpecification
StreamSpecification'
(Maybe StreamViewType -> Bool -> StreamSpecification)
-> Parser (Maybe StreamViewType)
-> Parser (Bool -> StreamSpecification)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe StreamViewType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StreamViewType")
Parser (Bool -> StreamSpecification)
-> Parser Bool -> Parser StreamSpecification
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"StreamEnabled")
)
instance Prelude.Hashable StreamSpecification
instance Prelude.NFData StreamSpecification
instance Core.ToJSON StreamSpecification where
toJSON :: StreamSpecification -> Value
toJSON StreamSpecification' {Bool
Maybe StreamViewType
streamEnabled :: Bool
streamViewType :: Maybe StreamViewType
$sel:streamEnabled:StreamSpecification' :: StreamSpecification -> Bool
$sel:streamViewType:StreamSpecification' :: StreamSpecification -> Maybe StreamViewType
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"StreamViewType" Text -> StreamViewType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(StreamViewType -> Pair) -> Maybe StreamViewType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StreamViewType
streamViewType,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"StreamEnabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
streamEnabled)
]
)