{-# 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.ApplicationInsights.Types.ConfigurationEvent
-- 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.ApplicationInsights.Types.ConfigurationEvent where

import Amazonka.ApplicationInsights.Types.ConfigurationEventResourceType
import Amazonka.ApplicationInsights.Types.ConfigurationEventStatus
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The event information.
--
-- /See:/ 'newConfigurationEvent' smart constructor.
data ConfigurationEvent = ConfigurationEvent'
  { -- | The resource monitored by Application Insights.
    ConfigurationEvent -> Maybe Text
monitoredResourceARN :: Prelude.Maybe Prelude.Text,
    -- | The status of the configuration update event. Possible values include
    -- INFO, WARN, and ERROR.
    ConfigurationEvent -> Maybe ConfigurationEventStatus
eventStatus :: Prelude.Maybe ConfigurationEventStatus,
    -- | The name of the resource Application Insights attempted to configure.
    ConfigurationEvent -> Maybe Text
eventResourceName :: Prelude.Maybe Prelude.Text,
    -- | The timestamp of the event.
    ConfigurationEvent -> Maybe POSIX
eventTime :: Prelude.Maybe Core.POSIX,
    -- | The details of the event in plain text.
    ConfigurationEvent -> Maybe Text
eventDetail :: Prelude.Maybe Prelude.Text,
    -- | The resource type that Application Insights attempted to configure, for
    -- example, CLOUDWATCH_ALARM.
    ConfigurationEvent -> Maybe ConfigurationEventResourceType
eventResourceType :: Prelude.Maybe ConfigurationEventResourceType
  }
  deriving (ConfigurationEvent -> ConfigurationEvent -> Bool
(ConfigurationEvent -> ConfigurationEvent -> Bool)
-> (ConfigurationEvent -> ConfigurationEvent -> Bool)
-> Eq ConfigurationEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfigurationEvent -> ConfigurationEvent -> Bool
$c/= :: ConfigurationEvent -> ConfigurationEvent -> Bool
== :: ConfigurationEvent -> ConfigurationEvent -> Bool
$c== :: ConfigurationEvent -> ConfigurationEvent -> Bool
Prelude.Eq, ReadPrec [ConfigurationEvent]
ReadPrec ConfigurationEvent
Int -> ReadS ConfigurationEvent
ReadS [ConfigurationEvent]
(Int -> ReadS ConfigurationEvent)
-> ReadS [ConfigurationEvent]
-> ReadPrec ConfigurationEvent
-> ReadPrec [ConfigurationEvent]
-> Read ConfigurationEvent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfigurationEvent]
$creadListPrec :: ReadPrec [ConfigurationEvent]
readPrec :: ReadPrec ConfigurationEvent
$creadPrec :: ReadPrec ConfigurationEvent
readList :: ReadS [ConfigurationEvent]
$creadList :: ReadS [ConfigurationEvent]
readsPrec :: Int -> ReadS ConfigurationEvent
$creadsPrec :: Int -> ReadS ConfigurationEvent
Prelude.Read, Int -> ConfigurationEvent -> ShowS
[ConfigurationEvent] -> ShowS
ConfigurationEvent -> String
(Int -> ConfigurationEvent -> ShowS)
-> (ConfigurationEvent -> String)
-> ([ConfigurationEvent] -> ShowS)
-> Show ConfigurationEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfigurationEvent] -> ShowS
$cshowList :: [ConfigurationEvent] -> ShowS
show :: ConfigurationEvent -> String
$cshow :: ConfigurationEvent -> String
showsPrec :: Int -> ConfigurationEvent -> ShowS
$cshowsPrec :: Int -> ConfigurationEvent -> ShowS
Prelude.Show, (forall x. ConfigurationEvent -> Rep ConfigurationEvent x)
-> (forall x. Rep ConfigurationEvent x -> ConfigurationEvent)
-> Generic ConfigurationEvent
forall x. Rep ConfigurationEvent x -> ConfigurationEvent
forall x. ConfigurationEvent -> Rep ConfigurationEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConfigurationEvent x -> ConfigurationEvent
$cfrom :: forall x. ConfigurationEvent -> Rep ConfigurationEvent x
Prelude.Generic)

