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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Rekognition.Types.FaceMatch
import Amazonka.Rekognition.Types.PersonDetail

-- | Information about a person whose face matches a face(s) in an Amazon
-- Rekognition collection. Includes information about the faces in the
-- Amazon Rekognition collection (FaceMatch), information about the person
-- (PersonDetail), and the time stamp for when the person was detected in a
-- video. An array of @PersonMatch@ objects is returned by GetFaceSearch.
--
-- /See:/ 'newPersonMatch' smart constructor.
data PersonMatch = PersonMatch'
  { -- | Information about the faces in the input collection that match the face
    -- of a person in the video.
    PersonMatch -> Maybe [FaceMatch]
faceMatches :: Prelude.Maybe [FaceMatch],
    -- | Information about the matched person.
    PersonMatch -> Maybe PersonDetail
person :: Prelude.Maybe PersonDetail,
    -- | The time, in milliseconds from the beginning of the video, that the
    -- person was matched in the video.
    PersonMatch -> Maybe Integer
timestamp :: Prelude.Maybe Prelude.Integer
  }
  deriving (PersonMatch -> PersonMatch -> Bool
(PersonMatch -> PersonMatch -> Bool)
-> (PersonMatch -> PersonMatch -> Bool) -> Eq PersonMatch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PersonMatch -> PersonMatch -> Bool
$c/= :: PersonMatch -> PersonMatch -> Bool
== :: PersonMatch -> PersonMatch -> Bool
$c== :: PersonMatch -> PersonMatch -> Bool
Prelude.Eq, ReadPrec [PersonMatch]
ReadPrec PersonMatch
Int -> ReadS PersonMatch
ReadS [PersonMatch]
(Int -> ReadS PersonMatch)
-> ReadS [PersonMatch]
-> ReadPrec PersonMatch
-> ReadPrec [PersonMatch]
-> Read PersonMatch
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PersonMatch]
$creadListPrec :: ReadPrec [PersonMatch]
readPrec :: ReadPrec PersonMatch
$creadPrec :: ReadPrec PersonMatch
readList :: ReadS [PersonMatch]
$creadList :: ReadS [PersonMatch]
readsPrec :: Int -> ReadS PersonMatch
$creadsPrec :: Int -> ReadS PersonMatch
Prelude.Read, Int -> PersonMatch -> ShowS
[PersonMatch] -> ShowS
PersonMatch -> String
(Int -> PersonMatch -> ShowS)
-> (PersonMatch -> String)
-> ([PersonMatch] -> ShowS)
-> Show PersonMatch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PersonMatch] -> ShowS
$cshowList :: [PersonMatch] -> ShowS
show :: PersonMatch -> String
$cshow :: PersonMatch -> String
showsPrec :: Int -> PersonMatch -> ShowS
$cshowsPrec :: Int -> PersonMatch -> ShowS
Prelude.Show, (forall x. PersonMatch -> Rep PersonMatch x)
-> (forall x. Rep PersonMatch x -> PersonMatch)
-> Generic PersonMatch
forall x. Rep PersonMatch x -> PersonMatch
forall x. PersonMatch -> Rep PersonMatch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PersonMatch x -> PersonMatch
$cfrom :: forall x. PersonMatch -> Rep PersonMatch x
Prelude.Generic)

-- |
-- Create a value of 'PersonMatch' 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:
--
-- 'faceMatches', 'personMatch_faceMatches' - Information about the faces in the input collection that match the face
-- of a person in the video.
--
-- 'person', 'personMatch_person' - Information about the matched person.
--
-- 'timestamp', 'personMatch_timestamp' - The time, in milliseconds from the beginning of the video, that the
-- person was matched in the video.
newPersonMatch ::
  PersonMatch
newPersonMatch :: PersonMatch
newPersonMatch =
  PersonMatch' :: Maybe [FaceMatch]
-> Maybe PersonDetail -> Maybe Integer -> PersonMatch
PersonMatch'
    { $sel:faceMatches:PersonMatch' :: Maybe [FaceMatch]
faceMatches = Maybe [FaceMatch]
forall a. Maybe a
Prelude.Nothing,
      $sel:person:PersonMatch' :: Maybe PersonDetail
person = Maybe PersonDetail
forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:PersonMatch' :: Maybe Integer
timestamp = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | Information about the faces in the input collection that match the face
-- of a person in the video.
personMatch_faceMatches :: Lens.Lens' PersonMatch (Prelude.Maybe [FaceMatch])
personMatch_faceMatches :: (Maybe [FaceMatch] -> f (Maybe [FaceMatch]))
-> PersonMatch -> f PersonMatch
personMatch_faceMatches = (PersonMatch -> Maybe [FaceMatch])
-> (PersonMatch -> Maybe [FaceMatch] -> PersonMatch)
-> Lens
     PersonMatch PersonMatch (Maybe [FaceMatch]) (Maybe [FaceMatch])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PersonMatch' {Maybe [FaceMatch]
faceMatches :: Maybe [FaceMatch]
$sel:faceMatches:PersonMatch' :: PersonMatch -> Maybe [FaceMatch]
faceMatches} -> Maybe [FaceMatch]
faceMatches) (\s :: PersonMatch
s@PersonMatch' {} Maybe [FaceMatch]
a -> PersonMatch
s {$sel:faceMatches:PersonMatch' :: Maybe [FaceMatch]
faceMatches = Maybe [FaceMatch]
a} :: PersonMatch) ((Maybe [FaceMatch] -> f (Maybe [FaceMatch]))
 -> PersonMatch -> f PersonMatch)
