{-# 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.CancelComponentDeployment
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Attempts to cancel a component deployment (for a component that is in
-- the @IN_PROGRESS@ deployment status).
--
-- For more information about components, see
-- <https://docs.aws.amazon.com/proton/latest/userguide/ag-components.html Proton components>
-- in the /Proton User Guide/.
module Amazonka.Proton.CancelComponentDeployment
  ( -- * Creating a Request
    CancelComponentDeployment (..),
    newCancelComponentDeployment,

    -- * Request Lenses
    cancelComponentDeployment_componentName,

    -- * Destructuring the Response
    CancelComponentDeploymentResponse (..),
    newCancelComponentDeploymentResponse,

    -- * Response Lenses
    cancelComponentDeploymentResponse_httpStatus,
    cancelComponentDeploymentResponse_component,
  )
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
import Amazonka.Proton.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

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

-- |
-- Create a value of 'CancelComponentDeployment' 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:
--
-- 'componentName', 'cancelComponentDeployment_componentName' - The name of the component with the deployment to cancel.
newCancelComponentDeployment ::
  -- | 'componentName'
  Prelude.Text ->
  CancelComponentDeployment
newCancelComponentDeployment :: Text -> CancelComponentDeployment
newCancelComponentDeployment Text
pComponentName_ =
  CancelComponentDeployment'
    { $sel:componentName:CancelComponentDeployment' :: Text
componentName =
        Text
pComponentName_
    }

-- | The name of the component with the deployment to cancel.
cancelComponentDeployment_componentName :: Lens.Lens' CancelComponentDeployment Prelude.Text
cancelComponentDeployment_componentName :: Lens' CancelComponentDeployment Text
cancelComponentDeployment_componentName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelComponentDeployment' {Text
componentName :: Text
$sel:componentName:CancelComponentDeployment' :: CancelComponentDeployment -> Text
componentName} -> Text
componentName) (\s :: CancelComponentDeployment
s@CancelComponentDeployment' {} Text
a -> CancelComponentDeployment
s {$sel:componentName:CancelComponentDeployment' :: Text
componentName = Text
a} :: CancelComponentDeployment)

instance Core.AWSRequest CancelComponentDeployment where
  type
    AWSResponse CancelComponentDeployment =
      CancelComponentDeploymentResponse
  request :: (Service -> Service)
-> CancelComponentDeployment -> Request CancelComponentDeployment
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CancelComponentDeployment
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CancelComponentDeployment)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> Component -> CancelComponentDeploymentResponse
CancelComponentDeploymentResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"component")
      )

instance Prelude.Hashable CancelComponentDeployment where
  hashWithSalt :: Int -> CancelComponentDeployment -> Int
hashWithSalt Int
_salt CancelComponentDeployment' {Text
componentName :: Text
$sel:componentName:CancelComponentDeployment' :: CancelComponentDeployment -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
componentName

instance Prelude.NFData CancelComponentDeployment where
  rnf :: CancelComponentDeployment -> ()
rnf CancelComponentDeployment' {Text
componentName :: Text
$sel:componentName:CancelComponentDeployment' :: CancelComponentDeployment -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
componentName

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

instance Data.ToJSON CancelComponentDeployment where
  toJSON :: CancelComponentDeployment -> Value
toJSON CancelComponentDeployment' {Text
componentName :: Text
$sel:componentName:CancelComponentDeployment' :: CancelComponentDeployment -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"componentName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
componentName)
          ]
      )

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

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

-- | /See:/ 'newCancelComponentDeploymentResponse' smart constructor.
data CancelComponentDeploymentResponse = CancelComponentDeploymentResponse'
  { -- | The response's http status code.
    CancelComponentDeploymentResponse -> Int
httpStatus :: Prelude.Int,
    -- | The detailed data of the component with the deployment that is being
    -- canceled.
    CancelComponentDeploymentResponse -> Component
component :: Component
  }
  deriving (CancelComponentDeploymentResponse
-> CancelComponentDeploymentResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelComponentDeploymentResponse
-> CancelComponentDeploymentResponse -> Bool
$c/= :: CancelComponentDeploymentResponse
-> CancelComponentDeploymentResponse -> Bool
== :: CancelComponentDeploymentResponse
-> CancelComponentDeploymentResponse -> Bool
$c== :: CancelComponentDeploymentResponse
-> CancelComponentDeploymentResponse -> Bool
Prelude.Eq, Int -> CancelComponentDeploymentResponse -> ShowS
[CancelComponentDeploymentResponse] -> ShowS
CancelComponentDeploymentResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelComponentDeploymentResponse] -> ShowS
$cshowList :: [CancelComponentDeploymentResponse] -> ShowS
show :: CancelComponentDeploymentResponse -> String
$cshow :: CancelComponentDeploymentResponse -> String
showsPrec :: Int -> CancelComponentDeploymentResponse -> ShowS
$cshowsPrec :: Int -> CancelComponentDeploymentResponse -> ShowS
Prelude.Show, forall x.
Rep CancelComponentDeploymentResponse x
-> CancelComponentDeploymentResponse
forall x.
CancelComponentDeploymentResponse
-> Rep CancelComponentDeploymentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CancelComponentDeploymentResponse x
-> CancelComponentDeploymentResponse
$cfrom :: forall x.
CancelComponentDeploymentResponse
-> Rep CancelComponentDeploymentResponse x
Prelude.Generic)

-- |
-- Create a value of 'CancelComponentDeploymentResponse' 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', 'cancelComponentDeploymentResponse_httpStatus' - The response's http status code.
--
-- 'component', 'cancelComponentDeploymentResponse_component' - The detailed data of the component with the deployment that is being
-- canceled.
newCancelComponentDeploymentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'component'
  Component ->
  CancelComponentDeploymentResponse
newCancelComponentDeploymentResponse :: Int -> Component -> CancelComponentDeploymentResponse
newCancelComponentDeploymentResponse
  Int
pHttpStatus_
  Component
pComponent_ =
    CancelComponentDeploymentResponse'
      { $sel:httpStatus:CancelComponentDeploymentResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:component:CancelComponentDeploymentResponse' :: Component
component = Component
pComponent_
      }

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

-- | The detailed data of the component with the deployment that is being
-- canceled.
cancelComponentDeploymentResponse_component :: Lens.Lens' CancelComponentDeploymentResponse Component
cancelComponentDeploymentResponse_component :: Lens' CancelComponentDeploymentResponse Component
cancelComponentDeploymentResponse_component = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelComponentDeploymentResponse' {Component
component :: Component
$sel:component:CancelComponentDeploymentResponse' :: CancelComponentDeploymentResponse -> Component
component} -> Component
component) (\s :: CancelComponentDeploymentResponse
s@CancelComponentDeploymentResponse' {} Component
a -> CancelComponentDeploymentResponse
s {$sel:component:CancelComponentDeploymentResponse' :: Component
component = Component
a} :: CancelComponentDeploymentResponse)

instance
  Prelude.NFData
    CancelComponentDeploymentResponse
  where
  rnf :: CancelComponentDeploymentResponse -> ()
rnf CancelComponentDeploymentResponse' {Int
Component
component :: Component
httpStatus :: Int
$sel:component:CancelComponentDeploymentResponse' :: CancelComponentDeploymentResponse -> Component
$sel:httpStatus:CancelComponentDeploymentResponse' :: CancelComponentDeploymentResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Component
component