{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.DisableStageTransition
-- 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)
--
-- Prevents artifacts in a pipeline from transitioning to the next stage in
-- the pipeline.
module Amazonka.CodePipeline.DisableStageTransition
  ( -- * Creating a Request
    DisableStageTransition (..),
    newDisableStageTransition,

    -- * Request Lenses
    disableStageTransition_pipelineName,
    disableStageTransition_stageName,
    disableStageTransition_transitionType,
    disableStageTransition_reason,

    -- * Destructuring the Response
    DisableStageTransitionResponse (..),
    newDisableStageTransitionResponse,
  )
where

import Amazonka.CodePipeline.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Represents the input of a @DisableStageTransition@ action.
--
-- /See:/ 'newDisableStageTransition' smart constructor.
data DisableStageTransition = DisableStageTransition'
  { -- | The name of the pipeline in which you want to disable the flow of
    -- artifacts from one stage to another.
    DisableStageTransition -> Text
pipelineName :: Prelude.Text,
    -- | The name of the stage where you want to disable the inbound or outbound
    -- transition of artifacts.
    DisableStageTransition -> Text
stageName :: Prelude.Text,
    -- | Specifies whether artifacts are prevented from transitioning into the
    -- stage and being processed by the actions in that stage (inbound), or
    -- prevented from transitioning from the stage after they have been
    -- processed by the actions in that stage (outbound).
    DisableStageTransition -> StageTransitionType
transitionType :: StageTransitionType,
    -- | The reason given to the user that a stage is disabled, such as waiting
    -- for manual approval or manual tests. This message is displayed in the
    -- pipeline console UI.
    DisableStageTransition -> Text
reason :: Prelude.Text
  }
  deriving (DisableStageTransition -> DisableStageTransition -> Bool
(DisableStageTransition -> DisableStageTransition -> Bool)
-> (DisableStageTransition -> DisableStageTransition -> Bool)
-> Eq DisableStageTransition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableStageTransition -> DisableStageTransition -> Bool
$c/= :: DisableStageTransition -> DisableStageTransition -> Bool
== :: DisableStageTransition -> DisableStageTransition -> Bool
$c== :: DisableStageTransition -> DisableStageTransition -> Bool
Prelude.Eq, ReadPrec [DisableStageTransition]
ReadPrec DisableStageTransition
Int -> ReadS DisableStageTransition
ReadS [DisableStageTransition]
(Int -> ReadS DisableStageTransition)
-> ReadS [DisableStageTransition]
-> ReadPrec DisableStageTransition
-> ReadPrec [DisableStageTransition]
-> Read DisableStageTransition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisableStageTransition]
$creadListPrec :: ReadPrec [DisableStageTransition]
readPrec :: ReadPrec DisableStageTransition
$creadPrec :: ReadPrec DisableStageTransition
readList :: ReadS [DisableStageTransition]
$creadList :: ReadS [DisableStageTransition]
readsPrec :: Int -> ReadS DisableStageTransition
$creadsPrec :: Int -> ReadS DisableStageTransition
Prelude.Read, Int -> DisableStageTransition -> ShowS
[DisableStageTransition] -> ShowS
DisableStageTransition -> String
(Int -> DisableStageTransition -> ShowS)
-> (DisableStageTransition -> String)
-> ([DisableStageTransition] -> ShowS)
-> Show DisableStageTransition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableStageTransition] -> ShowS
$cshowList :: [DisableStageTransition] -> ShowS
show :: DisableStageTransition -> String
$cshow :: DisableStageTransition -> String
showsPrec :: Int -> DisableStageTransition -> ShowS
$cshowsPrec :: Int -> DisableStageTransition -> ShowS
Prelude.Show, (forall x. DisableStageTransition -> Rep DisableStageTransition x)
-> (forall x.
    Rep DisableStageTransition x -> DisableStageTransition)
