{-# 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.Proton.CancelServicePipelineDeployment
-- 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)
--
-- Attempts to cancel a service pipeline deployment on an
-- UpdateServicePipeline action, if the deployment is @IN_PROGRESS@. For
-- more information, see /Update a service pipeline/ in the
-- <https://docs.aws.amazon.com/proton/latest/adminguide/ag-svc-pipeline-update.html AWS Proton Administrator guide>
-- or the
-- <https://docs.aws.amazon.com/proton/latest/userguide/ug-svc-pipeline-update.html AWS Proton User guide>.
--
-- The following list includes potential cancellation scenarios.
--
-- -   If the cancellation attempt succeeds, the resulting deployment state
--     is @CANCELLED@.
--
-- -   If the cancellation attempt fails, the resulting deployment state is
--     @FAILED@.
--
-- -   If the current UpdateServicePipeline action succeeds before the
--     cancellation attempt starts, the resulting deployment state is
--     @SUCCEEDED@ and the cancellation attempt has no effect.
module Amazonka.Proton.CancelServicePipelineDeployment
  ( -- * Creating a Request
    CancelServicePipelineDeployment (..),
    newCancelServicePipelineDeployment,

    -- * Request Lenses
    cancelServicePipelineDeployment_serviceName,

    -- * Destructuring the Response
    CancelServicePipelineDeploymentResponse (..),
    newCancelServicePipelineDeploymentResponse,

    -- * Response Lenses
    cancelServicePipelineDeploymentResponse_httpStatus,
    cancelServicePipelineDeploymentResponse_pipeline,
  )
where

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

-- | /See:/ 'newCancelServicePipelineDeployment' smart constructor.
data CancelServicePipelineDeployment = CancelServicePipelineDeployment'
  { -- | The name of the service with the service pipeline deployment to cancel.
    CancelServicePipelineDeployment -> Text
serviceName :: Prelude.Text
  }
  deriving (CancelServicePipelineDeployment
-> CancelServicePipelineDeployment -> Bool
(CancelServicePipelineDeployment
 -> CancelServicePipelineDeployment -> Bool)
-> (CancelServicePipelineDeployment
    -> CancelServicePipelineDeployment -> Bool)
-> Eq CancelServicePipelineDeployment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelServicePipelineDeployment
-> CancelServicePipelineDeployment -> Bool
$c/= :: CancelServicePipelineDeployment
-> CancelServicePipelineDeployment -> Bool
== :: CancelServicePipelineDeployment
-> CancelServicePipelineDeployment -> Bool
$c== :: CancelServicePipelineDeployment
-> CancelServicePipelineDeployment -> Bool
Prelude.Eq, ReadPrec [CancelServicePipelineDeployment]
ReadPrec CancelServicePipelineDeployment
Int -> ReadS CancelServicePipelineDeployment
ReadS [CancelServicePipelineDeployment]
(Int -> ReadS CancelServicePipelineDeployment)
-> ReadS [CancelServicePipelineDeployment]
-> ReadPrec CancelServicePipelineDeployment
-> ReadPrec [CancelServicePipelineDeployment]
-> Read CancelServicePipelineDeployment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelServicePipelineDeployment]
$creadListPrec :: ReadPrec [CancelServicePipelineDeployment]
readPrec :: ReadPrec CancelServicePipelineDeployment
$creadPrec :: ReadPrec CancelServicePipelineDeployment
readList :: ReadS [CancelServicePipelineDeployment]
$creadList :: ReadS [CancelServicePipelineDeployment]
readsPrec :: Int -> ReadS CancelServicePipelineDeployment
$creadsPrec :: Int -> ReadS CancelServicePipelineDeployment
Prelude.Read, Int -> CancelServicePipelineDeployment -> ShowS
[CancelServicePipelineDeployment] -> ShowS
CancelServicePipelineDeployment -> String
(Int -> CancelServicePipelineDeployment -> ShowS)
-> (CancelServicePipelineDeployment -> String)
-> ([CancelServicePipelineDeployment] -> ShowS)
-> Show CancelServicePipelineDeployment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelServicePipelineDeployment] -> ShowS
$cshowList :: [CancelServicePipelineDeployment] -> ShowS
show :: CancelServicePipelineDeployment -> String
$cshow :: CancelServicePipelineDeployment -> String
showsPrec :: Int -> CancelServicePipelineDeployment -> ShowS
$cshowsPrec :: Int -> CancelServicePipelineDeployment -> ShowS
Prelude.Show, (forall x.
 CancelServicePipelineDeployment
 -> Rep CancelServicePipelineDeployment x)
