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

import Amazonka.AWSHealth.Types.Event
import Amazonka.AWSHealth.Types.EventDescription
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(EventDetails -> EventDetails -> Bool)
-> (EventDetails -> EventDetails -> Bool) -> Eq EventDetails
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]
(Int -> ReadS EventDetails)
-> ReadS [EventDetails]
-> ReadPrec EventDetails
-> ReadPrec [EventDetails]
-> Read 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
(Int -> EventDetails -> ShowS)
-> (EventDetails -> String)
-> ([EventDetails] -> ShowS)
-> Show EventDetails
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. EventDetails -> Rep EventDetails x)
-> (forall x. Rep EventDetails x -> EventDetails)
-> Generic EventDetails
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' :: Maybe Event
-> Maybe EventDescription
-> Maybe (HashMap Text Text)
-> EventDetails
EventDetails'
    { $sel:event:EventDetails' :: Maybe Event
event = Maybe Event
forall a. Maybe a
Prelude.Nothing,
      $sel:eventDescription:EventDetails' :: Maybe EventDescription
eventDescription = Maybe EventDescription
forall a. Maybe a
Prelude.Nothing,
      $sel:eventMetadata:EventDetails' :: Maybe (HashMap Text Text)
eventMetadata = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | Summary information about the event.
eventDetails_event :: Lens.Lens' EventDetails (Prelude.Maybe Event)
eventDetails_event :: (Maybe Event -> f (Maybe Event)) -> EventDetails -> f EventDetails
eventDetails_event = (EventDetails -> Maybe Event)
-> (EventDetails -> Maybe Event -> EventDetails)
-> Lens EventDetails EventDetails (Maybe Event) (Maybe 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 :: (Maybe EventDescription -> f (Maybe EventDescription))
-> EventDetails -> f EventDetails
eventDetails_eventDescription = (EventDetails -> Maybe EventDescription)
-> (EventDetails -> Maybe EventDescription -> EventDetails)
-> Lens
     EventDetails
     EventDetails
     (Maybe EventDescription)
     (Maybe 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 :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> EventDetails -> f EventDetails
eventDetails_eventMetadata = (EventDetails -> Maybe (HashMap Text Text))
-> (EventDetails -> Maybe (HashMap Text Text) -> EventDetails)
-> Lens
     EventDetails
     EventDetails
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> EventDetails -> f EventDetails)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> EventDetails
-> f EventDetails
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON EventDetails where
  parseJSON :: Value -> Parser EventDetails
parseJSON =
    String
-> (Object -> Parser EventDetails) -> Value -> Parser EventDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EventDetails"
      ( \Object
x ->
          Maybe Event
-> Maybe EventDescription
-> Maybe (HashMap Text Text)
-> EventDetails
EventDetails'
            (Maybe Event
 -> Maybe EventDescription
 -> Maybe (HashMap Text Text)
 -> EventDetails)
-> Parser (Maybe Event)
-> Parser
     (Maybe EventDescription
      -> Maybe (HashMap Text Text) -> EventDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Event)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"event")
            Parser
  (Maybe EventDescription
   -> Maybe (HashMap Text Text) -> EventDetails)
-> Parser (Maybe EventDescription)
-> Parser (Maybe (HashMap Text Text) -> EventDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EventDescription)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"eventDescription")
            Parser (Maybe (HashMap Text Text) -> EventDetails)
-> Parser (Maybe (HashMap Text Text)) -> Parser EventDetails
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"eventMetadata" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable EventDetails

instance Prelude.NFData EventDetails