{-# 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.Lightsail.Types.RelationalDatabaseEvent
-- 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.Lightsail.Types.RelationalDatabaseEvent where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes an event for a database.
--
-- /See:/ 'newRelationalDatabaseEvent' smart constructor.
data RelationalDatabaseEvent = RelationalDatabaseEvent'
  { -- | The timestamp when the database event was created.
    RelationalDatabaseEvent -> Maybe POSIX
createdAt :: Prelude.Maybe Core.POSIX,
    -- | The category that the database event belongs to.
    RelationalDatabaseEvent -> Maybe [Text]
eventCategories :: Prelude.Maybe [Prelude.Text],
    -- | The database that the database event relates to.
    RelationalDatabaseEvent -> Maybe Text
resource :: Prelude.Maybe Prelude.Text,
    -- | The message of the database event.
    RelationalDatabaseEvent -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (RelationalDatabaseEvent -> RelationalDatabaseEvent -> Bool
(RelationalDatabaseEvent -> RelationalDatabaseEvent -> Bool)
-> (RelationalDatabaseEvent -> RelationalDatabaseEvent -> Bool)
-> Eq RelationalDatabaseEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RelationalDatabaseEvent -> RelationalDatabaseEvent -> Bool
$c/= :: RelationalDatabaseEvent -> RelationalDatabaseEvent -> Bool
== :: RelationalDatabaseEvent -> RelationalDatabaseEvent -> Bool
$c== :: RelationalDatabaseEvent -> RelationalDatabaseEvent -> Bool
Prelude.Eq, ReadPrec [RelationalDatabaseEvent]
ReadPrec RelationalDatabaseEvent
Int -> ReadS RelationalDatabaseEvent
ReadS [RelationalDatabaseEvent]
(Int -> ReadS RelationalDatabaseEvent)
-> ReadS [RelationalDatabaseEvent]
-> ReadPrec RelationalDatabaseEvent
-> ReadPrec [RelationalDatabaseEvent]
-> Read RelationalDatabaseEvent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RelationalDatabaseEvent]
$creadListPrec :: ReadPrec [RelationalDatabaseEvent]
readPrec :: ReadPrec RelationalDatabaseEvent
$creadPrec :: ReadPrec RelationalDatabaseEvent
readList :: ReadS [RelationalDatabaseEvent]
$creadList :: ReadS [RelationalDatabaseEvent]
readsPrec :: Int -> ReadS RelationalDatabaseEvent
$creadsPrec :: Int -> ReadS RelationalDatabaseEvent
Prelude.Read, Int -> RelationalDatabaseEvent -> ShowS
[RelationalDatabaseEvent] -> ShowS
RelationalDatabaseEvent -> String
(Int -> RelationalDatabaseEvent -> ShowS)
-> (RelationalDatabaseEvent -> String)
-> ([RelationalDatabaseEvent] -> ShowS)
-> Show RelationalDatabaseEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RelationalDatabaseEvent] -> ShowS
$cshowList :: [RelationalDatabaseEvent] -> ShowS
show :: RelationalDatabaseEvent -> String
$cshow :: RelationalDatabaseEvent -> String
showsPrec :: Int -> RelationalDatabaseEvent -> ShowS
$cshowsPrec :: Int -> RelationalDatabaseEvent -> ShowS
Prelude.Show, (forall x.
 RelationalDatabaseEvent -> Rep RelationalDatabaseEvent x)
-> (forall x.
    Rep RelationalDatabaseEvent x -> RelationalDatabaseEvent)
-> Generic RelationalDatabaseEvent
forall x. Rep RelationalDatabaseEvent x -> RelationalDatabaseEvent
forall x. RelationalDatabaseEvent -> Rep RelationalDatabaseEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RelationalDatabaseEvent x -> RelationalDatabaseEvent
$cfrom :: forall x. RelationalDatabaseEvent -> Rep RelationalDatabaseEvent x
Prelude.Generic)

-- |
-- Create a value of 'RelationalDatabaseEvent' 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:
--
-- 'createdAt', 'relationalDatabaseEvent_createdAt' - The timestamp when the database event was created.
--
-- 'eventCategories', 'relationalDatabaseEvent_eventCategories' - The category that the database event belongs to.
--
-- 'resource', 'relationalDatabaseEvent_resource' - The database that the database event relates to.
--
-- 'message', 'relationalDatabaseEvent_message' - The message of the database event.
newRelationalDatabaseEvent ::
  RelationalDatabaseEvent
