{-# 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.ConnectedHomeSettings
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Rekognition.Types.ConnectedHomeSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Label detection settings to use on a streaming video. Defining the
-- settings is required in the request parameter for CreateStreamProcessor.
-- Including this setting in the @CreateStreamProcessor@ request enables
-- you to use the stream processor for label detection. You can then select
-- what you want the stream processor to detect, such as people or pets.
-- When the stream processor has started, one notification is sent for each
-- object class specified. For example, if packages and pets are selected,
-- one SNS notification is published the first time a package is detected
-- and one SNS notification is published the first time a pet is detected,
-- as well as an end-of-session summary.
--
-- /See:/ 'newConnectedHomeSettings' smart constructor.
data ConnectedHomeSettings = ConnectedHomeSettings'
  { -- | The minimum confidence required to label an object in the video.
    ConnectedHomeSettings -> Maybe Double
minConfidence :: Prelude.Maybe Prelude.Double,
    -- | Specifies what you want to detect in the video, such as people,
    -- packages, or pets. The current valid labels you can include in this list
    -- are: \"PERSON\", \"PET\", \"PACKAGE\", and \"ALL\".
    ConnectedHomeSettings -> NonEmpty Text
labels :: Prelude.NonEmpty Prelude.Text
  }
  deriving (ConnectedHomeSettings -> ConnectedHomeSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConnectedHomeSettings -> ConnectedHomeSettings -> Bool
$c/= :: ConnectedHomeSettings -> ConnectedHomeSettings -> Bool
== :: ConnectedHomeSettings -> ConnectedHomeSettings -> Bool
$c== :: ConnectedHomeSettings -> ConnectedHomeSettings -> Bool
Prelude.Eq, ReadPrec [ConnectedHomeSettings]
ReadPrec ConnectedHomeSettings
Int -> ReadS ConnectedHomeSettings
ReadS [ConnectedHomeSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConnectedHomeSettings]
$creadListPrec :: ReadPrec [ConnectedHomeSettings]
readPrec :: ReadPrec ConnectedHomeSettings
$creadPrec :: ReadPrec ConnectedHomeSettings
readList :: ReadS [ConnectedHomeSettings]
$creadList :: ReadS [ConnectedHomeSettings]
readsPrec :: Int -> ReadS ConnectedHomeSettings
$creadsPrec :: Int -> ReadS ConnectedHomeSettings
Prelude.Read, Int -> ConnectedHomeSettings -> ShowS
[ConnectedHomeSettings] -> ShowS
ConnectedHomeSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConnectedHomeSettings] -> ShowS
$cshowList :: [ConnectedHomeSettings] -> ShowS
show :: ConnectedHomeSettings -> String
$cshow :: ConnectedHomeSettings -> String
showsPrec :: Int -> ConnectedHomeSettings -> ShowS
$cshowsPrec :: Int -> ConnectedHomeSettings -> ShowS
Prelude.Show, forall x. Rep ConnectedHomeSettings x -> ConnectedHomeSettings
forall x. ConnectedHomeSettings -> Rep ConnectedHomeSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConnectedHomeSettings x -> ConnectedHomeSettings
$cfrom :: forall x. ConnectedHomeSettings -> Rep ConnectedHomeSettings x
Prelude.Generic)

-- |
-- Create a value of 'ConnectedHomeSettings' 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:
--
-- 'minConfidence', 'connectedHomeSettings_minConfidence' - The minimum confidence required to label an object in the video.
--
-- 'labels', 'connectedHomeSettings_labels' - Specifies what you want to detect in the video, such as people,
-- packages, or pets. The current valid labels you can include in this list
-- are: \"PERSON\", \"PET\", \"PACKAGE\", and \"ALL\".
newConnectedHomeSettings ::
  -- | 'labels'
  Prelude.NonEmpty Prelude.Text ->
  ConnectedHomeSettings
