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

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

-- | Information about the detector (instance).
--
-- /See:/ 'newDetector' smart constructor.
data Detector = Detector'
  { -- | The value of the key (identifying the device or system) that caused the
    -- creation of this detector (instance).
    Detector -> Maybe Text
keyValue :: Prelude.Maybe Prelude.Text,
    -- | The time the detector (instance) was created.
    Detector -> Maybe POSIX
creationTime :: Prelude.Maybe Core.POSIX,
    -- | The current state of the detector (instance).
    Detector -> Maybe DetectorState
state :: Prelude.Maybe DetectorState,
    -- | The name of the detector model that created this detector (instance).
    Detector -> Maybe Text
detectorModelName :: Prelude.Maybe Prelude.Text,
    -- | The version of the detector model that created this detector (instance).
    Detector -> Maybe Text
detectorModelVersion :: Prelude.Maybe Prelude.Text,
    -- | The time the detector (instance) was last updated.
    Detector -> Maybe POSIX
lastUpdateTime :: Prelude.Maybe Core.POSIX
  }
  deriving (Detector -> Detector -> Bool
(Detector -> Detector -> Bool)
-> (Detector -> Detector -> Bool) -> Eq Detector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Detector -> Detector -> Bool
$c/= :: Detector -> Detector -> Bool
== :: Detector -> Detector -> Bool
$c== :: Detector -> Detector -> Bool
Prelude.Eq, ReadPrec [Detector]
ReadPrec Detector
Int -> ReadS Detector
ReadS [Detector]
(Int -> ReadS Detector)
-> ReadS [Detector]
-> ReadPrec Detector
-> ReadPrec [Detector]
-> Read Detector
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Detector]
$creadListPrec :: ReadPrec [Detector]
readPrec :: ReadPrec Detector
$creadPrec :: ReadPrec Detector
readList :: ReadS [Detector]
$creadList :: ReadS [Detector]
readsPrec :: Int -> ReadS Detector
$creadsPrec :: Int -> ReadS Detector
Prelude.Read, Int -> Detector -> ShowS
[Detector] -> ShowS
Detector -> String
(Int -> Detector -> ShowS)
-> (Detector -> String) -> ([Detector] -> ShowS) -> Show Detector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Detector] -> ShowS
$cshowList :: [Detector] -> ShowS
show :: Detector -> String
$cshow :: Detector -> String
showsPrec :: Int -> Detector -> ShowS
$cshowsPrec :: Int -> Detector -> ShowS
Prelude.Show, (forall x. Detector -> Rep Detector x)
-> (forall x. Rep Detector x -> Detector) -> Generic Detector
forall x. Rep Detector x -> Detector
forall x. Detector -> Rep Detector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Detector x -> Detector
$cfrom :: forall x. Detector -> Rep Detector x
Prelude.Generic)

-- |
-- Create a value of 'Detector' 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', 'detector_keyValue' - The value of the key (identifying the device or system) that caused the
-- creation of this detector (instance).
--
-- 'creationTime', 'detector_creationTime' - The time the detector (instance) was created.
--
-- 'state', 'detector_state' - The current state of the detector (instance).
--
-- 'detectorModelName', 'detector_detectorModelName' - The name of the detector model that created this detector (instance).
--
-- 'detectorModelVersion', 'detector_detectorModelVersion' - The version of the detector model that created this detector (instance).
--
-- 'lastUpdateTime', 'detector_lastUpdateTime' - The time the detector (instance) was last updated.
newDetector ::
  Detector
newDetector :: Detector
newDetector =
  Detector' :: Maybe Text
