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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | 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 (Core.Sensitive (Prelude.HashMap Prelude.Text Prelude.Text)),
    -- | The name of the intent that Amazon Lex suggests satisfies the user\'s
    -- intent.
    PredictedIntent -> Maybe Text
intentName :: Prelude.Maybe Prelude.Text
  }
  deriving (PredictedIntent -> PredictedIntent -> Bool
(PredictedIntent -> PredictedIntent -> Bool)
-> (PredictedIntent -> PredictedIntent -> Bool)
-> Eq PredictedIntent
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
(Int -> PredictedIntent -> ShowS)
-> (PredictedIntent -> String)
-> ([PredictedIntent] -> ShowS)
-> Show PredictedIntent
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. PredictedIntent -> Rep PredictedIntent x)
-> (forall x. Rep PredictedIntent x -> PredictedIntent)
-> Generic PredictedIntent
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:
--
-- '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.
--
-- 'intentName', 'predictedIntent_intentName' - The name of the intent that Amazon Lex suggests satisfies the user\'s
-- intent.
newPredictedIntent ::
  PredictedIntent
newPredictedIntent :: PredictedIntent
newPredictedIntent =
  PredictedIntent' :: Maybe IntentConfidence
-> Maybe (Sensitive (HashMap Text Text))
-> Maybe Text
-> PredictedIntent
PredictedIntent'
    { $sel:nluIntentConfidence:PredictedIntent' :: Maybe IntentConfidence
nluIntentConfidence =
        Maybe IntentConfidence
forall a. Maybe a
Prelude.Nothing,
      $sel:slots:PredictedIntent' :: Maybe (Sensitive (HashMap Text Text))
slots = Maybe (Sensitive (HashMap Text Text))
forall a. Maybe a
Prelude.Nothing,
      $sel:intentName:PredictedIntent' :: Maybe Text
intentName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates how confident Amazon Lex is that an intent satisfies the
-- user\'s intent.
predictedIntent_nluIntentConfidence :: Lens.Lens' PredictedIntent (Prelude.Maybe IntentConfidence)
predictedIntent_nluIntentConfidence :: (Maybe IntentConfidence -> f (Maybe IntentConfidence))
-> PredictedIntent -> f PredictedIntent
predictedIntent_nluIntentConfidence = (PredictedIntent -> Maybe IntentConfidence)
-> (PredictedIntent -> Maybe IntentConfidence -> PredictedIntent)
-> Lens
     PredictedIntent
     PredictedIntent
     (Maybe IntentConfidence)
     (Maybe IntentConfidence)
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 :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> PredictedIntent -> f PredictedIntent
predictedIntent_slots = (PredictedIntent -> Maybe (Sensitive (HashMap Text Text)))
-> (PredictedIntent
    -> Maybe (Sensitive (HashMap Text Text)) -> PredictedIntent)
-> Lens
     PredictedIntent
     PredictedIntent
     (Maybe (Sensitive (HashMap Text Text)))
     (Maybe (Sensitive (HashMap Text Text)))
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) ((Maybe (Sensitive (HashMap Text Text))
  -> f (Maybe (Sensitive (HashMap Text Text))))
 -> PredictedIntent -> f PredictedIntent)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (Sensitive (HashMap Text Text))
    -> f (Maybe (Sensitive (HashMap Text Text))))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> PredictedIntent
-> f PredictedIntent
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (Sensitive (HashMap Text Text))
  (Sensitive (HashMap Text Text))
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (Sensitive (HashMap Text Text)))
     (Maybe (Sensitive (HashMap Text Text)))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 (AnIso
  (Sensitive (HashMap Text Text))
  (Sensitive (HashMap Text Text))
  (HashMap Text Text)
  (HashMap Text Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive AnIso
  (Sensitive (HashMap Text Text))
  (Sensitive (HashMap Text Text))
  (HashMap Text Text)
  (HashMap Text Text)
-> (Exchange
      (HashMap Text Text)
      (HashMap Text Text)
      (HashMap Text Text)
      (Identity (HashMap Text Text))
    -> Exchange
         (HashMap Text Text)
         (HashMap Text Text)
         (HashMap Text Text)
         (Identity (HashMap Text Text)))
-> AnIso
     (Sensitive (HashMap Text Text))
     (Sensitive (HashMap Text Text))
     (HashMap Text Text)
     (HashMap Text Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Exchange
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (Identity (HashMap Text Text))
-> Exchange
     (HashMap Text Text)
     (HashMap Text Text)
     (HashMap Text Text)
     (Identity (HashMap Text Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced)

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> PredictedIntent -> f PredictedIntent
predictedIntent_intentName = (PredictedIntent -> Maybe Text)
-> (PredictedIntent -> Maybe Text -> PredictedIntent)
-> Lens PredictedIntent PredictedIntent (Maybe Text) (Maybe Text)
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)

instance Core.FromJSON PredictedIntent where
  parseJSON :: Value -> Parser PredictedIntent
parseJSON =
    String
-> (Object -> Parser PredictedIntent)
-> Value
-> Parser PredictedIntent
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PredictedIntent"
      ( \Object
x ->
          Maybe IntentConfidence
-> Maybe (Sensitive (HashMap Text Text))
-> Maybe Text
-> PredictedIntent
PredictedIntent'
            (Maybe IntentConfidence
 -> Maybe (Sensitive (HashMap Text Text))
 -> Maybe Text
 -> PredictedIntent)
-> Parser (Maybe IntentConfidence)
-> Parser
     (Maybe (Sensitive (HashMap Text Text))
      -> Maybe Text -> PredictedIntent)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe IntentConfidence)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"nluIntentConfidence")
            Parser
  (Maybe (Sensitive (HashMap Text Text))
   -> Maybe Text -> PredictedIntent)
-> Parser (Maybe (Sensitive (HashMap Text Text)))
-> Parser (Maybe Text -> PredictedIntent)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Parser (Maybe (Maybe (Sensitive (HashMap Text Text))))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"slots" Parser (Maybe (Maybe (Sensitive (HashMap Text Text))))
-> Maybe (Sensitive (HashMap Text Text))
-> Parser (Maybe (Sensitive (HashMap Text Text)))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (Sensitive (HashMap Text Text))
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> PredictedIntent)
-> Parser (Maybe Text) -> Parser PredictedIntent
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"intentName")
      )

instance Prelude.Hashable PredictedIntent

instance Prelude.NFData PredictedIntent