{-# 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.CodeDeploy.Types.LifecycleEvent
-- 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.CodeDeploy.Types.LifecycleEvent where

import Amazonka.CodeDeploy.Types.Diagnostics
import Amazonka.CodeDeploy.Types.LifecycleEventStatus
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about a deployment lifecycle event.
--
-- /See:/ 'newLifecycleEvent' smart constructor.
data LifecycleEvent = LifecycleEvent'
  { -- | The deployment lifecycle event status:
    --
    -- -   Pending: The deployment lifecycle event is pending.
    --
    -- -   InProgress: The deployment lifecycle event is in progress.
    --
    -- -   Succeeded: The deployment lifecycle event ran successfully.
    --
    -- -   Failed: The deployment lifecycle event has failed.
    --
    -- -   Skipped: The deployment lifecycle event has been skipped.
    --
    -- -   Unknown: The deployment lifecycle event is unknown.
    LifecycleEvent -> Maybe LifecycleEventStatus
status :: Prelude.Maybe LifecycleEventStatus,
    -- | The deployment lifecycle event name, such as @ApplicationStop@,
    -- @BeforeInstall@, @AfterInstall@, @ApplicationStart@, or
    -- @ValidateService@.
    LifecycleEvent -> Maybe Text
lifecycleEventName :: Prelude.Maybe Prelude.Text,
    -- | A timestamp that indicates when the deployment lifecycle event started.
    LifecycleEvent -> Maybe POSIX
startTime :: Prelude.Maybe Core.POSIX,
    -- | Diagnostic information about the deployment lifecycle event.
    LifecycleEvent -> Maybe Diagnostics
diagnostics :: Prelude.Maybe Diagnostics,
    -- | A timestamp that indicates when the deployment lifecycle event ended.
    LifecycleEvent -> Maybe POSIX
endTime :: Prelude.Maybe Core.POSIX
  }
  deriving (LifecycleEvent -> LifecycleEvent -> Bool
(LifecycleEvent -> LifecycleEvent -> Bool)
-> (LifecycleEvent -> LifecycleEvent -> Bool) -> Eq LifecycleEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LifecycleEvent -> LifecycleEvent -> Bool
$c/= :: LifecycleEvent -> LifecycleEvent -> Bool
== :: LifecycleEvent -> LifecycleEvent -> Bool
$c== :: LifecycleEvent -> LifecycleEvent -> Bool
Prelude.Eq, ReadPrec [LifecycleEvent]
ReadPrec LifecycleEvent
Int -> ReadS LifecycleEvent
ReadS [LifecycleEvent]
(Int -> ReadS LifecycleEvent)
-> ReadS [LifecycleEvent]
-> ReadPrec LifecycleEvent
-> ReadPrec [LifecycleEvent]
-> Read LifecycleEvent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LifecycleEvent]
$creadListPrec :: ReadPrec [LifecycleEvent]
readPrec :: ReadPrec LifecycleEvent
$creadPrec :: ReadPrec LifecycleEvent
readList :: ReadS [LifecycleEvent]
$creadList :: ReadS [LifecycleEvent]
readsPrec :: Int -> ReadS LifecycleEvent
$creadsPrec :: Int -> ReadS LifecycleEvent
Prelude.Read, Int -> LifecycleEvent -> ShowS
[LifecycleEvent] -> ShowS
LifecycleEvent -> String
(Int -> LifecycleEvent -> ShowS)
-> (LifecycleEvent -> String)
-> ([LifecycleEvent] -> ShowS)
-> Show LifecycleEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LifecycleEvent] -> ShowS
$cshowList :: [LifecycleEvent] -> ShowS
show :: LifecycleEvent -> String
$cshow :: LifecycleEvent -> String
showsPrec :: Int -> LifecycleEvent -> ShowS
$cshowsPrec :: Int -> LifecycleEvent -> ShowS
Prelude.Show, (forall x. LifecycleEvent -> Rep LifecycleEvent x)
-> (forall x. Rep LifecycleEvent x -> LifecycleEvent)
-> Generic LifecycleEvent
forall x. Rep LifecycleEvent x -> LifecycleEvent
forall x. LifecycleEvent -> Rep LifecycleEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LifecycleEvent x -> LifecycleEvent
$cfrom :: forall x. LifecycleEvent -> Rep LifecycleEvent x
Prelude.Generic)

