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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(Emotion -> Emotion -> Bool)
-> (Emotion -> Emotion -> Bool) -> Eq Emotion
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]
(Int -> ReadS Emotion)
-> ReadS [Emotion]
-> ReadPrec Emotion
-> ReadPrec [Emotion]
-> Read 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
(Int -> Emotion -> ShowS)
-> (Emotion -> String) -> ([Emotion] -> ShowS) -> Show Emotion
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. Emotion -> Rep Emotion x)
-> (forall x. Rep Emotion x -> Emotion) -> Generic Emotion
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' :: Maybe Double -> Maybe EmotionName -> Emotion
Emotion'
    { $sel:confidence:Emotion' :: Maybe Double
confidence = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Emotion' :: Maybe EmotionName
type' = Maybe EmotionName
forall a. Maybe a
Prelude.Nothing
    }

-- | Level of confidence in the determination.
emotion_confidence :: Lens.Lens' Emotion (Prelude.Maybe Prelude.Double)
emotion_confidence :: (Maybe Double -> f (Maybe Double)) -> Emotion -> f Emotion
emotion_confidence = (Emotion -> Maybe Double)
-> (Emotion -> Maybe Double -> Emotion)
-> Lens Emotion Emotion (Maybe Double) (Maybe Double)
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 :: (Maybe EmotionName -> f (Maybe EmotionName))
-> Emotion -> f Emotion
emotion_type = (Emotion -> Maybe EmotionName)
-> (Emotion -> Maybe EmotionName -> Emotion)
-> Lens Emotion Emotion (Maybe EmotionName) (Maybe EmotionName)
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 Core.FromJSON Emotion where
  parseJSON :: Value -> Parser Emotion
parseJSON =
    String -> (Object -> Parser Emotion) -> Value -> Parser Emotion
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Emotion"
      ( \Object
x ->
          Maybe Double -> Maybe EmotionName -> Emotion
Emotion'
            (Maybe Double -> Maybe EmotionName -> Emotion)
-> Parser (Maybe Double) -> Parser (Maybe EmotionName -> Emotion)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Confidence")
            Parser (Maybe EmotionName -> Emotion)
-> Parser (Maybe EmotionName) -> Parser Emotion
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EmotionName)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
      )

instance Prelude.Hashable Emotion

instance Prelude.NFData Emotion