-> Generic DisableStageTransition
forall x. Rep DisableStageTransition x -> DisableStageTransition
forall x. DisableStageTransition -> Rep DisableStageTransition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisableStageTransition x -> DisableStageTransition
$cfrom :: forall x. DisableStageTransition -> Rep DisableStageTransition x
Prelude.Generic)

-- |
-- Create a value of 'DisableStageTransition' 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:
--
-- 'pipelineName', 'disableStageTransition_pipelineName' - The name of the pipeline in which you want to disable the flow of
-- artifacts from one stage to another.
--
-- 'stageName', 'disableStageTransition_stageName' - The name of the stage where you want to disable the inbound or outbound
-- transition of artifacts.
--
-- 'transitionType', 'disableStageTransition_transitionType' - Specifies whether artifacts are prevented from transitioning into the
-- stage and being processed by the actions in that stage (inbound), or
-- prevented from transitioning from the stage after they have been
-- processed by the actions in that stage (outbound).
--
-- 'reason', 'disableStageTransition_reason' - The reason given to the user that a stage is disabled, such as waiting
-- for manual approval or manual tests. This message is displayed in the
-- pipeline console UI.
newDisableStageTransition ::
  -- | 'pipelineName'
  Prelude.Text ->
  -- | 'stageName'
  Prelude.Text ->
  -- | 'transitionType'
  StageTransitionType ->
  -- | 'reason'
  Prelude.Text ->
  DisableStageTransition
newDisableStageTransition :: Text
-> Text -> StageTransitionType -> Text -> DisableStageTransition
newDisableStageTransition
  Text
pPipelineName_
  Text
pStageName_
  StageTransitionType
pTransitionType_
  Text
pReason_ =
    DisableStageTransition' :: Text
-> Text -> StageTransitionType -> Text -> DisableStageTransition
DisableStageTransition'
      { $sel:pipelineName:DisableStageTransition' :: Text
pipelineName =
          Text
pPipelineName_,
        $sel:stageName:DisableStageTransition' :: Text
stageName = Text
pStageName_,
        $sel:transitionType:DisableStageTransition' :: StageTransitionType
transitionType = StageTransitionType
pTransitionType_,
        $sel:reason:DisableStageTransition' :: Text
reason = Text
pReason_
      }

-- | The name of the pipeline in which you want to disable the flow of
-- artifacts from one stage to another.
disableStageTransition_pipelineName :: Lens.Lens' DisableStageTransition Prelude.Text
disableStageTransition_pipelineName :: (Text -> f Text)
-> DisableStageTransition -> f DisableStageTransition
disableStageTransition_pipelineName = (DisableStageTransition -> Text)
-> (DisableStageTransition -> Text -> DisableStageTransition)
-> Lens DisableStageTransition DisableStageTransition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableStageTransition' {Text
pipelineName :: Text
$sel:pipelineName:DisableStageTransition' :: DisableStageTransition -> Text
pipelineName} -> Text
pipelineName) (\s :: DisableStageTransition
s@DisableStageTransition' {} Text
a -> DisableStageTransition
s {$sel:pipelineName:DisableStageTransition' :: Text
pipelineName = Text
a} :: DisableStageTransition)

-- | The name of the stage where you want to disable the inbound or outbound
-- transition of artifacts.
disableStageTransition_stageName :: Lens.Lens' DisableStageTransition Prelude.Text
disableStageTransition_stageName :: (Text -> f Text)
-> DisableStageTransition -> f DisableStageTransition
disableStageTransition_stageName = (DisableStageTransition -> Text)
-> (DisableStageTransition -> Text -> DisableStageTransition)
-> Lens DisableStageTransition DisableStageTransition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableStageTransition' {Text
stageName :: Text
$sel:stageName:DisableStageTransition' :: DisableStageTransition -> Text
stageName} -> Text
stageName) (\s :: DisableStageTransition
s@DisableStageTransition' {} Text
a -> DisableStageTransition
s {$sel:stageName:DisableStageTransition' :: Text
stageName = Text
a} :: DisableStageTransition)