-> (forall x.
    Rep CancelServicePipelineDeployment x
    -> CancelServicePipelineDeployment)
-> Generic CancelServicePipelineDeployment
forall x.
Rep CancelServicePipelineDeployment x
-> CancelServicePipelineDeployment
forall x.
CancelServicePipelineDeployment
-> Rep CancelServicePipelineDeployment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CancelServicePipelineDeployment x
-> CancelServicePipelineDeployment
$cfrom :: forall x.
CancelServicePipelineDeployment
-> Rep CancelServicePipelineDeployment x
Prelude.Generic)

-- |
-- Create a value of 'CancelServicePipelineDeployment' 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:
--
-- 'serviceName', 'cancelServicePipelineDeployment_serviceName' - The name of the service with the service pipeline deployment to cancel.
newCancelServicePipelineDeployment ::
  -- | 'serviceName'
  Prelude.Text ->
  CancelServicePipelineDeployment
newCancelServicePipelineDeployment :: Text -> CancelServicePipelineDeployment
newCancelServicePipelineDeployment Text
pServiceName_ =
  CancelServicePipelineDeployment' :: Text -> CancelServicePipelineDeployment
CancelServicePipelineDeployment'
    { $sel:serviceName:CancelServicePipelineDeployment' :: Text
serviceName =
        Text
pServiceName_
    }

-- | The name of the service with the service pipeline deployment to cancel.
cancelServicePipelineDeployment_serviceName :: Lens.Lens' CancelServicePipelineDeployment Prelude.Text
cancelServicePipelineDeployment_serviceName :: (Text -> f Text)
-> CancelServicePipelineDeployment
-> f CancelServicePipelineDeployment
cancelServicePipelineDeployment_serviceName = (CancelServicePipelineDeployment -> Text)
-> (CancelServicePipelineDeployment
    -> Text -> CancelServicePipelineDeployment)
-> Lens
     CancelServicePipelineDeployment
     CancelServicePipelineDeployment
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelServicePipelineDeployment' {Text
serviceName :: Text
$sel:serviceName:CancelServicePipelineDeployment' :: CancelServicePipelineDeployment -> Text
serviceName} -> Text
serviceName) (\s :: CancelServicePipelineDeployment
s@CancelServicePipelineDeployment' {} Text
a -> CancelServicePipelineDeployment
s {$sel:serviceName:CancelServicePipelineDeployment' :: Text
serviceName = Text
a} :: CancelServicePipelineDeployment)

instance
  Core.AWSRequest
    CancelServicePipelineDeployment
  where
  type
    AWSResponse CancelServicePipelineDeployment =
      CancelServicePipelineDeploymentResponse
  request :: CancelServicePipelineDeployment
-> Request CancelServicePipelineDeployment
request = Service
-> CancelServicePipelineDeployment
-> Request CancelServicePipelineDeployment
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CancelServicePipelineDeployment
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse CancelServicePipelineDeployment)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CancelServicePipelineDeployment))
-> Logger
-> Service
-> Proxy CancelServicePipelineDeployment
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse CancelServicePipelineDeployment)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> ServicePipeline -> CancelServicePipelineDeploymentResponse
CancelServicePipelineDeploymentResponse'
            (Int -> ServicePipeline -> CancelServicePipelineDeploymentResponse)
