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

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

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

-- |
-- Create a value of 'DetectorSummary' 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', 'detectorSummary_keyValue' - The value of the key (identifying the device or system) that caused the
-- creation of this detector (instance).
--
-- 'creationTime', 'detectorSummary_creationTime' - The time the detector (instance) was created.
--
-- 'state', 'detectorSummary_state' - The current state of the detector (instance).
--
-- 'detectorModelName', 'detectorSummary_detectorModelName' - The name of the detector model that created this detector (instance).
--
-- 'detectorModelVersion', 'detectorSummary_detectorModelVersion' - The version of the detector model that created this detector (instance).
--
-- 'lastUpdateTime', 'detectorSummary_lastUpdateTime' - The time the detector (instance) was last updated.
newDetectorSummary ::
  DetectorSummary
newDetectorSummary :: DetectorSummary
newDetectorSummary =
  DetectorSummary' :: Maybe Text
-> Maybe POSIX
-> Maybe DetectorStateSummary
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> DetectorSummary
DetectorSummary'
    { $sel:keyValue:DetectorSummary' :: Maybe Text
keyValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationTime:DetectorSummary' :: Maybe POSIX
creationTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:state:DetectorSummary' :: Maybe DetectorStateSummary
state = Maybe DetectorStateSummary
forall a. Maybe a
Prelude.Nothing,
      $sel:detectorModelName:DetectorSummary' :: Maybe Text
detectorModelName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:detectorModelVersion:DetectorSummary' :: Maybe Text
detectorModelVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdateTime:DetectorSummary' :: 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).
detectorSummary_keyValue :: Lens.Lens' DetectorSummary (Prelude.Maybe Prelude.Text)
detectorSummary_keyValue :: (Maybe Text -> f (Maybe Text))
-> DetectorSummary -> f DetectorSummary
detectorSummary_keyValue = (DetectorSummary -> Maybe Text)
-> (DetectorSummary -> Maybe Text -> DetectorSummary)
-> Lens DetectorSummary DetectorSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectorSummary' {Maybe Text
keyValue :: Maybe Text
$sel:keyValue:DetectorSummary' :: DetectorSummary -> Maybe Text
keyValue} -> Maybe Text
keyValue) (\s :: DetectorSummary
s@DetectorSummary' {} Maybe Text
a -> DetectorSummary
s {$sel:keyValue:DetectorSummary' :: Maybe Text
keyValue = Maybe Text
a} :: DetectorSummary)

-- | The time the detector (instance) was created.
detectorSummary_creationTime :: Lens.Lens' DetectorSummary (Prelude.Maybe Prelude.UTCTime)
detectorSummary_creationTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> DetectorSummary -> f DetectorSummary
detectorSummary_creationTime = (DetectorSummary -> Maybe POSIX)
-> (DetectorSummary -> Maybe POSIX -> DetectorSummary)
-> Lens DetectorSummary DetectorSummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectorSummary' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:DetectorSummary' :: DetectorSummary -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: DetectorSummary
s@DetectorSummary' {} Maybe POSIX
a -> DetectorSummary
s {$sel:creationTime:DetectorSummary' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: DetectorSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> DetectorSummary -> f DetectorSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DetectorSummary
-> f DetectorSummary
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).
detectorSummary_state :: Lens.Lens' DetectorSummary (Prelude.Maybe DetectorStateSummary)
detectorSummary_state :: (Maybe DetectorStateSummary -> f (Maybe DetectorStateSummary))
-> DetectorSummary -> f DetectorSummary
detectorSummary_state = (DetectorSummary -> Maybe DetectorStateSummary)
-> (DetectorSummary
    -> Maybe DetectorStateSummary -> DetectorSummary)
-> Lens
     DetectorSummary
     DetectorSummary
     (Maybe DetectorStateSummary)
     (Maybe DetectorStateSummary)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectorSummary' {Maybe DetectorStateSummary
state :: Maybe DetectorStateSummary
$sel:state:DetectorSummary' :: DetectorSummary -> Maybe DetectorStateSummary
state} -> Maybe DetectorStateSummary
state) (\s :: DetectorSummary
s@DetectorSummary' {} Maybe DetectorStateSummary
a -> DetectorSummary
s {$sel:state:DetectorSummary' :: Maybe DetectorStateSummary
state = Maybe DetectorStateSummary
a} :: DetectorSummary)

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

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

-- | The time the detector (instance) was last updated.
detectorSummary_lastUpdateTime :: Lens.Lens' DetectorSummary (Prelude.Maybe Prelude.UTCTime)
detectorSummary_lastUpdateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> DetectorSummary -> f DetectorSummary
detectorSummary_lastUpdateTime = (DetectorSummary -> Maybe POSIX)
-> (DetectorSummary -> Maybe POSIX -> DetectorSummary)
-> Lens DetectorSummary DetectorSummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectorSummary' {Maybe POSIX
lastUpdateTime :: Maybe POSIX
$sel:lastUpdateTime:DetectorSummary' :: DetectorSummary -> Maybe POSIX
lastUpdateTime} -> Maybe POSIX
lastUpdateTime) (\s :: DetectorSummary
s@DetectorSummary' {} Maybe POSIX
a -> DetectorSummary
s {$sel:lastUpdateTime:DetectorSummary' :: Maybe POSIX
lastUpdateTime = Maybe POSIX
a} :: DetectorSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> DetectorSummary -> f DetectorSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DetectorSummary
-> f DetectorSummary
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 DetectorSummary where
  parseJSON :: Value -> Parser DetectorSummary
parseJSON =
    String
-> (Object -> Parser DetectorSummary)
-> Value
-> Parser DetectorSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DetectorSummary"
      ( \Object
x ->
          Maybe Text
-> Maybe POSIX
-> Maybe DetectorStateSummary
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> DetectorSummary
DetectorSummary'
            (Maybe Text
 -> Maybe POSIX
 -> Maybe DetectorStateSummary
 -> Maybe Text
 -> Maybe Text
 -> Maybe POSIX
 -> DetectorSummary)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe DetectorStateSummary
      -> Maybe Text
      -> Maybe Text
      -> Maybe POSIX
      -> DetectorSummary)
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 DetectorStateSummary
   -> Maybe Text
   -> Maybe Text
   -> Maybe POSIX
   -> DetectorSummary)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe DetectorStateSummary
      -> Maybe Text -> Maybe Text -> Maybe POSIX -> DetectorSummary)
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 DetectorStateSummary
   -> Maybe Text -> Maybe Text -> Maybe POSIX -> DetectorSummary)
-> Parser (Maybe DetectorStateSummary)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe POSIX -> DetectorSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DetectorStateSummary)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"state")
            Parser (Maybe Text -> Maybe Text -> Maybe POSIX -> DetectorSummary)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe POSIX -> DetectorSummary)
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 -> DetectorSummary)
-> Parser (Maybe Text) -> Parser (Maybe POSIX -> DetectorSummary)
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 -> DetectorSummary)
-> Parser (Maybe POSIX) -> Parser DetectorSummary
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 DetectorSummary

instance Prelude.NFData DetectorSummary