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

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

-- | Information about a face detected in a video analysis request and the
-- time the face was detected in the video.
--
-- /See:/ 'newFaceDetection' smart constructor.
data FaceDetection = FaceDetection'
  { -- | Time, in milliseconds from the start of the video, that the face was
    -- detected.
    FaceDetection -> Maybe Integer
timestamp :: Prelude.Maybe Prelude.Integer,
    -- | The face properties for the detected face.
    FaceDetection -> Maybe FaceDetail
face :: Prelude.Maybe FaceDetail
  }
  deriving (FaceDetection -> FaceDetection -> Bool
(FaceDetection -> FaceDetection -> Bool)
-> (FaceDetection -> FaceDetection -> Bool) -> Eq FaceDetection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FaceDetection -> FaceDetection -> Bool
$c/= :: FaceDetection -> FaceDetection -> Bool
== :: FaceDetection -> FaceDetection -> Bool
$c== :: FaceDetection -> FaceDetection -> Bool
Prelude.Eq, ReadPrec [FaceDetection]
ReadPrec FaceDetection
Int -> ReadS FaceDetection
ReadS [FaceDetection]
(Int -> ReadS FaceDetection)
-> ReadS [FaceDetection]
-> ReadPrec FaceDetection
-> ReadPrec [FaceDetection]
-> Read FaceDetection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FaceDetection]
$creadListPrec :: ReadPrec [FaceDetection]
readPrec :: ReadPrec FaceDetection
$creadPrec :: ReadPrec FaceDetection
readList :: ReadS [FaceDetection]
$creadList :: ReadS [FaceDetection]
readsPrec :: Int -> ReadS FaceDetection
$creadsPrec :: Int -> ReadS FaceDetection
Prelude.Read, Int -> FaceDetection -> ShowS
[FaceDetection] -> ShowS
FaceDetection -> String
(Int -> FaceDetection -> ShowS)
-> (FaceDetection -> String)
-> ([FaceDetection] -> ShowS)
-> Show FaceDetection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FaceDetection] -> ShowS
$cshowList :: [FaceDetection] -> ShowS
show :: FaceDetection -> String
$cshow :: FaceDetection -> String
showsPrec :: Int -> FaceDetection -> ShowS
$cshowsPrec :: Int -> FaceDetection -> ShowS
Prelude.Show, (forall x. FaceDetection -> Rep FaceDetection x)
-> (forall x. Rep FaceDetection x -> FaceDetection)
-> Generic FaceDetection
forall x. Rep FaceDetection x -> FaceDetection
forall x. FaceDetection -> Rep FaceDetection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FaceDetection x -> FaceDetection
$cfrom :: forall x. FaceDetection -> Rep FaceDetection x
Prelude.Generic)

-- |
-- Create a value of 'FaceDetection' 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:
--
-- 'timestamp', 'faceDetection_timestamp' - Time, in milliseconds from the start of the video, that the face was
-- detected.
--
-- 'face', 'faceDetection_face' - The face properties for the detected face.
newFaceDetection ::
  FaceDetection
newFaceDetection :: FaceDetection
newFaceDetection =
  FaceDetection' :: Maybe Integer -> Maybe FaceDetail -> FaceDetection
FaceDetection'
    { $sel:timestamp:FaceDetection' :: Maybe Integer
timestamp = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:face:FaceDetection' :: Maybe FaceDetail
face = Maybe FaceDetail
forall a. Maybe a
Prelude.Nothing
    }

-- | Time, in milliseconds from the start of the video, that the face was
-- detected.
faceDetection_timestamp :: Lens.Lens' FaceDetection (Prelude.Maybe Prelude.Integer)
faceDetection_timestamp :: (Maybe Integer -> f (Maybe Integer))
-> FaceDetection -> f FaceDetection
faceDetection_timestamp = (FaceDetection -> Maybe Integer)
-> (FaceDetection -> Maybe Integer -> FaceDetection)
-> Lens FaceDetection FaceDetection (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FaceDetection' {Maybe Integer
timestamp :: Maybe Integer
$sel:timestamp:FaceDetection' :: FaceDetection -> Maybe Integer
timestamp} -> Maybe Integer
timestamp) (\s :: FaceDetection
s@FaceDetection' {} Maybe Integer
a -> FaceDetection
s {$sel:timestamp:FaceDetection' :: Maybe Integer
timestamp = Maybe Integer
a} :: FaceDetection)

-- | The face properties for the detected face.
faceDetection_face :: Lens.Lens' FaceDetection (Prelude.Maybe FaceDetail)
faceDetection_face :: (Maybe FaceDetail -> f (Maybe FaceDetail))
-> FaceDetection -> f FaceDetection
faceDetection_face = (FaceDetection -> Maybe FaceDetail)
-> (FaceDetection -> Maybe FaceDetail -> FaceDetection)
-> Lens
     FaceDetection FaceDetection (Maybe FaceDetail) (Maybe FaceDetail)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FaceDetection' {Maybe FaceDetail
face :: Maybe FaceDetail
$sel:face:FaceDetection' :: FaceDetection -> Maybe FaceDetail
face} -> Maybe FaceDetail
face) (\s :: FaceDetection
s@FaceDetection' {} Maybe FaceDetail
a -> FaceDetection
s {$sel:face:FaceDetection' :: Maybe FaceDetail
face = Maybe FaceDetail
a} :: FaceDetection)

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

instance Prelude.Hashable FaceDetection

instance Prelude.NFData FaceDetection