-- |
-- Create a value of 'ConfigurationEvent' 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:
--
-- 'monitoredResourceARN', 'configurationEvent_monitoredResourceARN' - The resource monitored by Application Insights.
--
-- 'eventStatus', 'configurationEvent_eventStatus' - The status of the configuration update event. Possible values include
-- INFO, WARN, and ERROR.
--
-- 'eventResourceName', 'configurationEvent_eventResourceName' - The name of the resource Application Insights attempted to configure.
--
-- 'eventTime', 'configurationEvent_eventTime' - The timestamp of the event.
--
-- 'eventDetail', 'configurationEvent_eventDetail' - The details of the event in plain text.
--
-- 'eventResourceType', 'configurationEvent_eventResourceType' - The resource type that Application Insights attempted to configure, for
-- example, CLOUDWATCH_ALARM.
newConfigurationEvent ::
  ConfigurationEvent
newConfigurationEvent :: ConfigurationEvent
newConfigurationEvent =
  ConfigurationEvent' :: Maybe Text
-> Maybe ConfigurationEventStatus
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe ConfigurationEventResourceType
-> ConfigurationEvent
ConfigurationEvent'
    { $sel:monitoredResourceARN:ConfigurationEvent' :: Maybe Text
monitoredResourceARN =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:eventStatus:ConfigurationEvent' :: Maybe ConfigurationEventStatus
eventStatus = Maybe ConfigurationEventStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:eventResourceName:ConfigurationEvent' :: Maybe Text
eventResourceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:eventTime:ConfigurationEvent' :: Maybe POSIX
eventTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:eventDetail:ConfigurationEvent' :: Maybe Text
eventDetail = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:eventResourceType:ConfigurationEvent' :: Maybe ConfigurationEventResourceType
eventResourceType = Maybe ConfigurationEventResourceType
forall a. Maybe a
Prelude.Nothing
    }

-- | The resource monitored by Application Insights.
configurationEvent_monitoredResourceARN :: Lens.Lens' ConfigurationEvent (Prelude.Maybe Prelude.Text)
configurationEvent_monitoredResourceARN :: (Maybe Text -> f (Maybe Text))
-> ConfigurationEvent -> f ConfigurationEvent
configurationEvent_monitoredResourceARN = (ConfigurationEvent -> Maybe Text)
-> (ConfigurationEvent -> Maybe Text -> ConfigurationEvent)
-> Lens
     ConfigurationEvent ConfigurationEvent (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigurationEvent' {Maybe Text
monitoredResourceARN :: Maybe Text
$sel:monitoredResourceARN:ConfigurationEvent' :: ConfigurationEvent -> Maybe Text
monitoredResourceARN} -> Maybe Text
monitoredResourceARN) (\s :: ConfigurationEvent
s@ConfigurationEvent' {} Maybe Text
a -> ConfigurationEvent
s {$sel:monitoredResourceARN:ConfigurationEvent' :: Maybe Text
monitoredResourceARN = Maybe Text
a} :: ConfigurationEvent)

-- | The status of the configuration update event. Possible values include
-- INFO, WARN, and ERROR.
configurationEvent_eventStatus :: Lens.Lens' ConfigurationEvent (Prelude.Maybe ConfigurationEventStatus)
configurationEvent_eventStatus :: (Maybe ConfigurationEventStatus
 -> f (Maybe ConfigurationEventStatus))
-> ConfigurationEvent -> f ConfigurationEvent
configurationEvent_eventStatus = (ConfigurationEvent -> Maybe ConfigurationEventStatus)
-> (ConfigurationEvent
    -> Maybe ConfigurationEventStatus -> ConfigurationEvent)
