{-# 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.IoTEvents.Types.DetectorDebugOption
-- 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.IoTEvents.Types.DetectorDebugOption where

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

-- | The detector model and the specific detectors (instances) for which the
-- logging level is given.
--
-- /See:/ 'newDetectorDebugOption' smart constructor.
data DetectorDebugOption = DetectorDebugOption'
  { -- | The value of the input attribute key used to create the detector (the
    -- instance of the detector model).
    DetectorDebugOption -> Maybe Text
keyValue :: Prelude.Maybe Prelude.Text,
    -- | The name of the detector model.
    DetectorDebugOption -> Text
detectorModelName :: Prelude.Text
  }
  deriving (DetectorDebugOption -> DetectorDebugOption -> Bool
(DetectorDebugOption -> DetectorDebugOption -> Bool)
-> (DetectorDebugOption -> DetectorDebugOption -> Bool)
-> Eq DetectorDebugOption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectorDebugOption -> DetectorDebugOption -> Bool
$c/= :: DetectorDebugOption -> DetectorDebugOption -> Bool
== :: DetectorDebugOption -> DetectorDebugOption -> Bool
$c== :: DetectorDebugOption -> DetectorDebugOption -> Bool
Prelude.Eq, ReadPrec [DetectorDebugOption]
ReadPrec DetectorDebugOption
Int -> ReadS DetectorDebugOption
ReadS [DetectorDebugOption]
(Int -> ReadS DetectorDebugOption)
-> ReadS [DetectorDebugOption]
-> ReadPrec DetectorDebugOption
-> ReadPrec [DetectorDebugOption]
-> Read DetectorDebugOption
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetectorDebugOption]
$creadListPrec :: ReadPrec [DetectorDebugOption]
readPrec :: ReadPrec DetectorDebugOption
$creadPrec :: ReadPrec DetectorDebugOption
readList :: ReadS [DetectorDebugOption]
$creadList :: ReadS [DetectorDebugOption]
readsPrec :: Int -> ReadS DetectorDebugOption
$creadsPrec :: Int -> ReadS DetectorDebugOption
Prelude.Read, Int -> DetectorDebugOption -> ShowS
[DetectorDebugOption] -> ShowS
DetectorDebugOption -> String
(Int -> DetectorDebugOption -> ShowS)
-> (DetectorDebugOption -> String)
-> ([DetectorDebugOption] -> ShowS)
-> Show DetectorDebugOption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectorDebugOption] -> ShowS
$cshowList :: [DetectorDebugOption] -> ShowS
show :: DetectorDebugOption -> String
$cshow :: DetectorDebugOption -> String
showsPrec :: Int -> DetectorDebugOption -> ShowS
$cshowsPrec :: Int -> DetectorDebugOption -> ShowS
Prelude.Show, (forall x. DetectorDebugOption -> Rep DetectorDebugOption x)
-> (forall x. Rep DetectorDebugOption x -> DetectorDebugOption)
-> Generic DetectorDebugOption
forall x. Rep DetectorDebugOption x -> DetectorDebugOption
forall x. DetectorDebugOption -> Rep DetectorDebugOption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetectorDebugOption x -> DetectorDebugOption
$cfrom :: forall x. DetectorDebugOption -> Rep DetectorDebugOption x
Prelude.Generic)

-- |
-- Create a value of 'DetectorDebugOption' 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:
--
-- 'keyValue', 'detectorDebugOption_keyValue' - The value of the input attribute key used to create the detector (the
-- instance of the detector model).
--
-- 'detectorModelName', 'detectorDebugOption_detectorModelName' - The name of the detector model.
newDetectorDebugOption ::
  -- | 'detectorModelName'
  Prelude.Text ->
  DetectorDebugOption
newDetectorDebugOption :: Text -> DetectorDebugOption
newDetectorDebugOption Text
pDetectorModelName_ =
  DetectorDebugOption' :: Maybe Text -> Text -> DetectorDebugOption
DetectorDebugOption'
    { $sel:keyValue:DetectorDebugOption' :: Maybe Text
keyValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:detectorModelName:DetectorDebugOption' :: Text
detectorModelName = Text
pDetectorModelName_
    }

-- | The value of the input attribute key used to create the detector (the
-- instance of the detector model).
detectorDebugOption_keyValue :: Lens.Lens' DetectorDebugOption (Prelude.Maybe Prelude.Text)
detectorDebugOption_keyValue :: (Maybe Text -> f (Maybe Text))
-> DetectorDebugOption -> f DetectorDebugOption
detectorDebugOption_keyValue = (DetectorDebugOption -> Maybe Text)
-> (DetectorDebugOption -> Maybe Text -> DetectorDebugOption)
-> Lens
     DetectorDebugOption DetectorDebugOption (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectorDebugOption' {Maybe Text
keyValue :: Maybe Text
$sel:keyValue:DetectorDebugOption' :: DetectorDebugOption -> Maybe Text
keyValue} -> Maybe Text
keyValue) (\s :: DetectorDebugOption
s@DetectorDebugOption' {} Maybe Text
a -> DetectorDebugOption
s {$sel:keyValue:DetectorDebugOption' :: Maybe Text
keyValue = Maybe Text
a} :: DetectorDebugOption)

-- | The name of the detector model.
detectorDebugOption_detectorModelName :: Lens.Lens' DetectorDebugOption Prelude.Text
detectorDebugOption_detectorModelName :: (Text -> f Text) -> DetectorDebugOption -> f DetectorDebugOption
detectorDebugOption_detectorModelName = (DetectorDebugOption -> Text)
-> (DetectorDebugOption -> Text -> DetectorDebugOption)
-> Lens DetectorDebugOption DetectorDebugOption Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectorDebugOption' {Text
detectorModelName :: Text
$sel:detectorModelName:DetectorDebugOption' :: DetectorDebugOption -> Text
detectorModelName} -> Text
detectorModelName) (\s :: DetectorDebugOption
s@DetectorDebugOption' {} Text
a -> DetectorDebugOption
s {$sel:detectorModelName:DetectorDebugOption' :: Text
detectorModelName = Text
a} :: DetectorDebugOption)

instance Core.FromJSON DetectorDebugOption where
  parseJSON :: Value -> Parser DetectorDebugOption
parseJSON =
    String
-> (Object -> Parser DetectorDebugOption)
-> Value
-> Parser DetectorDebugOption
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DetectorDebugOption"
      ( \Object
x ->
          Maybe Text -> Text -> DetectorDebugOption
DetectorDebugOption'
            (Maybe Text -> Text -> DetectorDebugOption)
-> Parser (Maybe Text) -> Parser (Text -> DetectorDebugOption)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"keyValue")
            Parser (Text -> DetectorDebugOption)
-> Parser Text -> Parser DetectorDebugOption
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"detectorModelName")
      )

instance Prelude.Hashable DetectorDebugOption

instance Prelude.NFData DetectorDebugOption

instance Core.ToJSON DetectorDebugOption where
  toJSON :: DetectorDebugOption -> Value
toJSON DetectorDebugOption' {Maybe Text
Text
detectorModelName :: Text
keyValue :: Maybe Text
$sel:detectorModelName:DetectorDebugOption' :: DetectorDebugOption -> Text
$sel:keyValue:DetectorDebugOption' :: DetectorDebugOption -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"keyValue" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
keyValue,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"detectorModelName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
detectorModelName)
          ]
      )