{-# 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.LambdaTarget
-- 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.LambdaTarget where

import Amazonka.CodeDeploy.Types.LambdaFunctionInfo
import Amazonka.CodeDeploy.Types.LifecycleEvent
import Amazonka.CodeDeploy.Types.TargetStatus
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the target AWS Lambda function during an AWS Lambda
-- deployment.
--
-- /See:/ 'newLambdaTarget' smart constructor.
data LambdaTarget = LambdaTarget'
  { -- | The Amazon Resource Name (ARN) of the target.
    LambdaTarget -> Maybe Text
targetArn :: Prelude.Maybe Prelude.Text,
    -- | The unique ID of a deployment target that has a type of @lambdaTarget@.
    LambdaTarget -> Maybe Text
targetId :: Prelude.Maybe Prelude.Text,
    -- | The status an AWS Lambda deployment\'s target Lambda function.
    LambdaTarget -> Maybe TargetStatus
status :: Prelude.Maybe TargetStatus,
    -- | The unique ID of a deployment.
    LambdaTarget -> Maybe Text
deploymentId :: Prelude.Maybe Prelude.Text,
    -- | The date and time when the target Lambda function was updated by a
    -- deployment.
    LambdaTarget -> Maybe POSIX
lastUpdatedAt :: Prelude.Maybe Core.POSIX,
    -- | The lifecycle events of the deployment to this target Lambda function.
    LambdaTarget -> Maybe [LifecycleEvent]
lifecycleEvents :: Prelude.Maybe [LifecycleEvent],
    -- | A @LambdaFunctionInfo@ object that describes a target Lambda function.
    LambdaTarget -> Maybe LambdaFunctionInfo
lambdaFunctionInfo :: Prelude.Maybe LambdaFunctionInfo
  }
  deriving (LambdaTarget -> LambdaTarget -> Bool
(LambdaTarget -> LambdaTarget -> Bool)
-> (LambdaTarget -> LambdaTarget -> Bool) -> Eq LambdaTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LambdaTarget -> LambdaTarget -> Bool
$c/= :: LambdaTarget -> LambdaTarget -> Bool
== :: LambdaTarget -> LambdaTarget -> Bool
$c== :: LambdaTarget -> LambdaTarget -> Bool
Prelude.Eq, ReadPrec [LambdaTarget]
ReadPrec LambdaTarget
Int -> ReadS LambdaTarget
ReadS [LambdaTarget]
(Int -> ReadS LambdaTarget)
-> ReadS [LambdaTarget]
-> ReadPrec LambdaTarget
-> ReadPrec [LambdaTarget]
-> Read LambdaTarget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LambdaTarget]
$creadListPrec :: ReadPrec [LambdaTarget]
readPrec :: ReadPrec LambdaTarget
$creadPrec :: ReadPrec LambdaTarget
readList :: ReadS [LambdaTarget]
$creadList :: ReadS [LambdaTarget]
readsPrec :: Int -> ReadS LambdaTarget
$creadsPrec :: Int -> ReadS LambdaTarget
Prelude.Read, Int -> LambdaTarget -> ShowS
[LambdaTarget] -> ShowS
LambdaTarget -> String
(Int -> LambdaTarget -> ShowS)
-> (LambdaTarget -> String)
-> ([LambdaTarget] -> ShowS)
-> Show LambdaTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LambdaTarget] -> ShowS
$cshowList :: [LambdaTarget] -> ShowS
show :: LambdaTarget -> String
$cshow :: LambdaTarget -> String
showsPrec :: Int -> LambdaTarget -> ShowS
$cshowsPrec :: Int -> LambdaTarget -> ShowS
Prelude.Show, (forall x. LambdaTarget -> Rep LambdaTarget x)
-> (forall x. Rep LambdaTarget x -> LambdaTarget)
-> Generic LambdaTarget
forall x. Rep LambdaTarget x -> LambdaTarget
forall x. LambdaTarget -> Rep LambdaTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LambdaTarget x -> LambdaTarget
$cfrom :: forall x. LambdaTarget -> Rep LambdaTarget x
Prelude.Generic)

