{-# 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.Rekognition.Types.Emotion
-- 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.Rekognition.Types.Emotion where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.Rekognition.Types.EmotionName

-- | The emotions that appear to be expressed on the face, and the confidence
-- level in the determination. The API is only making a determination of
-- the physical appearance of a person\'s face. It is not a determination
-- of the person’s internal emotional state and should not be used in such
-- a way. For example, a person pretending to have a sad face might not be
-- sad emotionally.
--
-- /See:/ 'newEmotion' smart constructor.
data Emotion = Emotion'
  { -- | Level of confidence in the determination.
    Emotion -> Maybe Double
confidence :: Prelude.Maybe Prelude.Double,
    -- | Type of emotion detected.
    Emotion -> Maybe EmotionName
type' :: Prelude.Maybe EmotionName
  }
  deriving (Emotion -> Emotion -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Emotion -> Emotion -> Bool
$c/= :: Emotion -> Emotion -> Bool
== :: Emotion -> Emotion -> Bool
$c== :: Emotion -> Emotion -> Bool
Prelude.Eq, ReadPrec [Emotion]
ReadPrec Emotion
Int -> ReadS Emotion
ReadS [Emotion]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Emotion]
$creadListPrec :: ReadPrec [Emotion]
readPrec :: ReadPrec Emotion
$creadPrec :: ReadPrec Emotion
readList :: ReadS [Emotion]
$creadList :: ReadS [Emotion]
readsPrec :: Int -> ReadS Emotion
$creadsPrec :: Int -> ReadS Emotion
Prelude.Read, Int -> Emotion -> ShowS
[Emotion] -> ShowS
Emotion -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Emotion] -> ShowS
$cshowList :: [Emotion] -> ShowS
show :: Emotion -> String
$cshow :: Emotion -> String
showsPrec :: Int -> Emotion -> ShowS
$cshowsPrec :: Int -> Emotion -> ShowS
Prelude.Show, forall x. Rep Emotion x -> Emotion
forall x. Emotion -> Rep Emotion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Emotion x -> Emotion
$cfrom :: forall x. Emotion -> Rep Emotion x
Prelude.Generic)

-- |
-- Create a value of 'Emotion' 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:
--
-- 'confidence', 'emotion_confidence' - Level of confidence in the determination.
--
-- 'type'', 'emotion_type' - Type of emotion detected.
newEmotion ::
  Emotion
newEmotion :: Emotion
newEmotion =
  Emotion'
    { $sel:confidence:Emotion' :: Maybe Double
confidence = forall a. Maybe a
Prelude.Nothing,
      $sel:type':Emotion' :: Maybe EmotionName
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | Level of confidence in the determination.
emotion_confidence :: Lens.Lens' Emotion (Prelude.Maybe Prelude.Double)
emotion_confidence :: Lens' Emotion (Maybe Double)
emotion_confidence = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Emotion' {Maybe Double
confidence :: Maybe Double
$sel:confidence:Emotion' :: Emotion -> Maybe Double
confidence} -> Maybe Double
confidence) (\s :: Emotion
s@Emotion' {} Maybe Double
a -> Emotion
s {$sel:confidence:Emotion' :: Maybe Double
confidence = Maybe Double
a} :: Emotion)

-- | Type of emotion detected.
emotion_type :: Lens.Lens' Emotion (Prelude.Maybe EmotionName)
emotion_type :: Lens' Emotion (Maybe EmotionName)
emotion_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Emotion' {Maybe EmotionName
type' :: Maybe EmotionName
$sel:type':Emotion' :: Emotion -> Maybe EmotionName
type'} -> Maybe EmotionName
type') (\s :: Emotion
s@Emotion' {} Maybe EmotionName
a -> Emotion
s {$sel:type':Emotion' :: Maybe EmotionName
type' = Maybe EmotionName
a} :: Emotion)

instance Data.FromJSON Emotion where
  parseJSON :: Value -> Parser Emotion
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Emotion"
      ( \Object
x ->
          Maybe Double -> Maybe EmotionName -> Emotion
Emotion'
            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
"Confidence")
            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
"Type")
      )

instance Prelude.Hashable Emotion where
  hashWithSalt :: Int -> Emotion -> Int
hashWithSalt Int
_salt Emotion' {Maybe Double
Maybe EmotionName
type' :: Maybe EmotionName
confidence :: Maybe Double
$sel:type':Emotion' :: Emotion -> Maybe EmotionName
$sel:confidence:Emotion' :: Emotion -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
confidence
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EmotionName
type'

instance Prelude.NFData Emotion where
  rnf :: Emotion -> ()
rnf Emotion' {Maybe Double
Maybe EmotionName
type' :: Maybe EmotionName
confidence :: Maybe Double
$sel:type':Emotion' :: Emotion -> Maybe EmotionName
$sel:confidence:Emotion' :: Emotion -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
confidence
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EmotionName
type'