{-# 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-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.LexRuntime.Types.ActiveContextTimeToLive where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | 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
  }
  deriving (ActiveContextTimeToLive -> ActiveContextTimeToLive -> Bool
(ActiveContextTimeToLive -> ActiveContextTimeToLive -> Bool)
-> (ActiveContextTimeToLive -> ActiveContextTimeToLive -> Bool)
-> Eq ActiveContextTimeToLive
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]
(Int -> ReadS ActiveContextTimeToLive)
-> ReadS [ActiveContextTimeToLive]
-> ReadPrec ActiveContextTimeToLive
-> ReadPrec [ActiveContextTimeToLive]
-> Read 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
(Int -> ActiveContextTimeToLive -> ShowS)
-> (ActiveContextTimeToLive -> String)
-> ([ActiveContextTimeToLive] -> ShowS)
-> Show ActiveContextTimeToLive
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.
 ActiveContextTimeToLive -> Rep ActiveContextTimeToLive x)
-> (forall x.
    Rep ActiveContextTimeToLive x -> ActiveContextTimeToLive)
-> Generic ActiveContextTimeToLive
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:
--
-- '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.
--
-- '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).
newActiveContextTimeToLive ::
  ActiveContextTimeToLive
newActiveContextTimeToLive :: ActiveContextTimeToLive
newActiveContextTimeToLive =
  ActiveContextTimeToLive' :: Maybe Natural -> Maybe Natural -> ActiveContextTimeToLive
ActiveContextTimeToLive'
    { $sel:turnsToLive:ActiveContextTimeToLive' :: Maybe Natural
turnsToLive =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:timeToLiveInSeconds:ActiveContextTimeToLive' :: Maybe Natural
timeToLiveInSeconds = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Natural -> f (Maybe Natural))
-> ActiveContextTimeToLive -> f ActiveContextTimeToLive
activeContextTimeToLive_turnsToLive = (ActiveContextTimeToLive -> Maybe Natural)
-> (ActiveContextTimeToLive
    -> Maybe Natural -> ActiveContextTimeToLive)
-> Lens
     ActiveContextTimeToLive
     ActiveContextTimeToLive
     (Maybe Natural)
     (Maybe Natural)
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)

-- | 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 :: (Maybe Natural -> f (Maybe Natural))
-> ActiveContextTimeToLive -> f ActiveContextTimeToLive
activeContextTimeToLive_timeToLiveInSeconds = (ActiveContextTimeToLive -> Maybe Natural)
-> (ActiveContextTimeToLive
    -> Maybe Natural -> ActiveContextTimeToLive)
-> Lens
     ActiveContextTimeToLive
     ActiveContextTimeToLive
     (Maybe Natural)
     (Maybe Natural)
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)

instance Core.FromJSON ActiveContextTimeToLive where
  parseJSON :: Value -> Parser ActiveContextTimeToLive
parseJSON =
    String
-> (Object -> Parser ActiveContextTimeToLive)
-> Value
-> Parser ActiveContextTimeToLive
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ActiveContextTimeToLive"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> ActiveContextTimeToLive
ActiveContextTimeToLive'
            (Maybe Natural -> Maybe Natural -> ActiveContextTimeToLive)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> ActiveContextTimeToLive)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"turnsToLive")
            Parser (Maybe Natural -> ActiveContextTimeToLive)
-> Parser (Maybe Natural) -> Parser ActiveContextTimeToLive
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"timeToLiveInSeconds")
      )

instance Prelude.Hashable ActiveContextTimeToLive

instance Prelude.NFData ActiveContextTimeToLive

instance Core.ToJSON ActiveContextTimeToLive where
  toJSON :: ActiveContextTimeToLive -> Value
toJSON ActiveContextTimeToLive' {Maybe Natural
timeToLiveInSeconds :: Maybe Natural
turnsToLive :: Maybe Natural
$sel:timeToLiveInSeconds:ActiveContextTimeToLive' :: ActiveContextTimeToLive -> Maybe Natural
$sel:turnsToLive:ActiveContextTimeToLive' :: ActiveContextTimeToLive -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"turnsToLive" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
turnsToLive,
            (Text
"timeToLiveInSeconds" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
timeToLiveInSeconds
          ]
      )