{-# 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.ECS.Types.ServiceEvent
-- 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.ECS.Types.ServiceEvent where

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

-- | Details on an event associated with a service.
--
-- /See:/ 'newServiceEvent' smart constructor.
data ServiceEvent = ServiceEvent'
  { -- | The Unix timestamp for when the event was triggered.
    ServiceEvent -> Maybe POSIX
createdAt :: Prelude.Maybe Core.POSIX,
    -- | The ID string of the event.
    ServiceEvent -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The event message.
    ServiceEvent -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (ServiceEvent -> ServiceEvent -> Bool
(ServiceEvent -> ServiceEvent -> Bool)
-> (ServiceEvent -> ServiceEvent -> Bool) -> Eq ServiceEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServiceEvent -> ServiceEvent -> Bool
$c/= :: ServiceEvent -> ServiceEvent -> Bool
== :: ServiceEvent -> ServiceEvent -> Bool
$c== :: ServiceEvent -> ServiceEvent -> Bool
Prelude.Eq, ReadPrec [ServiceEvent]
ReadPrec ServiceEvent
Int -> ReadS ServiceEvent
ReadS [ServiceEvent]
(Int -> ReadS ServiceEvent)
-> ReadS [ServiceEvent]
-> ReadPrec ServiceEvent
-> ReadPrec [ServiceEvent]
-> Read ServiceEvent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServiceEvent]
$creadListPrec :: ReadPrec [ServiceEvent]
readPrec :: ReadPrec ServiceEvent
$creadPrec :: ReadPrec ServiceEvent
readList :: ReadS [ServiceEvent]
$creadList :: ReadS [ServiceEvent]
readsPrec :: Int -> ReadS ServiceEvent
$creadsPrec :: Int -> ReadS ServiceEvent
Prelude.Read, Int -> ServiceEvent -> ShowS
[ServiceEvent] -> ShowS
ServiceEvent -> String
(Int -> ServiceEvent -> ShowS)
-> (ServiceEvent -> String)
-> ([ServiceEvent] -> ShowS)
-> Show ServiceEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServiceEvent] -> ShowS
$cshowList :: [ServiceEvent] -> ShowS
show :: ServiceEvent -> String
$cshow :: ServiceEvent -> String
showsPrec :: Int -> ServiceEvent -> ShowS
$cshowsPrec :: Int -> ServiceEvent -> ShowS
Prelude.Show, (forall x. ServiceEvent -> Rep ServiceEvent x)
-> (forall x. Rep ServiceEvent x -> ServiceEvent)
-> Generic ServiceEvent
forall x. Rep ServiceEvent x -> ServiceEvent
forall x. ServiceEvent -> Rep ServiceEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ServiceEvent x -> ServiceEvent
$cfrom :: forall x. ServiceEvent -> Rep ServiceEvent x
Prelude.Generic)

-- |
-- Create a value of 'ServiceEvent' 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', 'serviceEvent_createdAt' - The Unix timestamp for when the event was triggered.
--
-- 'id', 'serviceEvent_id' - The ID string of the event.
--
-- 'message', 'serviceEvent_message' - The event message.
newServiceEvent ::
  ServiceEvent
newServiceEvent :: ServiceEvent
newServiceEvent =
  ServiceEvent' :: Maybe POSIX -> Maybe Text -> Maybe Text -> ServiceEvent
ServiceEvent'
    { $sel:createdAt:ServiceEvent' :: Maybe POSIX
createdAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:id:ServiceEvent' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:message:ServiceEvent' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Unix timestamp for when the event was triggered.
serviceEvent_createdAt :: Lens.Lens' ServiceEvent (Prelude.Maybe Prelude.UTCTime)
serviceEvent_createdAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ServiceEvent -> f ServiceEvent
serviceEvent_createdAt = (ServiceEvent -> Maybe POSIX)
-> (ServiceEvent -> Maybe POSIX -> ServiceEvent)
-> Lens ServiceEvent ServiceEvent (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceEvent' {Maybe POSIX
createdAt :: Maybe POSIX
$sel:createdAt:ServiceEvent' :: ServiceEvent -> Maybe POSIX
createdAt} -> Maybe POSIX
createdAt) (\s :: ServiceEvent
s@ServiceEvent' {} Maybe POSIX
a -> ServiceEvent
s {$sel:createdAt:ServiceEvent' :: Maybe POSIX
createdAt = Maybe POSIX
a} :: ServiceEvent) ((Maybe POSIX -> f (Maybe POSIX))
 -> ServiceEvent -> f ServiceEvent)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ServiceEvent
-> f ServiceEvent
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 ID string of the event.
serviceEvent_id :: Lens.Lens' ServiceEvent (Prelude.Maybe Prelude.Text)
serviceEvent_id :: (Maybe Text -> f (Maybe Text)) -> ServiceEvent -> f ServiceEvent
serviceEvent_id = (ServiceEvent -> Maybe Text)
-> (ServiceEvent -> Maybe Text -> ServiceEvent)
-> Lens ServiceEvent ServiceEvent (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceEvent' {Maybe Text
id :: Maybe Text
$sel:id:ServiceEvent' :: ServiceEvent -> Maybe Text
id} -> Maybe Text
id) (\s :: ServiceEvent
s@ServiceEvent' {} Maybe Text
a -> ServiceEvent
s {$sel:id:ServiceEvent' :: Maybe Text
id = Maybe Text
a} :: ServiceEvent)

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

instance Core.FromJSON ServiceEvent where
  parseJSON :: Value -> Parser ServiceEvent
parseJSON =
    String
-> (Object -> Parser ServiceEvent) -> Value -> Parser ServiceEvent
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ServiceEvent"
      ( \Object
x ->
          Maybe POSIX -> Maybe Text -> Maybe Text -> ServiceEvent
ServiceEvent'
            (Maybe POSIX -> Maybe Text -> Maybe Text -> ServiceEvent)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> Maybe Text -> ServiceEvent)
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 -> ServiceEvent)
-> Parser (Maybe Text) -> Parser (Maybe Text -> ServiceEvent)
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
"id")
            Parser (Maybe Text -> ServiceEvent)
-> Parser (Maybe Text) -> Parser ServiceEvent
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 ServiceEvent

instance Prelude.NFData ServiceEvent