{-# 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.CreateProposal
(
CreateProposal (..),
newCreateProposal,
createProposal_description,
createProposal_tags,
createProposal_clientRequestToken,
createProposal_networkId,
createProposal_memberId,
createProposal_actions,
CreateProposalResponse (..),
newCreateProposalResponse,
createProposalResponse_proposalId,
createProposalResponse_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 CreateProposal = CreateProposal'
{
CreateProposal -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
CreateProposal -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
CreateProposal -> Text
clientRequestToken :: Prelude.Text,
CreateProposal -> Text
networkId :: Prelude.Text,
CreateProposal -> Text
memberId :: Prelude.Text,
CreateProposal -> ProposalActions
actions :: ProposalActions
}
deriving (CreateProposal -> CreateProposal -> Bool
(CreateProposal -> CreateProposal -> Bool)
-> (CreateProposal -> CreateProposal -> Bool) -> Eq CreateProposal
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateProposal -> CreateProposal -> Bool
$c/= :: CreateProposal -> CreateProposal -> Bool
== :: CreateProposal -> CreateProposal -> Bool
$c== :: CreateProposal -> CreateProposal -> Bool
Prelude.Eq, ReadPrec [CreateProposal]
ReadPrec CreateProposal
Int -> ReadS CreateProposal
ReadS [CreateProposal]
(Int -> ReadS CreateProposal)
-> ReadS [CreateProposal]
-> ReadPrec CreateProposal
-> ReadPrec [CreateProposal]
-> Read CreateProposal
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateProposal]
$creadListPrec :: ReadPrec [CreateProposal]
readPrec :: ReadPrec CreateProposal
$creadPrec :: ReadPrec CreateProposal
readList :: ReadS [CreateProposal]
$creadList :: ReadS [CreateProposal]
readsPrec :: Int -> ReadS CreateProposal
$creadsPrec :: Int -> ReadS CreateProposal
Prelude.Read, Int -> CreateProposal -> ShowS
[CreateProposal] -> ShowS
CreateProposal -> String
(Int -> CreateProposal -> ShowS)
-> (CreateProposal -> String)
-> ([CreateProposal] -> ShowS)
-> Show CreateProposal
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateProposal] -> ShowS
$cshowList :: [CreateProposal] -> ShowS
show :: CreateProposal -> String
$cshow :: CreateProposal -> String
showsPrec :: Int -> CreateProposal -> ShowS
$cshowsPrec :: Int -> CreateProposal -> ShowS
Prelude.Show, (forall x. CreateProposal -> Rep CreateProposal x)
-> (forall x. Rep CreateProposal x -> CreateProposal)
-> Generic CreateProposal
forall x. Rep CreateProposal x -> CreateProposal
forall x. CreateProposal -> Rep CreateProposal x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateProposal x -> CreateProposal
$cfrom :: forall x. CreateProposal -> Rep CreateProposal x
Prelude.Generic)
newCreateProposal ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
ProposalActions ->
CreateProposal
newCreateProposal :: Text -> Text -> Text -> ProposalActions -> CreateProposal
newCreateProposal
Text
pClientRequestToken_
Text
pNetworkId_
Text
pMemberId_
ProposalActions
pActions_ =
CreateProposal' :: Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> Text
-> ProposalActions
-> CreateProposal
CreateProposal'
{ $sel:description:CreateProposal' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateProposal' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
$sel:clientRequestToken:CreateProposal' :: Text
clientRequestToken = Text
pClientRequestToken_,
$sel:networkId:CreateProposal' :: Text
networkId = Text
pNetworkId_,
$sel:memberId:CreateProposal' :: Text
memberId = Text
pMemberId_,
$sel:actions:CreateProposal' :: ProposalActions
actions = ProposalActions
pActions_
}
createProposal_description :: Lens.Lens' CreateProposal (Prelude.Maybe Prelude.Text)
createProposal_description :: (Maybe Text -> f (Maybe Text))
-> CreateProposal -> f CreateProposal
createProposal_description = (CreateProposal -> Maybe Text)
-> (CreateProposal -> Maybe Text -> CreateProposal)
-> Lens CreateProposal CreateProposal (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProposal' {Maybe Text
description :: Maybe Text
$sel:description:CreateProposal' :: CreateProposal -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateProposal
s@CreateProposal' {} Maybe Text
a -> CreateProposal
s {$sel:description:CreateProposal' :: Maybe Text
description = Maybe Text
a} :: CreateProposal)
createProposal_tags :: Lens.Lens' CreateProposal (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createProposal_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateProposal -> f CreateProposal
createProposal_tags = (CreateProposal -> Maybe (HashMap Text Text))
-> (CreateProposal -> Maybe (HashMap Text Text) -> CreateProposal)
-> Lens
CreateProposal
CreateProposal
(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 (\CreateProposal' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateProposal' :: CreateProposal -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateProposal
s@CreateProposal' {} Maybe (HashMap Text Text)
a -> CreateProposal
s {$sel:tags:CreateProposal' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateProposal) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateProposal -> f CreateProposal)
-> ((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)))
-> CreateProposal
-> f CreateProposal
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
createProposal_clientRequestToken :: Lens.Lens' CreateProposal Prelude.Text
createProposal_clientRequestToken :: (Text -> f Text) -> CreateProposal -> f CreateProposal
createProposal_clientRequestToken = (CreateProposal -> Text)
-> (CreateProposal -> Text -> CreateProposal)
-> Lens CreateProposal CreateProposal Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProposal' {Text
clientRequestToken :: Text
$sel:clientRequestToken:CreateProposal' :: CreateProposal -> Text
clientRequestToken} -> Text
clientRequestToken) (\s :: CreateProposal
s@CreateProposal' {} Text
a -> CreateProposal
s {$sel:clientRequestToken:CreateProposal' :: Text
clientRequestToken = Text
a} :: CreateProposal)
createProposal_networkId :: Lens.Lens' CreateProposal Prelude.Text
createProposal_networkId :: (Text -> f Text) -> CreateProposal -> f CreateProposal
createProposal_networkId = (CreateProposal -> Text)
-> (CreateProposal -> Text -> CreateProposal)
-> Lens CreateProposal CreateProposal Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProposal' {Text
networkId :: Text
$sel:networkId:CreateProposal' :: CreateProposal -> Text
networkId} -> Text
networkId) (\s :: CreateProposal
s@CreateProposal' {} Text
a -> CreateProposal
s {$sel:networkId:CreateProposal' :: Text
networkId = Text
a} :: CreateProposal)
createProposal_memberId :: Lens.Lens' CreateProposal Prelude.Text
createProposal_memberId :: (Text -> f Text) -> CreateProposal -> f CreateProposal
createProposal_memberId = (CreateProposal -> Text)
-> (CreateProposal -> Text -> CreateProposal)
-> Lens CreateProposal CreateProposal Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProposal' {Text
memberId :: Text
$sel:memberId:CreateProposal' :: CreateProposal -> Text
memberId} -> Text
memberId) (\s :: CreateProposal
s@CreateProposal' {} Text
a -> CreateProposal
s {$sel:memberId:CreateProposal' :: Text
memberId = Text
a} :: CreateProposal)
createProposal_actions :: Lens.Lens' CreateProposal ProposalActions
createProposal_actions :: (ProposalActions -> f ProposalActions)
-> CreateProposal -> f CreateProposal
createProposal_actions = (CreateProposal -> ProposalActions)
-> (CreateProposal -> ProposalActions -> CreateProposal)
-> Lens
CreateProposal CreateProposal ProposalActions ProposalActions
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProposal' {ProposalActions
actions :: ProposalActions
$sel:actions:CreateProposal' :: CreateProposal -> ProposalActions
actions} -> ProposalActions
actions) (\s :: CreateProposal
s@CreateProposal' {} ProposalActions
a -> CreateProposal
s {$sel:actions:CreateProposal' :: ProposalActions
actions = ProposalActions
a} :: CreateProposal)
instance Core.AWSRequest CreateProposal where
type
AWSResponse CreateProposal =
CreateProposalResponse
request :: CreateProposal -> Request CreateProposal
request = Service -> CreateProposal -> Request CreateProposal
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateProposal
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateProposal)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateProposal))
-> Logger
-> Service
-> Proxy CreateProposal
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateProposal)))
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 -> CreateProposalResponse
CreateProposalResponse'
(Maybe Text -> Int -> CreateProposalResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateProposalResponse)
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
"ProposalId")
Either String (Int -> CreateProposalResponse)
-> Either String Int -> Either String CreateProposalResponse
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 CreateProposal
instance Prelude.NFData CreateProposal
instance Core.ToHeaders CreateProposal where
toHeaders :: CreateProposal -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateProposal -> 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 CreateProposal where
toJSON :: CreateProposal -> Value
toJSON CreateProposal' {Maybe Text
Maybe (HashMap Text Text)
Text
ProposalActions
actions :: ProposalActions
memberId :: Text
networkId :: Text
clientRequestToken :: Text
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
$sel:actions:CreateProposal' :: CreateProposal -> ProposalActions
$sel:memberId:CreateProposal' :: CreateProposal -> Text
$sel:networkId:CreateProposal' :: CreateProposal -> Text
$sel:clientRequestToken:CreateProposal' :: CreateProposal -> Text
$sel:tags:CreateProposal' :: CreateProposal -> Maybe (HashMap Text Text)
$sel:description:CreateProposal' :: CreateProposal -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Description" 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
description,
(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
"MemberId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
memberId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Actions" Text -> ProposalActions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ProposalActions
actions)
]
)
instance Core.ToPath CreateProposal where
toPath :: CreateProposal -> ByteString
toPath CreateProposal' {Maybe Text
Maybe (HashMap Text Text)
Text
ProposalActions
actions :: ProposalActions
memberId :: Text
networkId :: Text
clientRequestToken :: Text
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
$sel:actions:CreateProposal' :: CreateProposal -> ProposalActions
$sel:memberId:CreateProposal' :: CreateProposal -> Text
$sel:networkId:CreateProposal' :: CreateProposal -> Text
$sel:clientRequestToken:CreateProposal' :: CreateProposal -> Text
$sel:tags:CreateProposal' :: CreateProposal -> Maybe (HashMap Text Text)
$sel:description:CreateProposal' :: CreateProposal -> 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
"/proposals"]
instance Core.ToQuery CreateProposal where
toQuery :: CreateProposal -> QueryString
toQuery = QueryString -> CreateProposal -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateProposalResponse = CreateProposalResponse'
{
CreateProposalResponse -> Maybe Text
proposalId :: Prelude.Maybe Prelude.Text,
CreateProposalResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateProposalResponse -> CreateProposalResponse -> Bool
(CreateProposalResponse -> CreateProposalResponse -> Bool)
-> (CreateProposalResponse -> CreateProposalResponse -> Bool)
-> Eq CreateProposalResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateProposalResponse -> CreateProposalResponse -> Bool
$c/= :: CreateProposalResponse -> CreateProposalResponse -> Bool
== :: CreateProposalResponse -> CreateProposalResponse -> Bool
$c== :: CreateProposalResponse -> CreateProposalResponse -> Bool
Prelude.Eq, ReadPrec [CreateProposalResponse]
ReadPrec CreateProposalResponse
Int -> ReadS CreateProposalResponse
ReadS [CreateProposalResponse]
(Int -> ReadS CreateProposalResponse)
-> ReadS [CreateProposalResponse]
-> ReadPrec CreateProposalResponse
-> ReadPrec [CreateProposalResponse]
-> Read CreateProposalResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateProposalResponse]
$creadListPrec :: ReadPrec [CreateProposalResponse]
readPrec :: ReadPrec CreateProposalResponse
$creadPrec :: ReadPrec CreateProposalResponse
readList :: ReadS [CreateProposalResponse]
$creadList :: ReadS [CreateProposalResponse]
readsPrec :: Int -> ReadS CreateProposalResponse
$creadsPrec :: Int -> ReadS CreateProposalResponse
Prelude.Read, Int -> CreateProposalResponse -> ShowS
[CreateProposalResponse] -> ShowS
CreateProposalResponse -> String
(Int -> CreateProposalResponse -> ShowS)
-> (CreateProposalResponse -> String)
-> ([CreateProposalResponse] -> ShowS)
-> Show CreateProposalResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateProposalResponse] -> ShowS
$cshowList :: [CreateProposalResponse] -> ShowS
show :: CreateProposalResponse -> String
$cshow :: CreateProposalResponse -> String
showsPrec :: Int -> CreateProposalResponse -> ShowS
$cshowsPrec :: Int -> CreateProposalResponse -> ShowS
Prelude.Show, (forall x. CreateProposalResponse -> Rep CreateProposalResponse x)
-> (forall x.
Rep CreateProposalResponse x -> CreateProposalResponse)
-> Generic CreateProposalResponse
forall x. Rep CreateProposalResponse x -> CreateProposalResponse
forall x. CreateProposalResponse -> Rep CreateProposalResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateProposalResponse x -> CreateProposalResponse
$cfrom :: forall x. CreateProposalResponse -> Rep CreateProposalResponse x
Prelude.Generic)
newCreateProposalResponse ::
Prelude.Int ->
CreateProposalResponse
newCreateProposalResponse :: Int -> CreateProposalResponse
newCreateProposalResponse Int
pHttpStatus_ =
CreateProposalResponse' :: Maybe Text -> Int -> CreateProposalResponse
CreateProposalResponse'
{ $sel:proposalId:CreateProposalResponse' :: Maybe Text
proposalId =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateProposalResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createProposalResponse_proposalId :: Lens.Lens' CreateProposalResponse (Prelude.Maybe Prelude.Text)
createProposalResponse_proposalId :: (Maybe Text -> f (Maybe Text))
-> CreateProposalResponse -> f CreateProposalResponse
createProposalResponse_proposalId = (CreateProposalResponse -> Maybe Text)
-> (CreateProposalResponse -> Maybe Text -> CreateProposalResponse)
-> Lens
CreateProposalResponse
CreateProposalResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProposalResponse' {Maybe Text
proposalId :: Maybe Text
$sel:proposalId:CreateProposalResponse' :: CreateProposalResponse -> Maybe Text
proposalId} -> Maybe Text
proposalId) (\s :: CreateProposalResponse
s@CreateProposalResponse' {} Maybe Text
a -> CreateProposalResponse
s {$sel:proposalId:CreateProposalResponse' :: Maybe Text
proposalId = Maybe Text
a} :: CreateProposalResponse)
createProposalResponse_httpStatus :: Lens.Lens' CreateProposalResponse Prelude.Int
createProposalResponse_httpStatus :: (Int -> f Int)
-> CreateProposalResponse -> f CreateProposalResponse
createProposalResponse_httpStatus = (CreateProposalResponse -> Int)
-> (CreateProposalResponse -> Int -> CreateProposalResponse)
-> Lens CreateProposalResponse CreateProposalResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProposalResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateProposalResponse' :: CreateProposalResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateProposalResponse
s@CreateProposalResponse' {} Int
a -> CreateProposalResponse
s {$sel:httpStatus:CreateProposalResponse' :: Int
httpStatus = Int
a} :: CreateProposalResponse)
instance Prelude.NFData CreateProposalResponse