{-# 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.SlotValueOverride
-- 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.SlotValueOverride 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.SlotShape
import Amazonka.LexV2Models.Types.SlotValue
import qualified Amazonka.Prelude as Prelude

-- | The slot values that Amazon Lex uses when it sets slot values in a
-- dialog step.
--
-- /See:/ 'newSlotValueOverride' smart constructor.
data SlotValueOverride = SlotValueOverride'
  { -- | When the shape value is @List@, it indicates that the @values@ field
    -- contains a list of slot values. When the value is @Scalar@, it indicates
    -- that the @value@ field contains a single value.
    SlotValueOverride -> Maybe SlotShape
shape :: Prelude.Maybe SlotShape,
    -- | The current value of the slot.
    SlotValueOverride -> Maybe SlotValue
value :: Prelude.Maybe SlotValue,
    -- | A list of one or more values that the user provided for the slot. For
    -- example, for a slot that elicits pizza toppings, the values might be
    -- \"pepperoni\" and \"pineapple.\"
    SlotValueOverride -> Maybe [SlotValueOverride]
values :: Prelude.Maybe [SlotValueOverride]
  }
  deriving (SlotValueOverride -> SlotValueOverride -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SlotValueOverride -> SlotValueOverride -> Bool
$c/= :: SlotValueOverride -> SlotValueOverride -> Bool
== :: SlotValueOverride -> SlotValueOverride -> Bool
$c== :: SlotValueOverride -> SlotValueOverride -> Bool
Prelude.Eq, ReadPrec [SlotValueOverride]
ReadPrec SlotValueOverride
Int -> ReadS SlotValueOverride
ReadS [SlotValueOverride]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SlotValueOverride]
$creadListPrec :: ReadPrec [SlotValueOverride]
readPrec :: ReadPrec SlotValueOverride
$creadPrec :: ReadPrec SlotValueOverride
readList :: ReadS [SlotValueOverride]
$creadList :: ReadS [SlotValueOverride]
readsPrec :: Int -> ReadS SlotValueOverride
$creadsPrec :: Int -> ReadS SlotValueOverride
Prelude.Read, Int -> SlotValueOverride -> ShowS
[SlotValueOverride] -> ShowS
SlotValueOverride -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SlotValueOverride] -> ShowS
$cshowList :: [SlotValueOverride] -> ShowS
show :: SlotValueOverride -> String
$cshow :: SlotValueOverride -> String
showsPrec :: Int -> SlotValueOverride -> ShowS
$cshowsPrec :: Int -> SlotValueOverride -> ShowS
Prelude.Show, forall x. Rep SlotValueOverride x -> SlotValueOverride
forall x. SlotValueOverride -> Rep SlotValueOverride x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SlotValueOverride x -> SlotValueOverride
$cfrom :: forall x. SlotValueOverride -> Rep SlotValueOverride x
Prelude.Generic)

-- |
-- Create a value of 'SlotValueOverride' 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:
--
-- 'shape', 'slotValueOverride_shape' - When the shape value is @List@, it indicates that the @values@ field
-- contains a list of slot values. When the value is @Scalar@, it indicates
-- that the @value@ field contains a single value.
--
-- 'value', 'slotValueOverride_value' - The current value of the slot.
--
-- 'values', 'slotValueOverride_values' - A list of one or more values that the user provided for the slot. For
-- example, for a slot that elicits pizza toppings, the values might be
-- \"pepperoni\" and \"pineapple.\"
newSlotValueOverride ::
  SlotValueOverride
newSlotValueOverride :: SlotValueOverride
newSlotValueOverride =
  SlotValueOverride'
    { $sel:shape:SlotValueOverride' :: Maybe SlotShape
shape = forall a. Maybe a
Prelude.Nothing,
      $sel:value:SlotValueOverride' :: Maybe SlotValue
value = forall a. Maybe a
Prelude.Nothing,
      $sel:values:SlotValueOverride' :: Maybe [SlotValueOverride]
values = forall a. Maybe a
Prelude.Nothing
    }

-- | When the shape value is @List@, it indicates that the @values@ field
-- contains a list of slot values. When the value is @Scalar@, it indicates
-- that the @value@ field contains a single value.
slotValueOverride_shape :: Lens.Lens' SlotValueOverride (Prelude.Maybe SlotShape)
slotValueOverride_shape :: Lens' SlotValueOverride (Maybe SlotShape)
slotValueOverride_shape = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotValueOverride' {Maybe SlotShape
shape :: Maybe SlotShape
$sel:shape:SlotValueOverride' :: SlotValueOverride -> Maybe SlotShape
shape} -> Maybe SlotShape
shape) (\s :: SlotValueOverride
s@SlotValueOverride' {} Maybe SlotShape
a -> SlotValueOverride
s {$sel:shape:SlotValueOverride' :: Maybe SlotShape
shape = Maybe SlotShape
a} :: SlotValueOverride)

