{-# 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.LexV2Models.Types.FulfillmentUpdatesSpecification
-- 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.LexV2Models.Types.FulfillmentUpdatesSpecification where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LexV2Models.Types.FulfillmentStartResponseSpecification
import Amazonka.LexV2Models.Types.FulfillmentUpdateResponseSpecification
import qualified Amazonka.Prelude as Prelude

-- | Provides information for updating the user on the progress of fulfilling
-- an intent.
--
-- /See:/ 'newFulfillmentUpdatesSpecification' smart constructor.
data FulfillmentUpdatesSpecification = FulfillmentUpdatesSpecification'
  { -- | Provides configuration information for the message sent to users when
    -- the fulfillment Lambda functions starts running.
    FulfillmentUpdatesSpecification
-> Maybe FulfillmentStartResponseSpecification
startResponse :: Prelude.Maybe FulfillmentStartResponseSpecification,
    -- | The length of time that the fulfillment Lambda function should run
    -- before it times out.
    FulfillmentUpdatesSpecification -> Maybe Natural
timeoutInSeconds :: Prelude.Maybe Prelude.Natural,
    -- | Provides configuration information for messages sent periodically to the
    -- user while the fulfillment Lambda function is running.
    FulfillmentUpdatesSpecification
-> Maybe FulfillmentUpdateResponseSpecification
updateResponse :: Prelude.Maybe FulfillmentUpdateResponseSpecification,
    -- | Determines whether fulfillment updates are sent to the user. When this
    -- field is true, updates are sent.
    --
    -- If the @active@ field is set to true, the @startResponse@,
    -- @updateResponse@, and @timeoutInSeconds@ fields are required.
    FulfillmentUpdatesSpecification -> Bool
active :: Prelude.Bool
  }
  deriving (FulfillmentUpdatesSpecification
-> FulfillmentUpdatesSpecification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FulfillmentUpdatesSpecification
-> FulfillmentUpdatesSpecification -> Bool
$c/= :: FulfillmentUpdatesSpecification
-> FulfillmentUpdatesSpecification -> Bool
== :: FulfillmentUpdatesSpecification
-> FulfillmentUpdatesSpecification -> Bool
$c== :: FulfillmentUpdatesSpecification
-> FulfillmentUpdatesSpecification -> Bool
Prelude.Eq, ReadPrec [FulfillmentUpdatesSpecification]
ReadPrec FulfillmentUpdatesSpecification
Int -> ReadS FulfillmentUpdatesSpecification
ReadS [FulfillmentUpdatesSpecification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FulfillmentUpdatesSpecification]
$creadListPrec :: ReadPrec [FulfillmentUpdatesSpecification]
readPrec :: ReadPrec FulfillmentUpdatesSpecification
$creadPrec :: ReadPrec FulfillmentUpdatesSpecification
readList :: ReadS [FulfillmentUpdatesSpecification]
$creadList :: ReadS [FulfillmentUpdatesSpecification]
readsPrec :: Int -> ReadS FulfillmentUpdatesSpecification
$creadsPrec :: Int -> ReadS FulfillmentUpdatesSpecification
Prelude.Read, Int -> FulfillmentUpdatesSpecification -> ShowS
[FulfillmentUpdatesSpecification] -> ShowS
FulfillmentUpdatesSpecification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FulfillmentUpdatesSpecification] -> ShowS
$cshowList :: [FulfillmentUpdatesSpecification] -> ShowS
show :: FulfillmentUpdatesSpecification -> String
$cshow :: FulfillmentUpdatesSpecification -> String
showsPrec :: Int -> FulfillmentUpdatesSpecification -> ShowS
$cshowsPrec :: Int -> FulfillmentUpdatesSpecification -> ShowS
Prelude.Show, forall x.
Rep FulfillmentUpdatesSpecification x
-> FulfillmentUpdatesSpecification
forall x.
FulfillmentUpdatesSpecification
-> Rep FulfillmentUpdatesSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FulfillmentUpdatesSpecification x
-> FulfillmentUpdatesSpecification
$cfrom :: forall x.
FulfillmentUpdatesSpecification
-> Rep FulfillmentUpdatesSpecification x
Prelude.Generic)