-- | Specifies whether artifacts are prevented from transitioning into the
-- stage and being processed by the actions in that stage (inbound), or
-- prevented from transitioning from the stage after they have been
-- processed by the actions in that stage (outbound).
disableStageTransition_transitionType :: Lens.Lens' DisableStageTransition StageTransitionType
disableStageTransition_transitionType :: (StageTransitionType -> f StageTransitionType)
-> DisableStageTransition -> f DisableStageTransition
disableStageTransition_transitionType = (DisableStageTransition -> StageTransitionType)
-> (DisableStageTransition
    -> StageTransitionType -> DisableStageTransition)
-> Lens
     DisableStageTransition
     DisableStageTransition
     StageTransitionType
     StageTransitionType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableStageTransition' {StageTransitionType
transitionType :: StageTransitionType
$sel:transitionType:DisableStageTransition' :: DisableStageTransition -> StageTransitionType
transitionType} -> StageTransitionType
transitionType) (\s :: DisableStageTransition
s@DisableStageTransition' {} StageTransitionType
a -> DisableStageTransition
s {$sel:transitionType:DisableStageTransition' :: StageTransitionType
transitionType = StageTransitionType
a} :: DisableStageTransition)

-- | The reason given to the user that a stage is disabled, such as waiting
-- for manual approval or manual tests. This message is displayed in the
-- pipeline console UI.
disableStageTransition_reason :: Lens.Lens' DisableStageTransition Prelude.Text
disableStageTransition_reason :: (Text -> f Text)
-> DisableStageTransition -> f DisableStageTransition
disableStageTransition_reason = (DisableStageTransition -> Text)
-> (DisableStageTransition -> Text -> DisableStageTransition)
-> Lens DisableStageTransition DisableStageTransition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableStageTransition' {Text
reason :: Text
$sel:reason:DisableStageTransition' :: DisableStageTransition -> Text
reason} -> Text
reason) (\s :: DisableStageTransition
s@DisableStageTransition' {} Text
a -> DisableStageTransition
s {$sel:reason:DisableStageTransition' :: Text
reason = Text
a} :: DisableStageTransition)

instance Core.AWSRequest DisableStageTransition where
  type
    AWSResponse DisableStageTransition =
      DisableStageTransitionResponse
  request :: DisableStageTransition -> Request DisableStageTransition
request = Service -> DisableStageTransition -> Request DisableStageTransition
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DisableStageTransition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisableStageTransition)))
response =
    AWSResponse DisableStageTransition
-> Logger
-> Service
-> Proxy DisableStageTransition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisableStageTransition)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse DisableStageTransition
DisableStageTransitionResponse
DisableStageTransitionResponse'

instance Prelude.Hashable DisableStageTransition

instance Prelude.NFData DisableStageTransition

instance Core.ToHeaders DisableStageTransition where
  toHeaders :: DisableStageTransition -> [Header]
toHeaders =
    [Header] -> DisableStageTransition -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"CodePipeline_20150709.DisableStageTransition" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DisableStageTransition where
  toJSON :: DisableStageTransition -> Value
toJSON DisableStageTransition' {Text
StageTransitionType
reason :: Text
transitionType :: StageTransitionType
stageName :: Text
pipelineName :: Text
$sel:reason:DisableStageTransition' :: DisableStageTransition -> Text
$sel:transitionType:DisableStageTransition' :: DisableStageTransition -> StageTransitionType
$sel:stageName:DisableStageTransition' :: DisableStageTransition -> Text
$sel:pipelineName:DisableStageTransition' :: DisableStageTransition -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"pipelineName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
pipelineName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"stageName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
stageName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"transitionType" Text -> StageTransitionType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= StageTransitionType
transitionType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"reason" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
reason)
          ]
      )

