{-# 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.ManagedBlockChain.CreateNode
(
CreateNode (..),
newCreateNode,
createNode_memberId,
createNode_tags,
createNode_clientRequestToken,
createNode_networkId,
createNode_nodeConfiguration,
CreateNodeResponse (..),
newCreateNodeResponse,
createNodeResponse_nodeId,
createNodeResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.ManagedBlockChain.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateNode = CreateNode'
{
CreateNode -> Maybe Text
memberId :: Prelude.Maybe Prelude.Text,
CreateNode -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
CreateNode -> Text
clientRequestToken :: Prelude.Text,
CreateNode -> Text
networkId :: Prelude.Text,
CreateNode -> NodeConfiguration
nodeConfiguration :: NodeConfiguration
}
deriving (CreateNode -> CreateNode -> Bool
(CreateNode -> CreateNode -> Bool)
-> (CreateNode -> CreateNode -> Bool) -> Eq CreateNode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateNode -> CreateNode -> Bool
$c/= :: CreateNode -> CreateNode -> Bool
== :: CreateNode -> CreateNode -> Bool
$c== :: CreateNode -> CreateNode -> Bool
Prelude.Eq, ReadPrec [CreateNode]
ReadPrec CreateNode
Int -> ReadS CreateNode
ReadS [CreateNode]
(Int -> ReadS CreateNode)
-> ReadS [CreateNode]
-> ReadPrec CreateNode
-> ReadPrec [CreateNode]
-> Read CreateNode
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateNode]
$creadListPrec :: ReadPrec [CreateNode]
readPrec :: ReadPrec CreateNode
$creadPrec :: ReadPrec CreateNode
readList :: ReadS [CreateNode]
$creadList :: ReadS [CreateNode]
readsPrec :: Int -> ReadS CreateNode
$creadsPrec :: Int -> ReadS CreateNode
Prelude.Read, Int -> CreateNode -> ShowS
[CreateNode] -> ShowS
CreateNode -> String
(Int -> CreateNode -> ShowS)
-> (CreateNode -> String)
-> ([CreateNode] -> ShowS)
-> Show CreateNode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateNode] -> ShowS
$cshowList :: [CreateNode] -> ShowS
show :: CreateNode -> String
$cshow :: CreateNode -> String
showsPrec :: Int -> CreateNode -> ShowS
$cshowsPrec :: Int -> CreateNode -> ShowS
Prelude.Show, (forall x. CreateNode -> Rep CreateNode x)
-> (forall x. Rep CreateNode x -> CreateNode) -> Generic CreateNode
forall x. Rep CreateNode x -> CreateNode
forall x. CreateNode -> Rep CreateNode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateNode x -> CreateNode
$cfrom :: forall x. CreateNode -> Rep CreateNode x
Prelude.Generic)
newCreateNode ::
Prelude.Text ->
Prelude.Text ->
NodeConfiguration ->
CreateNode
newCreateNode :: Text -> Text -> NodeConfiguration -> CreateNode
newCreateNode
Text
pClientRequestToken_
Text
pNetworkId_
NodeConfiguration
pNodeConfiguration_ =
CreateNode' :: Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> NodeConfiguration
-> CreateNode
CreateNode'
{ $sel:memberId:CreateNode' :: Maybe Text
memberId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateNode' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
$sel:clientRequestToken:CreateNode' :: Text
clientRequestToken = Text
pClientRequestToken_,
$sel:networkId:CreateNode' :: Text
networkId = Text
pNetworkId_,
$sel:nodeConfiguration:CreateNode' :: NodeConfiguration
nodeConfiguration = NodeConfiguration
pNodeConfiguration_
}
createNode_memberId :: Lens.Lens' CreateNode (Prelude.Maybe Prelude.Text)
createNode_memberId :: (Maybe Text -> f (Maybe Text)) -> CreateNode -> f CreateNode
createNode_memberId = (CreateNode -> Maybe Text)
-> (CreateNode -> Maybe Text -> CreateNode)
-> Lens CreateNode CreateNode (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNode' {Maybe Text
memberId :: Maybe Text
$sel:memberId:CreateNode' :: CreateNode -> Maybe Text
memberId} -> Maybe Text
memberId) (\s :: CreateNode
s@CreateNode' {} Maybe Text
a -> CreateNode
s {$sel:memberId:CreateNode' :: Maybe Text
memberId = Maybe Text
a} :: CreateNode)
createNode_tags :: Lens.Lens' CreateNode (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createNode_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateNode -> f CreateNode
createNode_tags = (CreateNode -> Maybe (HashMap Text Text))
-> (CreateNode -> Maybe (HashMap Text Text) -> CreateNode)
-> Lens
CreateNode
CreateNode
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNode' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateNode' :: CreateNode -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateNode
s@CreateNode' {} Maybe (HashMap Text Text)
a -> CreateNode
s {$sel:tags:CreateNode' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateNode) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateNode -> f CreateNode)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateNode
-> f CreateNode
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
-> Iso
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
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
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createNode_clientRequestToken :: Lens.Lens' CreateNode Prelude.Text
createNode_clientRequestToken :: (Text -> f Text) -> CreateNode -> f CreateNode
createNode_clientRequestToken = (CreateNode -> Text)
-> (CreateNode -> Text -> CreateNode)
-> Lens CreateNode CreateNode Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNode' {Text
clientRequestToken :: Text
$sel:clientRequestToken:CreateNode' :: CreateNode -> Text
clientRequestToken} -> Text
clientRequestToken) (\s :: CreateNode
s@CreateNode' {} Text
a -> CreateNode
s {$sel:clientRequestToken:CreateNode' :: Text
clientRequestToken = Text
a} :: CreateNode)
createNode_networkId :: Lens.Lens' CreateNode Prelude.Text
createNode_networkId :: (Text -> f Text) -> CreateNode -> f CreateNode
createNode_networkId = (CreateNode -> Text)
-> (CreateNode -> Text -> CreateNode)
-> Lens CreateNode CreateNode Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNode' {Text
networkId :: Text
$sel:networkId:CreateNode' :: CreateNode -> Text
networkId} -> Text
networkId) (\s :: CreateNode
s@CreateNode' {} Text
a -> CreateNode
s {$sel:networkId:CreateNode' :: Text
networkId = Text
a} :: CreateNode)
createNode_nodeConfiguration :: Lens.Lens' CreateNode NodeConfiguration
createNode_nodeConfiguration :: (NodeConfiguration -> f NodeConfiguration)
-> CreateNode -> f CreateNode
createNode_nodeConfiguration = (CreateNode -> NodeConfiguration)
-> (CreateNode -> NodeConfiguration -> CreateNode)
-> Lens CreateNode CreateNode NodeConfiguration NodeConfiguration
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNode' {NodeConfiguration
nodeConfiguration :: NodeConfiguration
$sel:nodeConfiguration:CreateNode' :: CreateNode -> NodeConfiguration
nodeConfiguration} -> NodeConfiguration
nodeConfiguration) (\s :: CreateNode
s@CreateNode' {} NodeConfiguration
a -> CreateNode
s {$sel:nodeConfiguration:CreateNode' :: NodeConfiguration
nodeConfiguration = NodeConfiguration
a} :: CreateNode)
instance Core.AWSRequest CreateNode where
type AWSResponse CreateNode = CreateNodeResponse
request :: CreateNode -> Request CreateNode
request = Service -> CreateNode -> Request CreateNode
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateNode
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateNode)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateNode))
-> Logger
-> Service
-> Proxy CreateNode
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateNode)))
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 -> Int -> CreateNodeResponse
CreateNodeResponse'
(Maybe Text -> Int -> CreateNodeResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateNodeResponse)
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
"NodeId")
Either String (Int -> CreateNodeResponse)
-> Either String Int -> Either String CreateNodeResponse
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 CreateNode
instance Prelude.NFData CreateNode
instance Core.ToHeaders CreateNode where
toHeaders :: CreateNode -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateNode -> 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 CreateNode where
toJSON :: CreateNode -> Value
toJSON CreateNode' {Maybe Text
Maybe (HashMap Text Text)
Text
NodeConfiguration
nodeConfiguration :: NodeConfiguration
networkId :: Text
clientRequestToken :: Text
tags :: Maybe (HashMap Text Text)
memberId :: Maybe Text
$sel:nodeConfiguration:CreateNode' :: CreateNode -> NodeConfiguration
$sel:networkId:CreateNode' :: CreateNode -> Text
$sel:clientRequestToken:CreateNode' :: CreateNode -> Text
$sel:tags:CreateNode' :: CreateNode -> Maybe (HashMap Text Text)
$sel:memberId:CreateNode' :: CreateNode -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"MemberId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
memberId,
(Text
"Tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"ClientRequestToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
clientRequestToken),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"NodeConfiguration" Text -> NodeConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NodeConfiguration
nodeConfiguration)
]
)
instance Core.ToPath CreateNode where
toPath :: CreateNode -> ByteString
toPath CreateNode' {Maybe Text
Maybe (HashMap Text Text)
Text
NodeConfiguration
nodeConfiguration :: NodeConfiguration
networkId :: Text
clientRequestToken :: Text
tags :: Maybe (HashMap Text Text)
memberId :: Maybe Text
$sel:nodeConfiguration:CreateNode' :: CreateNode -> NodeConfiguration
$sel:networkId:CreateNode' :: CreateNode -> Text
$sel:clientRequestToken:CreateNode' :: CreateNode -> Text
$sel:tags:CreateNode' :: CreateNode -> Maybe (HashMap Text Text)
$sel:memberId:CreateNode' :: CreateNode -> Maybe Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/networks/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
networkId, ByteString
"/nodes"]
instance Core.ToQuery CreateNode where
toQuery :: CreateNode -> QueryString
toQuery = QueryString -> CreateNode -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateNodeResponse = CreateNodeResponse'
{
CreateNodeResponse -> Maybe Text
nodeId :: Prelude.Maybe Prelude.Text,
CreateNodeResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateNodeResponse -> CreateNodeResponse -> Bool
(CreateNodeResponse -> CreateNodeResponse -> Bool)
-> (CreateNodeResponse -> CreateNodeResponse -> Bool)
-> Eq CreateNodeResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateNodeResponse -> CreateNodeResponse -> Bool
$c/= :: CreateNodeResponse -> CreateNodeResponse -> Bool
== :: CreateNodeResponse -> CreateNodeResponse -> Bool
$c== :: CreateNodeResponse -> CreateNodeResponse -> Bool
Prelude.Eq, ReadPrec [CreateNodeResponse]
ReadPrec CreateNodeResponse
Int -> ReadS CreateNodeResponse
ReadS [CreateNodeResponse]
(Int -> ReadS CreateNodeResponse)
-> ReadS [CreateNodeResponse]
-> ReadPrec CreateNodeResponse
-> ReadPrec [CreateNodeResponse]
-> Read CreateNodeResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateNodeResponse]
$creadListPrec :: ReadPrec [CreateNodeResponse]
readPrec :: ReadPrec CreateNodeResponse
$creadPrec :: ReadPrec CreateNodeResponse
readList :: ReadS [CreateNodeResponse]
$creadList :: ReadS [CreateNodeResponse]
readsPrec :: Int -> ReadS CreateNodeResponse
$creadsPrec :: Int -> ReadS CreateNodeResponse
Prelude.Read, Int -> CreateNodeResponse -> ShowS
[CreateNodeResponse] -> ShowS
CreateNodeResponse -> String
(Int -> CreateNodeResponse -> ShowS)
-> (CreateNodeResponse -> String)
-> ([CreateNodeResponse] -> ShowS)
-> Show CreateNodeResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateNodeResponse] -> ShowS
$cshowList :: [CreateNodeResponse] -> ShowS
show :: CreateNodeResponse -> String
$cshow :: CreateNodeResponse -> String
showsPrec :: Int -> CreateNodeResponse -> ShowS
$cshowsPrec :: Int -> CreateNodeResponse -> ShowS
Prelude.Show, (forall x. CreateNodeResponse -> Rep CreateNodeResponse x)
-> (forall x. Rep CreateNodeResponse x -> CreateNodeResponse)
-> Generic CreateNodeResponse
forall x. Rep CreateNodeResponse x -> CreateNodeResponse
forall x. CreateNodeResponse -> Rep CreateNodeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateNodeResponse x -> CreateNodeResponse
$cfrom :: forall x. CreateNodeResponse -> Rep CreateNodeResponse x
Prelude.Generic)
newCreateNodeResponse ::
Prelude.Int ->
CreateNodeResponse
newCreateNodeResponse :: Int -> CreateNodeResponse
newCreateNodeResponse Int
pHttpStatus_ =
CreateNodeResponse' :: Maybe Text -> Int -> CreateNodeResponse
CreateNodeResponse'
{ $sel:nodeId:CreateNodeResponse' :: Maybe Text
nodeId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateNodeResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createNodeResponse_nodeId :: Lens.Lens' CreateNodeResponse (Prelude.Maybe Prelude.Text)
createNodeResponse_nodeId :: (Maybe Text -> f (Maybe Text))
-> CreateNodeResponse -> f CreateNodeResponse
createNodeResponse_nodeId = (CreateNodeResponse -> Maybe Text)
-> (CreateNodeResponse -> Maybe Text -> CreateNodeResponse)
-> Lens
CreateNodeResponse CreateNodeResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNodeResponse' {Maybe Text
nodeId :: Maybe Text
$sel:nodeId:CreateNodeResponse' :: CreateNodeResponse -> Maybe Text
nodeId} -> Maybe Text
nodeId) (\s :: CreateNodeResponse
s@CreateNodeResponse' {} Maybe Text
a -> CreateNodeResponse
s {$sel:nodeId:CreateNodeResponse' :: Maybe Text
nodeId = Maybe Text
a} :: CreateNodeResponse)
createNodeResponse_httpStatus :: Lens.Lens' CreateNodeResponse Prelude.Int
createNodeResponse_httpStatus :: (Int -> f Int) -> CreateNodeResponse -> f CreateNodeResponse
createNodeResponse_httpStatus = (CreateNodeResponse -> Int)
-> (CreateNodeResponse -> Int -> CreateNodeResponse)
-> Lens CreateNodeResponse CreateNodeResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNodeResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateNodeResponse' :: CreateNodeResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateNodeResponse
s@CreateNodeResponse' {} Int
a -> CreateNodeResponse
s {$sel:httpStatus:CreateNodeResponse' :: Int
httpStatus = Int
a} :: CreateNodeResponse)
instance Prelude.NFData CreateNodeResponse