-- | The current value of the slot.
slotValueOverride_value :: Lens.Lens' SlotValueOverride (Prelude.Maybe SlotValue)
slotValueOverride_value :: Lens' SlotValueOverride (Maybe SlotValue)
slotValueOverride_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotValueOverride' {Maybe SlotValue
value :: Maybe SlotValue
$sel:value:SlotValueOverride' :: SlotValueOverride -> Maybe SlotValue
value} -> Maybe SlotValue
value) (\s :: SlotValueOverride
s@SlotValueOverride' {} Maybe SlotValue
a -> SlotValueOverride
s {$sel:value:SlotValueOverride' :: Maybe SlotValue
value = Maybe SlotValue
a} :: SlotValueOverride)

-- | A list of one or more values that the user provided for the slot. For
-- example, for a slot that elicits pizza toppings, the values might be
-- \"pepperoni\" and \"pineapple.\"
slotValueOverride_values :: Lens.Lens' SlotValueOverride (Prelude.Maybe [SlotValueOverride])
slotValueOverride_values :: Lens' SlotValueOverride (Maybe [SlotValueOverride])
slotValueOverride_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotValueOverride' {Maybe [SlotValueOverride]
values :: Maybe [SlotValueOverride]
$sel:values:SlotValueOverride' :: SlotValueOverride -> Maybe [SlotValueOverride]
values} -> Maybe [SlotValueOverride]
values) (\s :: SlotValueOverride
s@SlotValueOverride' {} Maybe [SlotValueOverride]
a -> SlotValueOverride
s {$sel:values:SlotValueOverride' :: Maybe [SlotValueOverride]
values = Maybe [SlotValueOverride]
a} :: SlotValueOverride) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON SlotValueOverride where
  parseJSON :: Value -> Parser SlotValueOverride
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SlotValueOverride"
      ( \Object
x ->
          Maybe SlotShape
-> Maybe SlotValue
-> Maybe [SlotValueOverride]
-> SlotValueOverride
SlotValueOverride'
            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
"shape")
            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
"value")
            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
"values" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable SlotValueOverride where
  hashWithSalt :: Int -> SlotValueOverride -> Int
hashWithSalt Int
_salt SlotValueOverride' {Maybe [SlotValueOverride]
Maybe SlotShape
Maybe SlotValue
values :: Maybe [SlotValueOverride]
value :: Maybe SlotValue
shape :: Maybe SlotShape
$sel:values:SlotValueOverride' :: SlotValueOverride -> Maybe [SlotValueOverride]
$sel:value:SlotValueOverride' :: SlotValueOverride -> Maybe SlotValue
$sel:shape:SlotValueOverride' :: SlotValueOverride -> Maybe SlotShape
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SlotShape
shape
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SlotValue
value
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [SlotValueOverride]
values

instance Prelude.NFData SlotValueOverride where
  rnf :: SlotValueOverride -> ()
rnf SlotValueOverride' {Maybe [SlotValueOverride]
Maybe SlotShape
Maybe SlotValue
values :: Maybe [SlotValueOverride]
value :: Maybe SlotValue
shape :: Maybe SlotShape
$sel:values:SlotValueOverride' :: SlotValueOverride -> Maybe [SlotValueOverride]
$sel:value:SlotValueOverride' :: SlotValueOverride -> Maybe SlotValue
$sel:shape:SlotValueOverride' :: SlotValueOverride -> Maybe SlotShape
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SlotShape
shape
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SlotValue
value
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [SlotValueOverride]
values

instance Data.ToJSON SlotValueOverride where
  toJSON :: SlotValueOverride -> Value
toJSON SlotValueOverride' {Maybe [SlotValueOverride]
Maybe SlotShape
Maybe SlotValue
values :: Maybe [SlotValueOverride]
value :: Maybe SlotValue
shape :: Maybe SlotShape
$sel:values:SlotValueOverride' :: SlotValueOverride -> Maybe [SlotValueOverride]
$sel:value:SlotValueOverride' :: SlotValueOverride -> Maybe SlotValue
$sel:shape:SlotValueOverride' :: SlotValueOverride -> Maybe SlotShape
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"shape" 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 SlotShape
shape,
            (Key
"value" 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 SlotValue
value,
            (Key
"values" 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 [SlotValueOverride]
values
          ]
      )