{-# 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-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.TransitionState 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 information about the state of transitions between one stage
-- and another stage.
--
-- /See:/ 'newTransitionState' smart constructor.
data TransitionState = TransitionState'
  { -- | The user-specified reason why the transition between two stages of a
    -- pipeline was disabled.
    TransitionState -> Maybe Text
disabledReason :: Prelude.Maybe Prelude.Text,
    -- | Whether the transition between stages is enabled (true) or disabled
    -- (false).
    TransitionState -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | The timestamp when the transition state was last changed.
    TransitionState -> Maybe POSIX
lastChangedAt :: Prelude.Maybe Data.POSIX,
    -- | The ID of the user who last changed the transition state.
    TransitionState -> Maybe Text
lastChangedBy :: Prelude.Maybe Prelude.Text
  }
  deriving (TransitionState -> TransitionState -> Bool
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]
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
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. 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:
--
-- 'disabledReason', 'transitionState_disabledReason' - The user-specified reason why the transition between two stages of a
-- pipeline was disabled.
--
-- 'enabled', 'transitionState_enabled' - Whether the transition between stages is enabled (true) or disabled
-- (false).
--
-- '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'
    { $sel:disabledReason:TransitionState' :: Maybe Text
disabledReason = forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:TransitionState' :: Maybe Bool
enabled = forall a. Maybe a
Prelude.Nothing,
      $sel:lastChangedAt:TransitionState' :: Maybe POSIX
lastChangedAt = forall a. Maybe a
Prelude.Nothing,
      $sel:lastChangedBy:TransitionState' :: Maybe Text
lastChangedBy = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' TransitionState (Maybe Text)
transitionState_disabledReason = 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)

-- | Whether the transition between stages is enabled (true) or disabled
-- (false).
transitionState_enabled :: Lens.Lens' TransitionState (Prelude.Maybe Prelude.Bool)
transitionState_enabled :: Lens' TransitionState (Maybe Bool)
transitionState_enabled = 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 timestamp when the transition state was last changed.
transitionState_lastChangedAt :: Lens.Lens' TransitionState (Prelude.Maybe Prelude.UTCTime)
transitionState_lastChangedAt :: Lens' TransitionState (Maybe UTCTime)
transitionState_lastChangedAt = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The ID of the user who last changed the transition state.
transitionState_lastChangedBy :: Lens.Lens' TransitionState (Prelude.Maybe Prelude.Text)
transitionState_lastChangedBy :: Lens' TransitionState (Maybe Text)
transitionState_lastChangedBy = 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 Data.FromJSON TransitionState where
  parseJSON :: Value -> Parser TransitionState
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TransitionState"
      ( \Object
x ->
          Maybe Text
-> Maybe Bool -> Maybe POSIX -> Maybe Text -> TransitionState
TransitionState'
            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
"disabledReason")
            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
"enabled")
            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
"lastChangedAt")
            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
"lastChangedBy")
      )

instance Prelude.Hashable TransitionState where
  hashWithSalt :: Int -> TransitionState -> Int
hashWithSalt Int
_salt TransitionState' {Maybe Bool
Maybe Text
Maybe POSIX
lastChangedBy :: Maybe Text
lastChangedAt :: Maybe POSIX
enabled :: Maybe Bool
disabledReason :: Maybe Text
$sel:lastChangedBy:TransitionState' :: TransitionState -> Maybe Text
$sel:lastChangedAt:TransitionState' :: TransitionState -> Maybe POSIX
$sel:enabled:TransitionState' :: TransitionState -> Maybe Bool
$sel:disabledReason:TransitionState' :: TransitionState -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
disabledReason
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastChangedAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
lastChangedBy

instance Prelude.NFData TransitionState where
  rnf :: TransitionState -> ()
rnf TransitionState' {Maybe Bool
Maybe Text
Maybe POSIX
lastChangedBy :: Maybe Text
lastChangedAt :: Maybe POSIX
enabled :: Maybe Bool
disabledReason :: Maybe Text
$sel:lastChangedBy:TransitionState' :: TransitionState -> Maybe Text
$sel:lastChangedAt:TransitionState' :: TransitionState -> Maybe POSIX
$sel:enabled:TransitionState' :: TransitionState -> Maybe Bool
$sel:disabledReason:TransitionState' :: TransitionState -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
disabledReason
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastChangedAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
lastChangedBy