{-# 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.MarketplaceCatalog.CancelChangeSet
-- 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)
--
-- Used to cancel an open change request. Must be sent before the status of
-- the request changes to @APPLYING@, the final stage of completing your
-- change request. You can describe a change during the 60-day request
-- history retention period for API calls.
module Amazonka.MarketplaceCatalog.CancelChangeSet
  ( -- * Creating a Request
    CancelChangeSet (..),
    newCancelChangeSet,

    -- * Request Lenses
    cancelChangeSet_catalog,
    cancelChangeSet_changeSetId,

    -- * Destructuring the Response
    CancelChangeSetResponse (..),
    newCancelChangeSetResponse,

    -- * Response Lenses
    cancelChangeSetResponse_changeSetId,
    cancelChangeSetResponse_changeSetArn,
    cancelChangeSetResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCancelChangeSet' smart constructor.
data CancelChangeSet = CancelChangeSet'
  { -- | Required. The catalog related to the request. Fixed value:
    -- @AWSMarketplace@.
    CancelChangeSet -> Text
catalog :: Prelude.Text,
    -- | Required. The unique identifier of the @StartChangeSet@ request that you
    -- want to cancel.
    CancelChangeSet -> Text
changeSetId :: Prelude.Text
  }
  deriving (CancelChangeSet -> CancelChangeSet -> Bool
(CancelChangeSet -> CancelChangeSet -> Bool)
-> (CancelChangeSet -> CancelChangeSet -> Bool)
-> Eq CancelChangeSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelChangeSet -> CancelChangeSet -> Bool
$c/= :: CancelChangeSet -> CancelChangeSet -> Bool
== :: CancelChangeSet -> CancelChangeSet -> Bool
$c== :: CancelChangeSet -> CancelChangeSet -> Bool
Prelude.Eq, ReadPrec [CancelChangeSet]
ReadPrec CancelChangeSet
Int -> ReadS CancelChangeSet
ReadS [CancelChangeSet]
(Int -> ReadS CancelChangeSet)
-> ReadS [CancelChangeSet]
-> ReadPrec CancelChangeSet
-> ReadPrec [CancelChangeSet]
-> Read CancelChangeSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelChangeSet]
$creadListPrec :: ReadPrec [CancelChangeSet]
readPrec :: ReadPrec CancelChangeSet
$creadPrec :: ReadPrec CancelChangeSet
readList :: ReadS [CancelChangeSet]
$creadList :: ReadS [CancelChangeSet]
readsPrec :: Int -> ReadS CancelChangeSet
$creadsPrec :: Int -> ReadS CancelChangeSet
Prelude.Read, Int -> CancelChangeSet -> ShowS
[CancelChangeSet] -> ShowS
CancelChangeSet -> String
(Int -> CancelChangeSet -> ShowS)
-> (CancelChangeSet -> String)
-> ([CancelChangeSet] -> ShowS)
-> Show CancelChangeSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelChangeSet] -> ShowS
$cshowList :: [CancelChangeSet] -> ShowS
show :: CancelChangeSet -> String
$cshow :: CancelChangeSet -> String
showsPrec :: Int -> CancelChangeSet -> ShowS
$cshowsPrec :: Int -> CancelChangeSet -> ShowS
Prelude.Show, (forall x. CancelChangeSet -> Rep CancelChangeSet x)
-> (forall x. Rep CancelChangeSet x -> CancelChangeSet)
-> Generic CancelChangeSet
forall x. Rep CancelChangeSet x -> CancelChangeSet
forall x. CancelChangeSet -> Rep CancelChangeSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelChangeSet x -> CancelChangeSet
$cfrom :: forall x. CancelChangeSet -> Rep CancelChangeSet x
Prelude.Generic)

-- |
-- Create a value of 'CancelChangeSet' 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:
--
-- 'catalog', 'cancelChangeSet_catalog' - Required. The catalog related to the request. Fixed value:
-- @AWSMarketplace@.
--
-- 'changeSetId', 'cancelChangeSet_changeSetId' - Required. The unique identifier of the @StartChangeSet@ request that you
-- want to cancel.
newCancelChangeSet ::
  -- | 'catalog'
  Prelude.Text ->
  -- | 'changeSetId'
  Prelude.Text ->
  CancelChangeSet
newCancelChangeSet :: Text -> Text -> CancelChangeSet
newCancelChangeSet Text
pCatalog_ Text
pChangeSetId_ =
  CancelChangeSet' :: Text -> Text -> CancelChangeSet
CancelChangeSet'
    { $sel:catalog:CancelChangeSet' :: Text
catalog = Text
pCatalog_,
      $sel:changeSetId:CancelChangeSet' :: Text
changeSetId = Text
pChangeSetId_
    }