-- |
-- Create a value of 'FulfillmentUpdatesSpecification' 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:
--
-- 'startResponse', 'fulfillmentUpdatesSpecification_startResponse' - Provides configuration information for the message sent to users when
-- the fulfillment Lambda functions starts running.
--
-- 'timeoutInSeconds', 'fulfillmentUpdatesSpecification_timeoutInSeconds' - The length of time that the fulfillment Lambda function should run
-- before it times out.
--
-- 'updateResponse', 'fulfillmentUpdatesSpecification_updateResponse' - Provides configuration information for messages sent periodically to the
-- user while the fulfillment Lambda function is running.
--
-- 'active', 'fulfillmentUpdatesSpecification_active' - Determines whether fulfillment updates are sent to the user. When this
-- field is true, updates are sent.
--
-- If the @active@ field is set to true, the @startResponse@,
-- @updateResponse@, and @timeoutInSeconds@ fields are required.
newFulfillmentUpdatesSpecification ::
  -- | 'active'
  Prelude.Bool ->
  FulfillmentUpdatesSpecification
newFulfillmentUpdatesSpecification :: Bool -> FulfillmentUpdatesSpecification
newFulfillmentUpdatesSpecification Bool
pActive_ =
  FulfillmentUpdatesSpecification'
    { $sel:startResponse:FulfillmentUpdatesSpecification' :: Maybe FulfillmentStartResponseSpecification
startResponse =
        forall a. Maybe a
Prelude.Nothing,
      $sel:timeoutInSeconds:FulfillmentUpdatesSpecification' :: Maybe Natural
timeoutInSeconds = forall a. Maybe a
Prelude.Nothing,
      $sel:updateResponse:FulfillmentUpdatesSpecification' :: Maybe FulfillmentUpdateResponseSpecification
updateResponse = forall a. Maybe a
Prelude.Nothing,
      $sel:active:FulfillmentUpdatesSpecification' :: Bool
active = Bool
pActive_
    }

-- | Provides configuration information for the message sent to users when
-- the fulfillment Lambda functions starts running.
fulfillmentUpdatesSpecification_startResponse :: Lens.Lens' FulfillmentUpdatesSpecification (Prelude.Maybe FulfillmentStartResponseSpecification)
fulfillmentUpdatesSpecification_startResponse :: Lens'
  FulfillmentUpdatesSpecification
  (Maybe FulfillmentStartResponseSpecification)
fulfillmentUpdatesSpecification_startResponse = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FulfillmentUpdatesSpecification' {Maybe FulfillmentStartResponseSpecification
startResponse :: Maybe FulfillmentStartResponseSpecification
$sel:startResponse:FulfillmentUpdatesSpecification' :: FulfillmentUpdatesSpecification
-> Maybe FulfillmentStartResponseSpecification
startResponse} -> Maybe FulfillmentStartResponseSpecification
startResponse) (\s :: FulfillmentUpdatesSpecification
s@FulfillmentUpdatesSpecification' {} Maybe FulfillmentStartResponseSpecification
a -> FulfillmentUpdatesSpecification
s {$sel:startResponse:FulfillmentUpdatesSpecification' :: Maybe FulfillmentStartResponseSpecification
startResponse = Maybe FulfillmentStartResponseSpecification
a} :: FulfillmentUpdatesSpecification)

