{-# 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.IoTEventsData.Types.UpdateDetectorRequest
-- 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.IoTEventsData.Types.UpdateDetectorRequest where

import qualified Amazonka.Core as Core
import Amazonka.IoTEventsData.Types.DetectorStateDefinition
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information used to update the detector (instance).
--
-- /See:/ 'newUpdateDetectorRequest' smart constructor.
data UpdateDetectorRequest = UpdateDetectorRequest'
  { -- | The value of the input key attribute (identifying the device or system)
    -- that caused the creation of this detector (instance).
    UpdateDetectorRequest -> Maybe Text
keyValue :: Prelude.Maybe Prelude.Text,
    -- | The ID to assign to the detector update @\"message\"@. Each
    -- @\"messageId\"@ must be unique within each batch sent.
    UpdateDetectorRequest -> Text
messageId :: Prelude.Text,
    -- | The name of the detector model that created the detectors (instances).
    UpdateDetectorRequest -> Text
detectorModelName :: Prelude.Text,
    -- | The new state, variable values, and timer settings of the detector
    -- (instance).
    UpdateDetectorRequest -> DetectorStateDefinition
state :: DetectorStateDefinition
  }
  deriving (UpdateDetectorRequest -> UpdateDetectorRequest -> Bool
(UpdateDetectorRequest -> UpdateDetectorRequest -> Bool)
-> (UpdateDetectorRequest -> UpdateDetectorRequest -> Bool)
-> Eq UpdateDetectorRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDetectorRequest -> UpdateDetectorRequest -> Bool
$c/= :: UpdateDetectorRequest -> UpdateDetectorRequest -> Bool
== :: UpdateDetectorRequest -> UpdateDetectorRequest -> Bool
$c== :: UpdateDetectorRequest -> UpdateDetectorRequest -> Bool
Prelude.Eq, ReadPrec [UpdateDetectorRequest]
ReadPrec UpdateDetectorRequest
Int -> ReadS UpdateDetectorRequest
ReadS [UpdateDetectorRequest]
(Int -> ReadS UpdateDetectorRequest)
-> ReadS [UpdateDetectorRequest]
-> ReadPrec UpdateDetectorRequest
-> ReadPrec [UpdateDetectorRequest]
-> Read UpdateDetectorRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDetectorRequest]
$creadListPrec :: ReadPrec [UpdateDetectorRequest]
readPrec :: ReadPrec UpdateDetectorRequest
$creadPrec :: ReadPrec UpdateDetectorRequest
readList :: ReadS [UpdateDetectorRequest]
$creadList :: ReadS [UpdateDetectorRequest]
readsPrec :: Int -> ReadS UpdateDetectorRequest
$creadsPrec :: Int -> ReadS UpdateDetectorRequest
Prelude.Read, Int -> UpdateDetectorRequest -> ShowS
[UpdateDetectorRequest] -> ShowS
UpdateDetectorRequest -> String
(Int -> UpdateDetectorRequest -> ShowS)
-> (UpdateDetectorRequest -> String)
-> ([UpdateDetectorRequest] -> ShowS)
-> Show UpdateDetectorRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDetectorRequest] -> ShowS
$cshowList :: [UpdateDetectorRequest] -> ShowS
show :: UpdateDetectorRequest -> String
$cshow :: UpdateDetectorRequest -> String
showsPrec :: Int -> UpdateDetectorRequest -> ShowS
$cshowsPrec :: Int -> UpdateDetectorRequest -> ShowS
Prelude.Show, (forall x. UpdateDetectorRequest -> Rep UpdateDetectorRequest x)
-> (forall x. Rep UpdateDetectorRequest x -> UpdateDetectorRequest)
-> Generic UpdateDetectorRequest
forall x. Rep UpdateDetectorRequest x -> UpdateDetectorRequest
forall x. UpdateDetectorRequest -> Rep UpdateDetectorRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateDetectorRequest x -> UpdateDetectorRequest
$cfrom :: forall x. UpdateDetectorRequest -> Rep UpdateDetectorRequest x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDetectorRequest' 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', 'updateDetectorRequest_keyValue' - The value of the input key attribute (identifying the device or system)
-- that caused the creation of this detector (instance).
--
-- 'messageId', 'updateDetectorRequest_messageId' - The ID to assign to the detector update @\"message\"@. Each
-- @\"messageId\"@ must be unique within each batch sent.
--
-- 'detectorModelName', 'updateDetectorRequest_detectorModelName' - The name of the detector model that created the detectors (instances).
--
-- 'state', 'updateDetectorRequest_state' - The new state, variable values, and timer settings of the detector
-- (instance).
newUpdateDetectorRequest ::
  -- | 'messageId'
  Prelude.Text ->
  -- | 'detectorModelName'
  Prelude.Text ->
  -- | 'state'
  DetectorStateDefinition ->
  UpdateDetectorRequest
newUpdateDetectorRequest :: Text -> Text -> DetectorStateDefinition -> UpdateDetectorRequest
newUpdateDetectorRequest
  Text
pMessageId_
  Text
pDetectorModelName_
  DetectorStateDefinition
