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

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

-- | Represents information about a stage to a job worker.
--
-- /See:/ 'newStageContext' smart constructor.
data StageContext = StageContext'
  { -- | The name of the stage.
    StageContext -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (StageContext -> StageContext -> Bool
(StageContext -> StageContext -> Bool)
-> (StageContext -> StageContext -> Bool) -> Eq StageContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StageContext -> StageContext -> Bool
$c/= :: StageContext -> StageContext -> Bool
== :: StageContext -> StageContext -> Bool
$c== :: StageContext -> StageContext -> Bool
Prelude.Eq, ReadPrec [StageContext]
ReadPrec StageContext
Int -> ReadS StageContext
ReadS [StageContext]
(Int -> ReadS StageContext)
-> ReadS [StageContext]
-> ReadPrec StageContext
-> ReadPrec [StageContext]
-> Read StageContext
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StageContext]
$creadListPrec :: ReadPrec [StageContext]
readPrec :: ReadPrec StageContext
$creadPrec :: ReadPrec StageContext
readList :: ReadS [StageContext]
$creadList :: ReadS [StageContext]
readsPrec :: Int -> ReadS StageContext
$creadsPrec :: Int -> ReadS StageContext
Prelude.Read, Int -> StageContext -> ShowS
[StageContext] -> ShowS
StageContext -> String
(Int -> StageContext -> ShowS)
-> (StageContext -> String)
-> ([StageContext] -> ShowS)
-> Show StageContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StageContext] -> ShowS
$cshowList :: [StageContext] -> ShowS
show :: StageContext -> String
$cshow :: StageContext -> String
showsPrec :: Int -> StageContext -> ShowS
$cshowsPrec :: Int -> StageContext -> ShowS
Prelude.Show, (forall x. StageContext -> Rep StageContext x)
-> (forall x. Rep StageContext x -> StageContext)
-> Generic StageContext
forall x. Rep StageContext x -> StageContext
forall x. StageContext -> Rep StageContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StageContext x -> StageContext
$cfrom :: forall x. StageContext -> Rep StageContext x
Prelude.Generic)

-- |
-- Create a value of 'StageContext' 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', 'stageContext_name' - The name of the stage.
newStageContext ::
  StageContext
newStageContext :: StageContext
newStageContext =
  StageContext' :: Maybe Text -> StageContext
StageContext' {$sel:name:StageContext' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The name of the stage.
stageContext_name :: Lens.Lens' StageContext (Prelude.Maybe Prelude.Text)
stageContext_name :: (Maybe Text -> f (Maybe Text)) -> StageContext -> f StageContext
stageContext_name = (StageContext -> Maybe Text)
-> (StageContext -> Maybe Text -> StageContext)
-> Lens StageContext StageContext (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StageContext' {Maybe Text
name :: Maybe Text
$sel:name:StageContext' :: StageContext -> Maybe Text
name} -> Maybe Text
name) (\s :: StageContext
s@StageContext' {} Maybe Text
a -> StageContext
s {$sel:name:StageContext' :: Maybe Text
name = Maybe Text
a} :: StageContext)

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

instance Prelude.Hashable StageContext

instance Prelude.NFData StageContext