-- |
-- Create a value of 'LifecycleEvent' 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:
--
-- 'status', 'lifecycleEvent_status' - The deployment lifecycle event status:
--
-- -   Pending: The deployment lifecycle event is pending.
--
-- -   InProgress: The deployment lifecycle event is in progress.
--
-- -   Succeeded: The deployment lifecycle event ran successfully.
--
-- -   Failed: The deployment lifecycle event has failed.
--
-- -   Skipped: The deployment lifecycle event has been skipped.
--
-- -   Unknown: The deployment lifecycle event is unknown.
--
-- 'lifecycleEventName', 'lifecycleEvent_lifecycleEventName' - The deployment lifecycle event name, such as @ApplicationStop@,
-- @BeforeInstall@, @AfterInstall@, @ApplicationStart@, or
-- @ValidateService@.
--
-- 'startTime', 'lifecycleEvent_startTime' - A timestamp that indicates when the deployment lifecycle event started.
--
-- 'diagnostics', 'lifecycleEvent_diagnostics' - Diagnostic information about the deployment lifecycle event.
--
-- 'endTime', 'lifecycleEvent_endTime' - A timestamp that indicates when the deployment lifecycle event ended.
newLifecycleEvent ::
  LifecycleEvent
newLifecycleEvent :: LifecycleEvent
newLifecycleEvent =
  LifecycleEvent' :: Maybe LifecycleEventStatus
-> Maybe Text
-> Maybe POSIX
-> Maybe Diagnostics
-> Maybe POSIX
-> LifecycleEvent
LifecycleEvent'
    { $sel:status:LifecycleEvent' :: Maybe LifecycleEventStatus
status = Maybe LifecycleEventStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:lifecycleEventName:LifecycleEvent' :: Maybe Text
lifecycleEventName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:LifecycleEvent' :: Maybe POSIX
startTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:diagnostics:LifecycleEvent' :: Maybe Diagnostics
diagnostics = Maybe Diagnostics
forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:LifecycleEvent' :: Maybe POSIX
endTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The deployment lifecycle event status:
--
-- -   Pending: The deployment lifecycle event is pending.
--
-- -   InProgress: The deployment lifecycle event is in progress.
--
-- -   Succeeded: The deployment lifecycle event ran successfully.
--
-- -   Failed: The deployment lifecycle event has failed.
--
-- -   Skipped: The deployment lifecycle event has been skipped.
--
-- -   Unknown: The deployment lifecycle event is unknown.
lifecycleEvent_status :: Lens.Lens' LifecycleEvent (Prelude.Maybe LifecycleEventStatus)
lifecycleEvent_status :: (Maybe LifecycleEventStatus -> f (Maybe LifecycleEventStatus))
-> LifecycleEvent -> f LifecycleEvent
lifecycleEvent_status = (LifecycleEvent -> Maybe LifecycleEventStatus)
-> (LifecycleEvent -> Maybe LifecycleEventStatus -> LifecycleEvent)
-> Lens
     LifecycleEvent
     LifecycleEvent
     (Maybe LifecycleEventStatus)
     (Maybe LifecycleEventStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LifecycleEvent' {Maybe LifecycleEventStatus
status :: Maybe LifecycleEventStatus
$sel:status:LifecycleEvent' :: LifecycleEvent -> Maybe LifecycleEventStatus
status} -> Maybe LifecycleEventStatus
status) (\s :: LifecycleEvent
s@LifecycleEvent' {} Maybe LifecycleEventStatus
a -> LifecycleEvent
s {$sel:status:LifecycleEvent' :: Maybe LifecycleEventStatus
status = Maybe LifecycleEventStatus
a} :: LifecycleEvent)

-- | The deployment lifecycle event name, such as @ApplicationStop@,
-- @BeforeInstall@, @AfterInstall@, @ApplicationStart@, or
-- @ValidateService@.
lifecycleEvent_lifecycleEventName :: Lens.Lens' LifecycleEvent (Prelude.Maybe Prelude.Text)
lifecycleEvent_lifecycleEventName :: (Maybe Text -> f (Maybe Text))
-> LifecycleEvent -> f LifecycleEvent
lifecycleEvent_lifecycleEventName = (LifecycleEvent -> Maybe Text)
-> (LifecycleEvent -> Maybe Text -> LifecycleEvent)
-> Lens LifecycleEvent LifecycleEvent (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LifecycleEvent' {Maybe Text
lifecycleEventName :: Maybe Text
$sel:lifecycleEventName:LifecycleEvent' :: LifecycleEvent -> Maybe Text
lifecycleEventName} -> Maybe Text
lifecycleEventName) (\s :: LifecycleEvent
s@LifecycleEvent' {} Maybe Text
a -> LifecycleEvent
s {$sel:lifecycleEventName:LifecycleEvent' :: Maybe Text
lifecycleEventName = Maybe Text
a} :: LifecycleEvent)

