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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Rekognition.Types.BodyPart
import Amazonka.Rekognition.Types.EquipmentDetection

-- | Information about a body part detected by DetectProtectiveEquipment that
-- contains PPE. An array of @ProtectiveEquipmentBodyPart@ objects is
-- returned for each person detected by @DetectProtectiveEquipment@.
--
-- /See:/ 'newProtectiveEquipmentBodyPart' smart constructor.
data ProtectiveEquipmentBodyPart = ProtectiveEquipmentBodyPart'
  { -- | An array of Personal Protective Equipment items detected around a body
    -- part.
    ProtectiveEquipmentBodyPart -> Maybe [EquipmentDetection]
equipmentDetections :: Prelude.Maybe [EquipmentDetection],
    -- | The confidence that Amazon Rekognition has in the detection accuracy of
    -- the detected body part.
    ProtectiveEquipmentBodyPart -> Maybe Double
confidence :: Prelude.Maybe Prelude.Double,
    -- | The detected body part.
    ProtectiveEquipmentBodyPart -> Maybe BodyPart
name :: Prelude.Maybe BodyPart
  }
  deriving (ProtectiveEquipmentBodyPart -> ProtectiveEquipmentBodyPart -> Bool
(ProtectiveEquipmentBodyPart
 -> ProtectiveEquipmentBodyPart -> Bool)
-> (ProtectiveEquipmentBodyPart
    -> ProtectiveEquipmentBodyPart -> Bool)
-> Eq ProtectiveEquipmentBodyPart
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProtectiveEquipmentBodyPart -> ProtectiveEquipmentBodyPart -> Bool
$c/= :: ProtectiveEquipmentBodyPart -> ProtectiveEquipmentBodyPart -> Bool
== :: ProtectiveEquipmentBodyPart -> ProtectiveEquipmentBodyPart -> Bool
$c== :: ProtectiveEquipmentBodyPart -> ProtectiveEquipmentBodyPart -> Bool
Prelude.Eq, ReadPrec [ProtectiveEquipmentBodyPart]
ReadPrec ProtectiveEquipmentBodyPart
Int -> ReadS ProtectiveEquipmentBodyPart
ReadS [ProtectiveEquipmentBodyPart]
(Int -> ReadS ProtectiveEquipmentBodyPart)
-> ReadS [ProtectiveEquipmentBodyPart]
-> ReadPrec ProtectiveEquipmentBodyPart
-> ReadPrec [ProtectiveEquipmentBodyPart]
-> Read ProtectiveEquipmentBodyPart
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProtectiveEquipmentBodyPart]
$creadListPrec :: ReadPrec [ProtectiveEquipmentBodyPart]
readPrec :: ReadPrec ProtectiveEquipmentBodyPart
$creadPrec :: ReadPrec ProtectiveEquipmentBodyPart
readList :: ReadS [ProtectiveEquipmentBodyPart]
$creadList :: ReadS [ProtectiveEquipmentBodyPart]
readsPrec :: Int -> ReadS ProtectiveEquipmentBodyPart
$creadsPrec :: Int -> ReadS ProtectiveEquipmentBodyPart
Prelude.Read, Int -> ProtectiveEquipmentBodyPart -> ShowS
[ProtectiveEquipmentBodyPart] -> ShowS
ProtectiveEquipmentBodyPart -> String
(Int -> ProtectiveEquipmentBodyPart -> ShowS)
-> (ProtectiveEquipmentBodyPart -> String)
-> ([ProtectiveEquipmentBodyPart] -> ShowS)
-> Show ProtectiveEquipmentBodyPart
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProtectiveEquipmentBodyPart] -> ShowS
$cshowList :: [ProtectiveEquipmentBodyPart] -> ShowS
show :: ProtectiveEquipmentBodyPart -> String
$cshow :: ProtectiveEquipmentBodyPart -> String
showsPrec :: Int -> ProtectiveEquipmentBodyPart -> ShowS
$cshowsPrec :: Int -> ProtectiveEquipmentBodyPart -> ShowS
Prelude.Show, (forall x.
 ProtectiveEquipmentBodyPart -> Rep ProtectiveEquipmentBodyPart x)
-> (forall x.
    Rep ProtectiveEquipmentBodyPart x -> ProtectiveEquipmentBodyPart)