-- |
-- Create a value of 'LambdaTarget' 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:
--
-- 'targetArn', 'lambdaTarget_targetArn' - The Amazon Resource Name (ARN) of the target.
--
-- 'targetId', 'lambdaTarget_targetId' - The unique ID of a deployment target that has a type of @lambdaTarget@.
--
-- 'status', 'lambdaTarget_status' - The status an AWS Lambda deployment\'s target Lambda function.
--
-- 'deploymentId', 'lambdaTarget_deploymentId' - The unique ID of a deployment.
--
-- 'lastUpdatedAt', 'lambdaTarget_lastUpdatedAt' - The date and time when the target Lambda function was updated by a
-- deployment.
--
-- 'lifecycleEvents', 'lambdaTarget_lifecycleEvents' - The lifecycle events of the deployment to this target Lambda function.
--
-- 'lambdaFunctionInfo', 'lambdaTarget_lambdaFunctionInfo' - A @LambdaFunctionInfo@ object that describes a target Lambda function.
newLambdaTarget ::
  LambdaTarget
newLambdaTarget :: LambdaTarget
newLambdaTarget =
  LambdaTarget' :: Maybe Text
-> Maybe Text
-> Maybe TargetStatus
-> Maybe Text
-> Maybe POSIX
-> Maybe [LifecycleEvent]
-> Maybe LambdaFunctionInfo
-> LambdaTarget
LambdaTarget'
    { $sel:targetArn:LambdaTarget' :: Maybe Text
targetArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetId:LambdaTarget' :: Maybe Text
targetId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:status:LambdaTarget' :: Maybe TargetStatus
status = Maybe TargetStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:deploymentId:LambdaTarget' :: Maybe Text
deploymentId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdatedAt:LambdaTarget' :: Maybe POSIX
lastUpdatedAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:lifecycleEvents:LambdaTarget' :: Maybe [LifecycleEvent]
lifecycleEvents = Maybe [LifecycleEvent]
forall a. Maybe a
Prelude.Nothing,
      $sel:lambdaFunctionInfo:LambdaTarget' :: Maybe LambdaFunctionInfo
lambdaFunctionInfo = Maybe LambdaFunctionInfo
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the target.
lambdaTarget_targetArn :: Lens.Lens' LambdaTarget (Prelude.Maybe Prelude.Text)
lambdaTarget_targetArn :: (Maybe Text -> f (Maybe Text)) -> LambdaTarget -> f LambdaTarget
lambdaTarget_targetArn = (LambdaTarget -> Maybe Text)
-> (LambdaTarget -> Maybe Text -> LambdaTarget)
-> Lens LambdaTarget LambdaTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaTarget' {Maybe Text
targetArn :: Maybe Text
$sel:targetArn:LambdaTarget' :: LambdaTarget -> Maybe Text
targetArn} -> Maybe Text
targetArn) (\s :: LambdaTarget
s@LambdaTarget' {} Maybe Text
a -> LambdaTarget
s {$sel:targetArn:LambdaTarget' :: Maybe Text
targetArn = Maybe Text
a} :: LambdaTarget)

-- | The unique ID of a deployment target that has a type of @lambdaTarget@.
lambdaTarget_targetId :: Lens.Lens' LambdaTarget (Prelude.Maybe Prelude.Text)
lambdaTarget_targetId :: (Maybe Text -> f (Maybe Text)) -> LambdaTarget -> f LambdaTarget
lambdaTarget_targetId = (LambdaTarget -> Maybe Text)
-> (LambdaTarget -> Maybe Text -> LambdaTarget)
-> Lens LambdaTarget LambdaTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaTarget' {Maybe Text
targetId :: Maybe Text
$sel:targetId:LambdaTarget' :: LambdaTarget -> Maybe Text
targetId} -> Maybe Text
targetId) (\s :: LambdaTarget
s@LambdaTarget' {} Maybe Text
a -> LambdaTarget
s {$sel:targetId:LambdaTarget' :: Maybe Text
targetId = Maybe Text
a} :: LambdaTarget)

-- | The status an AWS Lambda deployment\'s target Lambda function.
lambdaTarget_status :: Lens.Lens' LambdaTarget (Prelude.Maybe TargetStatus)
lambdaTarget_status :: (Maybe TargetStatus -> f (Maybe TargetStatus))
-> LambdaTarget -> f LambdaTarget
lambdaTarget_status = (LambdaTarget -> Maybe TargetStatus)
-> (LambdaTarget -> Maybe TargetStatus -> LambdaTarget)
-> Lens
     LambdaTarget LambdaTarget (Maybe TargetStatus) (Maybe TargetStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaTarget' {Maybe TargetStatus
status :: Maybe TargetStatus
$sel:status:LambdaTarget' :: LambdaTarget -> Maybe TargetStatus
status} -> Maybe TargetStatus
status) (\s :: LambdaTarget
s@LambdaTarget' {} Maybe TargetStatus
a -> LambdaTarget
s {$sel:status:LambdaTarget' :: Maybe TargetStatus
status = Maybe TargetStatus
a} :: LambdaTarget)

