{-# 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.AWSHealth.Types.EventDetails
-- 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.AWSHealth.Types.EventDetails where

import Amazonka.AWSHealth.Types.Event
import Amazonka.AWSHealth.Types.EventDescription
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Detailed information about an event. A combination of an
-- <https://docs.aws.amazon.com/health/latest/APIReference/API_Event.html Event>
-- object, an
-- <https://docs.aws.amazon.com/health/latest/APIReference/API_EventDescription.html EventDescription>
-- object, and additional metadata about the event. Returned by the
-- <https://docs.aws.amazon.com/health/latest/APIReference/API_DescribeEventDetails.html DescribeEventDetails>
-- operation.
--
-- /See:/ 'newEventDetails' smart constructor.
data EventDetails = EventDetails'
  { -- | Summary information about the event.
    EventDetails -> Maybe Event
event :: Prelude.Maybe Event,
    -- | The most recent description of the event.
    EventDetails -> Maybe EventDescription
eventDescription :: Prelude.Maybe EventDescription,
    -- | Additional metadata about the event.
    EventDetails -> Maybe (HashMap Text Text)
eventMetadata :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (EventDetails -> EventDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventDetails -> EventDetails -> Bool
$c/= :: EventDetails -> EventDetails -> Bool
== :: EventDetails -> EventDetails -> Bool
$c== :: EventDetails -> EventDetails -> Bool
Prelude.Eq, ReadPrec [EventDetails]
ReadPrec EventDetails
Int -> ReadS EventDetails
ReadS [EventDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventDetails]
$creadListPrec :: ReadPrec [EventDetails]
readPrec :: ReadPrec EventDetails
$creadPrec :: ReadPrec EventDetails
readList :: ReadS [EventDetails]
$creadList :: ReadS [EventDetails]
readsPrec :: Int -> ReadS EventDetails
$creadsPrec :: Int -> ReadS EventDetails
Prelude.Read, Int -> EventDetails -> ShowS
[EventDetails] -> ShowS
EventDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventDetails] -> ShowS
$cshowList :: [EventDetails] -> ShowS
show :: EventDetails -> String
$cshow :: EventDetails -> String
showsPrec :: Int -> EventDetails -> ShowS
$cshowsPrec :: Int -> EventDetails -> ShowS
Prelude.Show, forall x. Rep EventDetails x -> EventDetails
forall x. EventDetails -> Rep EventDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventDetails x -> EventDetails
$cfrom :: forall x. EventDetails -> Rep EventDetails x
Prelude.Generic)

-- |
-- Create a value of 'EventDetails' 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:
--
-- 'event', 'eventDetails_event' - Summary information about the event.
--
-- 'eventDescription', 'eventDetails_eventDescription' - The most recent description of the event.
--
-- 'eventMetadata', 'eventDetails_eventMetadata' - Additional metadata about the event.
newEventDetails ::
  EventDetails
newEventDetails :: EventDetails
newEventDetails =
  EventDetails'
    { $sel:event:EventDetails' :: Maybe Event
event = forall a. Maybe a
Prelude.Nothing,
      $sel:eventDescription:EventDetails' :: Maybe EventDescription
eventDescription = forall a. Maybe a
Prelude.Nothing,
      $sel:eventMetadata:EventDetails' :: Maybe (HashMap Text Text)
eventMetadata = forall a. Maybe a
Prelude.Nothing
    }

-- | Summary information about the event.
eventDetails_event :: Lens.Lens' EventDetails (Prelude.Maybe Event)
eventDetails_event :: Lens' EventDetails (Maybe Event)
eventDetails_event = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventDetails' {Maybe Event
event :: Maybe Event
$sel:event:EventDetails' :: EventDetails -> Maybe Event
event} -> Maybe Event
event) (\s :: EventDetails
s@EventDetails' {} Maybe Event
a -> EventDetails
s {$sel:event:EventDetails' :: Maybe Event
event = Maybe Event
a} :: EventDetails)

-- | The most recent description of the event.
eventDetails_eventDescription :: Lens.Lens' EventDetails (Prelude.Maybe EventDescription)
eventDetails_eventDescription :: Lens' EventDetails (Maybe EventDescription)
eventDetails_eventDescription = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventDetails' {Maybe EventDescription
eventDescription :: Maybe EventDescription
$sel:eventDescription:EventDetails' :: EventDetails -> Maybe EventDescription
eventDescription} -> Maybe EventDescription
eventDescription) (\s :: EventDetails
s@EventDetails' {} Maybe EventDescription
a -> EventDetails
s {$sel:eventDescription:EventDetails' :: Maybe EventDescription
eventDescription = Maybe EventDescription
a} :: EventDetails)

-- | Additional metadata about the event.
eventDetails_eventMetadata :: Lens.Lens' EventDetails (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
eventDetails_eventMetadata :: Lens' EventDetails (Maybe (HashMap Text Text))
eventDetails_eventMetadata = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventDetails' {Maybe (HashMap Text Text)
eventMetadata :: Maybe (HashMap Text Text)
$sel:eventMetadata:EventDetails' :: EventDetails -> Maybe (HashMap Text Text)
eventMetadata} -> Maybe (HashMap Text Text)
eventMetadata) (\s :: EventDetails
s@EventDetails' {} Maybe (HashMap Text Text)
a -> EventDetails
s {$sel:eventMetadata:EventDetails' :: Maybe (HashMap Text Text)
eventMetadata = Maybe (HashMap Text Text)
a} :: EventDetails) 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

instance Data.FromJSON EventDetails where
  parseJSON :: Value -> Parser EventDetails
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EventDetails"
      ( \Object
x ->
          Maybe Event
-> Maybe EventDescription
-> Maybe (HashMap Text Text)
-> EventDetails
EventDetails'
            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
"event")
            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
"eventDescription")
            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
"eventMetadata" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable EventDetails where
  hashWithSalt :: Int -> EventDetails -> Int
hashWithSalt Int
_salt EventDetails' {Maybe (HashMap Text Text)
Maybe EventDescription
Maybe Event
eventMetadata :: Maybe (HashMap Text Text)
eventDescription :: Maybe EventDescription
event :: Maybe Event
$sel:eventMetadata:EventDetails' :: EventDetails -> Maybe (HashMap Text Text)
$sel:eventDescription:EventDetails' :: EventDetails -> Maybe EventDescription
$sel:event:EventDetails' :: EventDetails -> Maybe Event
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Event
event
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EventDescription
eventDescription
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
eventMetadata

instance Prelude.NFData EventDetails where
  rnf :: EventDetails -> ()
rnf EventDetails' {Maybe (HashMap Text Text)
Maybe EventDescription
Maybe Event
eventMetadata :: Maybe (HashMap Text Text)
eventDescription :: Maybe EventDescription
event :: Maybe Event
$sel:eventMetadata:EventDetails' :: EventDetails -> Maybe (HashMap Text Text)
$sel:eventDescription:EventDetails' :: EventDetails -> Maybe EventDescription
$sel:event:EventDetails' :: EventDetails -> Maybe Event
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Event
event
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EventDescription
eventDescription
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
eventMetadata