{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ECS.Types.ServiceEvent where

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

-- | The details for an event that\'s associated with a service.
--
-- /See:/ 'newServiceEvent' smart constructor.
data ServiceEvent = ServiceEvent'
  { -- | The Unix timestamp for the time when the event was triggered.
    ServiceEvent -> Maybe POSIX
createdAt :: Prelude.Maybe Data.POSIX,
    -- | The ID string for 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
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]
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
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. 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 the time when the event was triggered.
--
-- 'id', 'serviceEvent_id' - The ID string for the event.
--
-- 'message', 'serviceEvent_message' - The event message.
newServiceEvent ::
  ServiceEvent
newServiceEvent :: ServiceEvent
newServiceEvent =
  ServiceEvent'
    { $sel:createdAt:ServiceEvent' :: Maybe POSIX
createdAt = forall a. Maybe a
Prelude.Nothing,
      $sel:id:ServiceEvent' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:message:ServiceEvent' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing
    }

-- | The Unix timestamp for the time when the event was triggered.
serviceEvent_createdAt :: Lens.Lens' ServiceEvent (Prelude.Maybe Prelude.UTCTime)
serviceEvent_createdAt :: Lens' ServiceEvent (Maybe UTCTime)
serviceEvent_createdAt = 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) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The ID string for the event.
serviceEvent_id :: Lens.Lens' ServiceEvent (Prelude.Maybe Prelude.Text)
serviceEvent_id :: Lens' ServiceEvent (Maybe Text)
serviceEvent_id = 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 :: Lens' ServiceEvent (Maybe Text)
serviceEvent_message = 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 Data.FromJSON ServiceEvent where
  parseJSON :: Value -> Parser ServiceEvent
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ServiceEvent"
      ( \Object
x ->
          Maybe POSIX -> Maybe Text -> Maybe Text -> ServiceEvent
ServiceEvent'
            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
"createdAt")
            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
"id")
            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
"message")
      )

instance Prelude.Hashable ServiceEvent where
  hashWithSalt :: Int -> ServiceEvent -> Int
hashWithSalt Int
_salt ServiceEvent' {Maybe Text
Maybe POSIX
message :: Maybe Text
id :: Maybe Text
createdAt :: Maybe POSIX
$sel:message:ServiceEvent' :: ServiceEvent -> Maybe Text
$sel:id:ServiceEvent' :: ServiceEvent -> Maybe Text
$sel:createdAt:ServiceEvent' :: ServiceEvent -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
createdAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message

instance Prelude.NFData ServiceEvent where
  rnf :: ServiceEvent -> ()
rnf ServiceEvent' {Maybe Text
Maybe POSIX
message :: Maybe Text
id :: Maybe Text
createdAt :: Maybe POSIX
$sel:message:ServiceEvent' :: ServiceEvent -> Maybe Text
$sel:id:ServiceEvent' :: ServiceEvent -> Maybe Text
$sel:createdAt:ServiceEvent' :: ServiceEvent -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
createdAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message