-- | The unique ID of a deployment.
lambdaTarget_deploymentId :: Lens.Lens' LambdaTarget (Prelude.Maybe Prelude.Text)
lambdaTarget_deploymentId :: (Maybe Text -> f (Maybe Text)) -> LambdaTarget -> f LambdaTarget
lambdaTarget_deploymentId = (LambdaTarget -> Maybe Text)
-> (LambdaTarget -> Maybe Text -> LambdaTarget)
-> Lens LambdaTarget LambdaTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaTarget' {Maybe Text
deploymentId :: Maybe Text
$sel:deploymentId:LambdaTarget' :: LambdaTarget -> Maybe Text
deploymentId} -> Maybe Text
deploymentId) (\s :: LambdaTarget
s@LambdaTarget' {} Maybe Text
a -> LambdaTarget
s {$sel:deploymentId:LambdaTarget' :: Maybe Text
deploymentId = Maybe Text
a} :: LambdaTarget)

-- | The date and time when the target Lambda function was updated by a
-- deployment.
lambdaTarget_lastUpdatedAt :: Lens.Lens' LambdaTarget (Prelude.Maybe Prelude.UTCTime)
lambdaTarget_lastUpdatedAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> LambdaTarget -> f LambdaTarget
lambdaTarget_lastUpdatedAt = (LambdaTarget -> Maybe POSIX)
-> (LambdaTarget -> Maybe POSIX -> LambdaTarget)
-> Lens LambdaTarget LambdaTarget (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaTarget' {Maybe POSIX
lastUpdatedAt :: Maybe POSIX
$sel:lastUpdatedAt:LambdaTarget' :: LambdaTarget -> Maybe POSIX
lastUpdatedAt} -> Maybe POSIX
lastUpdatedAt) (\s :: LambdaTarget
s@LambdaTarget' {} Maybe POSIX
a -> LambdaTarget
s {$sel:lastUpdatedAt:LambdaTarget' :: Maybe POSIX
lastUpdatedAt = Maybe POSIX
a} :: LambdaTarget) ((Maybe POSIX -> f (Maybe POSIX))
 -> LambdaTarget -> f LambdaTarget)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> LambdaTarget
-> f LambdaTarget
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 lifecycle events of the deployment to this target Lambda function.
lambdaTarget_lifecycleEvents :: Lens.Lens' LambdaTarget (Prelude.Maybe [LifecycleEvent])
lambdaTarget_lifecycleEvents :: (Maybe [LifecycleEvent] -> f (Maybe [LifecycleEvent]))
-> LambdaTarget -> f LambdaTarget
lambdaTarget_lifecycleEvents = (LambdaTarget -> Maybe [LifecycleEvent])
-> (LambdaTarget -> Maybe [LifecycleEvent] -> LambdaTarget)
-> Lens
     LambdaTarget
     LambdaTarget
     (Maybe [LifecycleEvent])
     (Maybe [LifecycleEvent])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaTarget' {Maybe [LifecycleEvent]
lifecycleEvents :: Maybe [LifecycleEvent]
$sel:lifecycleEvents:LambdaTarget' :: LambdaTarget -> Maybe [LifecycleEvent]
lifecycleEvents} -> Maybe [LifecycleEvent]
lifecycleEvents) (\s :: LambdaTarget
s@LambdaTarget' {} Maybe [LifecycleEvent]
a -> LambdaTarget
s {$sel:lifecycleEvents:LambdaTarget' :: Maybe [LifecycleEvent]
lifecycleEvents = Maybe [LifecycleEvent]
a} :: LambdaTarget) ((Maybe [LifecycleEvent] -> f (Maybe [LifecycleEvent]))
 -> LambdaTarget -> f LambdaTarget)
-> ((Maybe [LifecycleEvent] -> f (Maybe [LifecycleEvent]))
    -> Maybe [LifecycleEvent] -> f (Maybe [LifecycleEvent]))
-> (Maybe [LifecycleEvent] -> f (Maybe [LifecycleEvent]))
-> LambdaTarget
-> f LambdaTarget
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [LifecycleEvent] [LifecycleEvent] [LifecycleEvent] [LifecycleEvent]
-> Iso
     (Maybe [LifecycleEvent])
     (Maybe [LifecycleEvent])
     (Maybe [LifecycleEvent])
     (Maybe [LifecycleEvent])
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
  [LifecycleEvent] [LifecycleEvent] [LifecycleEvent] [LifecycleEvent]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A @LambdaFunctionInfo@ object that describes a target Lambda function.
