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

import Amazonka.CodePipeline.Types.ActionState
import Amazonka.CodePipeline.Types.StageExecution
import Amazonka.CodePipeline.Types.TransitionState
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents information about the state of the stage.
--
-- /See:/ 'newStageState' smart constructor.
data StageState = StageState'
  { StageState -> Maybe StageExecution
inboundExecution :: Prelude.Maybe StageExecution,
    -- | The state of the inbound transition, which is either enabled or
    -- disabled.
    StageState -> Maybe TransitionState
inboundTransitionState :: Prelude.Maybe TransitionState,
    -- | The state of the stage.
    StageState -> Maybe [ActionState]
actionStates :: Prelude.Maybe [ActionState],
    -- | The name of the stage.
    StageState -> Maybe Text
stageName :: Prelude.Maybe Prelude.Text,
    -- | Information about the latest execution in the stage, including its ID
    -- and status.
    StageState -> Maybe StageExecution
latestExecution :: Prelude.Maybe StageExecution
  }
  deriving (StageState -> StageState -> Bool
(StageState -> StageState -> Bool)
-> (StageState -> StageState -> Bool) -> Eq StageState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StageState -> StageState -> Bool
$c/= :: StageState -> StageState -> Bool
== :: StageState -> StageState -> Bool
$c== :: StageState -> StageState -> Bool
Prelude.Eq, ReadPrec [StageState]
ReadPrec StageState
Int -> ReadS StageState
ReadS [StageState]
(Int -> ReadS StageState)
-> ReadS [StageState]
-> ReadPrec StageState
-> ReadPrec [StageState]
-> Read StageState
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StageState]
$creadListPrec :: ReadPrec [StageState]
readPrec :: ReadPrec StageState
$creadPrec :: ReadPrec StageState
readList :: ReadS [StageState]
$creadList :: ReadS [StageState]
readsPrec :: Int -> ReadS StageState
$creadsPrec :: Int -> ReadS StageState
Prelude.Read, Int -> StageState -> ShowS
[StageState] -> ShowS
StageState -> String
(Int -> StageState -> ShowS)
-> (StageState -> String)
-> ([StageState] -> ShowS)
-> Show StageState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StageState] -> ShowS
$cshowList :: [StageState] -> ShowS
show :: StageState -> String
$cshow :: StageState -> String
showsPrec :: Int -> StageState -> ShowS
$cshowsPrec :: Int -> StageState -> ShowS
Prelude.Show, (forall x. StageState -> Rep StageState x)
-> (forall x. Rep StageState x -> StageState) -> Generic StageState
forall x. Rep StageState x -> StageState
forall x. StageState -> Rep StageState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StageState x -> StageState
$cfrom :: forall x. StageState -> Rep StageState x
Prelude.Generic)

-- |
-- Create a value of 'StageState' 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:
--
-- 'inboundExecution', 'stageState_inboundExecution' - Undocumented member.
--
-- 'inboundTransitionState', 'stageState_inboundTransitionState' - The state of the inbound transition, which is either enabled or
-- disabled.
--
-- 'actionStates', 'stageState_actionStates' - The state of the stage.
--
-- 'stageName', 'stageState_stageName' - The name of the stage.
--
-- 'latestExecution', 'stageState_latestExecution' - Information about the latest execution in the stage, including its ID
-- and status.
newStageState ::
  StageState
newStageState :: StageState
newStageState =
  StageState' :: Maybe StageExecution
-> Maybe TransitionState
-> Maybe [ActionState]
-> Maybe Text
-> Maybe StageExecution
-> StageState
StageState'
    { $sel:inboundExecution:StageState' :: Maybe StageExecution
inboundExecution = Maybe StageExecution
forall a. Maybe a
Prelude.Nothing,
      $sel:inboundTransitionState:StageState' :: Maybe TransitionState
inboundTransitionState = Maybe TransitionState
forall a. Maybe a
Prelude.Nothing,
      $sel:actionStates:StageState' :: Maybe [ActionState]
actionStates = Maybe [ActionState]
forall a. Maybe a
Prelude.Nothing,
      $sel:stageName:StageState' :: Maybe Text
stageName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:latestExecution:StageState' :: Maybe StageExecution
latestExecution = Maybe StageExecution
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
stageState_inboundExecution :: Lens.Lens' StageState (Prelude.Maybe StageExecution)
stageState_inboundExecution :: (Maybe StageExecution -> f (Maybe StageExecution))
-> StageState -> f StageState
stageState_inboundExecution = (StageState -> Maybe StageExecution)
-> (StageState -> Maybe StageExecution -> StageState)
-> Lens
     StageState StageState (Maybe StageExecution) (Maybe StageExecution)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StageState' {Maybe StageExecution
inboundExecution :: Maybe StageExecution
$sel:inboundExecution:StageState' :: StageState -> Maybe StageExecution
inboundExecution} -> Maybe StageExecution
inboundExecution) (\s :: StageState
s@StageState' {} Maybe StageExecution
a -> StageState
s {$sel:inboundExecution:StageState' :: Maybe StageExecution
inboundExecution = Maybe StageExecution
a} :: StageState)

