{-# 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.LexRuntime.Types.ActiveContextTimeToLive
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.LexRuntime.Types.ActiveContextTimeToLive 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

-- | The length of time or number of turns that a context remains active.
--
-- /See:/ 'newActiveContextTimeToLive' smart constructor.
data ActiveContextTimeToLive = ActiveContextTimeToLive'
  { -- | The number of seconds that the context should be active after it is
    -- first sent in a @PostContent@ or @PostText@ response. You can set the
    -- value between 5 and 86,400 seconds (24 hours).
    ActiveContextTimeToLive -> Maybe Natural
timeToLiveInSeconds :: Prelude.Maybe Prelude.Natural,
    -- | The number of conversation turns that the context should be active. A
    -- conversation turn is one @PostContent@ or @PostText@ request and the
    -- corresponding response from Amazon Lex.
    ActiveContextTimeToLive -> Maybe Natural
turnsToLive :: Prelude.Maybe Prelude.Natural
  }
  deriving (ActiveContextTimeToLive -> ActiveContextTimeToLive -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActiveContextTimeToLive -> ActiveContextTimeToLive -> Bool
$c/= :: ActiveContextTimeToLive -> ActiveContextTimeToLive -> Bool
== :: ActiveContextTimeToLive -> ActiveContextTimeToLive -> Bool
$c== :: ActiveContextTimeToLive -> ActiveContextTimeToLive -> Bool
Prelude.Eq, ReadPrec [ActiveContextTimeToLive]
ReadPrec ActiveContextTimeToLive
Int -> ReadS ActiveContextTimeToLive
ReadS [ActiveContextTimeToLive]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ActiveContextTimeToLive]
$creadListPrec :: ReadPrec [ActiveContextTimeToLive]
readPrec :: ReadPrec ActiveContextTimeToLive
$creadPrec :: ReadPrec ActiveContextTimeToLive
readList :: ReadS [ActiveContextTimeToLive]
$creadList :: ReadS [ActiveContextTimeToLive]
readsPrec :: Int -> ReadS ActiveContextTimeToLive
$creadsPrec :: Int -> ReadS ActiveContextTimeToLive
Prelude.Read, Int -> ActiveContextTimeToLive -> ShowS
[ActiveContextTimeToLive] -> ShowS
ActiveContextTimeToLive -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActiveContextTimeToLive] -> ShowS
$cshowList :: [ActiveContextTimeToLive] -> ShowS
show :: ActiveContextTimeToLive -> String
$cshow :: ActiveContextTimeToLive -> String
showsPrec :: Int -> ActiveContextTimeToLive -> ShowS
$cshowsPrec :: Int -> ActiveContextTimeToLive -> ShowS
Prelude.Show, forall x. Rep ActiveContextTimeToLive x -> ActiveContextTimeToLive
forall x. ActiveContextTimeToLive -> Rep ActiveContextTimeToLive x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActiveContextTimeToLive x -> ActiveContextTimeToLive
$cfrom :: forall x. ActiveContextTimeToLive -> Rep ActiveContextTimeToLive x
Prelude.Generic)

-- |
-- Create a value of 'ActiveContextTimeToLive' 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:
--
-- 'timeToLiveInSeconds', 'activeContextTimeToLive_timeToLiveInSeconds' - The number of seconds that the context should be active after it is
-- first sent in a @PostContent@ or @PostText@ response. You can set the
-- value between 5 and 86,400 seconds (24 hours).
--
-- 'turnsToLive', 'activeContextTimeToLive_turnsToLive' - The number of conversation turns that the context should be active. A
-- conversation turn is one @PostContent@ or @PostText@ request and the
-- corresponding response from Amazon Lex.
newActiveContextTimeToLive ::
  ActiveContextTimeToLive
