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

import Amazonka.CodePipeline.Types.ActionExecution
import Amazonka.CodePipeline.Types.ActionRevision
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents information about the state of an action.
--
-- /See:/ 'newActionState' smart constructor.
data ActionState = ActionState'
  { -- | A URL link for more information about the revision, such as a commit
    -- details page.
    ActionState -> Maybe Text
revisionUrl :: Prelude.Maybe Prelude.Text,
    -- | A URL link for more information about the state of the action, such as a
    -- deployment group details page.
    ActionState -> Maybe Text
entityUrl :: Prelude.Maybe Prelude.Text,
    -- | The name of the action.
    ActionState -> Maybe Text
actionName :: Prelude.Maybe Prelude.Text,
    -- | Represents information about the version (or revision) of an action.
    ActionState -> Maybe ActionRevision
currentRevision :: Prelude.Maybe ActionRevision,
    -- | Represents information about the run of an action.
    ActionState -> Maybe ActionExecution
latestExecution :: Prelude.Maybe ActionExecution
  }
  deriving (ActionState -> ActionState -> Bool
(ActionState -> ActionState -> Bool)
-> (ActionState -> ActionState -> Bool) -> Eq ActionState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActionState -> ActionState -> Bool
$c/= :: ActionState -> ActionState -> Bool
== :: ActionState -> ActionState -> Bool
$c== :: ActionState -> ActionState -> Bool
Prelude.Eq, ReadPrec [ActionState]
ReadPrec ActionState
Int -> ReadS ActionState
ReadS [ActionState]
(Int -> ReadS ActionState)
-> ReadS [ActionState]
-> ReadPrec ActionState
-> ReadPrec [ActionState]
-> Read ActionState
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ActionState]
$creadListPrec :: ReadPrec [ActionState]
readPrec :: ReadPrec ActionState
$creadPrec :: ReadPrec ActionState
readList :: ReadS [ActionState]
$creadList :: ReadS [ActionState]
readsPrec :: Int -> ReadS ActionState
$creadsPrec :: Int -> ReadS ActionState
Prelude.Read, Int -> ActionState -> ShowS
[ActionState] -> ShowS
ActionState -> String
(Int -> ActionState -> ShowS)
-> (ActionState -> String)
-> ([ActionState] -> ShowS)
-> Show ActionState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActionState] -> ShowS
$cshowList :: [ActionState] -> ShowS
show :: ActionState -> String
$cshow :: ActionState -> String
showsPrec :: Int -> ActionState -> ShowS
$cshowsPrec :: Int -> ActionState -> ShowS
Prelude.Show, (forall x. ActionState -> Rep ActionState x)
-> (forall x. Rep ActionState x -> ActionState)
-> Generic ActionState
forall x. Rep ActionState x -> ActionState
forall x. ActionState -> Rep ActionState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActionState x -> ActionState
$cfrom :: forall x. ActionState -> Rep ActionState x
Prelude.Generic)

-- |
-- Create a value of 'ActionState' 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:
--
-- 'revisionUrl', 'actionState_revisionUrl' - A URL link for more information about the revision, such as a commit
-- details page.
--
-- 'entityUrl', 'actionState_entityUrl' - A URL link for more information about the state of the action, such as a
-- deployment group details page.
--
-- 'actionName', 'actionState_actionName' - The name of the action.
--
-- 'currentRevision', 'actionState_currentRevision' - Represents information about the version (or revision) of an action.
--
-- 'latestExecution', 'actionState_latestExecution' - Represents information about the run of an action.
newActionState ::
  ActionState
newActionState :: ActionState
newActionState =
  ActionState' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ActionRevision
-> Maybe ActionExecution
-> ActionState
ActionState'
    { $sel:revisionUrl:ActionState' :: Maybe Text
revisionUrl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:entityUrl:ActionState' :: Maybe Text
entityUrl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:actionName:ActionState' :: Maybe Text
actionName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:currentRevision:ActionState' :: Maybe ActionRevision
currentRevision = Maybe ActionRevision
forall a. Maybe a
Prelude.Nothing,
      $sel:latestExecution:ActionState' :: Maybe ActionExecution
latestExecution = Maybe ActionExecution
forall a. Maybe a
Prelude.Nothing
    }

-- | A URL link for more information about the revision, such as a commit
-- details page.
actionState_revisionUrl :: Lens.Lens' ActionState (Prelude.Maybe Prelude.Text)
actionState_revisionUrl :: (Maybe Text -> f (Maybe Text)) -> ActionState -> f ActionState
actionState_revisionUrl = (ActionState -> Maybe Text)
-> (ActionState -> Maybe Text -> ActionState)
-> Lens ActionState ActionState (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionState' {Maybe Text
revisionUrl :: Maybe Text
$sel:revisionUrl:ActionState' :: ActionState -> Maybe Text
revisionUrl} -> Maybe Text
revisionUrl) (\s :: ActionState
s@ActionState' {} Maybe Text
a -> ActionState
s {$sel:revisionUrl:ActionState' :: Maybe Text
revisionUrl = Maybe Text
a} :: ActionState)

