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

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

-- | This data type is used as a response element in the @DescribeEvents@
-- action.
--
-- /See:/ 'newEvent' smart constructor.
data Event = Event'
  { -- | Specifies the source type for this event.
    Event -> Maybe SourceType
sourceType :: Prelude.Maybe SourceType,
    -- | The Amazon Resource Name (ARN) for the event.
    Event -> Maybe Text
sourceArn :: Prelude.Maybe Prelude.Text,
    -- | Provides the identifier for the source of the event.
    Event -> Maybe Text
sourceIdentifier :: Prelude.Maybe Prelude.Text,
    -- | Specifies the date and time of the event.
    Event -> Maybe ISO8601
date :: Prelude.Maybe Core.ISO8601,
    -- | Specifies the category for the event.
    Event -> Maybe [Text]
eventCategories :: Prelude.Maybe [Prelude.Text],
    -- | Provides the text of this 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 source type for this event.
--
-- 'sourceArn', 'event_sourceArn' - The Amazon Resource Name (ARN) for the event.
--
-- 'sourceIdentifier', 'event_sourceIdentifier' - Provides the identifier for the source of the event.
--
-- 'date', 'event_date' - Specifies the date and time of the event.
--
-- 'eventCategories', 'event_eventCategories' - Specifies the category for the event.
--
-- 'message', 'event_message' - Provides the text of this event.
newEvent ::
  Event
newEvent :: Event
newEvent =
  Event' :: Maybe SourceType
-> Maybe Text
-> Maybe Text
-> Maybe ISO8601
-> Maybe [Text]
-> Maybe Text
-> Event
Event'
    { $sel:sourceType:Event' :: Maybe SourceType
sourceType = Maybe SourceType
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceArn:Event' :: Maybe Text
sourceArn = Maybe Text
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:eventCategories:Event' :: Maybe [Text]
eventCategories = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:message:Event' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the source type for this event.
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 Amazon Resource Name (ARN) for the event.
event_sourceArn :: Lens.Lens' Event (Prelude.Maybe Prelude.Text)
event_sourceArn :: (Maybe Text -> f (Maybe Text)) -> Event -> f Event
event_sourceArn = (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
sourceArn :: Maybe Text
$sel:sourceArn:Event' :: Event -> Maybe Text
sourceArn} -> Maybe Text
sourceArn) (\s :: Event
s@Event' {} Maybe Text
a -> Event
s {$sel:sourceArn:Event' :: Maybe Text
sourceArn = Maybe Text
a} :: Event)

-- | Provides the identifier for the source of the event.
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)

-- | Specifies the date and time of the event.
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

-- | Specifies the category for the event.
event_eventCategories :: Lens.Lens' Event (Prelude.Maybe [Prelude.Text])
event_eventCategories :: (Maybe [Text] -> f (Maybe [Text])) -> Event -> f Event
event_eventCategories = (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]
eventCategories :: Maybe [Text]
$sel:eventCategories:Event' :: Event -> Maybe [Text]
eventCategories} -> Maybe [Text]
eventCategories) (\s :: Event
s@Event' {} Maybe [Text]
a -> Event
s {$sel:eventCategories:Event' :: Maybe [Text]
eventCategories = Maybe [Text]
a} :: Event) ((Maybe [Text] -> f (Maybe [Text])) -> Event -> f Event)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Event
-> f Event
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Provides the text of this 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 Text
-> Maybe ISO8601
-> Maybe [Text]
-> Maybe Text
-> Event
Event'
      (Maybe SourceType
 -> Maybe Text
 -> Maybe Text
 -> Maybe ISO8601
 -> Maybe [Text]
 -> Maybe Text
 -> Event)
-> Either String (Maybe SourceType)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe ISO8601
      -> Maybe [Text]
      -> 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 Text
   -> Maybe ISO8601
   -> Maybe [Text]
   -> Maybe Text
   -> Event)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe ISO8601 -> Maybe [Text] -> 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
"SourceArn")
      Either
  String
  (Maybe Text
   -> Maybe ISO8601 -> Maybe [Text] -> Maybe Text -> Event)
-> Either String (Maybe Text)
-> Either
     String (Maybe ISO8601 -> Maybe [Text] -> 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] -> Maybe Text -> Event)
-> Either String (Maybe ISO8601)
-> Either String (Maybe [Text] -> 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] -> Maybe Text -> Event)
-> Either String (Maybe [Text])
-> 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 [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"EventCategories" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [Text]))
-> Either String (Maybe [Text])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Text])
-> [Node] -> Either String (Maybe [Text])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Text]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"EventCategory")
                  )
      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