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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Rekognition.Types.Face
import Amazonka.Rekognition.Types.FaceDetail

-- | Object containing both the face metadata (stored in the backend
-- database), and facial attributes that are detected but aren\'t stored in
-- the database.
--
-- /See:/ 'newFaceRecord' smart constructor.
data FaceRecord = FaceRecord'
  { -- | Structure containing attributes of the face that the algorithm detected.
    FaceRecord -> Maybe FaceDetail
faceDetail :: Prelude.Maybe FaceDetail,
    -- | Describes the face properties such as the bounding box, face ID, image
    -- ID of the input image, and external image ID that you assigned.
    FaceRecord -> Maybe Face
face :: Prelude.Maybe Face
  }
  deriving (FaceRecord -> FaceRecord -> Bool
(FaceRecord -> FaceRecord -> Bool)
-> (FaceRecord -> FaceRecord -> Bool) -> Eq FaceRecord
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FaceRecord -> FaceRecord -> Bool
$c/= :: FaceRecord -> FaceRecord -> Bool
== :: FaceRecord -> FaceRecord -> Bool
$c== :: FaceRecord -> FaceRecord -> Bool
Prelude.Eq, ReadPrec [FaceRecord]
ReadPrec FaceRecord
Int -> ReadS FaceRecord
ReadS [FaceRecord]
(Int -> ReadS FaceRecord)
-> ReadS [FaceRecord]
-> ReadPrec FaceRecord
-> ReadPrec [FaceRecord]
-> Read FaceRecord
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FaceRecord]
$creadListPrec :: ReadPrec [FaceRecord]
readPrec :: ReadPrec FaceRecord
$creadPrec :: ReadPrec FaceRecord
readList :: ReadS [FaceRecord]
$creadList :: ReadS [FaceRecord]
readsPrec :: Int -> ReadS FaceRecord
$creadsPrec :: Int -> ReadS FaceRecord
Prelude.Read, Int -> FaceRecord -> ShowS
[FaceRecord] -> ShowS
FaceRecord -> String
(Int -> FaceRecord -> ShowS)
-> (FaceRecord -> String)
-> ([FaceRecord] -> ShowS)
-> Show FaceRecord
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FaceRecord] -> ShowS
$cshowList :: [FaceRecord] -> ShowS
show :: FaceRecord -> String
$cshow :: FaceRecord -> String
showsPrec :: Int -> FaceRecord -> ShowS
$cshowsPrec :: Int -> FaceRecord -> ShowS
Prelude.Show, (forall x. FaceRecord -> Rep FaceRecord x)
-> (forall x. Rep FaceRecord x -> FaceRecord) -> Generic FaceRecord
forall x. Rep FaceRecord x -> FaceRecord
forall x. FaceRecord -> Rep FaceRecord x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FaceRecord x -> FaceRecord
$cfrom :: forall x. FaceRecord -> Rep FaceRecord x
Prelude.Generic)

-- |
-- Create a value of 'FaceRecord' 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:
--
-- 'faceDetail', 'faceRecord_faceDetail' - Structure containing attributes of the face that the algorithm detected.
--
-- 'face', 'faceRecord_face' - Describes the face properties such as the bounding box, face ID, image
-- ID of the input image, and external image ID that you assigned.
newFaceRecord ::
  FaceRecord
newFaceRecord :: FaceRecord
newFaceRecord =
  FaceRecord' :: Maybe FaceDetail -> Maybe Face -> FaceRecord
FaceRecord'
    { $sel:faceDetail:FaceRecord' :: Maybe FaceDetail
faceDetail = Maybe FaceDetail
forall a. Maybe a
Prelude.Nothing,
      $sel:face:FaceRecord' :: Maybe Face
face = Maybe Face
forall a. Maybe a
Prelude.Nothing
    }

-- | Structure containing attributes of the face that the algorithm detected.
faceRecord_faceDetail :: Lens.Lens' FaceRecord (Prelude.Maybe FaceDetail)
faceRecord_faceDetail :: (Maybe FaceDetail -> f (Maybe FaceDetail))
-> FaceRecord -> f FaceRecord
faceRecord_faceDetail = (FaceRecord -> Maybe FaceDetail)
-> (FaceRecord -> Maybe FaceDetail -> FaceRecord)
-> Lens FaceRecord FaceRecord (Maybe FaceDetail) (Maybe FaceDetail)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FaceRecord' {Maybe FaceDetail
faceDetail :: Maybe FaceDetail
$sel:faceDetail:FaceRecord' :: FaceRecord -> Maybe FaceDetail
faceDetail} -> Maybe FaceDetail
faceDetail) (\s :: FaceRecord
s@FaceRecord' {} Maybe FaceDetail
a -> FaceRecord
s {$sel:faceDetail:FaceRecord' :: Maybe FaceDetail
faceDetail = Maybe FaceDetail
a} :: FaceRecord)

-- | Describes the face properties such as the bounding box, face ID, image
-- ID of the input image, and external image ID that you assigned.
faceRecord_face :: Lens.Lens' FaceRecord (Prelude.Maybe Face)
faceRecord_face :: (Maybe Face -> f (Maybe Face)) -> FaceRecord -> f FaceRecord
faceRecord_face = (FaceRecord -> Maybe Face)
-> (FaceRecord -> Maybe Face -> FaceRecord)
-> Lens FaceRecord FaceRecord (Maybe Face) (Maybe Face)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FaceRecord' {Maybe Face
face :: Maybe Face
$sel:face:FaceRecord' :: FaceRecord -> Maybe Face
face} -> Maybe Face
face) (\s :: FaceRecord
s@FaceRecord' {} Maybe Face
a -> FaceRecord
s {$sel:face:FaceRecord' :: Maybe Face
face = Maybe Face
a} :: FaceRecord)

instance Core.FromJSON FaceRecord where
  parseJSON :: Value -> Parser FaceRecord
parseJSON =
    String
-> (Object -> Parser FaceRecord) -> Value -> Parser FaceRecord
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FaceRecord"
      ( \Object
x ->
          Maybe FaceDetail -> Maybe Face -> FaceRecord
FaceRecord'
            (Maybe FaceDetail -> Maybe Face -> FaceRecord)
-> Parser (Maybe FaceDetail) -> Parser (Maybe Face -> FaceRecord)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe FaceDetail)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FaceDetail")
            Parser (Maybe Face -> FaceRecord)
-> Parser (Maybe Face) -> Parser FaceRecord
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Face)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Face")
      )

instance Prelude.Hashable FaceRecord

instance Prelude.NFData FaceRecord