-- | A URL link for more information about the state of the action, such as a
-- deployment group details page.
actionState_entityUrl :: Lens.Lens' ActionState (Prelude.Maybe Prelude.Text)
actionState_entityUrl :: (Maybe Text -> f (Maybe Text)) -> ActionState -> f ActionState
actionState_entityUrl = (ActionState -> Maybe Text)
-> (ActionState -> Maybe Text -> ActionState)
-> Lens ActionState ActionState (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionState' {Maybe Text
entityUrl :: Maybe Text
$sel:entityUrl:ActionState' :: ActionState -> Maybe Text
entityUrl} -> Maybe Text
entityUrl) (\s :: ActionState
s@ActionState' {} Maybe Text
a -> ActionState
s {$sel:entityUrl:ActionState' :: Maybe Text
entityUrl = Maybe Text
a} :: ActionState)

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

-- | Represents information about the version (or revision) of an action.
actionState_currentRevision :: Lens.Lens' ActionState (Prelude.Maybe ActionRevision)
actionState_currentRevision :: (Maybe ActionRevision -> f (Maybe ActionRevision))
-> ActionState -> f ActionState
actionState_currentRevision = (ActionState -> Maybe ActionRevision)
-> (ActionState -> Maybe ActionRevision -> ActionState)
-> Lens
     ActionState
     ActionState
     (Maybe ActionRevision)
     (Maybe ActionRevision)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionState' {Maybe ActionRevision
currentRevision :: Maybe ActionRevision
$sel:currentRevision:ActionState' :: ActionState -> Maybe ActionRevision
currentRevision} -> Maybe ActionRevision
currentRevision) (\s :: ActionState
s@ActionState' {} Maybe ActionRevision
a -> ActionState
s {$sel:currentRevision:ActionState' :: Maybe ActionRevision
currentRevision = Maybe ActionRevision
a} :: ActionState)

-- | Represents information about the run of an action.
actionState_latestExecution :: Lens.Lens' ActionState (Prelude.Maybe ActionExecution)
actionState_latestExecution :: (Maybe ActionExecution -> f (Maybe ActionExecution))
-> ActionState -> f ActionState
actionState_latestExecution = (ActionState -> Maybe ActionExecution)
-> (ActionState -> Maybe ActionExecution -> ActionState)
-> Lens
     ActionState
     ActionState
     (Maybe ActionExecution)
     (Maybe ActionExecution)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionState' {Maybe ActionExecution
latestExecution :: Maybe ActionExecution
$sel:latestExecution:ActionState' :: ActionState -> Maybe ActionExecution
latestExecution} -> Maybe ActionExecution
latestExecution) (\s :: ActionState
s@ActionState' {} Maybe ActionExecution
a -> ActionState
s {$sel:latestExecution:ActionState' :: Maybe ActionExecution
latestExecution = Maybe ActionExecution
a} :: ActionState)

instance Core.FromJSON ActionState where
  parseJSON :: Value -> Parser ActionState
parseJSON =
    String
-> (Object -> Parser ActionState) -> Value -> Parser ActionState
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ActionState"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ActionRevision
-> Maybe ActionExecution
-> ActionState
ActionState'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe ActionRevision
 -> Maybe ActionExecution
 -> ActionState)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe ActionRevision
      -> Maybe ActionExecution
      -> ActionState)
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
"revisionUrl")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe ActionRevision
   -> Maybe ActionExecution
   -> ActionState)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe ActionRevision -> Maybe ActionExecution -> ActionState)
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
"entityUrl")
            Parser
  (Maybe Text
   -> Maybe ActionRevision -> Maybe ActionExecution -> ActionState)
-> Parser (Maybe Text)
-> Parser
     (Maybe ActionRevision -> Maybe ActionExecution -> ActionState)
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
"actionName")
            Parser
  (Maybe ActionRevision -> Maybe ActionExecution -> ActionState)
-> Parser (Maybe ActionRevision)
-> Parser (Maybe ActionExecution -> ActionState)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ActionRevision)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"currentRevision")
            Parser (Maybe ActionExecution -> ActionState)
-> Parser (Maybe ActionExecution) -> Parser ActionState
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ActionExecution)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"latestExecution")
      )

instance Prelude.Hashable ActionState

instance Prelude.NFData ActionState