{-# 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.LexRuntime.Types.ActiveContext where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LexRuntime.Types.ActiveContextTimeToLive
import qualified Amazonka.Prelude as Prelude
data ActiveContext = ActiveContext'
{
ActiveContext -> Text
name :: Prelude.Text,
ActiveContext -> ActiveContextTimeToLive
timeToLive :: ActiveContextTimeToLive,
ActiveContext -> HashMap Text (Sensitive Text)
parameters :: Prelude.HashMap Prelude.Text (Core.Sensitive Prelude.Text)
}
deriving (ActiveContext -> ActiveContext -> Bool
(ActiveContext -> ActiveContext -> Bool)
-> (ActiveContext -> ActiveContext -> Bool) -> Eq ActiveContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActiveContext -> ActiveContext -> Bool
$c/= :: ActiveContext -> ActiveContext -> Bool
== :: ActiveContext -> ActiveContext -> Bool
$c== :: ActiveContext -> ActiveContext -> Bool
Prelude.Eq, Int -> ActiveContext -> ShowS
[ActiveContext] -> ShowS
ActiveContext -> String
(Int -> ActiveContext -> ShowS)
-> (ActiveContext -> String)
-> ([ActiveContext] -> ShowS)
-> Show ActiveContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActiveContext] -> ShowS
$cshowList :: [ActiveContext] -> ShowS
show :: ActiveContext -> String
$cshow :: ActiveContext -> String
showsPrec :: Int -> ActiveContext -> ShowS
$cshowsPrec :: Int -> ActiveContext -> ShowS
Prelude.Show, (forall x. ActiveContext -> Rep ActiveContext x)
-> (forall x. Rep ActiveContext x -> ActiveContext)
-> Generic ActiveContext
forall x. Rep ActiveContext x -> ActiveContext
forall x. ActiveContext -> Rep ActiveContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActiveContext x -> ActiveContext
$cfrom :: forall x. ActiveContext -> Rep ActiveContext x
Prelude.Generic)
newActiveContext ::
Prelude.Text ->
ActiveContextTimeToLive ->
ActiveContext
newActiveContext :: Text -> ActiveContextTimeToLive -> ActiveContext
newActiveContext Text
pName_ ActiveContextTimeToLive
pTimeToLive_ =
ActiveContext' :: Text
-> ActiveContextTimeToLive
-> HashMap Text (Sensitive Text)
-> ActiveContext
ActiveContext'
{ $sel:name:ActiveContext' :: Text
name = Text
pName_,
$sel:timeToLive:ActiveContext' :: ActiveContextTimeToLive
timeToLive = ActiveContextTimeToLive
pTimeToLive_,
$sel:parameters:ActiveContext' :: HashMap Text (Sensitive Text)
parameters = HashMap Text (Sensitive Text)
forall a. Monoid a => a
Prelude.mempty
}
activeContext_name :: Lens.Lens' ActiveContext Prelude.Text
activeContext_name :: (Text -> f Text) -> ActiveContext -> f ActiveContext
activeContext_name = (ActiveContext -> Text)
-> (ActiveContext -> Text -> ActiveContext)
-> Lens ActiveContext ActiveContext Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActiveContext' {Text
name :: Text
$sel:name:ActiveContext' :: ActiveContext -> Text
name} -> Text
name) (\s :: ActiveContext
s@ActiveContext' {} Text
a -> ActiveContext
s {$sel:name:ActiveContext' :: Text
name = Text
a} :: ActiveContext)
activeContext_timeToLive :: Lens.Lens' ActiveContext ActiveContextTimeToLive
activeContext_timeToLive :: (ActiveContextTimeToLive -> f ActiveContextTimeToLive)
-> ActiveContext -> f ActiveContext
activeContext_timeToLive = (ActiveContext -> ActiveContextTimeToLive)
-> (ActiveContext -> ActiveContextTimeToLive -> ActiveContext)
-> Lens
ActiveContext
ActiveContext
ActiveContextTimeToLive
ActiveContextTimeToLive
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActiveContext' {ActiveContextTimeToLive
timeToLive :: ActiveContextTimeToLive
$sel:timeToLive:ActiveContext' :: ActiveContext -> ActiveContextTimeToLive
timeToLive} -> ActiveContextTimeToLive
timeToLive) (\s :: ActiveContext
s@ActiveContext' {} ActiveContextTimeToLive
a -> ActiveContext
s {$sel:timeToLive:ActiveContext' :: ActiveContextTimeToLive
timeToLive = ActiveContextTimeToLive
a} :: ActiveContext)
activeContext_parameters :: Lens.Lens' ActiveContext (Prelude.HashMap Prelude.Text Prelude.Text)
activeContext_parameters :: (HashMap Text Text -> f (HashMap Text Text))
-> ActiveContext -> f ActiveContext
activeContext_parameters = (ActiveContext -> HashMap Text (Sensitive Text))
-> (ActiveContext
-> HashMap Text (Sensitive Text) -> ActiveContext)
-> Lens
ActiveContext
ActiveContext
(HashMap Text (Sensitive Text))
(HashMap Text (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActiveContext' {HashMap Text (Sensitive Text)
parameters :: HashMap Text (Sensitive Text)
$sel:parameters:ActiveContext' :: ActiveContext -> HashMap Text (Sensitive Text)
parameters} -> HashMap Text (Sensitive Text)
parameters) (\s :: ActiveContext
s@ActiveContext' {} HashMap Text (Sensitive Text)
a -> ActiveContext
s {$sel:parameters:ActiveContext' :: HashMap Text (Sensitive Text)
parameters = HashMap Text (Sensitive Text)
a} :: ActiveContext) ((HashMap Text (Sensitive Text)
-> f (HashMap Text (Sensitive Text)))
-> ActiveContext -> f ActiveContext)
-> ((HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text (Sensitive Text)
-> f (HashMap Text (Sensitive Text)))
-> (HashMap Text Text -> f (HashMap Text Text))
-> ActiveContext
-> f ActiveContext
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text (Sensitive Text)
-> f (HashMap Text (Sensitive Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON ActiveContext where
parseJSON :: Value -> Parser ActiveContext
parseJSON =
String
-> (Object -> Parser ActiveContext)
-> Value
-> Parser ActiveContext
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"ActiveContext"
( \Object
x ->
Text
-> ActiveContextTimeToLive
-> HashMap Text (Sensitive Text)
-> ActiveContext
ActiveContext'
(Text
-> ActiveContextTimeToLive
-> HashMap Text (Sensitive Text)
-> ActiveContext)
-> Parser Text
-> Parser
(ActiveContextTimeToLive
-> HashMap Text (Sensitive Text) -> ActiveContext)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"name")
Parser
(ActiveContextTimeToLive
-> HashMap Text (Sensitive Text) -> ActiveContext)
-> Parser ActiveContextTimeToLive
-> Parser (HashMap Text (Sensitive Text) -> ActiveContext)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ActiveContextTimeToLive
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"timeToLive")
Parser (HashMap Text (Sensitive Text) -> ActiveContext)
-> Parser (HashMap Text (Sensitive Text)) -> Parser ActiveContext
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (HashMap Text (Sensitive Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"parameters" Parser (Maybe (HashMap Text (Sensitive Text)))
-> HashMap Text (Sensitive Text)
-> Parser (HashMap Text (Sensitive Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= HashMap Text (Sensitive Text)
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable ActiveContext
instance Prelude.NFData ActiveContext
instance Core.ToJSON ActiveContext where
toJSON :: ActiveContext -> Value
toJSON ActiveContext' {Text
HashMap Text (Sensitive Text)
ActiveContextTimeToLive
parameters :: HashMap Text (Sensitive Text)
timeToLive :: ActiveContextTimeToLive
name :: Text
$sel:parameters:ActiveContext' :: ActiveContext -> HashMap Text (Sensitive Text)
$sel:timeToLive:ActiveContext' :: ActiveContext -> ActiveContextTimeToLive
$sel:name:ActiveContext' :: ActiveContext -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"timeToLive" Text -> ActiveContextTimeToLive -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ActiveContextTimeToLive
timeToLive),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"parameters" Text -> HashMap Text (Sensitive Text) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text (Sensitive Text)
parameters)
]
)