-> Generic ProtectiveEquipmentBodyPart
forall x.
Rep ProtectiveEquipmentBodyPart x -> ProtectiveEquipmentBodyPart
forall x.
ProtectiveEquipmentBodyPart -> Rep ProtectiveEquipmentBodyPart x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ProtectiveEquipmentBodyPart x -> ProtectiveEquipmentBodyPart
$cfrom :: forall x.
ProtectiveEquipmentBodyPart -> Rep ProtectiveEquipmentBodyPart x
Prelude.Generic)

-- |
-- Create a value of 'ProtectiveEquipmentBodyPart' 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:
--
-- 'equipmentDetections', 'protectiveEquipmentBodyPart_equipmentDetections' - An array of Personal Protective Equipment items detected around a body
-- part.
--
-- 'confidence', 'protectiveEquipmentBodyPart_confidence' - The confidence that Amazon Rekognition has in the detection accuracy of
-- the detected body part.
--
-- 'name', 'protectiveEquipmentBodyPart_name' - The detected body part.
newProtectiveEquipmentBodyPart ::
  ProtectiveEquipmentBodyPart
newProtectiveEquipmentBodyPart :: ProtectiveEquipmentBodyPart
newProtectiveEquipmentBodyPart =
  ProtectiveEquipmentBodyPart' :: Maybe [EquipmentDetection]
-> Maybe Double -> Maybe BodyPart -> ProtectiveEquipmentBodyPart
ProtectiveEquipmentBodyPart'
    { $sel:equipmentDetections:ProtectiveEquipmentBodyPart' :: Maybe [EquipmentDetection]
equipmentDetections =
        Maybe [EquipmentDetection]
forall a. Maybe a
Prelude.Nothing,
      $sel:confidence:ProtectiveEquipmentBodyPart' :: Maybe Double
confidence = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ProtectiveEquipmentBodyPart' :: Maybe BodyPart
name = Maybe BodyPart
forall a. Maybe a
Prelude.Nothing
    }

-- | An array of Personal Protective Equipment items detected around a body
-- part.
protectiveEquipmentBodyPart_equipmentDetections :: Lens.Lens' ProtectiveEquipmentBodyPart (Prelude.Maybe [EquipmentDetection])
protectiveEquipmentBodyPart_equipmentDetections :: (Maybe [EquipmentDetection] -> f (Maybe [EquipmentDetection]))
-> ProtectiveEquipmentBodyPart -> f ProtectiveEquipmentBodyPart
protectiveEquipmentBodyPart_equipmentDetections = (ProtectiveEquipmentBodyPart -> Maybe [EquipmentDetection])
-> (ProtectiveEquipmentBodyPart
    -> Maybe [EquipmentDetection] -> ProtectiveEquipmentBodyPart)
-> Lens
     ProtectiveEquipmentBodyPart
     ProtectiveEquipmentBodyPart
     (Maybe [EquipmentDetection])
     (Maybe [EquipmentDetection])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProtectiveEquipmentBodyPart' {Maybe [EquipmentDetection]
equipmentDetections :: Maybe [EquipmentDetection]
$sel:equipmentDetections:ProtectiveEquipmentBodyPart' :: ProtectiveEquipmentBodyPart -> Maybe [EquipmentDetection]
equipmentDetections} -> Maybe [EquipmentDetection]
equipmentDetections) (\s :: ProtectiveEquipmentBodyPart
s@ProtectiveEquipmentBodyPart' {} Maybe [EquipmentDetection]
a -> ProtectiveEquipmentBodyPart
s {$sel:equipmentDetections:ProtectiveEquipmentBodyPart' :: Maybe [EquipmentDetection]
equipmentDetections = Maybe [EquipmentDetection]
a} :: ProtectiveEquipmentBodyPart) ((Maybe [EquipmentDetection] -> f (Maybe [EquipmentDetection]))
 -> ProtectiveEquipmentBodyPart -> f ProtectiveEquipmentBodyPart)
-> ((Maybe [EquipmentDetection] -> f (Maybe [EquipmentDetection]))
    -> Maybe [EquipmentDetection] -> f (Maybe [EquipmentDetection]))
-> (Maybe [EquipmentDetection] -> f (Maybe [EquipmentDetection]))
-> ProtectiveEquipmentBodyPart
-> f ProtectiveEquipmentBodyPart
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [EquipmentDetection]
  [EquipmentDetection]
  [EquipmentDetection]
  [EquipmentDetection]
-> Iso
     (Maybe [EquipmentDetection])
     (Maybe [EquipmentDetection])
     (Maybe [EquipmentDetection])
     (Maybe [EquipmentDetection])
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
  [EquipmentDetection]
  [EquipmentDetection]
  [EquipmentDetection]
  [EquipmentDetection]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The confidence that Amazon Rekognition has in the detection accuracy of
