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

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

-- | Represents information about the state of transitions between one stage
-- and another stage.
--
-- /See:/ 'newTransitionState' smart constructor.
data TransitionState = TransitionState'
  { -- | Whether the transition between stages is enabled (true) or disabled
    -- (false).
    TransitionState -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | The user-specified reason why the transition between two stages of a
    -- pipeline was disabled.
    TransitionState -> Maybe Text
disabledReason :: Prelude.Maybe Prelude.Text,
    -- | The timestamp when the transition state was last changed.
    TransitionState -> Maybe POSIX
lastChangedAt :: Prelude.Maybe Core.POSIX,
    -- | The ID of the user who last changed the transition state.
    TransitionState -> Maybe Text
lastChangedBy :: Prelude.Maybe Prelude.Text
  }
  deriving (TransitionState -> TransitionState -> Bool
(TransitionState -> TransitionState -> Bool)
-> (TransitionState -> TransitionState -> Bool)
-> Eq TransitionState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TransitionState -> TransitionState -> Bool
$c/= :: TransitionState -> TransitionState -> Bool
== :: TransitionState -> TransitionState -> Bool
$c== :: TransitionState -> TransitionState -> Bool
Prelude.Eq, ReadPrec [TransitionState]
ReadPrec TransitionState
Int -> ReadS TransitionState
ReadS [TransitionState]
(Int -> ReadS TransitionState)
-> ReadS [TransitionState]
-> ReadPrec TransitionState
-> ReadPrec [TransitionState]
-> Read TransitionState
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TransitionState]
$creadListPrec :: ReadPrec [TransitionState]
readPrec :: ReadPrec TransitionState
$creadPrec :: ReadPrec TransitionState
readList :: ReadS [TransitionState]
$creadList :: ReadS [TransitionState]
readsPrec :: Int -> ReadS TransitionState
$creadsPrec :: Int -> ReadS TransitionState
Prelude.Read, Int -> TransitionState -> ShowS
[TransitionState] -> ShowS
TransitionState -> String
(Int -> TransitionState -> ShowS)
-> (TransitionState -> String)
-> ([TransitionState] -> ShowS)
-> Show TransitionState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TransitionState] -> ShowS
$cshowList :: [TransitionState] -> ShowS
show :: TransitionState -> String
$cshow :: TransitionState -> String
showsPrec :: Int -> TransitionState -> ShowS
$cshowsPrec :: Int -> TransitionState -> ShowS
Prelude.Show, (forall x. TransitionState -> Rep TransitionState x)
-> (forall x. Rep TransitionState x -> TransitionState)
-> Generic TransitionState
forall x. Rep TransitionState x -> TransitionState
forall x. TransitionState -> Rep TransitionState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TransitionState x -> TransitionState
$cfrom :: forall x. TransitionState -> Rep TransitionState x
Prelude.Generic)

-- |
-- Create a value of 'TransitionState' 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:
--
-- 'enabled', 'transitionState_enabled' - Whether the transition between stages is enabled (true) or disabled
-- (false).
--
-- 'disabledReason', 'transitionState_disabledReason' - The user-specified reason why the transition between two stages of a
-- pipeline was disabled.
--
-- 'lastChangedAt', 'transitionState_lastChangedAt' - The timestamp when the transition state was last changed.
--
-- 'lastChangedBy', 'transitionState_lastChangedBy' - The ID of the user who last changed the transition state.
newTransitionState ::
  TransitionState
newTransitionState :: TransitionState
newTransitionState =
  TransitionState' :: Maybe Bool
