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

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

-- | Details and path tracking information for a single time a person\'s path
-- is tracked in a video. Amazon Rekognition operations that track
-- people\'s paths return an array of @PersonDetection@ objects with
-- elements for each time a person\'s path is tracked in a video.
--
-- For more information, see GetPersonTracking in the Amazon Rekognition
-- Developer Guide.
--
-- /See:/ 'newPersonDetection' smart constructor.
data PersonDetection = PersonDetection'
  { -- | Details about a person whose path was tracked in a video.
    PersonDetection -> Maybe PersonDetail
person :: Prelude.Maybe PersonDetail,
    -- | The time, in milliseconds from the start of the video, that the
    -- person\'s path was tracked.
    PersonDetection -> Maybe Integer
timestamp :: Prelude.Maybe Prelude.Integer
  }
  deriving (PersonDetection -> PersonDetection -> Bool
(PersonDetection -> PersonDetection -> Bool)
-> (PersonDetection -> PersonDetection -> Bool)
-> Eq PersonDetection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PersonDetection -> PersonDetection -> Bool
$c/= :: PersonDetection -> PersonDetection -> Bool
== :: PersonDetection -> PersonDetection -> Bool
$c== :: PersonDetection -> PersonDetection -> Bool
Prelude.Eq, ReadPrec [PersonDetection]
ReadPrec PersonDetection
Int -> ReadS PersonDetection
ReadS [PersonDetection]
(Int -> ReadS PersonDetection)
-> ReadS [PersonDetection]
-> ReadPrec PersonDetection
-> ReadPrec [PersonDetection]
-> Read PersonDetection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PersonDetection]
$creadListPrec :: ReadPrec [PersonDetection]
readPrec :: ReadPrec PersonDetection
$creadPrec :: ReadPrec PersonDetection
readList :: ReadS [PersonDetection]
$creadList :: ReadS [PersonDetection]
readsPrec :: Int -> ReadS PersonDetection
$creadsPrec :: Int -> ReadS PersonDetection
Prelude.Read, Int -> PersonDetection -> ShowS
[PersonDetection] -> ShowS
PersonDetection -> String
(Int -> PersonDetection -> ShowS)
-> (PersonDetection -> String)
-> ([PersonDetection] -> ShowS)
-> Show PersonDetection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PersonDetection] -> ShowS
$cshowList :: [PersonDetection] -> ShowS
show :: PersonDetection -> String
$cshow :: PersonDetection -> String
showsPrec :: Int -> PersonDetection -> ShowS
$cshowsPrec :: Int -> PersonDetection -> ShowS
Prelude.Show, (forall x. PersonDetection -> Rep PersonDetection x)
-> (forall x. Rep PersonDetection x -> PersonDetection)
-> Generic PersonDetection
forall x. Rep PersonDetection x -> PersonDetection
forall x. PersonDetection -> Rep PersonDetection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PersonDetection x -> PersonDetection
$cfrom :: forall x. PersonDetection -> Rep PersonDetection x
Prelude.Generic)

-- |
-- Create a value of 'PersonDetection' 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:
--
-- 'person', 'personDetection_person' - Details about a person whose path was tracked in a video.
--
-- 'timestamp', 'personDetection_timestamp' - The time, in milliseconds from the start of the video, that the
-- person\'s path was tracked.
newPersonDetection ::
  PersonDetection
newPersonDetection :: PersonDetection
newPersonDetection =
  PersonDetection' :: Maybe PersonDetail -> Maybe Integer -> PersonDetection
PersonDetection'
    { $sel:person:PersonDetection' :: Maybe PersonDetail
person = Maybe PersonDetail
forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:PersonDetection' :: Maybe Integer
timestamp = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | Details about a person whose path was tracked in a video.
personDetection_person :: Lens.Lens' PersonDetection (Prelude.Maybe PersonDetail)
personDetection_person :: (Maybe PersonDetail -> f (Maybe PersonDetail))
-> PersonDetection -> f PersonDetection
personDetection_person = (PersonDetection -> Maybe PersonDetail)
-> (PersonDetection -> Maybe PersonDetail -> PersonDetection)
-> Lens
     PersonDetection
     PersonDetection
     (Maybe PersonDetail)
     (Maybe PersonDetail)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PersonDetection' {Maybe PersonDetail
person :: Maybe PersonDetail
$sel:person:PersonDetection' :: PersonDetection -> Maybe PersonDetail
person} -> Maybe PersonDetail
person) (\s :: PersonDetection
s@PersonDetection' {} Maybe PersonDetail
a -> PersonDetection
s {$sel:person:PersonDetection' :: Maybe PersonDetail
person = Maybe PersonDetail
a} :: PersonDetection)

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

instance Core.FromJSON PersonDetection where
  parseJSON :: Value -> Parser PersonDetection
parseJSON =
    String
-> (Object -> Parser PersonDetection)
-> Value
-> Parser PersonDetection
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PersonDetection"
      ( \Object
x ->
          Maybe PersonDetail -> Maybe Integer -> PersonDetection
PersonDetection'
            (Maybe PersonDetail -> Maybe Integer -> PersonDetection)
-> Parser (Maybe PersonDetail)
-> Parser (Maybe Integer -> PersonDetection)
forall (f :: * -> *) a b. Functor 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 -> PersonDetection)
-> Parser (Maybe Integer) -> Parser PersonDetection
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 PersonDetection

instance Prelude.NFData PersonDetection