{-# 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.EnableStageTransition
-- 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)
--
-- Enables artifacts in a pipeline to transition to a stage in a pipeline.
module Amazonka.CodePipeline.EnableStageTransition
  ( -- * Creating a Request
    EnableStageTransition (..),
    newEnableStageTransition,

    -- * Request Lenses
    enableStageTransition_pipelineName,
    enableStageTransition_stageName,
    enableStageTransition_transitionType,

    -- * Destructuring the Response
    EnableStageTransitionResponse (..),
    newEnableStageTransitionResponse,
  )
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 an @EnableStageTransition@ action.
--
-- /See:/ 'newEnableStageTransition' smart constructor.
data EnableStageTransition = EnableStageTransition'
  { -- | The name of the pipeline in which you want to enable the flow of
    -- artifacts from one stage to another.
    EnableStageTransition -> Text
pipelineName :: Prelude.Text,
    -- | The name of the stage where you want to enable the transition of
    -- artifacts, either into the stage (inbound) or from that stage to the
    -- next stage (outbound).
    EnableStageTransition -> Text
stageName :: Prelude.Text,
    -- | Specifies whether artifacts are allowed to enter the stage and be
    -- processed by the actions in that stage (inbound) or whether already
    -- processed artifacts are allowed to transition to the next stage
    -- (outbound).
    EnableStageTransition -> StageTransitionType
transitionType :: StageTransitionType
  }
  deriving (EnableStageTransition -> EnableStageTransition -> Bool
(EnableStageTransition -> EnableStageTransition -> Bool)
-> (EnableStageTransition -> EnableStageTransition -> Bool)
-> Eq EnableStageTransition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnableStageTransition -> EnableStageTransition -> Bool
$c/= :: EnableStageTransition -> EnableStageTransition -> Bool
== :: EnableStageTransition -> EnableStageTransition -> Bool
$c== :: EnableStageTransition -> EnableStageTransition -> Bool
Prelude.Eq, ReadPrec [EnableStageTransition]
ReadPrec EnableStageTransition
Int -> ReadS EnableStageTransition
ReadS [EnableStageTransition]
(Int -> ReadS EnableStageTransition)
-> ReadS [EnableStageTransition]
-> ReadPrec EnableStageTransition
-> ReadPrec [EnableStageTransition]
-> Read EnableStageTransition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnableStageTransition]
$creadListPrec :: ReadPrec [EnableStageTransition]
readPrec :: ReadPrec EnableStageTransition
$creadPrec :: ReadPrec EnableStageTransition
readList :: ReadS [EnableStageTransition]
$creadList :: ReadS [EnableStageTransition]
readsPrec :: Int -> ReadS EnableStageTransition
$creadsPrec :: Int -> ReadS EnableStageTransition
Prelude.Read, Int -> EnableStageTransition -> ShowS
[EnableStageTransition] -> ShowS
EnableStageTransition -> String
(Int -> EnableStageTransition -> ShowS)
-> (EnableStageTransition -> String)
-> ([EnableStageTransition] -> ShowS)
-> Show EnableStageTransition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnableStageTransition] -> ShowS
$cshowList :: [EnableStageTransition] -> ShowS
show :: EnableStageTransition -> String
$cshow :: EnableStageTransition -> String
showsPrec :: Int -> EnableStageTransition -> ShowS
$cshowsPrec :: Int -> EnableStageTransition -> ShowS
Prelude.Show, (forall x. EnableStageTransition -> Rep EnableStageTransition x)
-> (forall x. Rep EnableStageTransition x -> EnableStageTransition)
-> Generic EnableStageTransition
forall x. Rep EnableStageTransition x -> EnableStageTransition
forall x. EnableStageTransition -> Rep EnableStageTransition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnableStageTransition x -> EnableStageTransition
$cfrom :: forall x. EnableStageTransition -> Rep EnableStageTransition x
Prelude.Generic)

