{-# 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.AppConfig.Types.DeploymentEvent
-- 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.AppConfig.Types.DeploymentEvent where

import Amazonka.AppConfig.Types.DeploymentEventType
import Amazonka.AppConfig.Types.TriggeredBy
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that describes a deployment event.
--
-- /See:/ 'newDeploymentEvent' smart constructor.
data DeploymentEvent = DeploymentEvent'
  { -- | The entity that triggered the deployment event. Events can be triggered
    -- by a user, AWS AppConfig, an Amazon CloudWatch alarm, or an internal
    -- error.
    DeploymentEvent -> Maybe TriggeredBy
triggeredBy :: Prelude.Maybe TriggeredBy,
    -- | The date and time the event occurred.
    DeploymentEvent -> Maybe POSIX
occurredAt :: Prelude.Maybe Core.POSIX,
    -- | The type of deployment event. Deployment event types include the start,
    -- stop, or completion of a deployment; a percentage update; the start or
    -- stop of a bake period; the start or completion of a rollback.
    DeploymentEvent -> Maybe DeploymentEventType
eventType :: Prelude.Maybe DeploymentEventType,
    -- | A description of the deployment event. Descriptions include, but are not
    -- limited to, the user account or the CloudWatch alarm ARN that initiated
    -- a rollback, the percentage of hosts that received the deployment, or in
    -- the case of an internal error, a recommendation to attempt a new
    -- deployment.
    DeploymentEvent -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (DeploymentEvent -> DeploymentEvent -> Bool
(DeploymentEvent -> DeploymentEvent -> Bool)
-> (DeploymentEvent -> DeploymentEvent -> Bool)
-> Eq DeploymentEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeploymentEvent -> DeploymentEvent -> Bool
$c/= :: DeploymentEvent -> DeploymentEvent -> Bool
== :: DeploymentEvent -> DeploymentEvent -> Bool
$c== :: DeploymentEvent -> DeploymentEvent -> Bool
Prelude.Eq, ReadPrec [DeploymentEvent]
ReadPrec DeploymentEvent
Int -> ReadS DeploymentEvent
ReadS [DeploymentEvent]
(Int -> ReadS DeploymentEvent)
-> ReadS [DeploymentEvent]
-> ReadPrec DeploymentEvent
-> ReadPrec [DeploymentEvent]
-> Read DeploymentEvent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeploymentEvent]
$creadListPrec :: ReadPrec [DeploymentEvent]
readPrec :: ReadPrec DeploymentEvent
$creadPrec :: ReadPrec DeploymentEvent
readList :: ReadS [DeploymentEvent]
$creadList :: ReadS [DeploymentEvent]
readsPrec :: Int -> ReadS DeploymentEvent
$creadsPrec :: Int -> ReadS DeploymentEvent
Prelude.Read, Int -> DeploymentEvent -> ShowS
[DeploymentEvent] -> ShowS
DeploymentEvent -> String
(Int -> DeploymentEvent -> ShowS)
-> (DeploymentEvent -> String)
-> ([DeploymentEvent] -> ShowS)
-> Show DeploymentEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeploymentEvent] -> ShowS
$cshowList :: [DeploymentEvent] -> ShowS
show :: DeploymentEvent -> String
$cshow :: DeploymentEvent -> String
showsPrec :: Int -> DeploymentEvent -> ShowS
$cshowsPrec :: Int -> DeploymentEvent -> ShowS
Prelude.Show, (forall x. DeploymentEvent -> Rep DeploymentEvent x)
-> (forall x. Rep DeploymentEvent x -> DeploymentEvent)
-> Generic DeploymentEvent
forall x. Rep DeploymentEvent x -> DeploymentEvent
forall x. DeploymentEvent -> Rep DeploymentEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeploymentEvent x -> DeploymentEvent
$cfrom :: forall x. DeploymentEvent -> Rep DeploymentEvent x
Prelude.Generic)