pState_ =
    UpdateDetectorRequest' :: Maybe Text
-> Text -> Text -> DetectorStateDefinition -> UpdateDetectorRequest
UpdateDetectorRequest'
      { $sel:keyValue:UpdateDetectorRequest' :: Maybe Text
keyValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:messageId:UpdateDetectorRequest' :: Text
messageId = Text
pMessageId_,
        $sel:detectorModelName:UpdateDetectorRequest' :: Text
detectorModelName = Text
pDetectorModelName_,
        $sel:state:UpdateDetectorRequest' :: DetectorStateDefinition
state = DetectorStateDefinition
pState_
      }

-- | The value of the input key attribute (identifying the device or system)
-- that caused the creation of this detector (instance).
updateDetectorRequest_keyValue :: Lens.Lens' UpdateDetectorRequest (Prelude.Maybe Prelude.Text)
updateDetectorRequest_keyValue :: (Maybe Text -> f (Maybe Text))
-> UpdateDetectorRequest -> f UpdateDetectorRequest
updateDetectorRequest_keyValue = (UpdateDetectorRequest -> Maybe Text)
-> (UpdateDetectorRequest -> Maybe Text -> UpdateDetectorRequest)
-> Lens
     UpdateDetectorRequest
     UpdateDetectorRequest
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDetectorRequest' {Maybe Text
keyValue :: Maybe Text
$sel:keyValue:UpdateDetectorRequest' :: UpdateDetectorRequest -> Maybe Text
keyValue} -> Maybe Text
keyValue) (\s :: UpdateDetectorRequest
s@UpdateDetectorRequest' {} Maybe Text
a -> UpdateDetectorRequest
s {$sel:keyValue:UpdateDetectorRequest' :: Maybe Text
keyValue = Maybe Text
a} :: UpdateDetectorRequest)

-- | The ID to assign to the detector update @\"message\"@. Each
-- @\"messageId\"@ must be unique within each batch sent.
updateDetectorRequest_messageId :: Lens.Lens' UpdateDetectorRequest Prelude.Text
updateDetectorRequest_messageId :: (Text -> f Text)
-> UpdateDetectorRequest -> f UpdateDetectorRequest
updateDetectorRequest_messageId = (UpdateDetectorRequest -> Text)
-> (UpdateDetectorRequest -> Text -> UpdateDetectorRequest)
-> Lens UpdateDetectorRequest UpdateDetectorRequest Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDetectorRequest' {Text
messageId :: Text
$sel:messageId:UpdateDetectorRequest' :: UpdateDetectorRequest -> Text
messageId} -> Text
messageId) (\s :: UpdateDetectorRequest
s@UpdateDetectorRequest' {} Text
a -> UpdateDetectorRequest
s {$sel:messageId:UpdateDetectorRequest' :: Text
messageId = Text
a} :: UpdateDetectorRequest)

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

-- | The new state, variable values, and timer settings of the detector
-- (instance).
updateDetectorRequest_state :: Lens.Lens' UpdateDetectorRequest DetectorStateDefinition
updateDetectorRequest_state :: (DetectorStateDefinition -> f DetectorStateDefinition)
-> UpdateDetectorRequest -> f UpdateDetectorRequest
updateDetectorRequest_state = (UpdateDetectorRequest -> DetectorStateDefinition)
-> (UpdateDetectorRequest
    -> DetectorStateDefinition -> UpdateDetectorRequest)
-> Lens
     UpdateDetectorRequest
     UpdateDetectorRequest
     DetectorStateDefinition
     DetectorStateDefinition
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDetectorRequest' {DetectorStateDefinition
state :: DetectorStateDefinition
$sel:state:UpdateDetectorRequest' :: UpdateDetectorRequest -> DetectorStateDefinition
state} -> DetectorStateDefinition
state) (\s :: UpdateDetectorRequest
s@UpdateDetectorRequest' {} DetectorStateDefinition
a -> UpdateDetectorRequest
s {$sel:state:UpdateDetectorRequest' :: DetectorStateDefinition
state = DetectorStateDefinition
a} :: UpdateDetectorRequest)

instance Prelude.Hashable UpdateDetectorRequest

instance Prelude.NFData UpdateDetectorRequest

instance Core.ToJSON UpdateDetectorRequest where
  toJSON :: UpdateDetectorRequest -> Value
toJSON UpdateDetectorRequest' {Maybe Text
Text
DetectorStateDefinition
state :: DetectorStateDefinition
detectorModelName :: Text
messageId :: Text
keyValue :: Maybe Text
$sel:state:UpdateDetectorRequest' :: UpdateDetectorRequest -> DetectorStateDefinition
$sel:detectorModelName:UpdateDetectorRequest' :: UpdateDetectorRequest -> Text
$sel:messageId:UpdateDetectorRequest' :: UpdateDetectorRequest -> Text
$sel:keyValue:UpdateDetectorRequest' :: UpdateDetectorRequest -> 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
"messageId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
messageId),
            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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"state" Text -> DetectorStateDefinition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DetectorStateDefinition
state)
          ]
      )