-- | Required. The catalog related to the request. Fixed value:
-- @AWSMarketplace@.
cancelChangeSet_catalog :: Lens.Lens' CancelChangeSet Prelude.Text
cancelChangeSet_catalog :: (Text -> f Text) -> CancelChangeSet -> f CancelChangeSet
cancelChangeSet_catalog = (CancelChangeSet -> Text)
-> (CancelChangeSet -> Text -> CancelChangeSet)
-> Lens CancelChangeSet CancelChangeSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelChangeSet' {Text
catalog :: Text
$sel:catalog:CancelChangeSet' :: CancelChangeSet -> Text
catalog} -> Text
catalog) (\s :: CancelChangeSet
s@CancelChangeSet' {} Text
a -> CancelChangeSet
s {$sel:catalog:CancelChangeSet' :: Text
catalog = Text
a} :: CancelChangeSet)

-- | Required. The unique identifier of the @StartChangeSet@ request that you
-- want to cancel.
cancelChangeSet_changeSetId :: Lens.Lens' CancelChangeSet Prelude.Text
cancelChangeSet_changeSetId :: (Text -> f Text) -> CancelChangeSet -> f CancelChangeSet
cancelChangeSet_changeSetId = (CancelChangeSet -> Text)
-> (CancelChangeSet -> Text -> CancelChangeSet)
-> Lens CancelChangeSet CancelChangeSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelChangeSet' {Text
changeSetId :: Text
$sel:changeSetId:CancelChangeSet' :: CancelChangeSet -> Text
changeSetId} -> Text
changeSetId) (\s :: CancelChangeSet
s@CancelChangeSet' {} Text
a -> CancelChangeSet
s {$sel:changeSetId:CancelChangeSet' :: Text
changeSetId = Text
a} :: CancelChangeSet)

instance Core.AWSRequest CancelChangeSet where
  type
    AWSResponse CancelChangeSet =
      CancelChangeSetResponse
  request :: CancelChangeSet -> Request CancelChangeSet
request = Service -> CancelChangeSet -> Request CancelChangeSet
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CancelChangeSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CancelChangeSet)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CancelChangeSet))
-> Logger
-> Service
-> Proxy CancelChangeSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CancelChangeSet)))
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 ->
          Maybe Text -> Maybe Text -> Int -> CancelChangeSetResponse
CancelChangeSetResponse'
            (Maybe Text -> Maybe Text -> Int -> CancelChangeSetResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> CancelChangeSetResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ChangeSetId")
            Either String (Maybe Text -> Int -> CancelChangeSetResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CancelChangeSetResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ChangeSetArn")
            Either String (Int -> CancelChangeSetResponse)
-> Either String Int -> Either String CancelChangeSetResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable CancelChangeSet

instance Prelude.NFData CancelChangeSet

instance Core.ToHeaders CancelChangeSet where
  toHeaders :: CancelChangeSet -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CancelChangeSet -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON CancelChangeSet where
  toJSON :: CancelChangeSet -> Value
toJSON = Value -> CancelChangeSet -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

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

instance Core.ToQuery CancelChangeSet where
  toQuery :: CancelChangeSet -> QueryString
toQuery CancelChangeSet' {Text
changeSetId :: Text
catalog :: Text
$sel:changeSetId:CancelChangeSet' :: CancelChangeSet -> Text
$sel:catalog:CancelChangeSet' :: CancelChangeSet -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"catalog" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
catalog,
        ByteString
"changeSetId" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
changeSetId
      ]

-- | /See:/ 'newCancelChangeSetResponse' smart constructor.
data CancelChangeSetResponse = CancelChangeSetResponse'
  { -- | The unique identifier for the change set referenced in this request.
    CancelChangeSetResponse -> Maybe Text
changeSetId :: Prelude.Maybe Prelude.Text,
    -- | The ARN associated with the change set referenced in this request.
    CancelChangeSetResponse -> Maybe Text
changeSetArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CancelChangeSetResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CancelChangeSetResponse -> CancelChangeSetResponse -> Bool
(CancelChangeSetResponse -> CancelChangeSetResponse -> Bool)
-> (CancelChangeSetResponse -> CancelChangeSetResponse -> Bool)
-> Eq CancelChangeSetResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelChangeSetResponse -> CancelChangeSetResponse -> Bool
$c/= :: CancelChangeSetResponse -> CancelChangeSetResponse -> Bool
== :: CancelChangeSetResponse -> CancelChangeSetResponse -> Bool
$c== :: CancelChangeSetResponse -> CancelChangeSetResponse -> Bool
Prelude.Eq, ReadPrec [CancelChangeSetResponse]
ReadPrec CancelChangeSetResponse
Int -> ReadS CancelChangeSetResponse
ReadS [CancelChangeSetResponse]
(Int -> ReadS CancelChangeSetResponse)
-> ReadS [CancelChangeSetResponse]
-> ReadPrec CancelChangeSetResponse
-> ReadPrec [CancelChangeSetResponse]
-> Read CancelChangeSetResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelChangeSetResponse]
$creadListPrec :: ReadPrec [CancelChangeSetResponse]
readPrec :: ReadPrec CancelChangeSetResponse
$creadPrec :: ReadPrec CancelChangeSetResponse
readList :: ReadS [CancelChangeSetResponse]
$creadList :: ReadS [CancelChangeSetResponse]
readsPrec :: Int -> ReadS CancelChangeSetResponse
$creadsPrec :: Int -> ReadS CancelChangeSetResponse
Prelude.Read, Int -> CancelChangeSetResponse -> ShowS
[CancelChangeSetResponse] -> ShowS
CancelChangeSetResponse -> String
(Int -> CancelChangeSetResponse -> ShowS)
-> (CancelChangeSetResponse -> String)
-> ([CancelChangeSetResponse] -> ShowS)
-> Show CancelChangeSetResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelChangeSetResponse] -> ShowS
$cshowList :: [CancelChangeSetResponse] -> ShowS
show :: CancelChangeSetResponse -> String
$cshow :: CancelChangeSetResponse -> String
showsPrec :: Int -> CancelChangeSetResponse -> ShowS
$cshowsPrec :: Int -> CancelChangeSetResponse -> ShowS
Prelude.Show, (forall x.
 CancelChangeSetResponse -> Rep CancelChangeSetResponse x)
