{-# 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.Face
-- 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.Face where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Rekognition.Types.BoundingBox

-- | Describes the face properties such as the bounding box, face ID, image
-- ID of the input image, and external image ID that you assigned.
--
-- /See:/ 'newFace' smart constructor.
data Face = Face'
  { -- | Unique identifier that Amazon Rekognition assigns to the face.
    Face -> Maybe Text
faceId :: Prelude.Maybe Prelude.Text,
    -- | Bounding box of the face.
    Face -> Maybe BoundingBox
boundingBox :: Prelude.Maybe BoundingBox,
    -- | Identifier that you assign to all the faces in the input image.
    Face -> Maybe Text
externalImageId :: Prelude.Maybe Prelude.Text,
    -- | Confidence level that the bounding box contains a face (and not a
    -- different object such as a tree).
    Face -> Maybe Double
confidence :: Prelude.Maybe Prelude.Double,
    -- | Unique identifier that Amazon Rekognition assigns to the input image.
    Face -> Maybe Text
imageId :: Prelude.Maybe Prelude.Text
  }
  deriving (Face -> Face -> Bool
(Face -> Face -> Bool) -> (Face -> Face -> Bool) -> Eq Face
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Face -> Face -> Bool
$c/= :: Face -> Face -> Bool
== :: Face -> Face -> Bool
$c== :: Face -> Face -> Bool
Prelude.Eq, ReadPrec [Face]
ReadPrec Face
Int -> ReadS Face
ReadS [Face]
(Int -> ReadS Face)
-> ReadS [Face] -> ReadPrec Face -> ReadPrec [Face] -> Read Face
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Face]
$creadListPrec :: ReadPrec [Face]
readPrec :: ReadPrec Face
$creadPrec :: ReadPrec Face
readList :: ReadS [Face]
$creadList :: ReadS [Face]
readsPrec :: Int -> ReadS Face
$creadsPrec :: Int -> ReadS Face
Prelude.Read, Int -> Face -> ShowS
[Face] -> ShowS
Face -> String
(Int -> Face -> ShowS)
-> (Face -> String) -> ([Face] -> ShowS) -> Show Face
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Face] -> ShowS
$cshowList :: [Face] -> ShowS
show :: Face -> String
$cshow :: Face -> String
showsPrec :: Int -> Face -> ShowS
$cshowsPrec :: Int -> Face -> ShowS
Prelude.Show, (forall x. Face -> Rep Face x)
-> (forall x. Rep Face x -> Face) -> Generic Face
forall x. Rep Face x -> Face
forall x. Face -> Rep Face x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Face x -> Face
$cfrom :: forall x. Face -> Rep Face x
Prelude.Generic)

-- |
-- Create a value of 'Face' 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:
--
-- 'faceId', 'face_faceId' - Unique identifier that Amazon Rekognition assigns to the face.
--
-- 'boundingBox', 'face_boundingBox' - Bounding box of the face.
--
-- 'externalImageId', 'face_externalImageId' - Identifier that you assign to all the faces in the input image.
--
-- 'confidence', 'face_confidence' - Confidence level that the bounding box contains a face (and not a
-- different object such as a tree).
--
-- 'imageId', 'face_imageId' - Unique identifier that Amazon Rekognition assigns to the input image.
newFace ::
  Face
newFace :: Face
newFace =
  Face' :: Maybe Text
-> Maybe BoundingBox
-> Maybe Text
-> Maybe Double
-> Maybe Text
-> Face
Face'
    { $sel:faceId:Face' :: Maybe Text
faceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:boundingBox:Face' :: Maybe BoundingBox
boundingBox = Maybe BoundingBox
forall a. Maybe a
Prelude.Nothing,
      $sel:externalImageId:Face' :: Maybe Text
externalImageId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:confidence:Face' :: Maybe Double
confidence = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:imageId:Face' :: Maybe Text
imageId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Unique identifier that Amazon Rekognition assigns to the face.
face_faceId :: Lens.Lens' Face (Prelude.Maybe Prelude.Text)
face_faceId :: (Maybe Text -> f (Maybe Text)) -> Face -> f Face
face_faceId = (Face -> Maybe Text)
-> (Face -> Maybe Text -> Face)
-> Lens Face Face (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Face' {Maybe Text
faceId :: Maybe Text
$sel:faceId:Face' :: Face -> Maybe Text
faceId} -> Maybe Text
faceId) (\s :: Face
s@Face' {} Maybe Text
a -> Face
s {$sel:faceId:Face' :: Maybe Text
faceId = Maybe Text
a} :: Face)

