{-# 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.LakeFormation.CancelTransaction
-- 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 the specified transaction. Returns an exception if
-- the transaction was previously committed.
module Amazonka.LakeFormation.CancelTransaction
  ( -- * Creating a Request
    CancelTransaction (..),
    newCancelTransaction,

    -- * Request Lenses
    cancelTransaction_transactionId,

    -- * Destructuring the Response
    CancelTransactionResponse (..),
    newCancelTransactionResponse,

    -- * Response Lenses
    cancelTransactionResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LakeFormation.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

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

-- |
-- Create a value of 'CancelTransaction' 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:
--
-- 'transactionId', 'cancelTransaction_transactionId' - The transaction to cancel.
newCancelTransaction ::
  -- | 'transactionId'
  Prelude.Text ->
  CancelTransaction
newCancelTransaction :: Text -> CancelTransaction
newCancelTransaction Text
pTransactionId_ =
  CancelTransaction' {$sel:transactionId:CancelTransaction' :: Text
transactionId = Text
pTransactionId_}

-- | The transaction to cancel.
cancelTransaction_transactionId :: Lens.Lens' CancelTransaction Prelude.Text
cancelTransaction_transactionId :: Lens' CancelTransaction Text
cancelTransaction_transactionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelTransaction' {Text
transactionId :: Text
$sel:transactionId:CancelTransaction' :: CancelTransaction -> Text
transactionId} -> Text
transactionId) (\s :: CancelTransaction
s@CancelTransaction' {} Text
a -> CancelTransaction
s {$sel:transactionId:CancelTransaction' :: Text
transactionId = Text
a} :: CancelTransaction)

instance Core.AWSRequest CancelTransaction where
  type
    AWSResponse CancelTransaction =
      CancelTransactionResponse
  request :: (Service -> Service)
-> CancelTransaction -> Request CancelTransaction
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 CancelTransaction
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CancelTransaction)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> CancelTransactionResponse
CancelTransactionResponse'
            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))
      )

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

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

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

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

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

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

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

-- |
-- Create a value of 'CancelTransactionResponse' 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', 'cancelTransactionResponse_httpStatus' - The response's http status code.
newCancelTransactionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CancelTransactionResponse
newCancelTransactionResponse :: Int -> CancelTransactionResponse
newCancelTransactionResponse Int
pHttpStatus_ =
  CancelTransactionResponse'
    { $sel:httpStatus:CancelTransactionResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData CancelTransactionResponse where
  rnf :: CancelTransactionResponse -> ()
rnf CancelTransactionResponse' {Int
httpStatus :: Int
$sel:httpStatus:CancelTransactionResponse' :: CancelTransactionResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus