{-# 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.DevOpsGuru.Types.Event
-- 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.DevOpsGuru.Types.Event where

import qualified Amazonka.Core as Core
import Amazonka.DevOpsGuru.Types.EventClass
import Amazonka.DevOpsGuru.Types.EventDataSource
import Amazonka.DevOpsGuru.Types.EventResource
import Amazonka.DevOpsGuru.Types.ResourceCollection
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An AWS resource event. AWS resource events and metrics are analyzed by
-- DevOps Guru to find anomalous behavior and provide recommendations to
-- improve your operational solutions.
--
-- /See:/ 'newEvent' smart constructor.
data Event = Event'
  { Event -> Maybe ResourceCollection
resourceCollection :: Prelude.Maybe ResourceCollection,
    -- | The class of the event. The class specifies what the event is related
    -- to, such as an infrastructure change, a deployment, or a schema change.
    Event -> Maybe EventClass
eventClass :: Prelude.Maybe EventClass,
    -- | A @Timestamp@ that specifies the time the event occurred.
    Event -> Maybe POSIX
time :: Prelude.Maybe Core.POSIX,
    -- | An @EventResource@ object that contains information about the resource
    -- that emitted the event.
    Event -> Maybe [EventResource]
resources :: Prelude.Maybe [EventResource],
    -- | The name of the event.
    Event -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The ID of the event.
    Event -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The source, @AWS_CLOUD_TRAIL@ or @AWS_CODE_DEPLOY@, where DevOps Guru
    -- analysis found the event.
    Event -> Maybe EventDataSource
dataSource :: Prelude.Maybe EventDataSource,
    -- | The AWS source that emitted the event.
    Event -> Maybe Text
eventSource :: Prelude.Maybe Prelude.Text
  }
  deriving (Event -> Event -> Bool
(Event -> Event -> Bool) -> (Event -> Event -> Bool) -> Eq Event
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Event -> Event -> Bool
$c/= :: Event -> Event -> Bool
== :: Event -> Event -> Bool
$c== :: Event -> Event -> Bool
Prelude.Eq, ReadPrec [Event]
ReadPrec Event
Int -> ReadS Event
ReadS [Event]
(Int -> ReadS Event)
-> ReadS [Event]
-> ReadPrec Event
-> ReadPrec [Event]
-> Read Event
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Event]
$creadListPrec :: ReadPrec [Event]
readPrec :: ReadPrec Event
$creadPrec :: ReadPrec Event
readList :: ReadS [Event]
$creadList :: ReadS [Event]
readsPrec :: Int -> ReadS Event
$creadsPrec :: Int -> ReadS Event
Prelude.Read, Int -> Event -> ShowS
[Event] -> ShowS
Event -> String
(Int -> Event -> ShowS)
-> (Event -> String) -> ([Event] -> ShowS) -> Show Event
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Event] -> ShowS
$cshowList :: [Event] -> ShowS
show :: Event -> String
$cshow :: Event -> String
showsPrec :: Int -> Event -> ShowS
$cshowsPrec :: Int -> Event -> ShowS
Prelude.Show, (forall x. Event -> Rep Event x)
-> (forall x. Rep Event x -> Event) -> Generic Event
forall x. Rep Event x -> Event
forall x. Event -> Rep Event x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Event x -> Event
$cfrom :: forall x. Event -> Rep Event x
Prelude.Generic)

-- |
-- Create a value of 'Event' 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:
--
-- 'resourceCollection', 'event_resourceCollection' - Undocumented member.
--
-- 'eventClass', 'event_eventClass' - The class of the event. The class specifies what the event is related
-- to, such as an infrastructure change, a deployment, or a schema change.
--
-- 'time', 'event_time' - A @Timestamp@ that specifies the time the event occurred.
--
-- 'resources', 'event_resources' - An @EventResource@ object that contains information about the resource
-- that emitted the event.
--
-- 'name', 'event_name' - The name of the event.
--
-- 'id', 'event_id' - The ID of the event.
--
-- 'dataSource', 'event_dataSource' - The source, @AWS_CLOUD_TRAIL@ or @AWS_CODE_DEPLOY@, where DevOps Guru
-- analysis found the event.
--
-- 'eventSource', 'event_eventSource' - The AWS source that emitted the event.
newEvent ::
  Event
newEvent :: Event
newEvent =
  Event' :: Maybe ResourceCollection
