{-# 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.LexModels.Types.SlotDefaultValue
-- 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.LexModels.Types.SlotDefaultValue where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A default value for a slot.
--
-- /See:/ 'newSlotDefaultValue' smart constructor.
data SlotDefaultValue = SlotDefaultValue'
  { -- | The default value for the slot. You can specify one of the following:
    --
    -- -   @#context-name.slot-name@ - The slot value \"slot-name\" in the
    --     context \"context-name.\"
    --
    -- -   @{attribute}@ - The slot value of the session attribute
    --     \"attribute.\"
    --
    -- -   @\'value\'@ - The discrete value \"value.\"
    SlotDefaultValue -> Text
defaultValue :: Prelude.Text
  }
  deriving (SlotDefaultValue -> SlotDefaultValue -> Bool
(SlotDefaultValue -> SlotDefaultValue -> Bool)
-> (SlotDefaultValue -> SlotDefaultValue -> Bool)
-> Eq SlotDefaultValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SlotDefaultValue -> SlotDefaultValue -> Bool
$c/= :: SlotDefaultValue -> SlotDefaultValue -> Bool
== :: SlotDefaultValue -> SlotDefaultValue -> Bool
$c== :: SlotDefaultValue -> SlotDefaultValue -> Bool
Prelude.Eq, ReadPrec [SlotDefaultValue]
ReadPrec SlotDefaultValue
Int -> ReadS SlotDefaultValue
ReadS [SlotDefaultValue]
(Int -> ReadS SlotDefaultValue)
-> ReadS [SlotDefaultValue]
-> ReadPrec SlotDefaultValue
-> ReadPrec [SlotDefaultValue]
-> Read SlotDefaultValue
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SlotDefaultValue]
$creadListPrec :: ReadPrec [SlotDefaultValue]
readPrec :: ReadPrec SlotDefaultValue
$creadPrec :: ReadPrec SlotDefaultValue
readList :: ReadS [SlotDefaultValue]
$creadList :: ReadS [SlotDefaultValue]
readsPrec :: Int -> ReadS SlotDefaultValue
$creadsPrec :: Int -> ReadS SlotDefaultValue
Prelude.Read, Int -> SlotDefaultValue -> ShowS
[SlotDefaultValue] -> ShowS
SlotDefaultValue -> String
(Int -> SlotDefaultValue -> ShowS)
-> (SlotDefaultValue -> String)
-> ([SlotDefaultValue] -> ShowS)
-> Show SlotDefaultValue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SlotDefaultValue] -> ShowS
$cshowList :: [SlotDefaultValue] -> ShowS
show :: SlotDefaultValue -> String
$cshow :: SlotDefaultValue -> String
showsPrec :: Int -> SlotDefaultValue -> ShowS
$cshowsPrec :: Int -> SlotDefaultValue -> ShowS
Prelude.Show, (forall x. SlotDefaultValue -> Rep SlotDefaultValue x)
-> (forall x. Rep SlotDefaultValue x -> SlotDefaultValue)
-> Generic SlotDefaultValue
forall x. Rep SlotDefaultValue x -> SlotDefaultValue
forall x. SlotDefaultValue -> Rep SlotDefaultValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SlotDefaultValue x -> SlotDefaultValue
$cfrom :: forall x. SlotDefaultValue -> Rep SlotDefaultValue x
Prelude.Generic)

-- |
-- Create a value of 'SlotDefaultValue' 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:
--
-- 'defaultValue', 'slotDefaultValue_defaultValue' - The default value for the slot. You can specify one of the following:
--
-- -   @#context-name.slot-name@ - The slot value \"slot-name\" in the
--     context \"context-name.\"
--
-- -   @{attribute}@ - The slot value of the session attribute
--     \"attribute.\"
--
-- -   @\'value\'@ - The discrete value \"value.\"
newSlotDefaultValue ::
  -- | 'defaultValue'
  Prelude.Text ->
  SlotDefaultValue
newSlotDefaultValue :: Text -> SlotDefaultValue
newSlotDefaultValue Text
pDefaultValue_ =
  SlotDefaultValue' :: Text -> SlotDefaultValue
SlotDefaultValue' {$sel:defaultValue:SlotDefaultValue' :: Text
defaultValue = Text
pDefaultValue_}

-- | The default value for the slot. You can specify one of the following:
--
-- -   @#context-name.slot-name@ - The slot value \"slot-name\" in the
--     context \"context-name.\"
--
-- -   @{attribute}@ - The slot value of the session attribute
--     \"attribute.\"
--
-- -   @\'value\'@ - The discrete value \"value.\"
slotDefaultValue_defaultValue :: Lens.Lens' SlotDefaultValue Prelude.Text
slotDefaultValue_defaultValue :: (Text -> f Text) -> SlotDefaultValue -> f SlotDefaultValue
slotDefaultValue_defaultValue = (SlotDefaultValue -> Text)
-> (SlotDefaultValue -> Text -> SlotDefaultValue)
-> Lens SlotDefaultValue SlotDefaultValue Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotDefaultValue' {Text
defaultValue :: Text
$sel:defaultValue:SlotDefaultValue' :: SlotDefaultValue -> Text
defaultValue} -> Text
defaultValue) (\s :: SlotDefaultValue
s@SlotDefaultValue' {} Text
a -> SlotDefaultValue
s {$sel:defaultValue:SlotDefaultValue' :: Text
defaultValue = Text
a} :: SlotDefaultValue)

instance Core.FromJSON SlotDefaultValue where
  parseJSON :: Value -> Parser SlotDefaultValue
parseJSON =
    String
-> (Object -> Parser SlotDefaultValue)
-> Value
-> Parser SlotDefaultValue
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SlotDefaultValue"
      ( \Object
x ->
          Text -> SlotDefaultValue
SlotDefaultValue'
            (Text -> SlotDefaultValue)
-> Parser Text -> Parser SlotDefaultValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"defaultValue")
      )

instance Prelude.Hashable SlotDefaultValue

instance Prelude.NFData SlotDefaultValue

instance Core.ToJSON SlotDefaultValue where
  toJSON :: SlotDefaultValue -> Value
toJSON SlotDefaultValue' {Text
defaultValue :: Text
$sel:defaultValue:SlotDefaultValue' :: SlotDefaultValue -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"defaultValue" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
defaultValue)]
      )