-- | The length of time that the fulfillment Lambda function should run
-- before it times out.
fulfillmentUpdatesSpecification_timeoutInSeconds :: Lens.Lens' FulfillmentUpdatesSpecification (Prelude.Maybe Prelude.Natural)
fulfillmentUpdatesSpecification_timeoutInSeconds :: Lens' FulfillmentUpdatesSpecification (Maybe Natural)
fulfillmentUpdatesSpecification_timeoutInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FulfillmentUpdatesSpecification' {Maybe Natural
timeoutInSeconds :: Maybe Natural
$sel:timeoutInSeconds:FulfillmentUpdatesSpecification' :: FulfillmentUpdatesSpecification -> Maybe Natural
timeoutInSeconds} -> Maybe Natural
timeoutInSeconds) (\s :: FulfillmentUpdatesSpecification
s@FulfillmentUpdatesSpecification' {} Maybe Natural
a -> FulfillmentUpdatesSpecification
s {$sel:timeoutInSeconds:FulfillmentUpdatesSpecification' :: Maybe Natural
timeoutInSeconds = Maybe Natural
a} :: FulfillmentUpdatesSpecification)

-- | Provides configuration information for messages sent periodically to the
-- user while the fulfillment Lambda function is running.
fulfillmentUpdatesSpecification_updateResponse :: Lens.Lens' FulfillmentUpdatesSpecification (Prelude.Maybe FulfillmentUpdateResponseSpecification)
fulfillmentUpdatesSpecification_updateResponse :: Lens'
  FulfillmentUpdatesSpecification
  (Maybe FulfillmentUpdateResponseSpecification)
fulfillmentUpdatesSpecification_updateResponse = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FulfillmentUpdatesSpecification' {Maybe FulfillmentUpdateResponseSpecification
updateResponse :: Maybe FulfillmentUpdateResponseSpecification
$sel:updateResponse:FulfillmentUpdatesSpecification' :: FulfillmentUpdatesSpecification
-> Maybe FulfillmentUpdateResponseSpecification
updateResponse} -> Maybe FulfillmentUpdateResponseSpecification
updateResponse) (\s :: FulfillmentUpdatesSpecification
s@FulfillmentUpdatesSpecification' {} Maybe FulfillmentUpdateResponseSpecification
a -> FulfillmentUpdatesSpecification
s {$sel:updateResponse:FulfillmentUpdatesSpecification' :: Maybe FulfillmentUpdateResponseSpecification
updateResponse = Maybe FulfillmentUpdateResponseSpecification
a} :: FulfillmentUpdatesSpecification)

-- | Determines whether fulfillment updates are sent to the user. When this
-- field is true, updates are sent.
--
-- If the @active@ field is set to true, the @startResponse@,
-- @updateResponse@, and @timeoutInSeconds@ fields are required.
fulfillmentUpdatesSpecification_active :: Lens.Lens' FulfillmentUpdatesSpecification Prelude.Bool
fulfillmentUpdatesSpecification_active :: Lens' FulfillmentUpdatesSpecification Bool
fulfillmentUpdatesSpecification_active = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FulfillmentUpdatesSpecification' {Bool
active :: Bool
$sel:active:FulfillmentUpdatesSpecification' :: FulfillmentUpdatesSpecification -> Bool
active} -> Bool
active) (\s :: FulfillmentUpdatesSpecification
s@FulfillmentUpdatesSpecification' {} Bool
a -> FulfillmentUpdatesSpecification
s {$sel:active:FulfillmentUpdatesSpecification' :: Bool
active = Bool
a} :: FulfillmentUpdatesSpecification)

instance
  Data.FromJSON
    FulfillmentUpdatesSpecification
  where
  parseJSON :: Value -> Parser FulfillmentUpdatesSpecification
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FulfillmentUpdatesSpecification"
      ( \Object
x ->
          Maybe FulfillmentStartResponseSpecification
-> Maybe Natural
-> Maybe FulfillmentUpdateResponseSpecification
-> Bool
-> FulfillmentUpdatesSpecification
FulfillmentUpdatesSpecification'
            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
"startResponse")
            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
"timeoutInSeconds")
            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
"updateResponse")
            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
"active")
      )

instance
  Prelude.Hashable
    FulfillmentUpdatesSpecification
  where
  hashWithSalt :: Int -> FulfillmentUpdatesSpecification -> Int