-> Maybe EventClass
-> Maybe POSIX
-> Maybe [EventResource]
-> Maybe Text
-> Maybe Text
-> Maybe EventDataSource
-> Maybe Text
-> Event
Event'
    { $sel:resourceCollection:Event' :: Maybe ResourceCollection
resourceCollection = Maybe ResourceCollection
forall a. Maybe a
Prelude.Nothing,
      $sel:eventClass:Event' :: Maybe EventClass
eventClass = Maybe EventClass
forall a. Maybe a
Prelude.Nothing,
      $sel:time:Event' :: Maybe POSIX
time = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:resources:Event' :: Maybe [EventResource]
resources = Maybe [EventResource]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Event' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Event' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:dataSource:Event' :: Maybe EventDataSource
dataSource = Maybe EventDataSource
forall a. Maybe a
Prelude.Nothing,
      $sel:eventSource:Event' :: Maybe Text
eventSource = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
event_resourceCollection :: Lens.Lens' Event (Prelude.Maybe ResourceCollection)
event_resourceCollection :: (Maybe ResourceCollection -> f (Maybe ResourceCollection))
-> Event -> f Event
event_resourceCollection = (Event -> Maybe ResourceCollection)
-> (Event -> Maybe ResourceCollection -> Event)
-> Lens
     Event Event (Maybe ResourceCollection) (Maybe ResourceCollection)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe ResourceCollection
resourceCollection :: Maybe ResourceCollection
$sel:resourceCollection:Event' :: Event -> Maybe ResourceCollection
resourceCollection} -> Maybe ResourceCollection
resourceCollection) (\s :: Event
s@Event' {} Maybe ResourceCollection
a -> Event
s {$sel:resourceCollection:Event' :: Maybe ResourceCollection
resourceCollection = Maybe ResourceCollection
a} :: Event)

-- | The class of the event. The class specifies what the event is related
-- to, such as an infrastructure change, a deployment, or a schema change.
event_eventClass :: Lens.Lens' Event (Prelude.Maybe EventClass)
event_eventClass :: (Maybe EventClass -> f (Maybe EventClass)) -> Event -> f Event
event_eventClass = (Event -> Maybe EventClass)
-> (Event -> Maybe EventClass -> Event)
-> Lens Event Event (Maybe EventClass) (Maybe EventClass)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe EventClass
eventClass :: Maybe EventClass
$sel:eventClass:Event' :: Event -> Maybe EventClass
eventClass} -> Maybe EventClass
eventClass) (\s :: Event
s@Event' {} Maybe EventClass
a -> Event
s {$sel:eventClass:Event' :: Maybe EventClass
eventClass = Maybe EventClass
a} :: Event)

-- | A @Timestamp@ that specifies the time the event occurred.
event_time :: Lens.Lens' Event (Prelude.Maybe Prelude.UTCTime)
event_time :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Event -> f Event
event_time = (Event -> Maybe POSIX)
-> (Event -> Maybe POSIX -> Event)
-> Lens Event Event (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe POSIX
time :: Maybe POSIX
$sel:time:Event' :: Event -> Maybe POSIX
time} -> Maybe POSIX
time) (\s :: Event
s@Event' {} Maybe POSIX
a -> Event
s {$sel:time:Event' :: Maybe POSIX
time = Maybe POSIX
a} :: Event) ((Maybe POSIX -> f (Maybe POSIX)) -> Event -> f Event)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Event
-> f Event
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

-- | An @EventResource@ object that contains information about the resource
-- that emitted the event.
event_resources :: Lens.Lens' Event (Prelude.Maybe [EventResource])
event_resources :: (Maybe [EventResource] -> f (Maybe [EventResource]))
-> Event -> f Event
event_resources = (Event -> Maybe [EventResource])
-> (Event -> Maybe [EventResource] -> Event)
-> Lens Event Event (Maybe [EventResource]) (Maybe [EventResource])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe [EventResource]
resources :: Maybe [EventResource]
$sel:resources:Event' :: Event -> Maybe [EventResource]
resources} -> Maybe [EventResource]
resources) (\s :: Event
s@Event' {} Maybe [EventResource]
a -> Event
s {$sel:resources:Event' :: Maybe [EventResource]
resources = Maybe [EventResource]
a} :: Event) ((Maybe [EventResource] -> f (Maybe [EventResource]))
 -> Event -> f Event)
-> ((Maybe [EventResource] -> f (Maybe [EventResource]))
    -> Maybe [EventResource] -> f (Maybe [EventResource]))
-> (Maybe [EventResource] -> f (Maybe [EventResource]))
-> Event
-> f Event
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [EventResource] [EventResource] [EventResource] [EventResource]
-> Iso
     (Maybe [EventResource])
     (Maybe [EventResource])
     (Maybe [EventResource])
     (Maybe [EventResource])
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
  [EventResource] [EventResource] [EventResource] [EventResource]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the event.
event_name :: Lens.Lens' Event (Prelude.Maybe Prelude.Text)
event_name :: (Maybe Text -> f (Maybe Text)) -> Event -> f Event
event_name = (Event -> Maybe Text)
-> (Event -> Maybe Text -> Event)
-> Lens Event Event (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe Text
name :: Maybe Text
$sel:name:Event' :: Event -> Maybe Text
name} -> Maybe Text
name) (\s :: Event
s@Event' {} Maybe Text
a -> Event
s {$sel:name:Event' :: Maybe Text
name = Maybe Text
a} :: Event)