newRelationalDatabaseEvent :: RelationalDatabaseEvent
newRelationalDatabaseEvent =
  RelationalDatabaseEvent' :: Maybe POSIX
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> RelationalDatabaseEvent
RelationalDatabaseEvent'
    { $sel:createdAt:RelationalDatabaseEvent' :: Maybe POSIX
createdAt =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:eventCategories:RelationalDatabaseEvent' :: Maybe [Text]
eventCategories = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:resource:RelationalDatabaseEvent' :: Maybe Text
resource = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:message:RelationalDatabaseEvent' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The timestamp when the database event was created.
relationalDatabaseEvent_createdAt :: Lens.Lens' RelationalDatabaseEvent (Prelude.Maybe Prelude.UTCTime)
relationalDatabaseEvent_createdAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> RelationalDatabaseEvent -> f RelationalDatabaseEvent
relationalDatabaseEvent_createdAt = (RelationalDatabaseEvent -> Maybe POSIX)
-> (RelationalDatabaseEvent
    -> Maybe POSIX -> RelationalDatabaseEvent)
-> Lens
     RelationalDatabaseEvent
     RelationalDatabaseEvent
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelationalDatabaseEvent' {Maybe POSIX
createdAt :: Maybe POSIX
$sel:createdAt:RelationalDatabaseEvent' :: RelationalDatabaseEvent -> Maybe POSIX
createdAt} -> Maybe POSIX
createdAt) (\s :: RelationalDatabaseEvent
s@RelationalDatabaseEvent' {} Maybe POSIX
a -> RelationalDatabaseEvent
s {$sel:createdAt:RelationalDatabaseEvent' :: Maybe POSIX
createdAt = Maybe POSIX
a} :: RelationalDatabaseEvent) ((Maybe POSIX -> f (Maybe POSIX))
 -> RelationalDatabaseEvent -> f RelationalDatabaseEvent)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> RelationalDatabaseEvent
-> f RelationalDatabaseEvent
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 category that the database event belongs to.
relationalDatabaseEvent_eventCategories :: Lens.Lens' RelationalDatabaseEvent (Prelude.Maybe [Prelude.Text])
relationalDatabaseEvent_eventCategories :: (Maybe [Text] -> f (Maybe [Text]))
-> RelationalDatabaseEvent -> f RelationalDatabaseEvent
relationalDatabaseEvent_eventCategories = (RelationalDatabaseEvent -> Maybe [Text])
-> (RelationalDatabaseEvent
    -> Maybe [Text] -> RelationalDatabaseEvent)
-> Lens
     RelationalDatabaseEvent
     RelationalDatabaseEvent
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelationalDatabaseEvent' {Maybe [Text]
eventCategories :: Maybe [Text]
$sel:eventCategories:RelationalDatabaseEvent' :: RelationalDatabaseEvent -> Maybe [Text]
eventCategories} -> Maybe [Text]
eventCategories) (\s :: RelationalDatabaseEvent
s@RelationalDatabaseEvent' {} Maybe [Text]
a -> RelationalDatabaseEvent
s {$sel:eventCategories:RelationalDatabaseEvent' :: Maybe [Text]
eventCategories = Maybe [Text]
a} :: RelationalDatabaseEvent) ((Maybe [Text] -> f (Maybe [Text]))
 -> RelationalDatabaseEvent -> f RelationalDatabaseEvent)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> RelationalDatabaseEvent
-> f RelationalDatabaseEvent
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

-- | The database that the database event relates to.
relationalDatabaseEvent_resource :: Lens.Lens' RelationalDatabaseEvent (Prelude.Maybe Prelude.Text)
relationalDatabaseEvent_resource :: (Maybe Text -> f (Maybe Text))
-> RelationalDatabaseEvent -> f RelationalDatabaseEvent
relationalDatabaseEvent_resource = (RelationalDatabaseEvent -> Maybe Text)
-> (RelationalDatabaseEvent
    -> Maybe Text -> RelationalDatabaseEvent)
-> Lens
     RelationalDatabaseEvent
     RelationalDatabaseEvent
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelationalDatabaseEvent' {Maybe Text
resource :: Maybe Text
$sel:resource:RelationalDatabaseEvent' :: RelationalDatabaseEvent -> Maybe Text
resource} -> Maybe Text
resource) (\s :: RelationalDatabaseEvent
s@RelationalDatabaseEvent' {} Maybe Text
a -> RelationalDatabaseEvent
s {$sel:resource:RelationalDatabaseEvent' :: Maybe Text
resource = Maybe Text
a} :: RelationalDatabaseEvent)

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

instance Core.FromJSON RelationalDatabaseEvent where
  parseJSON :: Value -> Parser RelationalDatabaseEvent
parseJSON =
    String
-> (Object -> Parser RelationalDatabaseEvent)
-> Value
-> Parser RelationalDatabaseEvent
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RelationalDatabaseEvent"
      ( \Object
x ->
          Maybe POSIX
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> RelationalDatabaseEvent
RelationalDatabaseEvent'
            (Maybe POSIX
 -> Maybe [Text]
 -> Maybe Text
 -> Maybe Text
 -> RelationalDatabaseEvent)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe [Text]
      -> Maybe Text -> Maybe Text -> RelationalDatabaseEvent)
forall (f :: * -> *) a b. Functor 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
"createdAt")
            Parser
  (Maybe [Text]
   -> Maybe Text -> Maybe Text -> RelationalDatabaseEvent)
-> Parser (Maybe [Text])
-> Parser (Maybe Text -> Maybe Text -> RelationalDatabaseEvent)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"eventCategories"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Text -> Maybe Text -> RelationalDatabaseEvent)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> RelationalDatabaseEvent)
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
"resource")
            Parser (Maybe Text -> RelationalDatabaseEvent)
-> Parser (Maybe Text) -> Parser RelationalDatabaseEvent
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
"message")
      )

instance Prelude.Hashable RelationalDatabaseEvent

instance Prelude.NFData RelationalDatabaseEvent