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

import qualified Amazonka.Core as Core
import Amazonka.ElastiCache.Types.SourceType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents a single occurrence of something interesting within the
-- system. Some examples of events are creating a cluster, adding or
-- removing a cache node, or rebooting a node.
--
-- /See:/ 'newEvent' smart constructor.
data Event = Event'
  { -- | Specifies the origin of this event - a cluster, a parameter group, a
    -- security group, etc.
    Event -> Maybe SourceType
sourceType :: Prelude.Maybe SourceType,
    -- | The identifier for the source of the event. For example, if the event
    -- occurred at the cluster level, the identifier would be the name of the
    -- cluster.
    Event -> Maybe Text
sourceIdentifier :: Prelude.Maybe Prelude.Text,
    -- | The date and time when the event occurred.
    Event -> Maybe ISO8601
date :: Prelude.Maybe Core.ISO8601,
    -- | The text of the event.
    Event -> Maybe Text
message :: 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:
--
-- 'sourceType', 'event_sourceType' - Specifies the origin of this event - a cluster, a parameter group, a
-- security group, etc.
--
-- 'sourceIdentifier', 'event_sourceIdentifier' - The identifier for the source of the event. For example, if the event
-- occurred at the cluster level, the identifier would be the name of the
-- cluster.
--
-- 'date', 'event_date' - The date and time when the event occurred.
--
-- 'message', 'event_message' - The text of the event.
newEvent ::
  Event
newEvent :: Event
newEvent =
  Event' :: Maybe SourceType
-> Maybe Text -> Maybe ISO8601 -> Maybe Text -> Event
Event'
    { $sel:sourceType:Event' :: Maybe SourceType
sourceType = Maybe SourceType
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceIdentifier:Event' :: Maybe Text
sourceIdentifier = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:date:Event' :: Maybe ISO8601
date = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing,
      $sel:message:Event' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the origin of this event - a cluster, a parameter group, a
-- security group, etc.
event_sourceType :: Lens.Lens' Event (Prelude.Maybe SourceType)
event_sourceType :: (Maybe SourceType -> f (Maybe SourceType)) -> Event -> f Event
event_sourceType = (Event -> Maybe SourceType)
-> (Event -> Maybe SourceType -> Event)
-> Lens Event Event (Maybe SourceType) (Maybe SourceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe SourceType
sourceType :: Maybe SourceType
$sel:sourceType:Event' :: Event -> Maybe SourceType
sourceType} -> Maybe SourceType
sourceType) (\s :: Event
s@Event' {} Maybe SourceType
a -> Event
s {$sel:sourceType:Event' :: Maybe SourceType
sourceType = Maybe SourceType
a} :: Event)

-- | The identifier for the source of the event. For example, if the event
-- occurred at the cluster level, the identifier would be the name of the
-- cluster.
event_sourceIdentifier :: Lens.Lens' Event (Prelude.Maybe Prelude.Text)
event_sourceIdentifier :: (Maybe Text -> f (Maybe Text)) -> Event -> f Event
event_sourceIdentifier = (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
sourceIdentifier :: Maybe Text
$sel:sourceIdentifier:Event' :: Event -> Maybe Text
sourceIdentifier} -> Maybe Text
sourceIdentifier) (\s :: Event
s@Event' {} Maybe Text
a -> Event
s {$sel:sourceIdentifier:Event' :: Maybe Text
sourceIdentifier = Maybe Text
a} :: Event)

-- | The date and time when the event occurred.
event_date :: Lens.Lens' Event (Prelude.Maybe Prelude.UTCTime)
event_date :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Event -> f Event
event_date = (Event -> Maybe ISO8601)
-> (Event -> Maybe ISO8601 -> Event)
-> Lens Event Event (Maybe ISO8601) (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Event' {Maybe ISO8601
date :: Maybe ISO8601
$sel:date:Event' :: Event -> Maybe ISO8601
date} -> Maybe ISO8601
date) (\s :: Event
s@Event' {} Maybe ISO8601
a -> Event
s {$sel:date:Event' :: Maybe ISO8601
date = Maybe ISO8601
a} :: Event) ((Maybe ISO8601 -> f (Maybe ISO8601)) -> Event -> f Event)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Event
-> f Event
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (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 ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The text of the event.
event_message :: Lens.Lens' Event (Prelude.Maybe Prelude.Text)
event_message :: (Maybe Text -> f (Maybe Text)) -> Event -> f Event
event_message = (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
message :: Maybe Text
$sel:message:Event' :: Event -> Maybe Text
message} -> Maybe Text
message) (\s :: Event
s@Event' {} Maybe Text
a -> Event
s {$sel:message:Event' :: Maybe Text
message = Maybe Text
a} :: Event)

instance Core.FromXML Event where
  parseXML :: [Node] -> Either String Event
parseXML [Node]
x =
    Maybe SourceType
-> Maybe Text -> Maybe ISO8601 -> Maybe Text -> Event
Event'
      (Maybe SourceType
 -> Maybe Text -> Maybe ISO8601 -> Maybe Text -> Event)
-> Either String (Maybe SourceType)
-> Either
     String (Maybe Text -> Maybe ISO8601 -> Maybe Text -> Event)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe SourceType)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SourceType")
      Either String (Maybe Text -> Maybe ISO8601 -> Maybe Text -> Event)
-> Either String (Maybe Text)
-> Either String (Maybe ISO8601 -> Maybe Text -> Event)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SourceIdentifier")
      Either String (Maybe ISO8601 -> Maybe Text -> Event)
-> Either String (Maybe ISO8601)
-> Either String (Maybe Text -> Event)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ISO8601)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Date")
      Either String (Maybe Text -> Event)
-> Either String (Maybe Text) -> Either String Event
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Message")

instance Prelude.Hashable Event

instance Prelude.NFData Event