lambdaTarget_lambdaFunctionInfo :: Lens.Lens' LambdaTarget (Prelude.Maybe LambdaFunctionInfo)
lambdaTarget_lambdaFunctionInfo :: (Maybe LambdaFunctionInfo -> f (Maybe LambdaFunctionInfo))
-> LambdaTarget -> f LambdaTarget
lambdaTarget_lambdaFunctionInfo = (LambdaTarget -> Maybe LambdaFunctionInfo)
-> (LambdaTarget -> Maybe LambdaFunctionInfo -> LambdaTarget)
-> Lens
     LambdaTarget
     LambdaTarget
     (Maybe LambdaFunctionInfo)
     (Maybe LambdaFunctionInfo)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaTarget' {Maybe LambdaFunctionInfo
lambdaFunctionInfo :: Maybe LambdaFunctionInfo
$sel:lambdaFunctionInfo:LambdaTarget' :: LambdaTarget -> Maybe LambdaFunctionInfo
lambdaFunctionInfo} -> Maybe LambdaFunctionInfo
lambdaFunctionInfo) (\s :: LambdaTarget
s@LambdaTarget' {} Maybe LambdaFunctionInfo
a -> LambdaTarget
s {$sel:lambdaFunctionInfo:LambdaTarget' :: Maybe LambdaFunctionInfo
lambdaFunctionInfo = Maybe LambdaFunctionInfo
a} :: LambdaTarget)

instance Core.FromJSON LambdaTarget where
  parseJSON :: Value -> Parser LambdaTarget
parseJSON =
    String
-> (Object -> Parser LambdaTarget) -> Value -> Parser LambdaTarget
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LambdaTarget"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe TargetStatus
-> Maybe Text
-> Maybe POSIX
-> Maybe [LifecycleEvent]
-> Maybe LambdaFunctionInfo
-> LambdaTarget
LambdaTarget'
            (Maybe Text
 -> Maybe Text
 -> Maybe TargetStatus
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe [LifecycleEvent]
 -> Maybe LambdaFunctionInfo
 -> LambdaTarget)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe TargetStatus
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe [LifecycleEvent]
      -> Maybe LambdaFunctionInfo
      -> LambdaTarget)
forall (f :: * -> *) a b. Functor 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
"targetArn")
            Parser
  (Maybe Text
   -> Maybe TargetStatus
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe [LifecycleEvent]
   -> Maybe LambdaFunctionInfo
   -> LambdaTarget)
-> Parser (Maybe Text)
-> Parser
     (Maybe TargetStatus
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe [LifecycleEvent]
      -> Maybe LambdaFunctionInfo
      -> LambdaTarget)
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
"targetId")
            Parser
  (Maybe TargetStatus
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe [LifecycleEvent]
   -> Maybe LambdaFunctionInfo
   -> LambdaTarget)
-> Parser (Maybe TargetStatus)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe [LifecycleEvent]
      -> Maybe LambdaFunctionInfo
      -> LambdaTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe TargetStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"status")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe [LifecycleEvent]
   -> Maybe LambdaFunctionInfo
   -> LambdaTarget)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe [LifecycleEvent]
      -> Maybe LambdaFunctionInfo
      -> LambdaTarget)
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
"deploymentId")
            Parser
  (Maybe POSIX
   -> Maybe [LifecycleEvent]
   -> Maybe LambdaFunctionInfo
   -> LambdaTarget)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe [LifecycleEvent]
      -> Maybe LambdaFunctionInfo -> LambdaTarget)
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
"lastUpdatedAt")
            Parser
  (Maybe [LifecycleEvent]
   -> Maybe LambdaFunctionInfo -> LambdaTarget)
-> Parser (Maybe [LifecycleEvent])
-> Parser (Maybe LambdaFunctionInfo -> LambdaTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [LifecycleEvent]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lifecycleEvents"
                            Parser (Maybe (Maybe [LifecycleEvent]))
-> Maybe [LifecycleEvent] -> Parser (Maybe [LifecycleEvent])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [LifecycleEvent]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe LambdaFunctionInfo -> LambdaTarget)
-> Parser (Maybe LambdaFunctionInfo) -> Parser LambdaTarget
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe LambdaFunctionInfo)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lambdaFunctionInfo")
      )

instance Prelude.Hashable LambdaTarget

instance Prelude.NFData LambdaTarget