-> Either String Int
-> Either
     String (ServicePipeline -> CancelServicePipelineDeploymentResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either
  String (ServicePipeline -> CancelServicePipelineDeploymentResponse)
-> Either String ServicePipeline
-> Either String CancelServicePipelineDeploymentResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String ServicePipeline
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"pipeline")
      )

instance
  Prelude.Hashable
    CancelServicePipelineDeployment

instance
  Prelude.NFData
    CancelServicePipelineDeployment

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

instance Core.ToJSON CancelServicePipelineDeployment where
  toJSON :: CancelServicePipelineDeployment -> Value
toJSON CancelServicePipelineDeployment' {Text
serviceName :: Text
$sel:serviceName:CancelServicePipelineDeployment' :: CancelServicePipelineDeployment -> 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
"serviceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
serviceName)]
      )

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

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

-- | /See:/ 'newCancelServicePipelineDeploymentResponse' smart constructor.
data CancelServicePipelineDeploymentResponse = CancelServicePipelineDeploymentResponse'
  { -- | The response's http status code.
    CancelServicePipelineDeploymentResponse -> Int
httpStatus :: Prelude.Int,
    -- | The service pipeline detail data that\'s returned by AWS Proton.
    CancelServicePipelineDeploymentResponse -> ServicePipeline
pipeline :: ServicePipeline
  }
  deriving (CancelServicePipelineDeploymentResponse
-> CancelServicePipelineDeploymentResponse -> Bool
(CancelServicePipelineDeploymentResponse
 -> CancelServicePipelineDeploymentResponse -> Bool)
-> (CancelServicePipelineDeploymentResponse
    -> CancelServicePipelineDeploymentResponse -> Bool)
-> Eq CancelServicePipelineDeploymentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelServicePipelineDeploymentResponse
-> CancelServicePipelineDeploymentResponse -> Bool
$c/= :: CancelServicePipelineDeploymentResponse
-> CancelServicePipelineDeploymentResponse -> Bool
== :: CancelServicePipelineDeploymentResponse
-> CancelServicePipelineDeploymentResponse -> Bool
$c== :: CancelServicePipelineDeploymentResponse
-> CancelServicePipelineDeploymentResponse -> Bool
Prelude.Eq, Int -> CancelServicePipelineDeploymentResponse -> ShowS
[CancelServicePipelineDeploymentResponse] -> ShowS
CancelServicePipelineDeploymentResponse -> String
(Int -> CancelServicePipelineDeploymentResponse -> ShowS)
-> (CancelServicePipelineDeploymentResponse -> String)
-> ([CancelServicePipelineDeploymentResponse] -> ShowS)
-> Show CancelServicePipelineDeploymentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelServicePipelineDeploymentResponse] -> ShowS
$cshowList :: [CancelServicePipelineDeploymentResponse] -> ShowS
show :: CancelServicePipelineDeploymentResponse -> String
$cshow :: CancelServicePipelineDeploymentResponse -> String
showsPrec :: Int -> CancelServicePipelineDeploymentResponse -> ShowS
$cshowsPrec :: Int -> CancelServicePipelineDeploymentResponse -> ShowS
Prelude.Show, (forall x.
 CancelServicePipelineDeploymentResponse
 -> Rep CancelServicePipelineDeploymentResponse x)
-> (forall x.
    Rep CancelServicePipelineDeploymentResponse x
    -> CancelServicePipelineDeploymentResponse)
-> Generic CancelServicePipelineDeploymentResponse
forall x.
Rep CancelServicePipelineDeploymentResponse x
-> CancelServicePipelineDeploymentResponse
forall x.
CancelServicePipelineDeploymentResponse
-> Rep CancelServicePipelineDeploymentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CancelServicePipelineDeploymentResponse x
-> CancelServicePipelineDeploymentResponse
$cfrom :: forall x.
CancelServicePipelineDeploymentResponse
-> Rep CancelServicePipelineDeploymentResponse x
Prelude.Generic)

