{-# 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.CodePipeline.Types.ActionContext
-- 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.CodePipeline.Types.ActionContext where

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

-- | Represents the context of an action in the stage of a pipeline to a job
-- worker.
--
-- /See:/ 'newActionContext' smart constructor.
data ActionContext = ActionContext'
  { -- | The name of the action in the context of a job.
    ActionContext -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The system-generated unique ID that corresponds to an action\'s
    -- execution.
    ActionContext -> Maybe Text
actionExecutionId :: Prelude.Maybe Prelude.Text
  }
  deriving (ActionContext -> ActionContext -> Bool
(ActionContext -> ActionContext -> Bool)
-> (ActionContext -> ActionContext -> Bool) -> Eq ActionContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActionContext -> ActionContext -> Bool
$c/= :: ActionContext -> ActionContext -> Bool
== :: ActionContext -> ActionContext -> Bool
$c== :: ActionContext -> ActionContext -> Bool
Prelude.Eq, ReadPrec [ActionContext]
ReadPrec ActionContext
Int -> ReadS ActionContext
ReadS [ActionContext]
(Int -> ReadS ActionContext)
-> ReadS [ActionContext]
-> ReadPrec ActionContext
-> ReadPrec [ActionContext]
-> Read ActionContext
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ActionContext]
$creadListPrec :: ReadPrec [ActionContext]
readPrec :: ReadPrec ActionContext
$creadPrec :: ReadPrec ActionContext
readList :: ReadS [ActionContext]
$creadList :: ReadS [ActionContext]
readsPrec :: Int -> ReadS ActionContext
$creadsPrec :: Int -> ReadS ActionContext
Prelude.Read, Int -> ActionContext -> ShowS
[ActionContext] -> ShowS
ActionContext -> String
(Int -> ActionContext -> ShowS)
-> (ActionContext -> String)
-> ([ActionContext] -> ShowS)
-> Show ActionContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActionContext] -> ShowS
$cshowList :: [ActionContext] -> ShowS
show :: ActionContext -> String
$cshow :: ActionContext -> String
showsPrec :: Int -> ActionContext -> ShowS
$cshowsPrec :: Int -> ActionContext -> ShowS
Prelude.Show, (forall x. ActionContext -> Rep ActionContext x)
-> (forall x. Rep ActionContext x -> ActionContext)
-> Generic ActionContext
forall x. Rep ActionContext x -> ActionContext
forall x. ActionContext -> Rep ActionContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActionContext x -> ActionContext
$cfrom :: forall x. ActionContext -> Rep ActionContext x
Prelude.Generic)

-- |
-- Create a value of 'ActionContext' 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:
--
-- 'name', 'actionContext_name' - The name of the action in the context of a job.
--
-- 'actionExecutionId', 'actionContext_actionExecutionId' - The system-generated unique ID that corresponds to an action\'s
-- execution.
newActionContext ::
  ActionContext
newActionContext :: ActionContext
newActionContext =
  ActionContext' :: Maybe Text -> Maybe Text -> ActionContext
ActionContext'
    { $sel:name:ActionContext' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:actionExecutionId:ActionContext' :: Maybe Text
actionExecutionId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the action in the context of a job.
actionContext_name :: Lens.Lens' ActionContext (Prelude.Maybe Prelude.Text)
actionContext_name :: (Maybe Text -> f (Maybe Text)) -> ActionContext -> f ActionContext
actionContext_name = (ActionContext -> Maybe Text)
-> (ActionContext -> Maybe Text -> ActionContext)
-> Lens ActionContext ActionContext (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionContext' {Maybe Text
name :: Maybe Text
$sel:name:ActionContext' :: ActionContext -> Maybe Text
name} -> Maybe Text
name) (\s :: ActionContext
s@ActionContext' {} Maybe Text
a -> ActionContext
s {$sel:name:ActionContext' :: Maybe Text
name = Maybe Text
a} :: ActionContext)

-- | The system-generated unique ID that corresponds to an action\'s
-- execution.
actionContext_actionExecutionId :: Lens.Lens' ActionContext (Prelude.Maybe Prelude.Text)
actionContext_actionExecutionId :: (Maybe Text -> f (Maybe Text)) -> ActionContext -> f ActionContext
actionContext_actionExecutionId = (ActionContext -> Maybe Text)
-> (ActionContext -> Maybe Text -> ActionContext)
-> Lens ActionContext ActionContext (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionContext' {Maybe Text
actionExecutionId :: Maybe Text
$sel:actionExecutionId:ActionContext' :: ActionContext -> Maybe Text
actionExecutionId} -> Maybe Text
actionExecutionId) (\s :: ActionContext
s@ActionContext' {} Maybe Text
a -> ActionContext
s {$sel:actionExecutionId:ActionContext' :: Maybe Text
actionExecutionId = Maybe Text
a} :: ActionContext)

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

instance Prelude.Hashable ActionContext

instance Prelude.NFData ActionContext