-- |
-- Create a value of 'DeploymentEvent' 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:
--
-- 'triggeredBy', 'deploymentEvent_triggeredBy' - The entity that triggered the deployment event. Events can be triggered
-- by a user, AWS AppConfig, an Amazon CloudWatch alarm, or an internal
-- error.
--
-- 'occurredAt', 'deploymentEvent_occurredAt' - The date and time the event occurred.
--
-- 'eventType', 'deploymentEvent_eventType' - The type of deployment event. Deployment event types include the start,
-- stop, or completion of a deployment; a percentage update; the start or
-- stop of a bake period; the start or completion of a rollback.
--
-- 'description', 'deploymentEvent_description' - A description of the deployment event. Descriptions include, but are not
-- limited to, the user account or the CloudWatch alarm ARN that initiated
-- a rollback, the percentage of hosts that received the deployment, or in
-- the case of an internal error, a recommendation to attempt a new
-- deployment.
newDeploymentEvent ::
  DeploymentEvent
newDeploymentEvent :: DeploymentEvent
newDeploymentEvent =
  DeploymentEvent' :: Maybe TriggeredBy
-> Maybe POSIX
-> Maybe DeploymentEventType
-> Maybe Text
-> DeploymentEvent
DeploymentEvent'
    { $sel:triggeredBy:DeploymentEvent' :: Maybe TriggeredBy
triggeredBy = Maybe TriggeredBy
forall a. Maybe a
Prelude.Nothing,
      $sel:occurredAt:DeploymentEvent' :: Maybe POSIX
occurredAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:eventType:DeploymentEvent' :: Maybe DeploymentEventType
eventType = Maybe DeploymentEventType
forall a. Maybe a
Prelude.Nothing,
      $sel:description:DeploymentEvent' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The entity that triggered the deployment event. Events can be triggered
-- by a user, AWS AppConfig, an Amazon CloudWatch alarm, or an internal
-- error.
deploymentEvent_triggeredBy :: Lens.Lens' DeploymentEvent (Prelude.Maybe TriggeredBy)
deploymentEvent_triggeredBy :: (Maybe TriggeredBy -> f (Maybe TriggeredBy))
-> DeploymentEvent -> f DeploymentEvent
deploymentEvent_triggeredBy = (DeploymentEvent -> Maybe TriggeredBy)
-> (DeploymentEvent -> Maybe TriggeredBy -> DeploymentEvent)
-> Lens
     DeploymentEvent
     DeploymentEvent
     (Maybe TriggeredBy)
     (Maybe TriggeredBy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentEvent' {Maybe TriggeredBy
triggeredBy :: Maybe TriggeredBy
$sel:triggeredBy:DeploymentEvent' :: DeploymentEvent -> Maybe TriggeredBy
triggeredBy} -> Maybe TriggeredBy
triggeredBy) (\s :: DeploymentEvent
s@DeploymentEvent' {} Maybe TriggeredBy
a -> DeploymentEvent
s {$sel:triggeredBy:DeploymentEvent' :: Maybe TriggeredBy
triggeredBy = Maybe TriggeredBy
a} :: DeploymentEvent)

-- | The date and time the event occurred.
deploymentEvent_occurredAt :: Lens.Lens' DeploymentEvent (Prelude.Maybe Prelude.UTCTime)
deploymentEvent_occurredAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> DeploymentEvent -> f DeploymentEvent
deploymentEvent_occurredAt = (DeploymentEvent -> Maybe POSIX)
-> (DeploymentEvent -> Maybe POSIX -> DeploymentEvent)
-> Lens DeploymentEvent DeploymentEvent (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentEvent' {Maybe POSIX
occurredAt :: Maybe POSIX
$sel:occurredAt:DeploymentEvent' :: DeploymentEvent -> Maybe POSIX
occurredAt} -> Maybe POSIX
occurredAt) (\s :: DeploymentEvent
s@DeploymentEvent' {} Maybe POSIX
a -> DeploymentEvent
s {$sel:occurredAt:DeploymentEvent' :: Maybe POSIX
occurredAt = Maybe POSIX
a} :: DeploymentEvent) ((Maybe POSIX -> f (Maybe POSIX))
 -> DeploymentEvent -> f DeploymentEvent)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DeploymentEvent