-> (forall x.
    Rep CancelChangeSetResponse x -> CancelChangeSetResponse)
-> Generic CancelChangeSetResponse
forall x. Rep CancelChangeSetResponse x -> CancelChangeSetResponse
forall x. CancelChangeSetResponse -> Rep CancelChangeSetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelChangeSetResponse x -> CancelChangeSetResponse
$cfrom :: forall x. CancelChangeSetResponse -> Rep CancelChangeSetResponse x
Prelude.Generic)

-- |
-- Create a value of 'CancelChangeSetResponse' 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:
--
-- 'changeSetId', 'cancelChangeSetResponse_changeSetId' - The unique identifier for the change set referenced in this request.
--
-- 'changeSetArn', 'cancelChangeSetResponse_changeSetArn' - The ARN associated with the change set referenced in this request.
--
-- 'httpStatus', 'cancelChangeSetResponse_httpStatus' - The response's http status code.
newCancelChangeSetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CancelChangeSetResponse
newCancelChangeSetResponse :: Int -> CancelChangeSetResponse
newCancelChangeSetResponse Int
pHttpStatus_ =
  CancelChangeSetResponse' :: Maybe Text -> Maybe Text -> Int -> CancelChangeSetResponse
CancelChangeSetResponse'
    { $sel:changeSetId:CancelChangeSetResponse' :: Maybe Text
changeSetId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:changeSetArn:CancelChangeSetResponse' :: Maybe Text
changeSetArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CancelChangeSetResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The unique identifier for the change set referenced in this request.
cancelChangeSetResponse_changeSetId :: Lens.Lens' CancelChangeSetResponse (Prelude.Maybe Prelude.Text)
cancelChangeSetResponse_changeSetId :: (Maybe Text -> f (Maybe Text))
-> CancelChangeSetResponse -> f CancelChangeSetResponse
cancelChangeSetResponse_changeSetId = (CancelChangeSetResponse -> Maybe Text)
-> (CancelChangeSetResponse
    -> Maybe Text -> CancelChangeSetResponse)
-> Lens
     CancelChangeSetResponse
     CancelChangeSetResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelChangeSetResponse' {Maybe Text
changeSetId :: Maybe Text
$sel:changeSetId:CancelChangeSetResponse' :: CancelChangeSetResponse -> Maybe Text
changeSetId} -> Maybe Text
changeSetId) (\s :: CancelChangeSetResponse
s@CancelChangeSetResponse' {} Maybe Text
a -> CancelChangeSetResponse
s {$sel:changeSetId:CancelChangeSetResponse' :: Maybe Text
changeSetId = Maybe Text
a} :: CancelChangeSetResponse)

-- | The ARN associated with the change set referenced in this request.
cancelChangeSetResponse_changeSetArn :: Lens.Lens' CancelChangeSetResponse (Prelude.Maybe Prelude.Text)
cancelChangeSetResponse_changeSetArn :: (Maybe Text -> f (Maybe Text))
-> CancelChangeSetResponse -> f CancelChangeSetResponse
cancelChangeSetResponse_changeSetArn = (CancelChangeSetResponse -> Maybe Text)
-> (CancelChangeSetResponse
    -> Maybe Text -> CancelChangeSetResponse)
-> Lens
     CancelChangeSetResponse
     CancelChangeSetResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelChangeSetResponse' {Maybe Text
changeSetArn :: Maybe Text
$sel:changeSetArn:CancelChangeSetResponse' :: CancelChangeSetResponse -> Maybe Text
changeSetArn} -> Maybe Text
changeSetArn) (\s :: CancelChangeSetResponse
s@CancelChangeSetResponse' {} Maybe Text
a -> CancelChangeSetResponse
s {$sel:changeSetArn:CancelChangeSetResponse' :: Maybe Text
changeSetArn = Maybe Text
a} :: CancelChangeSetResponse)

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

instance Prelude.NFData CancelChangeSetResponse