-- | The ID of the event.
event_id :: Lens.Lens' Event (Prelude.Maybe Prelude.Text)
event_id :: (Maybe Text -> f (Maybe Text)) -> Event -> f Event
event_id = (Event -> Maybe Text)
-> (Event -> Maybe Text -> Event)
-> Lens Event Event (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe Text
id :: Maybe Text
$sel:id:Event' :: Event -> Maybe Text
id} -> Maybe Text
id) (\s :: Event
s@Event' {} Maybe Text
a -> Event
s {$sel:id:Event' :: Maybe Text
id = Maybe Text
a} :: Event)

-- | The source, @AWS_CLOUD_TRAIL@ or @AWS_CODE_DEPLOY@, where DevOps Guru
-- analysis found the event.
event_dataSource :: Lens.Lens' Event (Prelude.Maybe EventDataSource)
event_dataSource :: (Maybe EventDataSource -> f (Maybe EventDataSource))
-> Event -> f Event
event_dataSource = (Event -> Maybe EventDataSource)
-> (Event -> Maybe EventDataSource -> Event)
-> Lens Event Event (Maybe EventDataSource) (Maybe EventDataSource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe EventDataSource
dataSource :: Maybe EventDataSource
$sel:dataSource:Event' :: Event -> Maybe EventDataSource
dataSource} -> Maybe EventDataSource
dataSource) (\s :: Event
s@Event' {} Maybe EventDataSource
a -> Event
s {$sel:dataSource:Event' :: Maybe EventDataSource
dataSource = Maybe EventDataSource
a} :: Event)

-- | The AWS source that emitted the event.
event_eventSource :: Lens.Lens' Event (Prelude.Maybe Prelude.Text)
event_eventSource :: (Maybe Text -> f (Maybe Text)) -> Event -> f Event
event_eventSource = (Event -> Maybe Text)
-> (Event -> Maybe Text -> Event)
-> Lens Event Event (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe Text
eventSource :: Maybe Text
$sel:eventSource:Event' :: Event -> Maybe Text
eventSource} -> Maybe Text
eventSource) (\s :: Event
s@Event' {} Maybe Text
a -> Event
s {$sel:eventSource:Event' :: Maybe Text
eventSource = Maybe Text
a} :: Event)

instance Core.FromJSON Event where
  parseJSON :: Value -> Parser Event
parseJSON =
    String -> (Object -> Parser Event) -> Value -> Parser Event
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Event"
      ( \Object
x ->
          Maybe ResourceCollection
-> Maybe EventClass
-> Maybe POSIX
-> Maybe [EventResource]
-> Maybe Text
-> Maybe Text
-> Maybe EventDataSource
-> Maybe Text
-> Event
Event'
            (Maybe ResourceCollection
 -> Maybe EventClass
 -> Maybe POSIX
 -> Maybe [EventResource]
 -> Maybe Text
 -> Maybe Text
 -> Maybe EventDataSource
 -> Maybe Text
 -> Event)
-> Parser (Maybe ResourceCollection)
-> Parser
     (Maybe EventClass
      -> Maybe POSIX
      -> Maybe [EventResource]
      -> Maybe Text
      -> Maybe Text
      -> Maybe EventDataSource
      -> Maybe Text
      -> Event)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ResourceCollection)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResourceCollection")
            Parser
  (Maybe EventClass
   -> Maybe POSIX
   -> Maybe [EventResource]
   -> Maybe Text
   -> Maybe Text
   -> Maybe EventDataSource
   -> Maybe Text
   -> Event)
-> Parser (Maybe EventClass)
-> Parser
     (Maybe POSIX
      -> Maybe [EventResource]
      -> Maybe Text
      -> Maybe Text
      -> Maybe EventDataSource
      -> Maybe Text
      -> Event)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EventClass)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EventClass")
            Parser
  (Maybe POSIX
   -> Maybe [EventResource]
   -> Maybe Text
   -> Maybe Text
   -> Maybe EventDataSource
   -> Maybe Text
   -> Event)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe [EventResource]
      -> Maybe Text
      -> Maybe Text
      -> Maybe EventDataSource
      -> Maybe Text
      -> Event)
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
"Time")
            Parser
  (Maybe [EventResource]
   -> Maybe Text
   -> Maybe Text
   -> Maybe EventDataSource
   -> Maybe Text
   -> Event)
-> Parser (Maybe [EventResource])
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe EventDataSource -> Maybe Text -> Event)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [EventResource]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Resources" Parser (Maybe (Maybe [EventResource]))
-> Maybe [EventResource] -> Parser (Maybe [EventResource])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [EventResource]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe EventDataSource -> Maybe Text -> Event)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe EventDataSource -> Maybe Text -> Event)
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
"Name")
            Parser (Maybe Text -> Maybe EventDataSource -> Maybe Text -> Event)
-> Parser (Maybe Text)
-> Parser (Maybe EventDataSource -> Maybe Text -> Event)
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
"Id")
            Parser (Maybe EventDataSource -> Maybe Text -> Event)
-> Parser (Maybe EventDataSource) -> Parser (Maybe Text -> Event)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EventDataSource)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DataSource")
            Parser (Maybe Text -> Event) -> Parser (Maybe Text) -> Parser Event
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
"EventSource")
      )

instance Prelude.Hashable Event

instance Prelude.NFData Event