-- the detected body part.
protectiveEquipmentBodyPart_confidence :: Lens.Lens' ProtectiveEquipmentBodyPart (Prelude.Maybe Prelude.Double)
protectiveEquipmentBodyPart_confidence :: (Maybe Double -> f (Maybe Double))
-> ProtectiveEquipmentBodyPart -> f ProtectiveEquipmentBodyPart
protectiveEquipmentBodyPart_confidence = (ProtectiveEquipmentBodyPart -> Maybe Double)
-> (ProtectiveEquipmentBodyPart
    -> Maybe Double -> ProtectiveEquipmentBodyPart)
-> Lens
     ProtectiveEquipmentBodyPart
     ProtectiveEquipmentBodyPart
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProtectiveEquipmentBodyPart' {Maybe Double
confidence :: Maybe Double
$sel:confidence:ProtectiveEquipmentBodyPart' :: ProtectiveEquipmentBodyPart -> Maybe Double
confidence} -> Maybe Double
confidence) (\s :: ProtectiveEquipmentBodyPart
s@ProtectiveEquipmentBodyPart' {} Maybe Double
a -> ProtectiveEquipmentBodyPart
s {$sel:confidence:ProtectiveEquipmentBodyPart' :: Maybe Double
confidence = Maybe Double
a} :: ProtectiveEquipmentBodyPart)

-- | The detected body part.
protectiveEquipmentBodyPart_name :: Lens.Lens' ProtectiveEquipmentBodyPart (Prelude.Maybe BodyPart)
protectiveEquipmentBodyPart_name :: (Maybe BodyPart -> f (Maybe BodyPart))
-> ProtectiveEquipmentBodyPart -> f ProtectiveEquipmentBodyPart
protectiveEquipmentBodyPart_name = (ProtectiveEquipmentBodyPart -> Maybe BodyPart)
-> (ProtectiveEquipmentBodyPart
    -> Maybe BodyPart -> ProtectiveEquipmentBodyPart)
-> Lens
     ProtectiveEquipmentBodyPart
     ProtectiveEquipmentBodyPart
     (Maybe BodyPart)
     (Maybe BodyPart)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProtectiveEquipmentBodyPart' {Maybe BodyPart
name :: Maybe BodyPart
$sel:name:ProtectiveEquipmentBodyPart' :: ProtectiveEquipmentBodyPart -> Maybe BodyPart
name} -> Maybe BodyPart
name) (\s :: ProtectiveEquipmentBodyPart
s@ProtectiveEquipmentBodyPart' {} Maybe BodyPart
a -> ProtectiveEquipmentBodyPart
s {$sel:name:ProtectiveEquipmentBodyPart' :: Maybe BodyPart
name = Maybe BodyPart
a} :: ProtectiveEquipmentBodyPart)

instance Core.FromJSON ProtectiveEquipmentBodyPart where
  parseJSON :: Value -> Parser ProtectiveEquipmentBodyPart
parseJSON =
    String
-> (Object -> Parser ProtectiveEquipmentBodyPart)
-> Value
-> Parser ProtectiveEquipmentBodyPart
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ProtectiveEquipmentBodyPart"
      ( \Object
x ->
          Maybe [EquipmentDetection]
-> Maybe Double -> Maybe BodyPart -> ProtectiveEquipmentBodyPart
ProtectiveEquipmentBodyPart'
            (Maybe [EquipmentDetection]
 -> Maybe Double -> Maybe BodyPart -> ProtectiveEquipmentBodyPart)
-> Parser (Maybe [EquipmentDetection])
-> Parser
     (Maybe Double -> Maybe BodyPart -> ProtectiveEquipmentBodyPart)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [EquipmentDetection]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EquipmentDetections"
                            Parser (Maybe (Maybe [EquipmentDetection]))
-> Maybe [EquipmentDetection]
-> Parser (Maybe [EquipmentDetection])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [EquipmentDetection]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe Double -> Maybe BodyPart -> ProtectiveEquipmentBodyPart)
-> Parser (Maybe Double)
-> Parser (Maybe BodyPart -> ProtectiveEquipmentBodyPart)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Confidence")
            Parser (Maybe BodyPart -> ProtectiveEquipmentBodyPart)
-> Parser (Maybe BodyPart) -> Parser ProtectiveEquipmentBodyPart
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe BodyPart)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
      )

instance Prelude.Hashable ProtectiveEquipmentBodyPart

instance Prelude.NFData ProtectiveEquipmentBodyPart