{-# 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.FulfillmentCodeHookSettings
-- 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.FulfillmentCodeHookSettings 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.FulfillmentUpdatesSpecification
import Amazonka.LexV2Models.Types.PostFulfillmentStatusSpecification
import qualified Amazonka.Prelude as Prelude

-- | Determines if a Lambda function should be invoked for a specific intent.
--
-- /See:/ 'newFulfillmentCodeHookSettings' smart constructor.
data FulfillmentCodeHookSettings = FulfillmentCodeHookSettings'
  { -- | Determines whether the fulfillment code hook is used. When @active@ is
    -- false, the code hook doesn\'t run.
    FulfillmentCodeHookSettings -> Maybe Bool
active :: Prelude.Maybe Prelude.Bool,
    -- | Provides settings for update messages sent to the user for long-running
    -- Lambda fulfillment functions. Fulfillment updates can be used only with
    -- streaming conversations.
    FulfillmentCodeHookSettings
-> Maybe FulfillmentUpdatesSpecification
fulfillmentUpdatesSpecification :: Prelude.Maybe FulfillmentUpdatesSpecification,
    -- | Provides settings for messages sent to the user for after the Lambda
    -- fulfillment function completes. Post-fulfillment messages can be sent
    -- for both streaming and non-streaming conversations.
    FulfillmentCodeHookSettings
-> Maybe PostFulfillmentStatusSpecification
postFulfillmentStatusSpecification :: Prelude.Maybe PostFulfillmentStatusSpecification,
    -- | Indicates whether a Lambda function should be invoked to fulfill a
    -- specific intent.
    FulfillmentCodeHookSettings -> Bool
enabled :: Prelude.Bool
  }
  deriving (FulfillmentCodeHookSettings -> FulfillmentCodeHookSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FulfillmentCodeHookSettings -> FulfillmentCodeHookSettings -> Bool
$c/= :: FulfillmentCodeHookSettings -> FulfillmentCodeHookSettings -> Bool
== :: FulfillmentCodeHookSettings -> FulfillmentCodeHookSettings -> Bool
$c== :: FulfillmentCodeHookSettings -> FulfillmentCodeHookSettings -> Bool
Prelude.Eq, ReadPrec [FulfillmentCodeHookSettings]
ReadPrec FulfillmentCodeHookSettings
Int -> ReadS FulfillmentCodeHookSettings
ReadS [FulfillmentCodeHookSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FulfillmentCodeHookSettings]
$creadListPrec :: ReadPrec [FulfillmentCodeHookSettings]
readPrec :: ReadPrec FulfillmentCodeHookSettings
$creadPrec :: ReadPrec FulfillmentCodeHookSettings
readList :: ReadS [FulfillmentCodeHookSettings]
$creadList :: ReadS [FulfillmentCodeHookSettings]
readsPrec :: Int -> ReadS FulfillmentCodeHookSettings
$creadsPrec :: Int -> ReadS FulfillmentCodeHookSettings
Prelude.Read, Int -> FulfillmentCodeHookSettings -> ShowS
[FulfillmentCodeHookSettings] -> ShowS
FulfillmentCodeHookSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FulfillmentCodeHookSettings] -> ShowS
$cshowList :: [FulfillmentCodeHookSettings] -> ShowS
show :: FulfillmentCodeHookSettings -> String
$cshow :: FulfillmentCodeHookSettings -> String
showsPrec :: Int -> FulfillmentCodeHookSettings -> ShowS
$cshowsPrec :: Int -> FulfillmentCodeHookSettings -> ShowS
Prelude.Show, forall x.
Rep FulfillmentCodeHookSettings x -> FulfillmentCodeHookSettings
forall x.
FulfillmentCodeHookSettings -> Rep FulfillmentCodeHookSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FulfillmentCodeHookSettings x -> FulfillmentCodeHookSettings
$cfrom :: forall x.
FulfillmentCodeHookSettings -> Rep FulfillmentCodeHookSettings x
Prelude.Generic)

