{-# 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.LexRuntime.Types.PredictedIntent
-- 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.LexRuntime.Types.PredictedIntent where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LexRuntime.Types.IntentConfidence
import qualified Amazonka.Prelude as Prelude

-- | An intent that Amazon Lex suggests satisfies the user\'s intent.
-- Includes the name of the intent, the confidence that Amazon Lex has that
-- the user\'s intent is satisfied, and the slots defined for the intent.
--
-- /See:/ 'newPredictedIntent' smart constructor.
data PredictedIntent = PredictedIntent'
  { -- | The name of the intent that Amazon Lex suggests satisfies the user\'s
    -- intent.
    PredictedIntent -> Maybe Text
intentName :: Prelude.Maybe Prelude.Text,
    -- | Indicates how confident Amazon Lex is that an intent satisfies the
    -- user\'s intent.
    PredictedIntent -> Maybe IntentConfidence
nluIntentConfidence :: Prelude.Maybe IntentConfidence,
    -- | The slot and slot values associated with the predicted intent.
    PredictedIntent -> Maybe (Sensitive (HashMap Text Text))
slots :: Prelude.Maybe (Data.Sensitive (Prelude.HashMap Prelude.Text Prelude.Text))
  }
  deriving (PredictedIntent -> PredictedIntent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PredictedIntent -> PredictedIntent -> Bool
$c/= :: PredictedIntent -> PredictedIntent -> Bool
== :: PredictedIntent -> PredictedIntent -> Bool
$c== :: PredictedIntent -> PredictedIntent -> Bool
Prelude.Eq, Int -> PredictedIntent -> ShowS
[PredictedIntent] -> ShowS
PredictedIntent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PredictedIntent] -> ShowS
$cshowList :: [PredictedIntent] -> ShowS
show :: PredictedIntent -> String
$cshow :: PredictedIntent -> String
showsPrec :: Int -> PredictedIntent -> ShowS
$cshowsPrec :: Int -> PredictedIntent -> ShowS
Prelude.Show, forall x. Rep PredictedIntent x -> PredictedIntent
forall x. PredictedIntent -> Rep PredictedIntent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PredictedIntent x -> PredictedIntent
$cfrom :: forall x. PredictedIntent -> Rep PredictedIntent x
Prelude.Generic)

-- |
-- Create a value of 'PredictedIntent' 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:
--
-- 'intentName', 'predictedIntent_intentName' - The name of the intent that Amazon Lex suggests satisfies the user\'s
-- intent.
--
-- 'nluIntentConfidence', 'predictedIntent_nluIntentConfidence' - Indicates how confident Amazon Lex is that an intent satisfies the
-- user\'s intent.
--
-- 'slots', 'predictedIntent_slots' - The slot and slot values associated with the predicted intent.
newPredictedIntent ::
  PredictedIntent
newPredictedIntent :: PredictedIntent
newPredictedIntent =
  PredictedIntent'
    { $sel:intentName:PredictedIntent' :: Maybe Text
intentName = forall a. Maybe a
Prelude.Nothing,
      $sel:nluIntentConfidence:PredictedIntent' :: Maybe IntentConfidence
nluIntentConfidence = forall a. Maybe a
Prelude.Nothing,
      $sel:slots:PredictedIntent' :: Maybe (Sensitive (HashMap Text Text))
slots = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the intent that Amazon Lex suggests satisfies the user\'s
-- intent.
predictedIntent_intentName :: Lens.Lens' PredictedIntent (Prelude.Maybe Prelude.Text)
predictedIntent_intentName :: Lens' PredictedIntent (Maybe Text)
predictedIntent_intentName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictedIntent' {Maybe Text
intentName :: Maybe Text
$sel:intentName:PredictedIntent' :: PredictedIntent -> Maybe Text
intentName} -> Maybe Text
intentName) (\s :: PredictedIntent
s@PredictedIntent' {} Maybe Text
a -> PredictedIntent
s {$sel:intentName:PredictedIntent' :: Maybe Text
intentName = Maybe Text
a} :: PredictedIntent)