-> Lens
     ConfigurationEvent
     ConfigurationEvent
     (Maybe ConfigurationEventStatus)
     (Maybe ConfigurationEventStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigurationEvent' {Maybe ConfigurationEventStatus
eventStatus :: Maybe ConfigurationEventStatus
$sel:eventStatus:ConfigurationEvent' :: ConfigurationEvent -> Maybe ConfigurationEventStatus
eventStatus} -> Maybe ConfigurationEventStatus
eventStatus) (\s :: ConfigurationEvent
s@ConfigurationEvent' {} Maybe ConfigurationEventStatus
a -> ConfigurationEvent
s {$sel:eventStatus:ConfigurationEvent' :: Maybe ConfigurationEventStatus
eventStatus = Maybe ConfigurationEventStatus
a} :: ConfigurationEvent)

-- | The name of the resource Application Insights attempted to configure.
configurationEvent_eventResourceName :: Lens.Lens' ConfigurationEvent (Prelude.Maybe Prelude.Text)
configurationEvent_eventResourceName :: (Maybe Text -> f (Maybe Text))
-> ConfigurationEvent -> f ConfigurationEvent
configurationEvent_eventResourceName = (ConfigurationEvent -> Maybe Text)
-> (ConfigurationEvent -> Maybe Text -> ConfigurationEvent)
-> Lens
     ConfigurationEvent ConfigurationEvent (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigurationEvent' {Maybe Text
eventResourceName :: Maybe Text
$sel:eventResourceName:ConfigurationEvent' :: ConfigurationEvent -> Maybe Text
eventResourceName} -> Maybe Text
eventResourceName) (\s :: ConfigurationEvent
s@ConfigurationEvent' {} Maybe Text
a -> ConfigurationEvent
s {$sel:eventResourceName:ConfigurationEvent' :: Maybe Text
eventResourceName = Maybe Text
a} :: ConfigurationEvent)

-- | The timestamp of the event.
configurationEvent_eventTime :: Lens.Lens' ConfigurationEvent (Prelude.Maybe Prelude.UTCTime)
configurationEvent_eventTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ConfigurationEvent -> f ConfigurationEvent
configurationEvent_eventTime = (ConfigurationEvent -> Maybe POSIX)
-> (ConfigurationEvent -> Maybe POSIX -> ConfigurationEvent)
-> Lens
     ConfigurationEvent ConfigurationEvent (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigurationEvent' {Maybe POSIX
eventTime :: Maybe POSIX
$sel:eventTime:ConfigurationEvent' :: ConfigurationEvent -> Maybe POSIX
eventTime} -> Maybe POSIX
eventTime) (\s :: ConfigurationEvent
s@ConfigurationEvent' {} Maybe POSIX
a -> ConfigurationEvent
s {$sel:eventTime:ConfigurationEvent' :: Maybe POSIX
eventTime = Maybe POSIX
a} :: ConfigurationEvent) ((Maybe POSIX -> f (Maybe POSIX))
 -> ConfigurationEvent -> f ConfigurationEvent)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ConfigurationEvent
-> f ConfigurationEvent
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 details of the event in plain text.
configurationEvent_eventDetail :: Lens.Lens' ConfigurationEvent (Prelude.Maybe Prelude.Text)
configurationEvent_eventDetail :: (Maybe Text -> f (Maybe Text))
-> ConfigurationEvent -> f ConfigurationEvent
configurationEvent_eventDetail = (ConfigurationEvent -> Maybe Text)
-> (ConfigurationEvent -> Maybe Text -> ConfigurationEvent)
-> Lens
     ConfigurationEvent ConfigurationEvent (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigurationEvent' {Maybe Text
eventDetail :: Maybe Text
$sel:eventDetail:ConfigurationEvent' :: ConfigurationEvent -> Maybe Text
eventDetail} -> Maybe Text
eventDetail) (\s :: ConfigurationEvent
s@ConfigurationEvent' {} Maybe Text
a -> ConfigurationEvent
s {$sel:eventDetail:ConfigurationEvent' :: Maybe Text
eventDetail = Maybe Text
a} :: ConfigurationEvent)

