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

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

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

-- |
-- Create a value of 'LabelDetection' 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:
--
-- 'label', 'labelDetection_label' - Details about the detected label.
--
-- 'timestamp', 'labelDetection_timestamp' - Time, in milliseconds from the start of the video, that the label was
-- detected.
newLabelDetection ::
  LabelDetection
newLabelDetection :: LabelDetection
newLabelDetection =
  LabelDetection' :: Maybe Label -> Maybe Integer -> LabelDetection
LabelDetection'
    { $sel:label:LabelDetection' :: Maybe Label
label = Maybe Label
forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:LabelDetection' :: Maybe Integer
timestamp = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | Details about the detected label.
labelDetection_label :: Lens.Lens' LabelDetection (Prelude.Maybe Label)
labelDetection_label :: (Maybe Label -> f (Maybe Label))
-> LabelDetection -> f LabelDetection
labelDetection_label = (LabelDetection -> Maybe Label)
-> (LabelDetection -> Maybe Label -> LabelDetection)
-> Lens LabelDetection LabelDetection (Maybe Label) (Maybe Label)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LabelDetection' {Maybe Label
label :: Maybe Label
$sel:label:LabelDetection' :: LabelDetection -> Maybe Label
label} -> Maybe Label
label) (\s :: LabelDetection
s@LabelDetection' {} Maybe Label
a -> LabelDetection
s {$sel:label:LabelDetection' :: Maybe Label
label = Maybe Label
a} :: LabelDetection)

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

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

instance Prelude.NFData LabelDetection