{-# 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.AppSync.Types.CachingConfig where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
data CachingConfig = CachingConfig'
{
CachingConfig -> Maybe [Text]
cachingKeys :: Prelude.Maybe [Prelude.Text],
CachingConfig -> Integer
ttl :: Prelude.Integer
}
deriving (CachingConfig -> CachingConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CachingConfig -> CachingConfig -> Bool
$c/= :: CachingConfig -> CachingConfig -> Bool
== :: CachingConfig -> CachingConfig -> Bool
$c== :: CachingConfig -> CachingConfig -> Bool
Prelude.Eq, ReadPrec [CachingConfig]
ReadPrec CachingConfig
Int -> ReadS CachingConfig
ReadS [CachingConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CachingConfig]
$creadListPrec :: ReadPrec [CachingConfig]
readPrec :: ReadPrec CachingConfig
$creadPrec :: ReadPrec CachingConfig
readList :: ReadS [CachingConfig]
$creadList :: ReadS [CachingConfig]
readsPrec :: Int -> ReadS CachingConfig
$creadsPrec :: Int -> ReadS CachingConfig
Prelude.Read, Int -> CachingConfig -> ShowS
[CachingConfig] -> ShowS
CachingConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CachingConfig] -> ShowS
$cshowList :: [CachingConfig] -> ShowS
show :: CachingConfig -> String
$cshow :: CachingConfig -> String
showsPrec :: Int -> CachingConfig -> ShowS
$cshowsPrec :: Int -> CachingConfig -> ShowS
Prelude.Show, forall x. Rep CachingConfig x -> CachingConfig
forall x. CachingConfig -> Rep CachingConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CachingConfig x -> CachingConfig
$cfrom :: forall x. CachingConfig -> Rep CachingConfig x
Prelude.Generic)
newCachingConfig ::
Prelude.Integer ->
CachingConfig
newCachingConfig :: Integer -> CachingConfig
newCachingConfig Integer
pTtl_ =
CachingConfig'
{ $sel:cachingKeys:CachingConfig' :: Maybe [Text]
cachingKeys = forall a. Maybe a
Prelude.Nothing,
$sel:ttl:CachingConfig' :: Integer
ttl = Integer
pTtl_
}
cachingConfig_cachingKeys :: Lens.Lens' CachingConfig (Prelude.Maybe [Prelude.Text])
cachingConfig_cachingKeys :: Lens' CachingConfig (Maybe [Text])
cachingConfig_cachingKeys = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CachingConfig' {Maybe [Text]
cachingKeys :: Maybe [Text]
$sel:cachingKeys:CachingConfig' :: CachingConfig -> Maybe [Text]
cachingKeys} -> Maybe [Text]
cachingKeys) (\s :: CachingConfig
s@CachingConfig' {} Maybe [Text]
a -> CachingConfig
s {$sel:cachingKeys:CachingConfig' :: Maybe [Text]
cachingKeys = Maybe [Text]
a} :: CachingConfig) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
cachingConfig_ttl :: Lens.Lens' CachingConfig Prelude.Integer
cachingConfig_ttl :: Lens' CachingConfig Integer
cachingConfig_ttl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CachingConfig' {Integer
ttl :: Integer
$sel:ttl:CachingConfig' :: CachingConfig -> Integer
ttl} -> Integer
ttl) (\s :: CachingConfig
s@CachingConfig' {} Integer
a -> CachingConfig
s {$sel:ttl:CachingConfig' :: Integer
ttl = Integer
a} :: CachingConfig)
instance Data.FromJSON CachingConfig where
parseJSON :: Value -> Parser CachingConfig
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"CachingConfig"
( \Object
x ->
Maybe [Text] -> Integer -> CachingConfig
CachingConfig'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"cachingKeys" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
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
"ttl")
)
instance Prelude.Hashable CachingConfig where
hashWithSalt :: Int -> CachingConfig -> Int
hashWithSalt Int
_salt CachingConfig' {Integer
Maybe [Text]
ttl :: Integer
cachingKeys :: Maybe [Text]
$sel:ttl:CachingConfig' :: CachingConfig -> Integer
$sel:cachingKeys:CachingConfig' :: CachingConfig -> Maybe [Text]
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
cachingKeys
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Integer
ttl
instance Prelude.NFData CachingConfig where
rnf :: CachingConfig -> ()
rnf CachingConfig' {Integer
Maybe [Text]
ttl :: Integer
cachingKeys :: Maybe [Text]
$sel:ttl:CachingConfig' :: CachingConfig -> Integer
$sel:cachingKeys:CachingConfig' :: CachingConfig -> Maybe [Text]
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
cachingKeys
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Integer
ttl
instance Data.ToJSON CachingConfig where
toJSON :: CachingConfig -> Value
toJSON CachingConfig' {Integer
Maybe [Text]
ttl :: Integer
cachingKeys :: Maybe [Text]
$sel:ttl:CachingConfig' :: CachingConfig -> Integer
$sel:cachingKeys:CachingConfig' :: CachingConfig -> Maybe [Text]
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"cachingKeys" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
cachingKeys,
forall a. a -> Maybe a
Prelude.Just (Key
"ttl" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Integer
ttl)
]
)