instance Core.ToPath DisableStageTransition where
  toPath :: DisableStageTransition -> ByteString
toPath = ByteString -> DisableStageTransition -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery DisableStageTransition where
  toQuery :: DisableStageTransition -> QueryString
toQuery = QueryString -> DisableStageTransition -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newDisableStageTransitionResponse' smart constructor.
data DisableStageTransitionResponse = DisableStageTransitionResponse'
  {
  }
  deriving (DisableStageTransitionResponse
-> DisableStageTransitionResponse -> Bool
(DisableStageTransitionResponse
 -> DisableStageTransitionResponse -> Bool)
-> (DisableStageTransitionResponse
    -> DisableStageTransitionResponse -> Bool)
-> Eq DisableStageTransitionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableStageTransitionResponse
-> DisableStageTransitionResponse -> Bool
$c/= :: DisableStageTransitionResponse
-> DisableStageTransitionResponse -> Bool
== :: DisableStageTransitionResponse
-> DisableStageTransitionResponse -> Bool
$c== :: DisableStageTransitionResponse
-> DisableStageTransitionResponse -> Bool
Prelude.Eq, ReadPrec [DisableStageTransitionResponse]
ReadPrec DisableStageTransitionResponse
Int -> ReadS DisableStageTransitionResponse
ReadS [DisableStageTransitionResponse]
(Int -> ReadS DisableStageTransitionResponse)
-> ReadS [DisableStageTransitionResponse]
-> ReadPrec DisableStageTransitionResponse
-> ReadPrec [DisableStageTransitionResponse]
-> Read DisableStageTransitionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisableStageTransitionResponse]
$creadListPrec :: ReadPrec [DisableStageTransitionResponse]
readPrec :: ReadPrec DisableStageTransitionResponse
$creadPrec :: ReadPrec DisableStageTransitionResponse
readList :: ReadS [DisableStageTransitionResponse]
$creadList :: ReadS [DisableStageTransitionResponse]
readsPrec :: Int -> ReadS DisableStageTransitionResponse
$creadsPrec :: Int -> ReadS DisableStageTransitionResponse
Prelude.Read, Int -> DisableStageTransitionResponse -> ShowS
[DisableStageTransitionResponse] -> ShowS
DisableStageTransitionResponse -> String
(Int -> DisableStageTransitionResponse -> ShowS)
-> (DisableStageTransitionResponse -> String)
-> ([DisableStageTransitionResponse] -> ShowS)
-> Show DisableStageTransitionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableStageTransitionResponse] -> ShowS
$cshowList :: [DisableStageTransitionResponse] -> ShowS
show :: DisableStageTransitionResponse -> String
$cshow :: DisableStageTransitionResponse -> String
showsPrec :: Int -> DisableStageTransitionResponse -> ShowS
$cshowsPrec :: Int -> DisableStageTransitionResponse -> ShowS
Prelude.Show, (forall x.
 DisableStageTransitionResponse
 -> Rep DisableStageTransitionResponse x)
-> (forall x.
    Rep DisableStageTransitionResponse x
    -> DisableStageTransitionResponse)
-> Generic DisableStageTransitionResponse
forall x.
Rep DisableStageTransitionResponse x
-> DisableStageTransitionResponse
forall x.
DisableStageTransitionResponse
-> Rep DisableStageTransitionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisableStageTransitionResponse x
-> DisableStageTransitionResponse
$cfrom :: forall x.
DisableStageTransitionResponse
-> Rep DisableStageTransitionResponse x
Prelude.Generic)

-- |
-- Create a value of 'DisableStageTransitionResponse' 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.
newDisableStageTransitionResponse ::
  DisableStageTransitionResponse
newDisableStageTransitionResponse :: DisableStageTransitionResponse
newDisableStageTransitionResponse =
  DisableStageTransitionResponse
DisableStageTransitionResponse'

instance
  Prelude.NFData
    DisableStageTransitionResponse