-- | The state of the inbound transition, which is either enabled or
-- disabled.
stageState_inboundTransitionState :: Lens.Lens' StageState (Prelude.Maybe TransitionState)
stageState_inboundTransitionState :: (Maybe TransitionState -> f (Maybe TransitionState))
-> StageState -> f StageState
stageState_inboundTransitionState = (StageState -> Maybe TransitionState)
-> (StageState -> Maybe TransitionState -> StageState)
-> Lens
     StageState
     StageState
     (Maybe TransitionState)
     (Maybe TransitionState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StageState' {Maybe TransitionState
inboundTransitionState :: Maybe TransitionState
$sel:inboundTransitionState:StageState' :: StageState -> Maybe TransitionState
inboundTransitionState} -> Maybe TransitionState
inboundTransitionState) (\s :: StageState
s@StageState' {} Maybe TransitionState
a -> StageState
s {$sel:inboundTransitionState:StageState' :: Maybe TransitionState
inboundTransitionState = Maybe TransitionState
a} :: StageState)

-- | The state of the stage.
stageState_actionStates :: Lens.Lens' StageState (Prelude.Maybe [ActionState])
stageState_actionStates :: (Maybe [ActionState] -> f (Maybe [ActionState]))
-> StageState -> f StageState
stageState_actionStates = (StageState -> Maybe [ActionState])
-> (StageState -> Maybe [ActionState] -> StageState)
-> Lens
     StageState StageState (Maybe [ActionState]) (Maybe [ActionState])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StageState' {Maybe [ActionState]
actionStates :: Maybe [ActionState]
$sel:actionStates:StageState' :: StageState -> Maybe [ActionState]
actionStates} -> Maybe [ActionState]
actionStates) (\s :: StageState
s@StageState' {} Maybe [ActionState]
a -> StageState
s {$sel:actionStates:StageState' :: Maybe [ActionState]
actionStates = Maybe [ActionState]
a} :: StageState) ((Maybe [ActionState] -> f (Maybe [ActionState]))
 -> StageState -> f StageState)
-> ((Maybe [ActionState] -> f (Maybe [ActionState]))
    -> Maybe [ActionState] -> f (Maybe [ActionState]))
-> (Maybe [ActionState] -> f (Maybe [ActionState]))
-> StageState
-> f StageState
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ActionState] [ActionState] [ActionState] [ActionState]
-> Iso
     (Maybe [ActionState])
     (Maybe [ActionState])
     (Maybe [ActionState])
     (Maybe [ActionState])
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 [ActionState] [ActionState] [ActionState] [ActionState]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | Information about the latest execution in the stage, including its ID
-- and status.
stageState_latestExecution :: Lens.Lens' StageState (Prelude.Maybe StageExecution)
stageState_latestExecution :: (Maybe StageExecution -> f (Maybe StageExecution))
-> StageState -> f StageState
stageState_latestExecution = (StageState -> Maybe StageExecution)
-> (StageState -> Maybe StageExecution -> StageState)
-> Lens
     StageState StageState (Maybe StageExecution) (Maybe StageExecution)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StageState' {Maybe StageExecution
latestExecution :: Maybe StageExecution
$sel:latestExecution:StageState' :: StageState -> Maybe StageExecution
latestExecution} -> Maybe StageExecution
latestExecution) (\s :: StageState
s@StageState' {} Maybe StageExecution
a -> StageState
s {$sel:latestExecution:StageState' :: Maybe StageExecution
latestExecution = Maybe StageExecution
a} :: StageState)

instance Core.FromJSON StageState where
  parseJSON :: Value -> Parser StageState
parseJSON =
    String
-> (Object -> Parser StageState) -> Value -> Parser StageState
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StageState"
      ( \Object
x ->
          Maybe StageExecution
-> Maybe TransitionState
-> Maybe [ActionState]
-> Maybe Text
-> Maybe StageExecution
-> StageState
StageState'
            (Maybe StageExecution
 -> Maybe TransitionState
 -> Maybe [ActionState]
 -> Maybe Text
 -> Maybe StageExecution
 -> StageState)
-> Parser (Maybe StageExecution)
-> Parser
     (Maybe TransitionState
      -> Maybe [ActionState]
      -> Maybe Text
      -> Maybe StageExecution
      -> StageState)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe StageExecution)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"inboundExecution")
            Parser
  (Maybe TransitionState
   -> Maybe [ActionState]
   -> Maybe Text
   -> Maybe StageExecution
   -> StageState)
-> Parser (Maybe TransitionState)
-> Parser
     (Maybe [ActionState]
      -> Maybe Text -> Maybe StageExecution -> StageState)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe TransitionState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"inboundTransitionState")
            Parser
  (Maybe [ActionState]
   -> Maybe Text -> Maybe StageExecution -> StageState)
-> Parser (Maybe [ActionState])
-> Parser (Maybe Text -> Maybe StageExecution -> StageState)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [ActionState]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"actionStates" Parser (Maybe (Maybe [ActionState]))
-> Maybe [ActionState] -> Parser (Maybe [ActionState])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ActionState]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> Maybe StageExecution -> StageState)
-> Parser (Maybe Text)
-> Parser (Maybe StageExecution -> StageState)
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
"stageName")
            Parser (Maybe StageExecution -> StageState)
-> Parser (Maybe StageExecution) -> Parser StageState
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe StageExecution)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"latestExecution")
      )

instance Prelude.Hashable StageState

instance Prelude.NFData StageState