-- |
-- Create a value of 'FulfillmentCodeHookSettings' 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:
--
-- 'active', 'fulfillmentCodeHookSettings_active' - Determines whether the fulfillment code hook is used. When @active@ is
-- false, the code hook doesn\'t run.
--
-- 'fulfillmentUpdatesSpecification', 'fulfillmentCodeHookSettings_fulfillmentUpdatesSpecification' - Provides settings for update messages sent to the user for long-running
-- Lambda fulfillment functions. Fulfillment updates can be used only with
-- streaming conversations.
--
-- 'postFulfillmentStatusSpecification', 'fulfillmentCodeHookSettings_postFulfillmentStatusSpecification' - Provides settings for messages sent to the user for after the Lambda
-- fulfillment function completes. Post-fulfillment messages can be sent
-- for both streaming and non-streaming conversations.
--
-- 'enabled', 'fulfillmentCodeHookSettings_enabled' - Indicates whether a Lambda function should be invoked to fulfill a
-- specific intent.
newFulfillmentCodeHookSettings ::
  -- | 'enabled'
  Prelude.Bool ->
  FulfillmentCodeHookSettings
newFulfillmentCodeHookSettings :: Bool -> FulfillmentCodeHookSettings
newFulfillmentCodeHookSettings Bool
pEnabled_ =
  FulfillmentCodeHookSettings'
    { $sel:active:FulfillmentCodeHookSettings' :: Maybe Bool
active =
        forall a. Maybe a
Prelude.Nothing,
      $sel:fulfillmentUpdatesSpecification:FulfillmentCodeHookSettings' :: Maybe FulfillmentUpdatesSpecification
fulfillmentUpdatesSpecification =
        forall a. Maybe a
Prelude.Nothing,
      $sel:postFulfillmentStatusSpecification:FulfillmentCodeHookSettings' :: Maybe PostFulfillmentStatusSpecification
postFulfillmentStatusSpecification =
        forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:FulfillmentCodeHookSettings' :: Bool
enabled = Bool
pEnabled_
    }

-- | Determines whether the fulfillment code hook is used. When @active@ is
-- false, the code hook doesn\'t run.
fulfillmentCodeHookSettings_active :: Lens.Lens' FulfillmentCodeHookSettings (Prelude.Maybe Prelude.Bool)
fulfillmentCodeHookSettings_active :: Lens' FulfillmentCodeHookSettings (Maybe Bool)
fulfillmentCodeHookSettings_active = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FulfillmentCodeHookSettings' {Maybe Bool
active :: Maybe Bool
$sel:active:FulfillmentCodeHookSettings' :: FulfillmentCodeHookSettings -> Maybe Bool
active} -> Maybe Bool
active) (\s :: FulfillmentCodeHookSettings
s@FulfillmentCodeHookSettings' {} Maybe Bool
a -> FulfillmentCodeHookSettings
s {$sel:active:FulfillmentCodeHookSettings' :: Maybe Bool
active = Maybe Bool
a} :: FulfillmentCodeHookSettings)

-- | Provides settings for update messages sent to the user for long-running
-- Lambda fulfillment functions. Fulfillment updates can be used only with
-- streaming conversations.
fulfillmentCodeHookSettings_fulfillmentUpdatesSpecification :: Lens.Lens' FulfillmentCodeHookSettings (Prelude.Maybe FulfillmentUpdatesSpecification)
fulfillmentCodeHookSettings_fulfillmentUpdatesSpecification :: Lens'
  FulfillmentCodeHookSettings (Maybe FulfillmentUpdatesSpecification)
