{-# 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.BotAliasLocaleSettings
-- 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.BotAliasLocaleSettings 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.CodeHookSpecification
import qualified Amazonka.Prelude as Prelude

-- | Specifies settings that are unique to a locale. For example, you can use
-- different Lambda function depending on the bot\'s locale.
--
-- /See:/ 'newBotAliasLocaleSettings' smart constructor.
data BotAliasLocaleSettings = BotAliasLocaleSettings'
  { -- | Specifies the Lambda function that should be used in the locale.
    BotAliasLocaleSettings -> Maybe CodeHookSpecification
codeHookSpecification :: Prelude.Maybe CodeHookSpecification,
    -- | Determines whether the locale is enabled for the bot. If the value is
    -- @false@, the locale isn\'t available for use.
    BotAliasLocaleSettings -> Bool
enabled :: Prelude.Bool
  }
  deriving (BotAliasLocaleSettings -> BotAliasLocaleSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BotAliasLocaleSettings -> BotAliasLocaleSettings -> Bool
$c/= :: BotAliasLocaleSettings -> BotAliasLocaleSettings -> Bool
== :: BotAliasLocaleSettings -> BotAliasLocaleSettings -> Bool
$c== :: BotAliasLocaleSettings -> BotAliasLocaleSettings -> Bool
Prelude.Eq, ReadPrec [BotAliasLocaleSettings]
ReadPrec BotAliasLocaleSettings
Int -> ReadS BotAliasLocaleSettings
ReadS [BotAliasLocaleSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BotAliasLocaleSettings]
$creadListPrec :: ReadPrec [BotAliasLocaleSettings]
readPrec :: ReadPrec BotAliasLocaleSettings
$creadPrec :: ReadPrec BotAliasLocaleSettings
readList :: ReadS [BotAliasLocaleSettings]
$creadList :: ReadS [BotAliasLocaleSettings]
readsPrec :: Int -> ReadS BotAliasLocaleSettings
$creadsPrec :: Int -> ReadS BotAliasLocaleSettings
Prelude.Read, Int -> BotAliasLocaleSettings -> ShowS
[BotAliasLocaleSettings] -> ShowS
BotAliasLocaleSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BotAliasLocaleSettings] -> ShowS
$cshowList :: [BotAliasLocaleSettings] -> ShowS
show :: BotAliasLocaleSettings -> String
$cshow :: BotAliasLocaleSettings -> String
showsPrec :: Int -> BotAliasLocaleSettings -> ShowS
$cshowsPrec :: Int -> BotAliasLocaleSettings -> ShowS
Prelude.Show, forall x. Rep BotAliasLocaleSettings x -> BotAliasLocaleSettings
forall x. BotAliasLocaleSettings -> Rep BotAliasLocaleSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BotAliasLocaleSettings x -> BotAliasLocaleSettings
$cfrom :: forall x. BotAliasLocaleSettings -> Rep BotAliasLocaleSettings x
Prelude.Generic)

-- |
-- Create a value of 'BotAliasLocaleSettings' 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:
--
-- 'codeHookSpecification', 'botAliasLocaleSettings_codeHookSpecification' - Specifies the Lambda function that should be used in the locale.
--
-- 'enabled', 'botAliasLocaleSettings_enabled' - Determines whether the locale is enabled for the bot. If the value is
-- @false@, the locale isn\'t available for use.
newBotAliasLocaleSettings ::
  -- | 'enabled'
  Prelude.Bool ->
  BotAliasLocaleSettings
newBotAliasLocaleSettings :: Bool -> BotAliasLocaleSettings
newBotAliasLocaleSettings Bool
pEnabled_ =
  BotAliasLocaleSettings'
    { $sel:codeHookSpecification:BotAliasLocaleSettings' :: Maybe CodeHookSpecification
codeHookSpecification =
        forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:BotAliasLocaleSettings' :: Bool
enabled = Bool
pEnabled_
    }

-- | Specifies the Lambda function that should be used in the locale.
botAliasLocaleSettings_codeHookSpecification :: Lens.Lens' BotAliasLocaleSettings (Prelude.Maybe CodeHookSpecification)
botAliasLocaleSettings_codeHookSpecification :: Lens' BotAliasLocaleSettings (Maybe CodeHookSpecification)
botAliasLocaleSettings_codeHookSpecification = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BotAliasLocaleSettings' {Maybe CodeHookSpecification
codeHookSpecification :: Maybe CodeHookSpecification
$sel:codeHookSpecification:BotAliasLocaleSettings' :: BotAliasLocaleSettings -> Maybe CodeHookSpecification
codeHookSpecification} -> Maybe CodeHookSpecification
codeHookSpecification) (\s :: BotAliasLocaleSettings
s@BotAliasLocaleSettings' {} Maybe CodeHookSpecification
a -> BotAliasLocaleSettings
s {$sel:codeHookSpecification:BotAliasLocaleSettings' :: Maybe CodeHookSpecification
codeHookSpecification = Maybe CodeHookSpecification
a} :: BotAliasLocaleSettings)

-- | Determines whether the locale is enabled for the bot. If the value is
-- @false@, the locale isn\'t available for use.
botAliasLocaleSettings_enabled :: Lens.Lens' BotAliasLocaleSettings Prelude.Bool
botAliasLocaleSettings_enabled :: Lens' BotAliasLocaleSettings Bool
botAliasLocaleSettings_enabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BotAliasLocaleSettings' {Bool
enabled :: Bool
$sel:enabled:BotAliasLocaleSettings' :: BotAliasLocaleSettings -> Bool
enabled} -> Bool
enabled) (\s :: BotAliasLocaleSettings
s@BotAliasLocaleSettings' {} Bool
a -> BotAliasLocaleSettings
s {$sel:enabled:BotAliasLocaleSettings' :: Bool
enabled = Bool
a} :: BotAliasLocaleSettings)

instance Data.FromJSON BotAliasLocaleSettings where
  parseJSON :: Value -> Parser BotAliasLocaleSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BotAliasLocaleSettings"
      ( \Object
x ->
          Maybe CodeHookSpecification -> Bool -> BotAliasLocaleSettings
BotAliasLocaleSettings'
            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
"codeHookSpecification")
            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 BotAliasLocaleSettings where
  hashWithSalt :: Int -> BotAliasLocaleSettings -> Int
hashWithSalt Int
_salt BotAliasLocaleSettings' {Bool
Maybe CodeHookSpecification
enabled :: Bool
codeHookSpecification :: Maybe CodeHookSpecification
$sel:enabled:BotAliasLocaleSettings' :: BotAliasLocaleSettings -> Bool
$sel:codeHookSpecification:BotAliasLocaleSettings' :: BotAliasLocaleSettings -> Maybe CodeHookSpecification
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CodeHookSpecification
codeHookSpecification
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
enabled

instance Prelude.NFData BotAliasLocaleSettings where
  rnf :: BotAliasLocaleSettings -> ()
rnf BotAliasLocaleSettings' {Bool
Maybe CodeHookSpecification
enabled :: Bool
codeHookSpecification :: Maybe CodeHookSpecification
$sel:enabled:BotAliasLocaleSettings' :: BotAliasLocaleSettings -> Bool
$sel:codeHookSpecification:BotAliasLocaleSettings' :: BotAliasLocaleSettings -> Maybe CodeHookSpecification
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CodeHookSpecification
codeHookSpecification
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
enabled

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