-- |
-- Create a value of 'EnableStageTransition' 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', 'enableStageTransition_pipelineName' - The name of the pipeline in which you want to enable the flow of
-- artifacts from one stage to another.
--
-- 'stageName', 'enableStageTransition_stageName' - The name of the stage where you want to enable the transition of
-- artifacts, either into the stage (inbound) or from that stage to the
-- next stage (outbound).
--
-- 'transitionType', 'enableStageTransition_transitionType' - Specifies whether artifacts are allowed to enter the stage and be
-- processed by the actions in that stage (inbound) or whether already
-- processed artifacts are allowed to transition to the next stage
-- (outbound).
newEnableStageTransition ::
  -- | 'pipelineName'
  Prelude.Text ->
  -- | 'stageName'
  Prelude.Text ->
  -- | 'transitionType'
  StageTransitionType ->
  EnableStageTransition
newEnableStageTransition :: Text -> Text -> StageTransitionType -> EnableStageTransition
newEnableStageTransition
  Text
pPipelineName_
  Text
pStageName_
  StageTransitionType
pTransitionType_ =
    EnableStageTransition' :: Text -> Text -> StageTransitionType -> EnableStageTransition
EnableStageTransition'
      { $sel:pipelineName:EnableStageTransition' :: Text
pipelineName =
          Text
pPipelineName_,
        $sel:stageName:EnableStageTransition' :: Text
stageName = Text
pStageName_,
        $sel:transitionType:EnableStageTransition' :: StageTransitionType
transitionType = StageTransitionType
pTransitionType_
      }

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

-- | The name of the stage where you want to enable the transition of
-- artifacts, either into the stage (inbound) or from that stage to the
-- next stage (outbound).
enableStageTransition_stageName :: Lens.Lens' EnableStageTransition Prelude.Text
enableStageTransition_stageName :: (Text -> f Text)
-> EnableStageTransition -> f EnableStageTransition
enableStageTransition_stageName = (EnableStageTransition -> Text)
-> (EnableStageTransition -> Text -> EnableStageTransition)
-> Lens EnableStageTransition EnableStageTransition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableStageTransition' {Text
stageName :: Text
$sel:stageName:EnableStageTransition' :: EnableStageTransition -> Text
stageName} -> Text
stageName) (\s :: EnableStageTransition
s@EnableStageTransition' {} Text
a -> EnableStageTransition
s {$sel:stageName:EnableStageTransition' :: Text
stageName = Text
a} :: EnableStageTransition)

-- | Specifies whether artifacts are allowed to enter the stage and be
-- processed by the actions in that stage (inbound) or whether already
-- processed artifacts are allowed to transition to the next stage
-- (outbound).
enableStageTransition_transitionType :: Lens.Lens' EnableStageTransition StageTransitionType
enableStageTransition_transitionType :: (StageTransitionType -> f StageTransitionType)
-> EnableStageTransition -> f EnableStageTransition
enableStageTransition_transitionType = (EnableStageTransition -> StageTransitionType)
-> (EnableStageTransition
    -> StageTransitionType -> EnableStageTransition)
-> Lens
     EnableStageTransition
     EnableStageTransition
     StageTransitionType
     StageTransitionType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableStageTransition' {StageTransitionType
transitionType :: StageTransitionType
$sel:transitionType:EnableStageTransition' :: EnableStageTransition -> StageTransitionType
transitionType} -> StageTransitionType
transitionType) (\s :: EnableStageTransition
s@EnableStageTransition' {} StageTransitionType
a -> EnableStageTransition
s {$sel:transitionType:EnableStageTransition' :: StageTransitionType
transitionType = StageTransitionType
a} :: EnableStageTransition)

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

instance Prelude.Hashable EnableStageTransition

instance Prelude.NFData EnableStageTransition

instance Core.ToHeaders EnableStageTransition where
  toHeaders :: EnableStageTransition -> [Header]
toHeaders =
    [Header] -> EnableStageTransition -> [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.EnableStageTransition" ::
                          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 EnableStageTransition where
  toJSON :: EnableStageTransition -> Value
toJSON EnableStageTransition' {Text
StageTransitionType
transitionType :: StageTransitionType
stageName :: Text
pipelineName :: Text
$sel:transitionType:EnableStageTransition' :: EnableStageTransition -> StageTransitionType
$sel:stageName:EnableStageTransition' :: EnableStageTransition -> Text
$sel:pipelineName:EnableStageTransition' :: EnableStageTransition -> 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)
          ]
      )

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

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

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

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

instance Prelude.NFData EnableStageTransitionResponse