fulfillmentCodeHookSettings_fulfillmentUpdatesSpecification = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FulfillmentCodeHookSettings' {Maybe FulfillmentUpdatesSpecification
fulfillmentUpdatesSpecification :: Maybe FulfillmentUpdatesSpecification
$sel:fulfillmentUpdatesSpecification:FulfillmentCodeHookSettings' :: FulfillmentCodeHookSettings
-> Maybe FulfillmentUpdatesSpecification
fulfillmentUpdatesSpecification} -> Maybe FulfillmentUpdatesSpecification
fulfillmentUpdatesSpecification) (\s :: FulfillmentCodeHookSettings
s@FulfillmentCodeHookSettings' {} Maybe FulfillmentUpdatesSpecification
a -> FulfillmentCodeHookSettings
s {$sel:fulfillmentUpdatesSpecification:FulfillmentCodeHookSettings' :: Maybe FulfillmentUpdatesSpecification
fulfillmentUpdatesSpecification = Maybe FulfillmentUpdatesSpecification
a} :: FulfillmentCodeHookSettings)

-- | Provides settings for messages sent to the user for after the Lambda
-- fulfillment function completes. Post-fulfillment messages can be sent
-- for both streaming and non-streaming conversations.
fulfillmentCodeHookSettings_postFulfillmentStatusSpecification :: Lens.Lens' FulfillmentCodeHookSettings (Prelude.Maybe PostFulfillmentStatusSpecification)
fulfillmentCodeHookSettings_postFulfillmentStatusSpecification :: Lens'
  FulfillmentCodeHookSettings
  (Maybe PostFulfillmentStatusSpecification)
fulfillmentCodeHookSettings_postFulfillmentStatusSpecification = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FulfillmentCodeHookSettings' {Maybe PostFulfillmentStatusSpecification
postFulfillmentStatusSpecification :: Maybe PostFulfillmentStatusSpecification
$sel:postFulfillmentStatusSpecification:FulfillmentCodeHookSettings' :: FulfillmentCodeHookSettings
-> Maybe PostFulfillmentStatusSpecification
postFulfillmentStatusSpecification} -> Maybe PostFulfillmentStatusSpecification
postFulfillmentStatusSpecification) (\s :: FulfillmentCodeHookSettings
s@FulfillmentCodeHookSettings' {} Maybe PostFulfillmentStatusSpecification
a -> FulfillmentCodeHookSettings
s {$sel:postFulfillmentStatusSpecification:FulfillmentCodeHookSettings' :: Maybe PostFulfillmentStatusSpecification
postFulfillmentStatusSpecification = Maybe PostFulfillmentStatusSpecification
a} :: FulfillmentCodeHookSettings)

-- | Indicates whether a Lambda function should be invoked to fulfill a
-- specific intent.
fulfillmentCodeHookSettings_enabled :: Lens.Lens' FulfillmentCodeHookSettings Prelude.Bool
fulfillmentCodeHookSettings_enabled :: Lens' FulfillmentCodeHookSettings Bool
fulfillmentCodeHookSettings_enabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FulfillmentCodeHookSettings' {Bool
enabled :: Bool
$sel:enabled:FulfillmentCodeHookSettings' :: FulfillmentCodeHookSettings -> Bool
enabled} -> Bool
enabled) (\s :: FulfillmentCodeHookSettings
s@FulfillmentCodeHookSettings' {} Bool
a -> FulfillmentCodeHookSettings
s {$sel:enabled:FulfillmentCodeHookSettings' :: Bool
enabled = Bool
a} :: FulfillmentCodeHookSettings)

instance Data.FromJSON FulfillmentCodeHookSettings where
  parseJSON :: Value -> Parser FulfillmentCodeHookSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FulfillmentCodeHookSettings"
      ( \Object
x ->
          Maybe Bool
-> Maybe FulfillmentUpdatesSpecification
-> Maybe PostFulfillmentStatusSpecification
-> Bool
-> FulfillmentCodeHookSettings
FulfillmentCodeHookSettings'
            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
"active")
            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
"fulfillmentUpdatesSpecification")
            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
"postFulfillmentStatusSpecification")
            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
"enabled")
      )

instance Prelude.Hashable FulfillmentCodeHookSettings where
  hashWithSalt :: Int -> FulfillmentCodeHookSettings -> Int