-> Maybe POSIX
-> Maybe DetectorState
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Detector
Detector'
    { $sel:keyValue:Detector' :: Maybe Text
keyValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationTime:Detector' :: Maybe POSIX
creationTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:state:Detector' :: Maybe DetectorState
state = Maybe DetectorState
forall a. Maybe a
Prelude.Nothing,
      $sel:detectorModelName:Detector' :: Maybe Text
detectorModelName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:detectorModelVersion:Detector' :: Maybe Text
detectorModelVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdateTime:Detector' :: Maybe POSIX
lastUpdateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The time the detector (instance) was created.
detector_creationTime :: Lens.Lens' Detector (Prelude.Maybe Prelude.UTCTime)
detector_creationTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Detector -> f Detector
detector_creationTime = (Detector -> Maybe POSIX)
-> (Detector -> Maybe POSIX -> Detector)
-> Lens Detector Detector (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Detector' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:Detector' :: Detector -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: Detector
s@Detector' {} Maybe POSIX
a -> Detector
s {$sel:creationTime:Detector' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: Detector) ((Maybe POSIX -> f (Maybe POSIX)) -> Detector -> f Detector)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Detector
-> f Detector
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The current state of the detector (instance).
detector_state :: Lens.Lens' Detector (Prelude.Maybe DetectorState)
detector_state :: (Maybe DetectorState -> f (Maybe DetectorState))
-> Detector -> f Detector
detector_state = (Detector -> Maybe DetectorState)
-> (Detector -> Maybe DetectorState -> Detector)
-> Lens
     Detector Detector (Maybe DetectorState) (Maybe DetectorState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Detector' {Maybe DetectorState
state :: Maybe DetectorState
$sel:state:Detector' :: Detector -> Maybe DetectorState
state} -> Maybe DetectorState
state) (\s :: Detector
s@Detector' {} Maybe DetectorState
a -> Detector
s {$sel:state:Detector' :: Maybe DetectorState
state = Maybe DetectorState
a} :: Detector)

-- | The name of the detector model that created this detector (instance).
detector_detectorModelName :: Lens.Lens' Detector (Prelude.Maybe Prelude.Text)
detector_detectorModelName :: (Maybe Text -> f (Maybe Text)) -> Detector -> f Detector
detector_detectorModelName = (Detector -> Maybe Text)
-> (Detector -> Maybe Text -> Detector)
-> Lens Detector Detector (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Detector' {Maybe Text
detectorModelName :: Maybe Text
$sel:detectorModelName:Detector' :: Detector -> Maybe Text
detectorModelName} -> Maybe Text
detectorModelName) (\s :: Detector
s@Detector' {} Maybe Text
a -> Detector
s {$sel:detectorModelName:Detector' :: Maybe Text
detectorModelName = Maybe Text
a} :: Detector)

-- | The version of the detector model that created this detector (instance).
detector_detectorModelVersion :: Lens.Lens' Detector (Prelude.Maybe Prelude.Text)
detector_detectorModelVersion :: (Maybe Text -> f (Maybe Text)) -> Detector -> f Detector
detector_detectorModelVersion = (Detector -> Maybe Text)
-> (Detector -> Maybe Text -> Detector)
-> Lens Detector Detector (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Detector' {Maybe Text
detectorModelVersion :: Maybe Text
$sel:detectorModelVersion:Detector' :: Detector -> Maybe Text
detectorModelVersion} -> Maybe Text
detectorModelVersion) (\s :: Detector
s@Detector' {} Maybe Text
a -> Detector
s {$sel:detectorModelVersion:Detector' :: Maybe Text
detectorModelVersion = Maybe Text
a} :: Detector)

-- | The time the detector (instance) was last updated.
detector_lastUpdateTime :: Lens.Lens' Detector (Prelude.Maybe Prelude.UTCTime)
detector_lastUpdateTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Detector -> f Detector
detector_lastUpdateTime = (Detector -> Maybe POSIX)
-> (Detector -> Maybe POSIX -> Detector)
-> Lens Detector Detector (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Detector' {Maybe POSIX
lastUpdateTime :: Maybe POSIX
$sel:lastUpdateTime:Detector' :: Detector -> Maybe POSIX
lastUpdateTime} -> Maybe POSIX
lastUpdateTime) (\s :: Detector
s@Detector' {} Maybe POSIX
a -> Detector
s {$sel:lastUpdateTime:Detector' :: Maybe POSIX
lastUpdateTime = Maybe POSIX
a} :: Detector) ((Maybe POSIX -> f (Maybe POSIX)) -> Detector -> f Detector)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Detector
-> f Detector
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON Detector where
  parseJSON :: Value -> Parser Detector
parseJSON =
    String -> (Object -> Parser Detector) -> Value -> Parser Detector
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Detector"
      ( \Object
x ->
          Maybe Text
-> Maybe POSIX
-> Maybe DetectorState
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Detector
Detector'
            (Maybe Text
 -> Maybe POSIX
 -> Maybe DetectorState
 -> Maybe Text
 -> Maybe Text
 -> Maybe POSIX
 -> Detector)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe DetectorState
      -> Maybe Text
      -> Maybe Text
      -> Maybe POSIX
      -> Detector)
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
  (Maybe POSIX
   -> Maybe DetectorState
   -> Maybe Text
   -> Maybe Text
   -> Maybe POSIX
   -> Detector)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe DetectorState
      -> Maybe Text -> Maybe Text -> Maybe POSIX -> Detector)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"creationTime")
            Parser
  (Maybe DetectorState
   -> Maybe Text -> Maybe Text -> Maybe POSIX -> Detector)
-> Parser (Maybe DetectorState)
-> Parser (Maybe Text -> Maybe Text -> Maybe POSIX -> Detector)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DetectorState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"state")
            Parser (Maybe Text -> Maybe Text -> Maybe POSIX -> Detector)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe POSIX -> Detector)
forall (f :: * -> *) a b. Applicative f => 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
"detectorModelName")
            Parser (Maybe Text -> Maybe POSIX -> Detector)
-> Parser (Maybe Text) -> Parser (Maybe POSIX -> Detector)
forall (f :: * -> *) a b. Applicative f => 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
"detectorModelVersion")
            Parser (Maybe POSIX -> Detector)
-> Parser (Maybe POSIX) -> Parser Detector
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lastUpdateTime")
      )

instance Prelude.Hashable Detector

instance Prelude.NFData Detector