-- | Indicates how confident Amazon Lex is that an intent satisfies the
-- user\'s intent.
predictedIntent_nluIntentConfidence :: Lens.Lens' PredictedIntent (Prelude.Maybe IntentConfidence)
predictedIntent_nluIntentConfidence :: Lens' PredictedIntent (Maybe IntentConfidence)
predictedIntent_nluIntentConfidence = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictedIntent' {Maybe IntentConfidence
nluIntentConfidence :: Maybe IntentConfidence
$sel:nluIntentConfidence:PredictedIntent' :: PredictedIntent -> Maybe IntentConfidence
nluIntentConfidence} -> Maybe IntentConfidence
nluIntentConfidence) (\s :: PredictedIntent
s@PredictedIntent' {} Maybe IntentConfidence
a -> PredictedIntent
s {$sel:nluIntentConfidence:PredictedIntent' :: Maybe IntentConfidence
nluIntentConfidence = Maybe IntentConfidence
a} :: PredictedIntent)

-- | The slot and slot values associated with the predicted intent.
predictedIntent_slots :: Lens.Lens' PredictedIntent (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
predictedIntent_slots :: Lens' PredictedIntent (Maybe (HashMap Text Text))
predictedIntent_slots = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictedIntent' {Maybe (Sensitive (HashMap Text Text))
slots :: Maybe (Sensitive (HashMap Text Text))
$sel:slots:PredictedIntent' :: PredictedIntent -> Maybe (Sensitive (HashMap Text Text))
slots} -> Maybe (Sensitive (HashMap Text Text))
slots) (\s :: PredictedIntent
s@PredictedIntent' {} Maybe (Sensitive (HashMap Text Text))
a -> PredictedIntent
s {$sel:slots:PredictedIntent' :: Maybe (Sensitive (HashMap Text Text))
slots = Maybe (Sensitive (HashMap Text Text))
a} :: PredictedIntent) 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 a. Iso' (Sensitive a) a
Data._Sensitive forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced)

instance Data.FromJSON PredictedIntent where
  parseJSON :: Value -> Parser PredictedIntent
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PredictedIntent"
      ( \Object
x ->
          Maybe Text
-> Maybe IntentConfidence
-> Maybe (Sensitive (HashMap Text Text))
-> PredictedIntent
PredictedIntent'
            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
"intentName")
            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
"nluIntentConfidence")
            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
"slots" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable PredictedIntent where
  hashWithSalt :: Int -> PredictedIntent -> Int
hashWithSalt Int
_salt PredictedIntent' {Maybe Text
Maybe (Sensitive (HashMap Text Text))
Maybe IntentConfidence
slots :: Maybe (Sensitive (HashMap Text Text))
nluIntentConfidence :: Maybe IntentConfidence
intentName :: Maybe Text
$sel:slots:PredictedIntent' :: PredictedIntent -> Maybe (Sensitive (HashMap Text Text))
$sel:nluIntentConfidence:PredictedIntent' :: PredictedIntent -> Maybe IntentConfidence
$sel:intentName:PredictedIntent' :: PredictedIntent -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
intentName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe IntentConfidence
nluIntentConfidence
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive (HashMap Text Text))
slots

instance Prelude.NFData PredictedIntent where
  rnf :: PredictedIntent -> ()
rnf PredictedIntent' {Maybe Text
Maybe (Sensitive (HashMap Text Text))
Maybe IntentConfidence
slots :: Maybe (Sensitive (HashMap Text Text))
nluIntentConfidence :: Maybe IntentConfidence
intentName :: Maybe Text
$sel:slots:PredictedIntent' :: PredictedIntent -> Maybe (Sensitive (HashMap Text Text))
$sel:nluIntentConfidence:PredictedIntent' :: PredictedIntent -> Maybe IntentConfidence
$sel:intentName:PredictedIntent' :: PredictedIntent -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
intentName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe IntentConfidence
nluIntentConfidence
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive (HashMap Text Text))
slots