{-# 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.Lens as Lens
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 (Core.Sensitive ValueHolder),
GetBlock -> Text
name :: Prelude.Text,
GetBlock -> Sensitive ValueHolder
blockAddress :: Core.Sensitive ValueHolder
}
deriving (GetBlock -> GetBlock -> Bool
(GetBlock -> GetBlock -> Bool)
-> (GetBlock -> GetBlock -> Bool) -> Eq GetBlock
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
(Int -> GetBlock -> ShowS)
-> (GetBlock -> String) -> ([GetBlock] -> ShowS) -> Show GetBlock
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. GetBlock -> Rep GetBlock x)
-> (forall x. Rep GetBlock x -> GetBlock) -> Generic GetBlock
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' :: Maybe (Sensitive ValueHolder)
-> Text -> Sensitive ValueHolder -> GetBlock
GetBlock'
{ $sel:digestTipAddress:GetBlock' :: Maybe (Sensitive ValueHolder)
digestTipAddress = Maybe (Sensitive ValueHolder)
forall a. Maybe a
Prelude.Nothing,
$sel:name:GetBlock' :: Text
name = Text
pName_,
$sel:blockAddress:GetBlock' :: Sensitive ValueHolder
blockAddress = Tagged ValueHolder (Identity ValueHolder)
-> Tagged
(Sensitive ValueHolder) (Identity (Sensitive ValueHolder))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged ValueHolder (Identity ValueHolder)
-> Tagged
(Sensitive ValueHolder) (Identity (Sensitive ValueHolder)))
-> ValueHolder -> Sensitive ValueHolder
forall t b. AReview t b -> b -> t
Lens.# ValueHolder
pBlockAddress_
}
getBlock_digestTipAddress :: Lens.Lens' GetBlock (Prelude.Maybe ValueHolder)
getBlock_digestTipAddress :: (Maybe ValueHolder -> f (Maybe ValueHolder))
-> GetBlock -> f GetBlock
getBlock_digestTipAddress = (GetBlock -> Maybe (Sensitive ValueHolder))
-> (GetBlock -> Maybe (Sensitive ValueHolder) -> GetBlock)
-> Lens
GetBlock
GetBlock
(Maybe (Sensitive ValueHolder))
(Maybe (Sensitive ValueHolder))
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) ((Maybe (Sensitive ValueHolder)
-> f (Maybe (Sensitive ValueHolder)))
-> GetBlock -> f GetBlock)
-> ((Maybe ValueHolder -> f (Maybe ValueHolder))
-> Maybe (Sensitive ValueHolder)
-> f (Maybe (Sensitive ValueHolder)))
-> (Maybe ValueHolder -> f (Maybe ValueHolder))
-> GetBlock
-> f GetBlock
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(Sensitive ValueHolder)
(Sensitive ValueHolder)
ValueHolder
ValueHolder
-> Iso
(Maybe (Sensitive ValueHolder))
(Maybe (Sensitive ValueHolder))
(Maybe ValueHolder)
(Maybe ValueHolder)
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 AnIso
(Sensitive ValueHolder)
(Sensitive ValueHolder)
ValueHolder
ValueHolder
forall a. Iso' (Sensitive a) a
Core._Sensitive
getBlock_name :: Lens.Lens' GetBlock Prelude.Text
getBlock_name :: (Text -> f Text) -> GetBlock -> f GetBlock
getBlock_name = (GetBlock -> Text)
-> (GetBlock -> Text -> GetBlock)
-> Lens GetBlock GetBlock Text Text
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 :: (ValueHolder -> f ValueHolder) -> GetBlock -> f GetBlock
getBlock_blockAddress = (GetBlock -> Sensitive ValueHolder)
-> (GetBlock -> Sensitive ValueHolder -> GetBlock)
-> Lens
GetBlock GetBlock (Sensitive ValueHolder) (Sensitive ValueHolder)
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) ((Sensitive ValueHolder -> f (Sensitive ValueHolder))
-> GetBlock -> f GetBlock)
-> ((ValueHolder -> f ValueHolder)
-> Sensitive ValueHolder -> f (Sensitive ValueHolder))
-> (ValueHolder -> f ValueHolder)
-> GetBlock
-> f GetBlock
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ValueHolder -> f ValueHolder)
-> Sensitive ValueHolder -> f (Sensitive ValueHolder)
forall a. Iso' (Sensitive a) a
Core._Sensitive
instance Core.AWSRequest GetBlock where
type AWSResponse GetBlock = GetBlockResponse
request :: GetBlock -> Request GetBlock
request = Service -> GetBlock -> Request GetBlock
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetBlock
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetBlock)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetBlock))
-> Logger
-> Service
-> Proxy GetBlock
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetBlock)))
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 (Sensitive ValueHolder)
-> Int -> Sensitive ValueHolder -> GetBlockResponse
GetBlockResponse'
(Maybe (Sensitive ValueHolder)
-> Int -> Sensitive ValueHolder -> GetBlockResponse)
-> Either String (Maybe (Sensitive ValueHolder))
-> Either String (Int -> Sensitive ValueHolder -> GetBlockResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Sensitive ValueHolder))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Proof")
Either String (Int -> Sensitive ValueHolder -> GetBlockResponse)
-> Either String Int
-> Either String (Sensitive ValueHolder -> GetBlockResponse)
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))
Either String (Sensitive ValueHolder -> GetBlockResponse)
-> Either String (Sensitive ValueHolder)
-> Either String GetBlockResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Sensitive ValueHolder)
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"Block")
)
instance Prelude.Hashable GetBlock
instance Prelude.NFData GetBlock
instance Core.ToHeaders GetBlock where
toHeaders :: GetBlock -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetBlock -> 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.0" ::
Prelude.ByteString
)
]
)
instance Core.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
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"DigestTipAddress" Text -> Sensitive ValueHolder -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Sensitive ValueHolder -> Pair)
-> Maybe (Sensitive ValueHolder) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive ValueHolder)
digestTipAddress,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"BlockAddress" Text -> Sensitive ValueHolder -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive ValueHolder
blockAddress)
]
)
instance Core.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)
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/ledgers/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
name, ByteString
"/block"]
instance Core.ToQuery GetBlock where
toQuery :: GetBlock -> QueryString
toQuery = QueryString -> GetBlock -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetBlockResponse = GetBlockResponse'
{
GetBlockResponse -> Maybe (Sensitive ValueHolder)
proof :: Prelude.Maybe (Core.Sensitive ValueHolder),
GetBlockResponse -> Int
httpStatus :: Prelude.Int,
GetBlockResponse -> Sensitive ValueHolder
block :: Core.Sensitive ValueHolder
}
deriving (GetBlockResponse -> GetBlockResponse -> Bool
(GetBlockResponse -> GetBlockResponse -> Bool)
-> (GetBlockResponse -> GetBlockResponse -> Bool)
-> Eq GetBlockResponse
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
(Int -> GetBlockResponse -> ShowS)
-> (GetBlockResponse -> String)
-> ([GetBlockResponse] -> ShowS)
-> Show GetBlockResponse
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. GetBlockResponse -> Rep GetBlockResponse x)
-> (forall x. Rep GetBlockResponse x -> GetBlockResponse)
-> Generic GetBlockResponse
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' :: Maybe (Sensitive ValueHolder)
-> Int -> Sensitive ValueHolder -> GetBlockResponse
GetBlockResponse'
{ $sel:proof:GetBlockResponse' :: Maybe (Sensitive ValueHolder)
proof = Maybe (Sensitive ValueHolder)
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetBlockResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:block:GetBlockResponse' :: Sensitive ValueHolder
block = Tagged ValueHolder (Identity ValueHolder)
-> Tagged
(Sensitive ValueHolder) (Identity (Sensitive ValueHolder))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged ValueHolder (Identity ValueHolder)
-> Tagged
(Sensitive ValueHolder) (Identity (Sensitive ValueHolder)))
-> ValueHolder -> Sensitive ValueHolder
forall t b. AReview t b -> b -> t
Lens.# ValueHolder
pBlock_
}
getBlockResponse_proof :: Lens.Lens' GetBlockResponse (Prelude.Maybe ValueHolder)
getBlockResponse_proof :: (Maybe ValueHolder -> f (Maybe ValueHolder))
-> GetBlockResponse -> f GetBlockResponse
getBlockResponse_proof = (GetBlockResponse -> Maybe (Sensitive ValueHolder))
-> (GetBlockResponse
-> Maybe (Sensitive ValueHolder) -> GetBlockResponse)
-> Lens
GetBlockResponse
GetBlockResponse
(Maybe (Sensitive ValueHolder))
(Maybe (Sensitive ValueHolder))
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) ((Maybe (Sensitive ValueHolder)
-> f (Maybe (Sensitive ValueHolder)))
-> GetBlockResponse -> f GetBlockResponse)
-> ((Maybe ValueHolder -> f (Maybe ValueHolder))
-> Maybe (Sensitive ValueHolder)
-> f (Maybe (Sensitive ValueHolder)))
-> (Maybe ValueHolder -> f (Maybe ValueHolder))
-> GetBlockResponse
-> f GetBlockResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(Sensitive ValueHolder)
(Sensitive ValueHolder)
ValueHolder
ValueHolder
-> Iso
(Maybe (Sensitive ValueHolder))
(Maybe (Sensitive ValueHolder))
(Maybe ValueHolder)
(Maybe ValueHolder)
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 AnIso
(Sensitive ValueHolder)
(Sensitive ValueHolder)
ValueHolder
ValueHolder
forall a. Iso' (Sensitive a) a
Core._Sensitive
getBlockResponse_httpStatus :: Lens.Lens' GetBlockResponse Prelude.Int
getBlockResponse_httpStatus :: (Int -> f Int) -> GetBlockResponse -> f GetBlockResponse
getBlockResponse_httpStatus = (GetBlockResponse -> Int)
-> (GetBlockResponse -> Int -> GetBlockResponse)
-> Lens GetBlockResponse GetBlockResponse Int Int
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 :: (ValueHolder -> f ValueHolder)
-> GetBlockResponse -> f GetBlockResponse
getBlockResponse_block = (GetBlockResponse -> Sensitive ValueHolder)
-> (GetBlockResponse -> Sensitive ValueHolder -> GetBlockResponse)
-> Lens
GetBlockResponse
GetBlockResponse
(Sensitive ValueHolder)
(Sensitive ValueHolder)
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) ((Sensitive ValueHolder -> f (Sensitive ValueHolder))
-> GetBlockResponse -> f GetBlockResponse)
-> ((ValueHolder -> f ValueHolder)
-> Sensitive ValueHolder -> f (Sensitive ValueHolder))
-> (ValueHolder -> f ValueHolder)
-> GetBlockResponse
-> f GetBlockResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ValueHolder -> f ValueHolder)
-> Sensitive ValueHolder -> f (Sensitive ValueHolder)
forall a. Iso' (Sensitive a) a
Core._Sensitive
instance Prelude.NFData GetBlockResponse