-- | A timestamp that indicates when the deployment lifecycle event started.
lifecycleEvent_startTime :: Lens.Lens' LifecycleEvent (Prelude.Maybe Prelude.UTCTime)
lifecycleEvent_startTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> LifecycleEvent -> f LifecycleEvent
lifecycleEvent_startTime = (LifecycleEvent -> Maybe POSIX)
-> (LifecycleEvent -> Maybe POSIX -> LifecycleEvent)
-> Lens LifecycleEvent LifecycleEvent (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LifecycleEvent' {Maybe POSIX
startTime :: Maybe POSIX
$sel:startTime:LifecycleEvent' :: LifecycleEvent -> Maybe POSIX
startTime} -> Maybe POSIX
startTime) (\s :: LifecycleEvent
s@LifecycleEvent' {} Maybe POSIX
a -> LifecycleEvent
s {$sel:startTime:LifecycleEvent' :: Maybe POSIX
startTime = Maybe POSIX
a} :: LifecycleEvent) ((Maybe POSIX -> f (Maybe POSIX))
 -> LifecycleEvent -> f LifecycleEvent)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> LifecycleEvent
-> f LifecycleEvent
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

-- | Diagnostic information about the deployment lifecycle event.
lifecycleEvent_diagnostics :: Lens.Lens' LifecycleEvent (Prelude.Maybe Diagnostics)
lifecycleEvent_diagnostics :: (Maybe Diagnostics -> f (Maybe Diagnostics))
-> LifecycleEvent -> f LifecycleEvent
lifecycleEvent_diagnostics = (LifecycleEvent -> Maybe Diagnostics)
-> (LifecycleEvent -> Maybe Diagnostics -> LifecycleEvent)
-> Lens
     LifecycleEvent
     LifecycleEvent
     (Maybe Diagnostics)
     (Maybe Diagnostics)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LifecycleEvent' {Maybe Diagnostics
diagnostics :: Maybe Diagnostics
$sel:diagnostics:LifecycleEvent' :: LifecycleEvent -> Maybe Diagnostics
diagnostics} -> Maybe Diagnostics
diagnostics) (\s :: LifecycleEvent
s@LifecycleEvent' {} Maybe Diagnostics
a -> LifecycleEvent
s {$sel:diagnostics:LifecycleEvent' :: Maybe Diagnostics
diagnostics = Maybe Diagnostics
a} :: LifecycleEvent)

-- | A timestamp that indicates when the deployment lifecycle event ended.
lifecycleEvent_endTime :: Lens.Lens' LifecycleEvent (Prelude.Maybe Prelude.UTCTime)
lifecycleEvent_endTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> LifecycleEvent -> f LifecycleEvent
lifecycleEvent_endTime = (LifecycleEvent -> Maybe POSIX)
-> (LifecycleEvent -> Maybe POSIX -> LifecycleEvent)
-> Lens LifecycleEvent LifecycleEvent (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LifecycleEvent' {Maybe POSIX
endTime :: Maybe POSIX
$sel:endTime:LifecycleEvent' :: LifecycleEvent -> Maybe POSIX
endTime} -> Maybe POSIX
endTime) (\s :: LifecycleEvent
s@LifecycleEvent' {} Maybe POSIX
a -> LifecycleEvent
s {$sel:endTime:LifecycleEvent' :: Maybe POSIX
endTime = Maybe POSIX
a} :: LifecycleEvent) ((Maybe POSIX -> f (Maybe POSIX))
 -> LifecycleEvent -> f LifecycleEvent)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> LifecycleEvent
-> f LifecycleEvent
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

instance Core.FromJSON LifecycleEvent where
  parseJSON :: Value -> Parser LifecycleEvent
parseJSON =
    String
-> (Object -> Parser LifecycleEvent)
-> Value
-> Parser LifecycleEvent
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LifecycleEvent"
      ( \Object
x ->
          Maybe LifecycleEventStatus
-> Maybe Text
-> Maybe POSIX
-> Maybe Diagnostics
-> Maybe POSIX
-> LifecycleEvent
LifecycleEvent'
            (Maybe LifecycleEventStatus
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Diagnostics
 -> Maybe POSIX
 -> LifecycleEvent)
-> Parser (Maybe LifecycleEventStatus)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe Diagnostics
      -> Maybe POSIX
      -> LifecycleEvent)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe LifecycleEventStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"status")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe Diagnostics
   -> Maybe POSIX
   -> LifecycleEvent)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX -> Maybe Diagnostics -> Maybe POSIX -> LifecycleEvent)
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
"lifecycleEventName")
            Parser
  (Maybe POSIX -> Maybe Diagnostics -> Maybe POSIX -> LifecycleEvent)
-> Parser (Maybe POSIX)
-> Parser (Maybe Diagnostics -> Maybe POSIX -> LifecycleEvent)
forall (f :: * -> *) a b. Applicative f => 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
"startTime")
            Parser (Maybe Diagnostics -> Maybe POSIX -> LifecycleEvent)
-> Parser (Maybe Diagnostics)
-> Parser (Maybe POSIX -> LifecycleEvent)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Diagnostics)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"diagnostics")
            Parser (Maybe POSIX -> LifecycleEvent)
-> Parser (Maybe POSIX) -> Parser LifecycleEvent
forall (f :: * -> *) a b. Applicative f => 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
"endTime")
      )

instance Prelude.Hashable LifecycleEvent

instance Prelude.NFData LifecycleEvent