newConnectedHomeSettings :: NonEmpty Text -> ConnectedHomeSettings
newConnectedHomeSettings NonEmpty Text
pLabels_ =
  ConnectedHomeSettings'
    { $sel:minConfidence:ConnectedHomeSettings' :: Maybe Double
minConfidence =
        forall a. Maybe a
Prelude.Nothing,
      $sel:labels:ConnectedHomeSettings' :: NonEmpty Text
labels = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pLabels_
    }

-- | The minimum confidence required to label an object in the video.
connectedHomeSettings_minConfidence :: Lens.Lens' ConnectedHomeSettings (Prelude.Maybe Prelude.Double)
connectedHomeSettings_minConfidence :: Lens' ConnectedHomeSettings (Maybe Double)
connectedHomeSettings_minConfidence = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectedHomeSettings' {Maybe Double
minConfidence :: Maybe Double
$sel:minConfidence:ConnectedHomeSettings' :: ConnectedHomeSettings -> Maybe Double
minConfidence} -> Maybe Double
minConfidence) (\s :: ConnectedHomeSettings
s@ConnectedHomeSettings' {} Maybe Double
a -> ConnectedHomeSettings
s {$sel:minConfidence:ConnectedHomeSettings' :: Maybe Double
minConfidence = Maybe Double
a} :: ConnectedHomeSettings)

-- | Specifies what you want to detect in the video, such as people,
-- packages, or pets. The current valid labels you can include in this list
-- are: \"PERSON\", \"PET\", \"PACKAGE\", and \"ALL\".
connectedHomeSettings_labels :: Lens.Lens' ConnectedHomeSettings (Prelude.NonEmpty Prelude.Text)
connectedHomeSettings_labels :: Lens' ConnectedHomeSettings (NonEmpty Text)
connectedHomeSettings_labels = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectedHomeSettings' {NonEmpty Text
labels :: NonEmpty Text
$sel:labels:ConnectedHomeSettings' :: ConnectedHomeSettings -> NonEmpty Text
labels} -> NonEmpty Text
labels) (\s :: ConnectedHomeSettings
s@ConnectedHomeSettings' {} NonEmpty Text
a -> ConnectedHomeSettings
s {$sel:labels:ConnectedHomeSettings' :: NonEmpty Text
labels = NonEmpty Text
a} :: ConnectedHomeSettings) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ConnectedHomeSettings where
  parseJSON :: Value -> Parser ConnectedHomeSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ConnectedHomeSettings"
      ( \Object
x ->
          Maybe Double -> NonEmpty Text -> ConnectedHomeSettings
ConnectedHomeSettings'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"MinConfidence")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Labels")
      )

instance Prelude.Hashable ConnectedHomeSettings where
  hashWithSalt :: Int -> ConnectedHomeSettings -> Int
hashWithSalt Int
_salt ConnectedHomeSettings' {Maybe Double
NonEmpty Text
labels :: NonEmpty Text
minConfidence :: Maybe Double
$sel:labels:ConnectedHomeSettings' :: ConnectedHomeSettings -> NonEmpty Text
$sel:minConfidence:ConnectedHomeSettings' :: ConnectedHomeSettings -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
minConfidence
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
labels

instance Prelude.NFData ConnectedHomeSettings where
  rnf :: ConnectedHomeSettings -> ()
rnf ConnectedHomeSettings' {Maybe Double
NonEmpty Text
labels :: NonEmpty Text
minConfidence :: Maybe Double
$sel:labels:ConnectedHomeSettings' :: ConnectedHomeSettings -> NonEmpty Text
$sel:minConfidence:ConnectedHomeSettings' :: ConnectedHomeSettings -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
minConfidence
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
labels

instance Data.ToJSON ConnectedHomeSettings where
  toJSON :: ConnectedHomeSettings -> Value
toJSON ConnectedHomeSettings' {Maybe Double
NonEmpty Text
labels :: NonEmpty Text
minConfidence :: Maybe Double
$sel:labels:ConnectedHomeSettings' :: ConnectedHomeSettings -> NonEmpty Text
$sel:minConfidence:ConnectedHomeSettings' :: ConnectedHomeSettings -> Maybe Double
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"MinConfidence" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
minConfidence,
            forall a. a -> Maybe a
Prelude.Just (Key
"Labels" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
labels)
          ]
      )