-> ((Maybe [FaceMatch] -> f (Maybe [FaceMatch]))
    -> Maybe [FaceMatch] -> f (Maybe [FaceMatch]))
-> (Maybe [FaceMatch] -> f (Maybe [FaceMatch]))
-> PersonMatch
-> f PersonMatch
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [FaceMatch] [FaceMatch] [FaceMatch] [FaceMatch]
-> Iso
     (Maybe [FaceMatch])
     (Maybe [FaceMatch])
     (Maybe [FaceMatch])
     (Maybe [FaceMatch])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [FaceMatch] [FaceMatch] [FaceMatch] [FaceMatch]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Information about the matched person.
personMatch_person :: Lens.Lens' PersonMatch (Prelude.Maybe PersonDetail)
personMatch_person :: (Maybe PersonDetail -> f (Maybe PersonDetail))
-> PersonMatch -> f PersonMatch
personMatch_person = (PersonMatch -> Maybe PersonDetail)
-> (PersonMatch -> Maybe PersonDetail -> PersonMatch)
-> Lens
     PersonMatch PersonMatch (Maybe PersonDetail) (Maybe PersonDetail)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PersonMatch' {Maybe PersonDetail
person :: Maybe PersonDetail
$sel:person:PersonMatch' :: PersonMatch -> Maybe PersonDetail
person} -> Maybe PersonDetail
person) (\s :: PersonMatch
s@PersonMatch' {} Maybe PersonDetail
a -> PersonMatch
s {$sel:person:PersonMatch' :: Maybe PersonDetail
person = Maybe PersonDetail
a} :: PersonMatch)

-- | The time, in milliseconds from the beginning of the video, that the
-- person was matched in the video.
personMatch_timestamp :: Lens.Lens' PersonMatch (Prelude.Maybe Prelude.Integer)
personMatch_timestamp :: (Maybe Integer -> f (Maybe Integer))
-> PersonMatch -> f PersonMatch
personMatch_timestamp = (PersonMatch -> Maybe Integer)
-> (PersonMatch -> Maybe Integer -> PersonMatch)
-> Lens PersonMatch PersonMatch (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PersonMatch' {Maybe Integer
timestamp :: Maybe Integer
$sel:timestamp:PersonMatch' :: PersonMatch -> Maybe Integer
timestamp} -> Maybe Integer
timestamp) (\s :: PersonMatch
s@PersonMatch' {} Maybe Integer
a -> PersonMatch
s {$sel:timestamp:PersonMatch' :: Maybe Integer
timestamp = Maybe Integer
a} :: PersonMatch)

instance Core.FromJSON PersonMatch where
  parseJSON :: Value -> Parser PersonMatch
parseJSON =
    String
-> (Object -> Parser PersonMatch) -> Value -> Parser PersonMatch
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PersonMatch"
      ( \Object
x ->
          Maybe [FaceMatch]
-> Maybe PersonDetail -> Maybe Integer -> PersonMatch
PersonMatch'
            (Maybe [FaceMatch]
 -> Maybe PersonDetail -> Maybe Integer -> PersonMatch)
-> Parser (Maybe [FaceMatch])
-> Parser (Maybe PersonDetail -> Maybe Integer -> PersonMatch)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [FaceMatch]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FaceMatches" Parser (Maybe (Maybe [FaceMatch]))
-> Maybe [FaceMatch] -> Parser (Maybe [FaceMatch])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [FaceMatch]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe PersonDetail -> Maybe Integer -> PersonMatch)
-> Parser (Maybe PersonDetail)
-> Parser (Maybe Integer -> PersonMatch)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe PersonDetail)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Person")
            Parser (Maybe Integer -> PersonMatch)
-> Parser (Maybe Integer) -> Parser PersonMatch
forall (f :: * -> *) a b. Applicative f => 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")
      )

instance Prelude.Hashable PersonMatch

instance Prelude.NFData PersonMatch