-- |
-- Create a value of 'CancelServicePipelineDeploymentResponse' 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:
--
-- 'httpStatus', 'cancelServicePipelineDeploymentResponse_httpStatus' - The response's http status code.
--
-- 'pipeline', 'cancelServicePipelineDeploymentResponse_pipeline' - The service pipeline detail data that\'s returned by AWS Proton.
newCancelServicePipelineDeploymentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'pipeline'
  ServicePipeline ->
  CancelServicePipelineDeploymentResponse
newCancelServicePipelineDeploymentResponse :: Int -> ServicePipeline -> CancelServicePipelineDeploymentResponse
newCancelServicePipelineDeploymentResponse
  Int
pHttpStatus_
  ServicePipeline
pPipeline_ =
    CancelServicePipelineDeploymentResponse' :: Int -> ServicePipeline -> CancelServicePipelineDeploymentResponse
CancelServicePipelineDeploymentResponse'
      { $sel:httpStatus:CancelServicePipelineDeploymentResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:pipeline:CancelServicePipelineDeploymentResponse' :: ServicePipeline
pipeline = ServicePipeline
pPipeline_
      }

-- | The response's http status code.
cancelServicePipelineDeploymentResponse_httpStatus :: Lens.Lens' CancelServicePipelineDeploymentResponse Prelude.Int
cancelServicePipelineDeploymentResponse_httpStatus :: (Int -> f Int)
-> CancelServicePipelineDeploymentResponse
-> f CancelServicePipelineDeploymentResponse
cancelServicePipelineDeploymentResponse_httpStatus = (CancelServicePipelineDeploymentResponse -> Int)
-> (CancelServicePipelineDeploymentResponse
    -> Int -> CancelServicePipelineDeploymentResponse)
-> Lens
     CancelServicePipelineDeploymentResponse
     CancelServicePipelineDeploymentResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelServicePipelineDeploymentResponse' {Int
httpStatus :: Int
$sel:httpStatus:CancelServicePipelineDeploymentResponse' :: CancelServicePipelineDeploymentResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CancelServicePipelineDeploymentResponse
s@CancelServicePipelineDeploymentResponse' {} Int
a -> CancelServicePipelineDeploymentResponse
s {$sel:httpStatus:CancelServicePipelineDeploymentResponse' :: Int
httpStatus = Int
a} :: CancelServicePipelineDeploymentResponse)

-- | The service pipeline detail data that\'s returned by AWS Proton.
cancelServicePipelineDeploymentResponse_pipeline :: Lens.Lens' CancelServicePipelineDeploymentResponse ServicePipeline
cancelServicePipelineDeploymentResponse_pipeline :: (ServicePipeline -> f ServicePipeline)
-> CancelServicePipelineDeploymentResponse
-> f CancelServicePipelineDeploymentResponse
cancelServicePipelineDeploymentResponse_pipeline = (CancelServicePipelineDeploymentResponse -> ServicePipeline)
-> (CancelServicePipelineDeploymentResponse
    -> ServicePipeline -> CancelServicePipelineDeploymentResponse)
-> Lens
     CancelServicePipelineDeploymentResponse
     CancelServicePipelineDeploymentResponse
     ServicePipeline
     ServicePipeline
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelServicePipelineDeploymentResponse' {ServicePipeline
pipeline :: ServicePipeline
$sel:pipeline:CancelServicePipelineDeploymentResponse' :: CancelServicePipelineDeploymentResponse -> ServicePipeline
pipeline} -> ServicePipeline
pipeline) (\s :: CancelServicePipelineDeploymentResponse
s@CancelServicePipelineDeploymentResponse' {} ServicePipeline
a -> CancelServicePipelineDeploymentResponse
s {$sel:pipeline:CancelServicePipelineDeploymentResponse' :: ServicePipeline
pipeline = ServicePipeline
a} :: CancelServicePipelineDeploymentResponse)

instance
  Prelude.NFData
    CancelServicePipelineDeploymentResponse