{-# 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 #-}
module Amazonka.QLDB.GetBlock
(
GetBlock (..),
newGetBlock,
getBlock_digestTipAddress,
getBlock_name,
getBlock_blockAddress,
GetBlockResponse (..),
newGetBlockResponse,
getBlockResponse_proof,
getBlockResponse_httpStatus,
getBlockResponse_block,
)
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.QLDB.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data GetBlock = GetBlock'
{
GetBlock -> Maybe (Sensitive ValueHolder)
digestTipAddress :: Prelude.Maybe (Data.Sensitive ValueHolder),
GetBlock -> Text
name :: Prelude.Text,
GetBlock -> Sensitive ValueHolder
blockAddress :: Data.Sensitive ValueHolder
}
deriving (GetBlock -> GetBlock -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetBlock -> GetBlock -> Bool
$c/= :: GetBlock -> GetBlock -> Bool
== :: GetBlock -> GetBlock -> Bool
$c== :: GetBlock -> GetBlock -> Bool
Prelude.Eq, Int -> GetBlock -> ShowS
[GetBlock] -> ShowS
GetBlock -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetBlock] -> ShowS
$cshowList :: [GetBlock] -> ShowS
show :: GetBlock -> String
$cshow :: GetBlock -> String
showsPrec :: Int -> GetBlock -> ShowS
$cshowsPrec :: Int -> GetBlock -> ShowS
Prelude.Show, forall x. Rep GetBlock x -> GetBlock
forall x. GetBlock -> Rep GetBlock x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetBlock x -> GetBlock
$cfrom :: forall x. GetBlock -> Rep GetBlock x
Prelude.Generic)
newGetBlock ::
Prelude.Text ->
ValueHolder ->
GetBlock
newGetBlock :: Text -> ValueHolder -> GetBlock
newGetBlock Text
pName_ ValueHolder
pBlockAddress_ =
GetBlock'
{ $sel:digestTipAddress:GetBlock' :: Maybe (Sensitive ValueHolder)
digestTipAddress = forall a. Maybe a
Prelude.Nothing,
$sel:name:GetBlock' :: Text
name = Text
pName_,
$sel:blockAddress:GetBlock' :: Sensitive ValueHolder
blockAddress = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# ValueHolder
pBlockAddress_
}
getBlock_digestTipAddress :: Lens.Lens' GetBlock (Prelude.Maybe ValueHolder)
getBlock_digestTipAddress :: Lens' GetBlock (Maybe ValueHolder)
getBlock_digestTipAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBlock' {Maybe (Sensitive ValueHolder)
digestTipAddress :: Maybe (Sensitive ValueHolder)
$sel:digestTipAddress:GetBlock' :: GetBlock -> Maybe (Sensitive ValueHolder)
digestTipAddress} -> Maybe (Sensitive ValueHolder)
digestTipAddress) (\s :: GetBlock
s@GetBlock' {} Maybe (Sensitive ValueHolder)
a -> GetBlock
s {$sel:digestTipAddress:GetBlock' :: Maybe (Sensitive ValueHolder)
digestTipAddress = Maybe (Sensitive ValueHolder)
a} :: GetBlock) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall a. Iso' (Sensitive a) a
Data._Sensitive
getBlock_name :: Lens.Lens' GetBlock Prelude.Text
getBlock_name :: Lens' GetBlock Text
getBlock_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBlock' {Text
name :: Text
$sel:name:GetBlock' :: GetBlock -> Text
name} -> Text
name) (\s :: GetBlock
s@GetBlock' {} Text
a -> GetBlock
s {$sel:name:GetBlock' :: Text
name = Text
a} :: GetBlock)
getBlock_blockAddress :: Lens.Lens' GetBlock ValueHolder
getBlock_blockAddress :: Lens' GetBlock ValueHolder
getBlock_blockAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBlock' {Sensitive ValueHolder
blockAddress :: Sensitive ValueHolder
$sel:blockAddress:GetBlock' :: GetBlock -> Sensitive ValueHolder
blockAddress} -> Sensitive ValueHolder
blockAddress) (\s :: GetBlock
s@GetBlock' {} Sensitive ValueHolder
a -> GetBlock
s {$sel:blockAddress:GetBlock' :: Sensitive ValueHolder
blockAddress = Sensitive ValueHolder
a} :: GetBlock) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive
instance Core.AWSRequest GetBlock where
type AWSResponse GetBlock = GetBlockResponse
request :: (Service -> Service) -> GetBlock -> Request GetBlock
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 GetBlock
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetBlock)))
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 (Sensitive ValueHolder)
-> Int -> Sensitive ValueHolder -> GetBlockResponse
GetBlockResponse'
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
"Proof")
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))
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
"Block")
)
instance Prelude.Hashable GetBlock where
hashWithSalt :: Int -> GetBlock -> Int
hashWithSalt Int
_salt GetBlock' {Maybe (Sensitive ValueHolder)
Text
Sensitive ValueHolder
blockAddress :: Sensitive ValueHolder
name :: Text
digestTipAddress :: Maybe (Sensitive ValueHolder)
$sel:blockAddress:GetBlock' :: GetBlock -> Sensitive ValueHolder
$sel:name:GetBlock' :: GetBlock -> Text
$sel:digestTipAddress:GetBlock' :: GetBlock -> Maybe (Sensitive ValueHolder)
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive ValueHolder)
digestTipAddress
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive ValueHolder
blockAddress
instance Prelude.NFData GetBlock where
rnf :: GetBlock -> ()
rnf GetBlock' {Maybe (Sensitive ValueHolder)
Text
Sensitive ValueHolder
blockAddress :: Sensitive ValueHolder
name :: Text
digestTipAddress :: Maybe (Sensitive ValueHolder)
$sel:blockAddress:GetBlock' :: GetBlock -> Sensitive ValueHolder
$sel:name:GetBlock' :: GetBlock -> Text
$sel:digestTipAddress:GetBlock' :: GetBlock -> Maybe (Sensitive ValueHolder)
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive ValueHolder)
digestTipAddress
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive ValueHolder
blockAddress
instance Data.ToHeaders GetBlock where
toHeaders :: GetBlock -> 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.0" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON GetBlock where
toJSON :: GetBlock -> Value
toJSON GetBlock' {Maybe (Sensitive ValueHolder)
Text
Sensitive ValueHolder
blockAddress :: Sensitive ValueHolder
name :: Text
digestTipAddress :: Maybe (Sensitive ValueHolder)
$sel:blockAddress:GetBlock' :: GetBlock -> Sensitive ValueHolder
$sel:name:GetBlock' :: GetBlock -> Text
$sel:digestTipAddress:GetBlock' :: GetBlock -> Maybe (Sensitive ValueHolder)
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"DigestTipAddress" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive ValueHolder)
digestTipAddress,
forall a. a -> Maybe a
Prelude.Just (Key
"BlockAddress" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive ValueHolder
blockAddress)
]
)
instance Data.ToPath GetBlock where
toPath :: GetBlock -> ByteString
toPath GetBlock' {Maybe (Sensitive ValueHolder)
Text
Sensitive ValueHolder
blockAddress :: Sensitive ValueHolder
name :: Text
digestTipAddress :: Maybe (Sensitive ValueHolder)
$sel:blockAddress:GetBlock' :: GetBlock -> Sensitive ValueHolder
$sel:name:GetBlock' :: GetBlock -> Text
$sel:digestTipAddress:GetBlock' :: GetBlock -> Maybe (Sensitive ValueHolder)
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/ledgers/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
name, ByteString
"/block"]
instance Data.ToQuery GetBlock where
toQuery :: GetBlock -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data GetBlockResponse = GetBlockResponse'
{
GetBlockResponse -> Maybe (Sensitive ValueHolder)
proof :: Prelude.Maybe (Data.Sensitive ValueHolder),
GetBlockResponse -> Int
httpStatus :: Prelude.Int,
GetBlockResponse -> Sensitive ValueHolder
block :: Data.Sensitive ValueHolder
}
deriving (GetBlockResponse -> GetBlockResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetBlockResponse -> GetBlockResponse -> Bool
$c/= :: GetBlockResponse -> GetBlockResponse -> Bool
== :: GetBlockResponse -> GetBlockResponse -> Bool
$c== :: GetBlockResponse -> GetBlockResponse -> Bool
Prelude.Eq, Int -> GetBlockResponse -> ShowS
[GetBlockResponse] -> ShowS
GetBlockResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetBlockResponse] -> ShowS
$cshowList :: [GetBlockResponse] -> ShowS
show :: GetBlockResponse -> String
$cshow :: GetBlockResponse -> String
showsPrec :: Int -> GetBlockResponse -> ShowS
$cshowsPrec :: Int -> GetBlockResponse -> ShowS
Prelude.Show, forall x. Rep GetBlockResponse x -> GetBlockResponse
forall x. GetBlockResponse -> Rep GetBlockResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetBlockResponse x -> GetBlockResponse
$cfrom :: forall x. GetBlockResponse -> Rep GetBlockResponse x
Prelude.Generic)
newGetBlockResponse ::
Prelude.Int ->
ValueHolder ->
GetBlockResponse
newGetBlockResponse :: Int -> ValueHolder -> GetBlockResponse
newGetBlockResponse Int
pHttpStatus_ ValueHolder
pBlock_ =
GetBlockResponse'
{ $sel:proof:GetBlockResponse' :: Maybe (Sensitive ValueHolder)
proof = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetBlockResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:block:GetBlockResponse' :: Sensitive ValueHolder
block = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# ValueHolder
pBlock_
}
getBlockResponse_proof :: Lens.Lens' GetBlockResponse (Prelude.Maybe ValueHolder)
getBlockResponse_proof :: Lens' GetBlockResponse (Maybe ValueHolder)
getBlockResponse_proof = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBlockResponse' {Maybe (Sensitive ValueHolder)
proof :: Maybe (Sensitive ValueHolder)
$sel:proof:GetBlockResponse' :: GetBlockResponse -> Maybe (Sensitive ValueHolder)
proof} -> Maybe (Sensitive ValueHolder)
proof) (\s :: GetBlockResponse
s@GetBlockResponse' {} Maybe (Sensitive ValueHolder)
a -> GetBlockResponse
s {$sel:proof:GetBlockResponse' :: Maybe (Sensitive ValueHolder)
proof = Maybe (Sensitive ValueHolder)
a} :: GetBlockResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall a. Iso' (Sensitive a) a
Data._Sensitive
getBlockResponse_httpStatus :: Lens.Lens' GetBlockResponse Prelude.Int
getBlockResponse_httpStatus :: Lens' GetBlockResponse Int
getBlockResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBlockResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetBlockResponse' :: GetBlockResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetBlockResponse
s@GetBlockResponse' {} Int
a -> GetBlockResponse
s {$sel:httpStatus:GetBlockResponse' :: Int
httpStatus = Int
a} :: GetBlockResponse)
getBlockResponse_block :: Lens.Lens' GetBlockResponse ValueHolder
getBlockResponse_block :: Lens' GetBlockResponse ValueHolder
getBlockResponse_block = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBlockResponse' {Sensitive ValueHolder
block :: Sensitive ValueHolder
$sel:block:GetBlockResponse' :: GetBlockResponse -> Sensitive ValueHolder
block} -> Sensitive ValueHolder
block) (\s :: GetBlockResponse
s@GetBlockResponse' {} Sensitive ValueHolder
a -> GetBlockResponse
s {$sel:block:GetBlockResponse' :: Sensitive ValueHolder
block = Sensitive ValueHolder
a} :: GetBlockResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive
instance Prelude.NFData GetBlockResponse where
rnf :: GetBlockResponse -> ()
rnf GetBlockResponse' {Int
Maybe (Sensitive ValueHolder)
Sensitive ValueHolder
block :: Sensitive ValueHolder
httpStatus :: Int
proof :: Maybe (Sensitive ValueHolder)
$sel:block:GetBlockResponse' :: GetBlockResponse -> Sensitive ValueHolder
$sel:httpStatus:GetBlockResponse' :: GetBlockResponse -> Int
$sel:proof:GetBlockResponse' :: GetBlockResponse -> Maybe (Sensitive ValueHolder)
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive ValueHolder)
proof
seq :: forall a b. a -> b -> b
`Prelude.seq` 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 Sensitive ValueHolder
block