-- | Bounding box of the face.
face_boundingBox :: Lens.Lens' Face (Prelude.Maybe BoundingBox)
face_boundingBox :: (Maybe BoundingBox -> f (Maybe BoundingBox)) -> Face -> f Face
face_boundingBox = (Face -> Maybe BoundingBox)
-> (Face -> Maybe BoundingBox -> Face)
-> Lens Face Face (Maybe BoundingBox) (Maybe BoundingBox)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Face' {Maybe BoundingBox
boundingBox :: Maybe BoundingBox
$sel:boundingBox:Face' :: Face -> Maybe BoundingBox
boundingBox} -> Maybe BoundingBox
boundingBox) (\s :: Face
s@Face' {} Maybe BoundingBox
a -> Face
s {$sel:boundingBox:Face' :: Maybe BoundingBox
boundingBox = Maybe BoundingBox
a} :: Face)

-- | Identifier that you assign to all the faces in the input image.
face_externalImageId :: Lens.Lens' Face (Prelude.Maybe Prelude.Text)
face_externalImageId :: (Maybe Text -> f (Maybe Text)) -> Face -> f Face
face_externalImageId = (Face -> Maybe Text)
-> (Face -> Maybe Text -> Face)
-> Lens Face Face (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Face' {Maybe Text
externalImageId :: Maybe Text
$sel:externalImageId:Face' :: Face -> Maybe Text
externalImageId} -> Maybe Text
externalImageId) (\s :: Face
s@Face' {} Maybe Text
a -> Face
s {$sel:externalImageId:Face' :: Maybe Text
externalImageId = Maybe Text
a} :: Face)

-- | Confidence level that the bounding box contains a face (and not a
-- different object such as a tree).
face_confidence :: Lens.Lens' Face (Prelude.Maybe Prelude.Double)
face_confidence :: (Maybe Double -> f (Maybe Double)) -> Face -> f Face
face_confidence = (Face -> Maybe Double)
-> (Face -> Maybe Double -> Face)
-> Lens Face Face (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Face' {Maybe Double
confidence :: Maybe Double
$sel:confidence:Face' :: Face -> Maybe Double
confidence} -> Maybe Double
confidence) (\s :: Face
s@Face' {} Maybe Double
a -> Face
s {$sel:confidence:Face' :: Maybe Double
confidence = Maybe Double
a} :: Face)

-- | Unique identifier that Amazon Rekognition assigns to the input image.
face_imageId :: Lens.Lens' Face (Prelude.Maybe Prelude.Text)
face_imageId :: (Maybe Text -> f (Maybe Text)) -> Face -> f Face
face_imageId = (Face -> Maybe Text)
-> (Face -> Maybe Text -> Face)
-> Lens Face Face (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Face' {Maybe Text
imageId :: Maybe Text
$sel:imageId:Face' :: Face -> Maybe Text
imageId} -> Maybe Text
imageId) (\s :: Face
s@Face' {} Maybe Text
a -> Face
s {$sel:imageId:Face' :: Maybe Text
imageId = Maybe Text
a} :: Face)

instance Core.FromJSON Face where
  parseJSON :: Value -> Parser Face
parseJSON =
    String -> (Object -> Parser Face) -> Value -> Parser Face
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Face"
      ( \Object
x ->
          Maybe Text
-> Maybe BoundingBox
-> Maybe Text
-> Maybe Double
-> Maybe Text
-> Face
Face'
            (Maybe Text
 -> Maybe BoundingBox
 -> Maybe Text
 -> Maybe Double
 -> Maybe Text
 -> Face)
-> Parser (Maybe Text)
-> Parser
     (Maybe BoundingBox
      -> Maybe Text -> Maybe Double -> Maybe Text -> Face)
forall (f :: * -> *) a b. Functor 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
"FaceId")
            Parser
  (Maybe BoundingBox
   -> Maybe Text -> Maybe Double -> Maybe Text -> Face)
-> Parser (Maybe BoundingBox)
-> Parser (Maybe Text -> Maybe Double -> Maybe Text -> Face)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe BoundingBox)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BoundingBox")
            Parser (Maybe Text -> Maybe Double -> Maybe Text -> Face)
-> Parser (Maybe Text)
-> Parser (Maybe Double -> Maybe Text -> Face)
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
"ExternalImageId")
            Parser (Maybe Double -> Maybe Text -> Face)
-> Parser (Maybe Double) -> Parser (Maybe Text -> Face)
forall (f :: * -> *) a b. Applicative f => 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 Text -> Face) -> Parser (Maybe Text) -> Parser Face
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
"ImageId")
      )

instance Prelude.Hashable Face

instance Prelude.NFData Face