{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DevOpsGuru.Types.Event where

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

-- | An Amazon Web Services resource event. Amazon Web Services 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'
  { -- | The source, @AWS_CLOUD_TRAIL@ or @AWS_CODE_DEPLOY@, where DevOps Guru
    -- analysis found the event.
    Event -> Maybe EventDataSource
dataSource :: Prelude.Maybe EventDataSource,
    -- | 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,
    -- | The Amazon Web Services source that emitted the event.
    Event -> Maybe Text
eventSource :: Prelude.Maybe Prelude.Text,
    -- | The ID of the event.
    Event -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The name of the event.
    Event -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    Event -> Maybe ResourceCollection
resourceCollection :: Prelude.Maybe ResourceCollection,
    -- | An @EventResource@ object that contains information about the resource
    -- that emitted the event.
    Event -> Maybe [EventResource]
resources :: Prelude.Maybe [EventResource],
    -- | A @Timestamp@ that specifies the time the event occurred.
    Event -> Maybe POSIX
time :: Prelude.Maybe Data.POSIX
  }
  deriving (Event -> Event -> Bool
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]
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
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. 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:
--
-- 'dataSource', 'event_dataSource' - The source, @AWS_CLOUD_TRAIL@ or @AWS_CODE_DEPLOY@, where DevOps Guru
-- analysis found the event.
--
-- '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.
--
-- 'eventSource', 'event_eventSource' - The Amazon Web Services source that emitted the event.
--
-- 'id', 'event_id' - The ID of the event.
--
-- 'name', 'event_name' - The name of the event.
--
-- 'resourceCollection', 'event_resourceCollection' - Undocumented member.
--
-- 'resources', 'event_resources' - An @EventResource@ object that contains information about the resource
-- that emitted the event.
--
-- 'time', 'event_time' - A @Timestamp@ that specifies the time the event occurred.
newEvent ::
  Event
newEvent :: Event
newEvent =
  Event'
    { $sel:dataSource:Event' :: Maybe EventDataSource
dataSource = forall a. Maybe a
Prelude.Nothing,
      $sel:eventClass:Event' :: Maybe EventClass
eventClass = forall a. Maybe a
Prelude.Nothing,
      $sel:eventSource:Event' :: Maybe Text
eventSource = forall a. Maybe a
Prelude.Nothing,
      $sel:id:Event' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Event' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceCollection:Event' :: Maybe ResourceCollection
resourceCollection = forall a. Maybe a
Prelude.Nothing,
      $sel:resources:Event' :: Maybe [EventResource]
resources = forall a. Maybe a
Prelude.Nothing,
      $sel:time:Event' :: Maybe POSIX
time = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' Event (Maybe EventDataSource)
event_dataSource = 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 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 :: Lens' Event (Maybe EventClass)
event_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)

-- | The Amazon Web Services source that emitted the event.
event_eventSource :: Lens.Lens' Event (Prelude.Maybe Prelude.Text)
event_eventSource :: Lens' Event (Maybe Text)
event_eventSource = 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)

-- | The ID of the event.
event_id :: Lens.Lens' Event (Prelude.Maybe Prelude.Text)
event_id :: Lens' Event (Maybe Text)
event_id = 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 name of the event.
event_name :: Lens.Lens' Event (Prelude.Maybe Prelude.Text)
event_name :: Lens' Event (Maybe Text)
event_name = 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)

-- | Undocumented member.
event_resourceCollection :: Lens.Lens' Event (Prelude.Maybe ResourceCollection)
event_resourceCollection :: Lens' Event (Maybe ResourceCollection)
event_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)

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

-- | A @Timestamp@ that specifies the time the event occurred.
event_time :: Lens.Lens' Event (Prelude.Maybe Prelude.UTCTime)
event_time :: Lens' Event (Maybe UTCTime)
event_time = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

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

instance Prelude.Hashable Event where
  hashWithSalt :: Int -> Event -> Int
hashWithSalt Int
_salt Event' {Maybe [EventResource]
Maybe Text
Maybe POSIX
Maybe EventClass
Maybe EventDataSource
Maybe ResourceCollection
time :: Maybe POSIX
resources :: Maybe [EventResource]
resourceCollection :: Maybe ResourceCollection
name :: Maybe Text
id :: Maybe Text
eventSource :: Maybe Text
eventClass :: Maybe EventClass
dataSource :: Maybe EventDataSource
$sel:time:Event' :: Event -> Maybe POSIX
$sel:resources:Event' :: Event -> Maybe [EventResource]
$sel:resourceCollection:Event' :: Event -> Maybe ResourceCollection
$sel:name:Event' :: Event -> Maybe Text
$sel:id:Event' :: Event -> Maybe Text
$sel:eventSource:Event' :: Event -> Maybe Text
$sel:eventClass:Event' :: Event -> Maybe EventClass
$sel:dataSource:Event' :: Event -> Maybe EventDataSource
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EventDataSource
dataSource
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EventClass
eventClass
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
eventSource
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResourceCollection
resourceCollection
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [EventResource]
resources
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
time

instance Prelude.NFData Event where
  rnf :: Event -> ()
rnf Event' {Maybe [EventResource]
Maybe Text
Maybe POSIX
Maybe EventClass
Maybe EventDataSource
Maybe ResourceCollection
time :: Maybe POSIX
resources :: Maybe [EventResource]
resourceCollection :: Maybe ResourceCollection
name :: Maybe Text
id :: Maybe Text
eventSource :: Maybe Text
eventClass :: Maybe EventClass
dataSource :: Maybe EventDataSource
$sel:time:Event' :: Event -> Maybe POSIX
$sel:resources:Event' :: Event -> Maybe [EventResource]
$sel:resourceCollection:Event' :: Event -> Maybe ResourceCollection
$sel:name:Event' :: Event -> Maybe Text
$sel:id:Event' :: Event -> Maybe Text
$sel:eventSource:Event' :: Event -> Maybe Text
$sel:eventClass:Event' :: Event -> Maybe EventClass
$sel:dataSource:Event' :: Event -> Maybe EventDataSource
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe EventDataSource
dataSource
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EventClass
eventClass
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
eventSource
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ResourceCollection
resourceCollection
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [EventResource]
resources
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
time