-> Maybe Text -> Maybe POSIX -> Maybe Text -> TransitionState
TransitionState'
    { $sel:enabled:TransitionState' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:disabledReason:TransitionState' :: Maybe Text
disabledReason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastChangedAt:TransitionState' :: Maybe POSIX
lastChangedAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:lastChangedBy:TransitionState' :: Maybe Text
lastChangedBy = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Whether the transition between stages is enabled (true) or disabled
-- (false).
transitionState_enabled :: Lens.Lens' TransitionState (Prelude.Maybe Prelude.Bool)
transitionState_enabled :: (Maybe Bool -> f (Maybe Bool))
-> TransitionState -> f TransitionState
transitionState_enabled = (TransitionState -> Maybe Bool)
-> (TransitionState -> Maybe Bool -> TransitionState)
-> Lens TransitionState TransitionState (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransitionState' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:TransitionState' :: TransitionState -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: TransitionState
s@TransitionState' {} Maybe Bool
a -> TransitionState
s {$sel:enabled:TransitionState' :: Maybe Bool
enabled = Maybe Bool
a} :: TransitionState)

-- | The user-specified reason why the transition between two stages of a
-- pipeline was disabled.
transitionState_disabledReason :: Lens.Lens' TransitionState (Prelude.Maybe Prelude.Text)
transitionState_disabledReason :: (Maybe Text -> f (Maybe Text))
-> TransitionState -> f TransitionState
transitionState_disabledReason = (TransitionState -> Maybe Text)
-> (TransitionState -> Maybe Text -> TransitionState)
-> Lens TransitionState TransitionState (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransitionState' {Maybe Text
disabledReason :: Maybe Text
$sel:disabledReason:TransitionState' :: TransitionState -> Maybe Text
disabledReason} -> Maybe Text
disabledReason) (\s :: TransitionState
s@TransitionState' {} Maybe Text
a -> TransitionState
s {$sel:disabledReason:TransitionState' :: Maybe Text
disabledReason = Maybe Text
a} :: TransitionState)

-- | The timestamp when the transition state was last changed.
transitionState_lastChangedAt :: Lens.Lens' TransitionState (Prelude.Maybe Prelude.UTCTime)
transitionState_lastChangedAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> TransitionState -> f TransitionState
transitionState_lastChangedAt = (TransitionState -> Maybe POSIX)
-> (TransitionState -> Maybe POSIX -> TransitionState)
-> Lens TransitionState TransitionState (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransitionState' {Maybe POSIX
lastChangedAt :: Maybe POSIX
$sel:lastChangedAt:TransitionState' :: TransitionState -> Maybe POSIX
lastChangedAt} -> Maybe POSIX
lastChangedAt) (\s :: TransitionState
s@TransitionState' {} Maybe POSIX
a -> TransitionState
s {$sel:lastChangedAt:TransitionState' :: Maybe POSIX
lastChangedAt = Maybe POSIX
a} :: TransitionState) ((Maybe POSIX -> f (Maybe POSIX))
 -> TransitionState -> f TransitionState)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> TransitionState
-> f TransitionState
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The ID of the user who last changed the transition state.
transitionState_lastChangedBy :: Lens.Lens' TransitionState (Prelude.Maybe Prelude.Text)
transitionState_lastChangedBy :: (Maybe Text -> f (Maybe Text))
-> TransitionState -> f TransitionState
transitionState_lastChangedBy = (TransitionState -> Maybe Text)
-> (TransitionState -> Maybe Text -> TransitionState)
-> Lens TransitionState TransitionState (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransitionState' {Maybe Text
lastChangedBy :: Maybe Text
$sel:lastChangedBy:TransitionState' :: TransitionState -> Maybe Text
lastChangedBy} -> Maybe Text
lastChangedBy) (\s :: TransitionState
s@TransitionState' {} Maybe Text
a -> TransitionState
s {$sel:lastChangedBy:TransitionState' :: Maybe Text
lastChangedBy = Maybe Text
a} :: TransitionState)

instance Core.FromJSON TransitionState where
  parseJSON :: Value -> Parser TransitionState
parseJSON =
    String
-> (Object -> Parser TransitionState)
-> Value
-> Parser TransitionState
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TransitionState"
      ( \Object
x ->
          Maybe Bool
-> Maybe Text -> Maybe POSIX -> Maybe Text -> TransitionState
TransitionState'
            (Maybe Bool
 -> Maybe Text -> Maybe POSIX -> Maybe Text -> TransitionState)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Text -> Maybe POSIX -> Maybe Text -> TransitionState)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"enabled")
            Parser (Maybe Text -> Maybe POSIX -> Maybe Text -> TransitionState)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> Maybe Text -> TransitionState)
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
"disabledReason")
            Parser (Maybe POSIX -> Maybe Text -> TransitionState)
-> Parser (Maybe POSIX) -> Parser (Maybe Text -> TransitionState)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lastChangedAt")
            Parser (Maybe Text -> TransitionState)
-> Parser (Maybe Text) -> Parser TransitionState
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
"lastChangedBy")
      )

instance Prelude.Hashable TransitionState

instance Prelude.NFData TransitionState