-- | The resource type that Application Insights attempted to configure, for
-- example, CLOUDWATCH_ALARM.
configurationEvent_eventResourceType :: Lens.Lens' ConfigurationEvent (Prelude.Maybe ConfigurationEventResourceType)
configurationEvent_eventResourceType :: (Maybe ConfigurationEventResourceType
 -> f (Maybe ConfigurationEventResourceType))
-> ConfigurationEvent -> f ConfigurationEvent
configurationEvent_eventResourceType = (ConfigurationEvent -> Maybe ConfigurationEventResourceType)
-> (ConfigurationEvent
    -> Maybe ConfigurationEventResourceType -> ConfigurationEvent)
-> Lens
     ConfigurationEvent
     ConfigurationEvent
     (Maybe ConfigurationEventResourceType)
     (Maybe ConfigurationEventResourceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigurationEvent' {Maybe ConfigurationEventResourceType
eventResourceType :: Maybe ConfigurationEventResourceType
$sel:eventResourceType:ConfigurationEvent' :: ConfigurationEvent -> Maybe ConfigurationEventResourceType
eventResourceType} -> Maybe ConfigurationEventResourceType
eventResourceType) (\s :: ConfigurationEvent
s@ConfigurationEvent' {} Maybe ConfigurationEventResourceType
a -> ConfigurationEvent
s {$sel:eventResourceType:ConfigurationEvent' :: Maybe ConfigurationEventResourceType
eventResourceType = Maybe ConfigurationEventResourceType
a} :: ConfigurationEvent)

instance Core.FromJSON ConfigurationEvent where
  parseJSON :: Value -> Parser ConfigurationEvent
parseJSON =
    String
-> (Object -> Parser ConfigurationEvent)
-> Value
-> Parser ConfigurationEvent
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ConfigurationEvent"
      ( \Object
x ->
          Maybe Text
-> Maybe ConfigurationEventStatus
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe ConfigurationEventResourceType
-> ConfigurationEvent
ConfigurationEvent'
            (Maybe Text
 -> Maybe ConfigurationEventStatus
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe ConfigurationEventResourceType
 -> ConfigurationEvent)
-> Parser (Maybe Text)
-> Parser
     (Maybe ConfigurationEventStatus
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe ConfigurationEventResourceType
      -> ConfigurationEvent)
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
"MonitoredResourceARN")
            Parser
  (Maybe ConfigurationEventStatus
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe ConfigurationEventResourceType
   -> ConfigurationEvent)
-> Parser (Maybe ConfigurationEventStatus)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe ConfigurationEventResourceType
      -> ConfigurationEvent)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ConfigurationEventStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EventStatus")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe ConfigurationEventResourceType
   -> ConfigurationEvent)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe Text
      -> Maybe ConfigurationEventResourceType
      -> ConfigurationEvent)
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
"EventResourceName")
            Parser
  (Maybe POSIX
   -> Maybe Text
   -> Maybe ConfigurationEventResourceType
   -> ConfigurationEvent)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text
      -> Maybe ConfigurationEventResourceType -> ConfigurationEvent)
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
"EventTime")
            Parser
  (Maybe Text
   -> Maybe ConfigurationEventResourceType -> ConfigurationEvent)
-> Parser (Maybe Text)
-> Parser
     (Maybe ConfigurationEventResourceType -> ConfigurationEvent)
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
"EventDetail")
            Parser (Maybe ConfigurationEventResourceType -> ConfigurationEvent)
-> Parser (Maybe ConfigurationEventResourceType)
-> Parser ConfigurationEvent
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ConfigurationEventResourceType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EventResourceType")
      )

instance Prelude.Hashable ConfigurationEvent

instance Prelude.NFData ConfigurationEvent