newActiveContextTimeToLive :: ActiveContextTimeToLive
newActiveContextTimeToLive =
  ActiveContextTimeToLive'
    { $sel:timeToLiveInSeconds:ActiveContextTimeToLive' :: Maybe Natural
timeToLiveInSeconds =
        forall a. Maybe a
Prelude.Nothing,
      $sel:turnsToLive:ActiveContextTimeToLive' :: Maybe Natural
turnsToLive = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of seconds that the context should be active after it is
-- first sent in a @PostContent@ or @PostText@ response. You can set the
-- value between 5 and 86,400 seconds (24 hours).
activeContextTimeToLive_timeToLiveInSeconds :: Lens.Lens' ActiveContextTimeToLive (Prelude.Maybe Prelude.Natural)
activeContextTimeToLive_timeToLiveInSeconds :: Lens' ActiveContextTimeToLive (Maybe Natural)
activeContextTimeToLive_timeToLiveInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActiveContextTimeToLive' {Maybe Natural
timeToLiveInSeconds :: Maybe Natural
$sel:timeToLiveInSeconds:ActiveContextTimeToLive' :: ActiveContextTimeToLive -> Maybe Natural
timeToLiveInSeconds} -> Maybe Natural
timeToLiveInSeconds) (\s :: ActiveContextTimeToLive
s@ActiveContextTimeToLive' {} Maybe Natural
a -> ActiveContextTimeToLive
s {$sel:timeToLiveInSeconds:ActiveContextTimeToLive' :: Maybe Natural
timeToLiveInSeconds = Maybe Natural
a} :: ActiveContextTimeToLive)

-- | The number of conversation turns that the context should be active. A
-- conversation turn is one @PostContent@ or @PostText@ request and the
-- corresponding response from Amazon Lex.
activeContextTimeToLive_turnsToLive :: Lens.Lens' ActiveContextTimeToLive (Prelude.Maybe Prelude.Natural)
activeContextTimeToLive_turnsToLive :: Lens' ActiveContextTimeToLive (Maybe Natural)
activeContextTimeToLive_turnsToLive = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActiveContextTimeToLive' {Maybe Natural
turnsToLive :: Maybe Natural
$sel:turnsToLive:ActiveContextTimeToLive' :: ActiveContextTimeToLive -> Maybe Natural
turnsToLive} -> Maybe Natural
turnsToLive) (\s :: ActiveContextTimeToLive
s@ActiveContextTimeToLive' {} Maybe Natural
a -> ActiveContextTimeToLive
s {$sel:turnsToLive:ActiveContextTimeToLive' :: Maybe Natural
turnsToLive = Maybe Natural
a} :: ActiveContextTimeToLive)

instance Data.FromJSON ActiveContextTimeToLive where
  parseJSON :: Value -> Parser ActiveContextTimeToLive
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ActiveContextTimeToLive"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> ActiveContextTimeToLive
ActiveContextTimeToLive'
            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
"timeToLiveInSeconds")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"turnsToLive")
      )

instance Prelude.Hashable ActiveContextTimeToLive where
  hashWithSalt :: Int -> ActiveContextTimeToLive -> Int
hashWithSalt Int
_salt ActiveContextTimeToLive' {Maybe Natural
turnsToLive :: Maybe Natural
timeToLiveInSeconds :: Maybe Natural
$sel:turnsToLive:ActiveContextTimeToLive' :: ActiveContextTimeToLive -> Maybe Natural
$sel:timeToLiveInSeconds:ActiveContextTimeToLive' :: ActiveContextTimeToLive -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
timeToLiveInSeconds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
turnsToLive

instance Prelude.NFData ActiveContextTimeToLive where
  rnf :: ActiveContextTimeToLive -> ()
rnf ActiveContextTimeToLive' {Maybe Natural
turnsToLive :: Maybe Natural
timeToLiveInSeconds :: Maybe Natural
$sel:turnsToLive:ActiveContextTimeToLive' :: ActiveContextTimeToLive -> Maybe Natural
$sel:timeToLiveInSeconds:ActiveContextTimeToLive' :: ActiveContextTimeToLive -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
timeToLiveInSeconds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
turnsToLive

instance Data.ToJSON ActiveContextTimeToLive where
  toJSON :: ActiveContextTimeToLive -> Value
toJSON ActiveContextTimeToLive' {Maybe Natural
turnsToLive :: Maybe Natural
timeToLiveInSeconds :: Maybe Natural
$sel:turnsToLive:ActiveContextTimeToLive' :: ActiveContextTimeToLive -> Maybe Natural
$sel:timeToLiveInSeconds:ActiveContextTimeToLive' :: ActiveContextTimeToLive -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"timeToLiveInSeconds" 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 Natural
timeToLiveInSeconds,
            (Key
"turnsToLive" 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 Natural
turnsToLive
          ]
      )