hashWithSalt Int
_salt FulfillmentCodeHookSettings' {Bool
Maybe Bool
Maybe FulfillmentUpdatesSpecification
Maybe PostFulfillmentStatusSpecification
enabled :: Bool
postFulfillmentStatusSpecification :: Maybe PostFulfillmentStatusSpecification
fulfillmentUpdatesSpecification :: Maybe FulfillmentUpdatesSpecification
active :: Maybe Bool
$sel:enabled:FulfillmentCodeHookSettings' :: FulfillmentCodeHookSettings -> Bool
$sel:postFulfillmentStatusSpecification:FulfillmentCodeHookSettings' :: FulfillmentCodeHookSettings
-> Maybe PostFulfillmentStatusSpecification
$sel:fulfillmentUpdatesSpecification:FulfillmentCodeHookSettings' :: FulfillmentCodeHookSettings
-> Maybe FulfillmentUpdatesSpecification
$sel:active:FulfillmentCodeHookSettings' :: FulfillmentCodeHookSettings -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
active
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FulfillmentUpdatesSpecification
fulfillmentUpdatesSpecification
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PostFulfillmentStatusSpecification
postFulfillmentStatusSpecification
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
enabled

instance Prelude.NFData FulfillmentCodeHookSettings where
  rnf :: FulfillmentCodeHookSettings -> ()
rnf FulfillmentCodeHookSettings' {Bool
Maybe Bool
Maybe FulfillmentUpdatesSpecification
Maybe PostFulfillmentStatusSpecification
enabled :: Bool
postFulfillmentStatusSpecification :: Maybe PostFulfillmentStatusSpecification
fulfillmentUpdatesSpecification :: Maybe FulfillmentUpdatesSpecification
active :: Maybe Bool
$sel:enabled:FulfillmentCodeHookSettings' :: FulfillmentCodeHookSettings -> Bool
$sel:postFulfillmentStatusSpecification:FulfillmentCodeHookSettings' :: FulfillmentCodeHookSettings
-> Maybe PostFulfillmentStatusSpecification
$sel:fulfillmentUpdatesSpecification:FulfillmentCodeHookSettings' :: FulfillmentCodeHookSettings
-> Maybe FulfillmentUpdatesSpecification
$sel:active:FulfillmentCodeHookSettings' :: FulfillmentCodeHookSettings -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
active
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FulfillmentUpdatesSpecification
fulfillmentUpdatesSpecification
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PostFulfillmentStatusSpecification
postFulfillmentStatusSpecification
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
enabled

instance Data.ToJSON FulfillmentCodeHookSettings where
  toJSON :: FulfillmentCodeHookSettings -> Value
toJSON FulfillmentCodeHookSettings' {Bool
Maybe Bool
Maybe FulfillmentUpdatesSpecification
Maybe PostFulfillmentStatusSpecification
enabled :: Bool
postFulfillmentStatusSpecification :: Maybe PostFulfillmentStatusSpecification
fulfillmentUpdatesSpecification :: Maybe FulfillmentUpdatesSpecification
active :: Maybe Bool
$sel:enabled:FulfillmentCodeHookSettings' :: FulfillmentCodeHookSettings -> Bool
$sel:postFulfillmentStatusSpecification:FulfillmentCodeHookSettings' :: FulfillmentCodeHookSettings
-> Maybe PostFulfillmentStatusSpecification
$sel:fulfillmentUpdatesSpecification:FulfillmentCodeHookSettings' :: FulfillmentCodeHookSettings
-> Maybe FulfillmentUpdatesSpecification
$sel:active:FulfillmentCodeHookSettings' :: FulfillmentCodeHookSettings -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"active" 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 Bool
active,
            (Key
"fulfillmentUpdatesSpecification" 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 FulfillmentUpdatesSpecification
fulfillmentUpdatesSpecification,
            (Key
"postFulfillmentStatusSpecification" 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 PostFulfillmentStatusSpecification
postFulfillmentStatusSpecification,
            forall a. a -> Maybe a
Prelude.Just (Key
"enabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
enabled)
          ]
      )