hashWithSalt
    Int
_salt
    FulfillmentUpdatesSpecification' {Bool
Maybe Natural
Maybe FulfillmentUpdateResponseSpecification
Maybe FulfillmentStartResponseSpecification
active :: Bool
updateResponse :: Maybe FulfillmentUpdateResponseSpecification
timeoutInSeconds :: Maybe Natural
startResponse :: Maybe FulfillmentStartResponseSpecification
$sel:active:FulfillmentUpdatesSpecification' :: FulfillmentUpdatesSpecification -> Bool
$sel:updateResponse:FulfillmentUpdatesSpecification' :: FulfillmentUpdatesSpecification
-> Maybe FulfillmentUpdateResponseSpecification
$sel:timeoutInSeconds:FulfillmentUpdatesSpecification' :: FulfillmentUpdatesSpecification -> Maybe Natural
$sel:startResponse:FulfillmentUpdatesSpecification' :: FulfillmentUpdatesSpecification
-> Maybe FulfillmentStartResponseSpecification
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FulfillmentStartResponseSpecification
startResponse
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
timeoutInSeconds
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FulfillmentUpdateResponseSpecification
updateResponse
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
active

instance
  Prelude.NFData
    FulfillmentUpdatesSpecification
  where
  rnf :: FulfillmentUpdatesSpecification -> ()
rnf FulfillmentUpdatesSpecification' {Bool
Maybe Natural
Maybe FulfillmentUpdateResponseSpecification
Maybe FulfillmentStartResponseSpecification
active :: Bool
updateResponse :: Maybe FulfillmentUpdateResponseSpecification
timeoutInSeconds :: Maybe Natural
startResponse :: Maybe FulfillmentStartResponseSpecification
$sel:active:FulfillmentUpdatesSpecification' :: FulfillmentUpdatesSpecification -> Bool
$sel:updateResponse:FulfillmentUpdatesSpecification' :: FulfillmentUpdatesSpecification
-> Maybe FulfillmentUpdateResponseSpecification
$sel:timeoutInSeconds:FulfillmentUpdatesSpecification' :: FulfillmentUpdatesSpecification -> Maybe Natural
$sel:startResponse:FulfillmentUpdatesSpecification' :: FulfillmentUpdatesSpecification
-> Maybe FulfillmentStartResponseSpecification
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FulfillmentStartResponseSpecification
startResponse
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
timeoutInSeconds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FulfillmentUpdateResponseSpecification
updateResponse
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
active

instance Data.ToJSON FulfillmentUpdatesSpecification where
  toJSON :: FulfillmentUpdatesSpecification -> Value
toJSON FulfillmentUpdatesSpecification' {Bool
Maybe Natural
Maybe FulfillmentUpdateResponseSpecification
Maybe FulfillmentStartResponseSpecification
active :: Bool
updateResponse :: Maybe FulfillmentUpdateResponseSpecification
timeoutInSeconds :: Maybe Natural
startResponse :: Maybe FulfillmentStartResponseSpecification
$sel:active:FulfillmentUpdatesSpecification' :: FulfillmentUpdatesSpecification -> Bool
$sel:updateResponse:FulfillmentUpdatesSpecification' :: FulfillmentUpdatesSpecification
-> Maybe FulfillmentUpdateResponseSpecification
$sel:timeoutInSeconds:FulfillmentUpdatesSpecification' :: FulfillmentUpdatesSpecification -> Maybe Natural
$sel:startResponse:FulfillmentUpdatesSpecification' :: FulfillmentUpdatesSpecification
-> Maybe FulfillmentStartResponseSpecification
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"startResponse" 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 FulfillmentStartResponseSpecification
startResponse,
            (Key
"timeoutInSeconds" 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
timeoutInSeconds,
            (Key
"updateResponse" 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 FulfillmentUpdateResponseSpecification
updateResponse,
            forall a. a -> Maybe a
Prelude.Just (Key
"active" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
active)
          ]
      )