-> f DeploymentEvent
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 type of deployment event. Deployment event types include the start,
-- stop, or completion of a deployment; a percentage update; the start or
-- stop of a bake period; the start or completion of a rollback.
deploymentEvent_eventType :: Lens.Lens' DeploymentEvent (Prelude.Maybe DeploymentEventType)
deploymentEvent_eventType :: (Maybe DeploymentEventType -> f (Maybe DeploymentEventType))
-> DeploymentEvent -> f DeploymentEvent
deploymentEvent_eventType = (DeploymentEvent -> Maybe DeploymentEventType)
-> (DeploymentEvent
    -> Maybe DeploymentEventType -> DeploymentEvent)
-> Lens
     DeploymentEvent
     DeploymentEvent
     (Maybe DeploymentEventType)
     (Maybe DeploymentEventType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentEvent' {Maybe DeploymentEventType
eventType :: Maybe DeploymentEventType
$sel:eventType:DeploymentEvent' :: DeploymentEvent -> Maybe DeploymentEventType
eventType} -> Maybe DeploymentEventType
eventType) (\s :: DeploymentEvent
s@DeploymentEvent' {} Maybe DeploymentEventType
a -> DeploymentEvent
s {$sel:eventType:DeploymentEvent' :: Maybe DeploymentEventType
eventType = Maybe DeploymentEventType
a} :: DeploymentEvent)

-- | A description of the deployment event. Descriptions include, but are not
-- limited to, the user account or the CloudWatch alarm ARN that initiated
-- a rollback, the percentage of hosts that received the deployment, or in
-- the case of an internal error, a recommendation to attempt a new
-- deployment.
deploymentEvent_description :: Lens.Lens' DeploymentEvent (Prelude.Maybe Prelude.Text)
deploymentEvent_description :: (Maybe Text -> f (Maybe Text))
-> DeploymentEvent -> f DeploymentEvent
deploymentEvent_description = (DeploymentEvent -> Maybe Text)
-> (DeploymentEvent -> Maybe Text -> DeploymentEvent)
-> Lens DeploymentEvent DeploymentEvent (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentEvent' {Maybe Text
description :: Maybe Text
$sel:description:DeploymentEvent' :: DeploymentEvent -> Maybe Text
description} -> Maybe Text
description) (\s :: DeploymentEvent
s@DeploymentEvent' {} Maybe Text
a -> DeploymentEvent
s {$sel:description:DeploymentEvent' :: Maybe Text
description = Maybe Text
a} :: DeploymentEvent)

instance Core.FromJSON DeploymentEvent where
  parseJSON :: Value -> Parser DeploymentEvent
parseJSON =
    String
-> (Object -> Parser DeploymentEvent)
-> Value
-> Parser DeploymentEvent
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DeploymentEvent"
      ( \Object
x ->
          Maybe TriggeredBy
-> Maybe POSIX
-> Maybe DeploymentEventType
-> Maybe Text
-> DeploymentEvent
DeploymentEvent'
            (Maybe TriggeredBy
 -> Maybe POSIX
 -> Maybe DeploymentEventType
 -> Maybe Text
 -> DeploymentEvent)
-> Parser (Maybe TriggeredBy)
-> Parser
     (Maybe POSIX
      -> Maybe DeploymentEventType -> Maybe Text -> DeploymentEvent)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe TriggeredBy)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TriggeredBy")
            Parser
  (Maybe POSIX
   -> Maybe DeploymentEventType -> Maybe Text -> DeploymentEvent)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe DeploymentEventType -> Maybe Text -> DeploymentEvent)
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
"OccurredAt")
            Parser (Maybe DeploymentEventType -> Maybe Text -> DeploymentEvent)
-> Parser (Maybe DeploymentEventType)
-> Parser (Maybe Text -> DeploymentEvent)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DeploymentEventType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EventType")
            Parser (Maybe Text -> DeploymentEvent)
-> Parser (Maybe Text) -> Parser DeploymentEvent
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
"Description")
      )

instance Prelude.Hashable DeploymentEvent

instance Prelude.NFData DeploymentEvent