{-# 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.DescribeTransaction
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns the details of a single transaction.
module Amazonka.LakeFormation.DescribeTransaction
  ( -- * Creating a Request
    DescribeTransaction (..),
    newDescribeTransaction,

    -- * Request Lenses
    describeTransaction_transactionId,

    -- * Destructuring the Response
    DescribeTransactionResponse (..),
    newDescribeTransactionResponse,

    -- * Response Lenses
    describeTransactionResponse_transactionDescription,
    describeTransactionResponse_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:/ 'newDescribeTransaction' smart constructor.
data DescribeTransaction = DescribeTransaction'
  { -- | The transaction for which to return status.
    DescribeTransaction -> Text
transactionId :: Prelude.Text
  }
  deriving (DescribeTransaction -> DescribeTransaction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeTransaction -> DescribeTransaction -> Bool
$c/= :: DescribeTransaction -> DescribeTransaction -> Bool
== :: DescribeTransaction -> DescribeTransaction -> Bool
$c== :: DescribeTransaction -> DescribeTransaction -> Bool
Prelude.Eq, ReadPrec [DescribeTransaction]
ReadPrec DescribeTransaction
Int -> ReadS DescribeTransaction
ReadS [DescribeTransaction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeTransaction]
$creadListPrec :: ReadPrec [DescribeTransaction]
readPrec :: ReadPrec DescribeTransaction
$creadPrec :: ReadPrec DescribeTransaction
readList :: ReadS [DescribeTransaction]
$creadList :: ReadS [DescribeTransaction]
readsPrec :: Int -> ReadS DescribeTransaction
$creadsPrec :: Int -> ReadS DescribeTransaction
Prelude.Read, Int -> DescribeTransaction -> ShowS
[DescribeTransaction] -> ShowS
DescribeTransaction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeTransaction] -> ShowS
$cshowList :: [DescribeTransaction] -> ShowS
show :: DescribeTransaction -> String
$cshow :: DescribeTransaction -> String
showsPrec :: Int -> DescribeTransaction -> ShowS
$cshowsPrec :: Int -> DescribeTransaction -> ShowS
Prelude.Show, forall x. Rep DescribeTransaction x -> DescribeTransaction
forall x. DescribeTransaction -> Rep DescribeTransaction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeTransaction x -> DescribeTransaction
$cfrom :: forall x. DescribeTransaction -> Rep DescribeTransaction x
Prelude.Generic)

-- |
-- Create a value of 'DescribeTransaction' 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', 'describeTransaction_transactionId' - The transaction for which to return status.
newDescribeTransaction ::
  -- | 'transactionId'
  Prelude.Text ->
  DescribeTransaction
newDescribeTransaction :: Text -> DescribeTransaction
newDescribeTransaction Text
pTransactionId_ =
  DescribeTransaction'
    { $sel:transactionId:DescribeTransaction' :: Text
transactionId =
        Text
pTransactionId_
    }

-- | The transaction for which to return status.
describeTransaction_transactionId :: Lens.Lens' DescribeTransaction Prelude.Text
describeTransaction_transactionId :: Lens' DescribeTransaction Text
describeTransaction_transactionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTransaction' {Text
transactionId :: Text
$sel:transactionId:DescribeTransaction' :: DescribeTransaction -> Text
transactionId} -> Text
transactionId) (\s :: DescribeTransaction
s@DescribeTransaction' {} Text
a -> DescribeTransaction
s {$sel:transactionId:DescribeTransaction' :: Text
transactionId = Text
a} :: DescribeTransaction)

instance Core.AWSRequest DescribeTransaction where
  type
    AWSResponse DescribeTransaction =
      DescribeTransactionResponse
  request :: (Service -> Service)
-> DescribeTransaction -> Request DescribeTransaction
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 DescribeTransaction
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeTransaction)))
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 ->
          Maybe TransactionDescription -> Int -> DescribeTransactionResponse
DescribeTransactionResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"TransactionDescription")
            forall (f :: * -> *) a b. Applicative f => 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 DescribeTransaction where
  hashWithSalt :: Int -> DescribeTransaction -> Int
hashWithSalt Int
_salt DescribeTransaction' {Text
transactionId :: Text
$sel:transactionId:DescribeTransaction' :: DescribeTransaction -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
transactionId

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

instance Data.ToHeaders DescribeTransaction where
  toHeaders :: DescribeTransaction -> 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 DescribeTransaction where
  toJSON :: DescribeTransaction -> Value
toJSON DescribeTransaction' {Text
transactionId :: Text
$sel:transactionId:DescribeTransaction' :: DescribeTransaction -> 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 DescribeTransaction where
  toPath :: DescribeTransaction -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/DescribeTransaction"

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

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

-- |
-- Create a value of 'DescribeTransactionResponse' 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:
--
-- 'transactionDescription', 'describeTransactionResponse_transactionDescription' - Returns a @TransactionDescription@ object containing information about
-- the transaction.
--
-- 'httpStatus', 'describeTransactionResponse_httpStatus' - The response's http status code.
newDescribeTransactionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeTransactionResponse
newDescribeTransactionResponse :: Int -> DescribeTransactionResponse
newDescribeTransactionResponse Int
pHttpStatus_ =
  DescribeTransactionResponse'
    { $sel:transactionDescription:DescribeTransactionResponse' :: Maybe TransactionDescription
transactionDescription =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeTransactionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Returns a @TransactionDescription@ object containing information about
-- the transaction.
describeTransactionResponse_transactionDescription :: Lens.Lens' DescribeTransactionResponse (Prelude.Maybe TransactionDescription)
describeTransactionResponse_transactionDescription :: Lens' DescribeTransactionResponse (Maybe TransactionDescription)
describeTransactionResponse_transactionDescription = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTransactionResponse' {Maybe TransactionDescription
transactionDescription :: Maybe TransactionDescription
$sel:transactionDescription:DescribeTransactionResponse' :: DescribeTransactionResponse -> Maybe TransactionDescription
transactionDescription} -> Maybe TransactionDescription
transactionDescription) (\s :: DescribeTransactionResponse
s@DescribeTransactionResponse' {} Maybe TransactionDescription
a -> DescribeTransactionResponse
s {$sel:transactionDescription:DescribeTransactionResponse' :: Maybe TransactionDescription
transactionDescription = Maybe TransactionDescription
a} :: DescribeTransactionResponse)

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

instance Prelude.NFData DescribeTransactionResponse where
  rnf :: DescribeTransactionResponse -> ()
rnf DescribeTransactionResponse' {Int
Maybe TransactionDescription
httpStatus :: Int
transactionDescription :: Maybe TransactionDescription
$sel:httpStatus:DescribeTransactionResponse' :: DescribeTransactionResponse -> Int
$sel:transactionDescription:DescribeTransactionResponse' :: DescribeTransactionResponse -> Maybe TransactionDescription
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe TransactionDescription
transactionDescription
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus