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

-- | Represents the context of an action in the stage of a pipeline to a job
-- worker.
--
-- /See:/ 'newActionContext' smart constructor.
data ActionContext = ActionContext'
  { -- | The system-generated unique ID that corresponds to an action\'s
    -- execution.
    ActionContext -> Maybe Text
actionExecutionId :: Prelude.Maybe Prelude.Text,
    -- | The name of the action in the context of a job.
    ActionContext -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (ActionContext -> ActionContext -> Bool
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]
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
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. 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:
--
-- 'actionExecutionId', 'actionContext_actionExecutionId' - The system-generated unique ID that corresponds to an action\'s
-- execution.
--
-- 'name', 'actionContext_name' - The name of the action in the context of a job.
newActionContext ::
  ActionContext
newActionContext :: ActionContext
newActionContext =
  ActionContext'
    { $sel:actionExecutionId:ActionContext' :: Maybe Text
actionExecutionId = forall a. Maybe a
Prelude.Nothing,
      $sel:name:ActionContext' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing
    }

-- | The system-generated unique ID that corresponds to an action\'s
-- execution.
actionContext_actionExecutionId :: Lens.Lens' ActionContext (Prelude.Maybe Prelude.Text)
actionContext_actionExecutionId :: Lens' ActionContext (Maybe Text)
actionContext_actionExecutionId = 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)

-- | The name of the action in the context of a job.
actionContext_name :: Lens.Lens' ActionContext (Prelude.Maybe Prelude.Text)
actionContext_name :: Lens' ActionContext (Maybe Text)
actionContext_name = 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)

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

instance Prelude.Hashable ActionContext where
  hashWithSalt :: Int -> ActionContext -> Int
hashWithSalt Int
_salt ActionContext' {Maybe Text
name :: Maybe Text
actionExecutionId :: Maybe Text
$sel:name:ActionContext' :: ActionContext -> Maybe Text
$sel:actionExecutionId:ActionContext' :: ActionContext -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
actionExecutionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name

instance Prelude.NFData ActionContext where
  rnf :: ActionContext -> ()
rnf ActionContext' {Maybe Text
name :: Maybe Text
actionExecutionId :: Maybe Text
$sel:name:ActionContext' :: ActionContext -> Maybe Text
$sel:actionExecutionId:ActionContext' :: ActionContext -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
actionExecutionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name