{-# 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.ManagedBlockChain.CreateNetwork
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a new blockchain network using Amazon Managed Blockchain.
--
-- Applies only to Hyperledger Fabric.
module Amazonka.ManagedBlockChain.CreateNetwork
  ( -- * Creating a Request
    CreateNetwork (..),
    newCreateNetwork,

    -- * Request Lenses
    createNetwork_frameworkConfiguration,
    createNetwork_description,
    createNetwork_tags,
    createNetwork_clientRequestToken,
    createNetwork_name,
    createNetwork_framework,
    createNetwork_frameworkVersion,
    createNetwork_votingPolicy,
    createNetwork_memberConfiguration,

    -- * Destructuring the Response
    CreateNetworkResponse (..),
    newCreateNetworkResponse,

    -- * Response Lenses
    createNetworkResponse_memberId,
    createNetworkResponse_networkId,
    createNetworkResponse_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

-- | /See:/ 'newCreateNetwork' smart constructor.
data CreateNetwork = CreateNetwork'
  { -- | Configuration properties of the blockchain framework relevant to the
    -- network configuration.
    CreateNetwork -> Maybe NetworkFrameworkConfiguration
frameworkConfiguration :: Prelude.Maybe NetworkFrameworkConfiguration,
    -- | An optional description for the network.
    CreateNetwork -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | Tags to assign to the network. Each tag consists of a key and optional
    -- value.
    --
    -- When specifying tags during creation, you can specify multiple key-value
    -- pairs in a single request, with an overall maximum of 50 tags added to
    -- each resource.
    --
    -- For more information about tags, see
    -- <https://docs.aws.amazon.com/managed-blockchain/latest/ethereum-dev/tagging-resources.html Tagging Resources>
    -- in the /Amazon Managed Blockchain Ethereum Developer Guide/, or
    -- <https://docs.aws.amazon.com/managed-blockchain/latest/hyperledger-fabric-dev/tagging-resources.html Tagging Resources>
    -- in the /Amazon Managed Blockchain Hyperledger Fabric Developer Guide/.
    CreateNetwork -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | A unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the operation. An idempotent operation completes no more
    -- than one time. This identifier is required only if you make a service
    -- request directly using an HTTP client. It is generated automatically if
    -- you use an AWS SDK or the AWS CLI.
    CreateNetwork -> Text
clientRequestToken :: Prelude.Text,
    -- | The name of the network.
    CreateNetwork -> Text
name :: Prelude.Text,
    -- | The blockchain framework that the network uses.
    CreateNetwork -> Framework
framework :: Framework,
    -- | The version of the blockchain framework that the network uses.
    CreateNetwork -> Text
frameworkVersion :: Prelude.Text,
    -- | The voting rules used by the network to determine if a proposal is
    -- approved.
    CreateNetwork -> VotingPolicy
votingPolicy :: VotingPolicy,
    -- | Configuration properties for the first member within the network.
    CreateNetwork -> MemberConfiguration
memberConfiguration :: MemberConfiguration
  }
  deriving (CreateNetwork -> CreateNetwork -> Bool
(CreateNetwork -> CreateNetwork -> Bool)
-> (CreateNetwork -> CreateNetwork -> Bool) -> Eq CreateNetwork
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateNetwork -> CreateNetwork -> Bool
$c/= :: CreateNetwork -> CreateNetwork -> Bool
== :: CreateNetwork -> CreateNetwork -> Bool
$c== :: CreateNetwork -> CreateNetwork -> Bool
Prelude.Eq, Int -> CreateNetwork -> ShowS
[CreateNetwork] -> ShowS
CreateNetwork -> String
(Int -> CreateNetwork -> ShowS)
-> (CreateNetwork -> String)
-> ([CreateNetwork] -> ShowS)
-> Show CreateNetwork
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateNetwork] -> ShowS
$cshowList :: [CreateNetwork] -> ShowS
show :: CreateNetwork -> String
$cshow :: CreateNetwork -> String
showsPrec :: Int -> CreateNetwork -> ShowS
$cshowsPrec :: Int -> CreateNetwork -> ShowS
Prelude.Show, (forall x. CreateNetwork -> Rep CreateNetwork x)
-> (forall x. Rep CreateNetwork x -> CreateNetwork)
-> Generic CreateNetwork
forall x. Rep CreateNetwork x -> CreateNetwork
forall x. CreateNetwork -> Rep CreateNetwork x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateNetwork x -> CreateNetwork
$cfrom :: forall x. CreateNetwork -> Rep CreateNetwork x
Prelude.Generic)

-- |
-- Create a value of 'CreateNetwork' 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:
--
-- 'frameworkConfiguration', 'createNetwork_frameworkConfiguration' - Configuration properties of the blockchain framework relevant to the
-- network configuration.
--
-- 'description', 'createNetwork_description' - An optional description for the network.
--
-- 'tags', 'createNetwork_tags' - Tags to assign to the network. Each tag consists of a key and optional
-- value.
--
-- When specifying tags during creation, you can specify multiple key-value
-- pairs in a single request, with an overall maximum of 50 tags added to
-- each resource.
--
-- For more information about tags, see
-- <https://docs.aws.amazon.com/managed-blockchain/latest/ethereum-dev/tagging-resources.html Tagging Resources>
-- in the /Amazon Managed Blockchain Ethereum Developer Guide/, or
-- <https://docs.aws.amazon.com/managed-blockchain/latest/hyperledger-fabric-dev/tagging-resources.html Tagging Resources>
-- in the /Amazon Managed Blockchain Hyperledger Fabric Developer Guide/.
--
-- 'clientRequestToken', 'createNetwork_clientRequestToken' - A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the operation. An idempotent operation completes no more
-- than one time. This identifier is required only if you make a service
-- request directly using an HTTP client. It is generated automatically if
-- you use an AWS SDK or the AWS CLI.
--
-- 'name', 'createNetwork_name' - The name of the network.
--
-- 'framework', 'createNetwork_framework' - The blockchain framework that the network uses.
--
-- 'frameworkVersion', 'createNetwork_frameworkVersion' - The version of the blockchain framework that the network uses.
--
-- 'votingPolicy', 'createNetwork_votingPolicy' - The voting rules used by the network to determine if a proposal is
-- approved.
--
-- 'memberConfiguration', 'createNetwork_memberConfiguration' - Configuration properties for the first member within the network.
newCreateNetwork ::
  -- | 'clientRequestToken'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'framework'
  Framework ->
  -- | 'frameworkVersion'
  Prelude.Text ->
  -- | 'votingPolicy'
  VotingPolicy ->
  -- | 'memberConfiguration'
  MemberConfiguration ->
  CreateNetwork
newCreateNetwork :: Text
-> Text
-> Framework
-> Text
-> VotingPolicy
-> MemberConfiguration
-> CreateNetwork
newCreateNetwork
  Text
pClientRequestToken_
  Text
pName_
  Framework
pFramework_
  Text
pFrameworkVersion_
  VotingPolicy
pVotingPolicy_
  MemberConfiguration
pMemberConfiguration_ =
    CreateNetwork' :: Maybe NetworkFrameworkConfiguration
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> Framework
-> Text
-> VotingPolicy
-> MemberConfiguration
-> CreateNetwork
CreateNetwork'
      { $sel:frameworkConfiguration:CreateNetwork' :: Maybe NetworkFrameworkConfiguration
frameworkConfiguration =
          Maybe NetworkFrameworkConfiguration
forall a. Maybe a
Prelude.Nothing,
        $sel:description:CreateNetwork' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateNetwork' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:clientRequestToken:CreateNetwork' :: Text
clientRequestToken = Text
pClientRequestToken_,
        $sel:name:CreateNetwork' :: Text
name = Text
pName_,
        $sel:framework:CreateNetwork' :: Framework
framework = Framework
pFramework_,
        $sel:frameworkVersion:CreateNetwork' :: Text
frameworkVersion = Text
pFrameworkVersion_,
        $sel:votingPolicy:CreateNetwork' :: VotingPolicy
votingPolicy = VotingPolicy
pVotingPolicy_,
        $sel:memberConfiguration:CreateNetwork' :: MemberConfiguration
memberConfiguration = MemberConfiguration
pMemberConfiguration_
      }

-- | Configuration properties of the blockchain framework relevant to the
-- network configuration.
createNetwork_frameworkConfiguration :: Lens.Lens' CreateNetwork (Prelude.Maybe NetworkFrameworkConfiguration)
createNetwork_frameworkConfiguration :: (Maybe NetworkFrameworkConfiguration
 -> f (Maybe NetworkFrameworkConfiguration))
-> CreateNetwork -> f CreateNetwork
createNetwork_frameworkConfiguration = (CreateNetwork -> Maybe NetworkFrameworkConfiguration)
-> (CreateNetwork
    -> Maybe NetworkFrameworkConfiguration -> CreateNetwork)
-> Lens
     CreateNetwork
     CreateNetwork
     (Maybe NetworkFrameworkConfiguration)
     (Maybe NetworkFrameworkConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNetwork' {Maybe NetworkFrameworkConfiguration
frameworkConfiguration :: Maybe NetworkFrameworkConfiguration
$sel:frameworkConfiguration:CreateNetwork' :: CreateNetwork -> Maybe NetworkFrameworkConfiguration
frameworkConfiguration} -> Maybe NetworkFrameworkConfiguration
frameworkConfiguration) (\s :: CreateNetwork
s@CreateNetwork' {} Maybe NetworkFrameworkConfiguration
a -> CreateNetwork
s {$sel:frameworkConfiguration:CreateNetwork' :: Maybe NetworkFrameworkConfiguration
frameworkConfiguration = Maybe NetworkFrameworkConfiguration
a} :: CreateNetwork)

-- | An optional description for the network.
createNetwork_description :: Lens.Lens' CreateNetwork (Prelude.Maybe Prelude.Text)
createNetwork_description :: (Maybe Text -> f (Maybe Text)) -> CreateNetwork -> f CreateNetwork
createNetwork_description = (CreateNetwork -> Maybe Text)
-> (CreateNetwork -> Maybe Text -> CreateNetwork)
-> Lens CreateNetwork CreateNetwork (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNetwork' {Maybe Text
description :: Maybe Text
$sel:description:CreateNetwork' :: CreateNetwork -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateNetwork
s@CreateNetwork' {} Maybe Text
a -> CreateNetwork
s {$sel:description:CreateNetwork' :: Maybe Text
description = Maybe Text
a} :: CreateNetwork)

-- | Tags to assign to the network. Each tag consists of a key and optional
-- value.
--
-- When specifying tags during creation, you can specify multiple key-value
-- pairs in a single request, with an overall maximum of 50 tags added to
-- each resource.
--
-- For more information about tags, see
-- <https://docs.aws.amazon.com/managed-blockchain/latest/ethereum-dev/tagging-resources.html Tagging Resources>
-- in the /Amazon Managed Blockchain Ethereum Developer Guide/, or
-- <https://docs.aws.amazon.com/managed-blockchain/latest/hyperledger-fabric-dev/tagging-resources.html Tagging Resources>
-- in the /Amazon Managed Blockchain Hyperledger Fabric Developer Guide/.
createNetwork_tags :: Lens.Lens' CreateNetwork (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createNetwork_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateNetwork -> f CreateNetwork
createNetwork_tags = (CreateNetwork -> Maybe (HashMap Text Text))
-> (CreateNetwork -> Maybe (HashMap Text Text) -> CreateNetwork)
-> Lens
     CreateNetwork
     CreateNetwork
     (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 (\CreateNetwork' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateNetwork' :: CreateNetwork -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateNetwork
s@CreateNetwork' {} Maybe (HashMap Text Text)
a -> CreateNetwork
s {$sel:tags:CreateNetwork' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateNetwork) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateNetwork -> f CreateNetwork)
-> ((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)))
-> CreateNetwork
-> f CreateNetwork
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

-- | A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the operation. An idempotent operation completes no more
-- than one time. This identifier is required only if you make a service
-- request directly using an HTTP client. It is generated automatically if
-- you use an AWS SDK or the AWS CLI.
createNetwork_clientRequestToken :: Lens.Lens' CreateNetwork Prelude.Text
createNetwork_clientRequestToken :: (Text -> f Text) -> CreateNetwork -> f CreateNetwork
createNetwork_clientRequestToken = (CreateNetwork -> Text)
-> (CreateNetwork -> Text -> CreateNetwork)
-> Lens CreateNetwork CreateNetwork Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNetwork' {Text
clientRequestToken :: Text
$sel:clientRequestToken:CreateNetwork' :: CreateNetwork -> Text
clientRequestToken} -> Text
clientRequestToken) (\s :: CreateNetwork
s@CreateNetwork' {} Text
a -> CreateNetwork
s {$sel:clientRequestToken:CreateNetwork' :: Text
clientRequestToken = Text
a} :: CreateNetwork)

-- | The name of the network.
createNetwork_name :: Lens.Lens' CreateNetwork Prelude.Text
createNetwork_name :: (Text -> f Text) -> CreateNetwork -> f CreateNetwork
createNetwork_name = (CreateNetwork -> Text)
-> (CreateNetwork -> Text -> CreateNetwork)
-> Lens CreateNetwork CreateNetwork Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNetwork' {Text
name :: Text
$sel:name:CreateNetwork' :: CreateNetwork -> Text
name} -> Text
name) (\s :: CreateNetwork
s@CreateNetwork' {} Text
a -> CreateNetwork
s {$sel:name:CreateNetwork' :: Text
name = Text
a} :: CreateNetwork)

-- | The blockchain framework that the network uses.
createNetwork_framework :: Lens.Lens' CreateNetwork Framework
createNetwork_framework :: (Framework -> f Framework) -> CreateNetwork -> f CreateNetwork
createNetwork_framework = (CreateNetwork -> Framework)
-> (CreateNetwork -> Framework -> CreateNetwork)
-> Lens CreateNetwork CreateNetwork Framework Framework
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNetwork' {Framework
framework :: Framework
$sel:framework:CreateNetwork' :: CreateNetwork -> Framework
framework} -> Framework
framework) (\s :: CreateNetwork
s@CreateNetwork' {} Framework
a -> CreateNetwork
s {$sel:framework:CreateNetwork' :: Framework
framework = Framework
a} :: CreateNetwork)

-- | The version of the blockchain framework that the network uses.
createNetwork_frameworkVersion :: Lens.Lens' CreateNetwork Prelude.Text
createNetwork_frameworkVersion :: (Text -> f Text) -> CreateNetwork -> f CreateNetwork
createNetwork_frameworkVersion = (CreateNetwork -> Text)
-> (CreateNetwork -> Text -> CreateNetwork)
-> Lens CreateNetwork CreateNetwork Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNetwork' {Text
frameworkVersion :: Text
$sel:frameworkVersion:CreateNetwork' :: CreateNetwork -> Text
frameworkVersion} -> Text
frameworkVersion) (\s :: CreateNetwork
s@CreateNetwork' {} Text
a -> CreateNetwork
s {$sel:frameworkVersion:CreateNetwork' :: Text
frameworkVersion = Text
a} :: CreateNetwork)

-- | The voting rules used by the network to determine if a proposal is
-- approved.
createNetwork_votingPolicy :: Lens.Lens' CreateNetwork VotingPolicy
createNetwork_votingPolicy :: (VotingPolicy -> f VotingPolicy)
-> CreateNetwork -> f CreateNetwork
createNetwork_votingPolicy = (CreateNetwork -> VotingPolicy)
-> (CreateNetwork -> VotingPolicy -> CreateNetwork)
-> Lens CreateNetwork CreateNetwork VotingPolicy VotingPolicy
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNetwork' {VotingPolicy
votingPolicy :: VotingPolicy
$sel:votingPolicy:CreateNetwork' :: CreateNetwork -> VotingPolicy
votingPolicy} -> VotingPolicy
votingPolicy) (\s :: CreateNetwork
s@CreateNetwork' {} VotingPolicy
a -> CreateNetwork
s {$sel:votingPolicy:CreateNetwork' :: VotingPolicy
votingPolicy = VotingPolicy
a} :: CreateNetwork)

-- | Configuration properties for the first member within the network.
createNetwork_memberConfiguration :: Lens.Lens' CreateNetwork MemberConfiguration
createNetwork_memberConfiguration :: (MemberConfiguration -> f MemberConfiguration)
-> CreateNetwork -> f CreateNetwork
createNetwork_memberConfiguration = (CreateNetwork -> MemberConfiguration)
-> (CreateNetwork -> MemberConfiguration -> CreateNetwork)
-> Lens
     CreateNetwork CreateNetwork MemberConfiguration MemberConfiguration
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNetwork' {MemberConfiguration
memberConfiguration :: MemberConfiguration
$sel:memberConfiguration:CreateNetwork' :: CreateNetwork -> MemberConfiguration
memberConfiguration} -> MemberConfiguration
memberConfiguration) (\s :: CreateNetwork
s@CreateNetwork' {} MemberConfiguration
a -> CreateNetwork
s {$sel:memberConfiguration:CreateNetwork' :: MemberConfiguration
memberConfiguration = MemberConfiguration
a} :: CreateNetwork)

instance Core.AWSRequest CreateNetwork where
  type
    AWSResponse CreateNetwork =
      CreateNetworkResponse
  request :: CreateNetwork -> Request CreateNetwork
request = Service -> CreateNetwork -> Request CreateNetwork
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateNetwork
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateNetwork)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateNetwork))
-> Logger
-> Service
-> Proxy CreateNetwork
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateNetwork)))
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 -> Maybe Text -> Int -> CreateNetworkResponse
CreateNetworkResponse'
            (Maybe Text -> Maybe Text -> Int -> CreateNetworkResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> CreateNetworkResponse)
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
"MemberId")
            Either String (Maybe Text -> Int -> CreateNetworkResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateNetworkResponse)
forall (f :: * -> *) a b. Applicative f => 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
"NetworkId")
            Either String (Int -> CreateNetworkResponse)
-> Either String Int -> Either String CreateNetworkResponse
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 CreateNetwork

instance Prelude.NFData CreateNetwork

instance Core.ToHeaders CreateNetwork where
  toHeaders :: CreateNetwork -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateNetwork -> 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 CreateNetwork where
  toJSON :: CreateNetwork -> Value
toJSON CreateNetwork' {Maybe Text
Maybe (HashMap Text Text)
Maybe NetworkFrameworkConfiguration
Text
Framework
MemberConfiguration
VotingPolicy
memberConfiguration :: MemberConfiguration
votingPolicy :: VotingPolicy
frameworkVersion :: Text
framework :: Framework
name :: Text
clientRequestToken :: Text
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
frameworkConfiguration :: Maybe NetworkFrameworkConfiguration
$sel:memberConfiguration:CreateNetwork' :: CreateNetwork -> MemberConfiguration
$sel:votingPolicy:CreateNetwork' :: CreateNetwork -> VotingPolicy
$sel:frameworkVersion:CreateNetwork' :: CreateNetwork -> Text
$sel:framework:CreateNetwork' :: CreateNetwork -> Framework
$sel:name:CreateNetwork' :: CreateNetwork -> Text
$sel:clientRequestToken:CreateNetwork' :: CreateNetwork -> Text
$sel:tags:CreateNetwork' :: CreateNetwork -> Maybe (HashMap Text Text)
$sel:description:CreateNetwork' :: CreateNetwork -> Maybe Text
$sel:frameworkConfiguration:CreateNetwork' :: CreateNetwork -> Maybe NetworkFrameworkConfiguration
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"FrameworkConfiguration" Text -> NetworkFrameworkConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NetworkFrameworkConfiguration -> Pair)
-> Maybe NetworkFrameworkConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NetworkFrameworkConfiguration
frameworkConfiguration,
            (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
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Framework" Text -> Framework -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Framework
framework),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"FrameworkVersion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
frameworkVersion),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"VotingPolicy" Text -> VotingPolicy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= VotingPolicy
votingPolicy),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"MemberConfiguration" Text -> MemberConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= MemberConfiguration
memberConfiguration)
          ]
      )

instance Core.ToPath CreateNetwork where
  toPath :: CreateNetwork -> ByteString
toPath = ByteString -> CreateNetwork -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/networks"

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

-- | /See:/ 'newCreateNetworkResponse' smart constructor.
data CreateNetworkResponse = CreateNetworkResponse'
  { -- | The unique identifier for the first member within the network.
    CreateNetworkResponse -> Maybe Text
memberId :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the network.
    CreateNetworkResponse -> Maybe Text
networkId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateNetworkResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateNetworkResponse -> CreateNetworkResponse -> Bool
(CreateNetworkResponse -> CreateNetworkResponse -> Bool)
-> (CreateNetworkResponse -> CreateNetworkResponse -> Bool)
-> Eq CreateNetworkResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateNetworkResponse -> CreateNetworkResponse -> Bool
$c/= :: CreateNetworkResponse -> CreateNetworkResponse -> Bool
== :: CreateNetworkResponse -> CreateNetworkResponse -> Bool
$c== :: CreateNetworkResponse -> CreateNetworkResponse -> Bool
Prelude.Eq, ReadPrec [CreateNetworkResponse]
ReadPrec CreateNetworkResponse
Int -> ReadS CreateNetworkResponse
ReadS [CreateNetworkResponse]
(Int -> ReadS CreateNetworkResponse)
-> ReadS [CreateNetworkResponse]
-> ReadPrec CreateNetworkResponse
-> ReadPrec [CreateNetworkResponse]
-> Read CreateNetworkResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateNetworkResponse]
$creadListPrec :: ReadPrec [CreateNetworkResponse]
readPrec :: ReadPrec CreateNetworkResponse
$creadPrec :: ReadPrec CreateNetworkResponse
readList :: ReadS [CreateNetworkResponse]
$creadList :: ReadS [CreateNetworkResponse]
readsPrec :: Int -> ReadS CreateNetworkResponse
$creadsPrec :: Int -> ReadS CreateNetworkResponse
Prelude.Read, Int -> CreateNetworkResponse -> ShowS
[CreateNetworkResponse] -> ShowS
CreateNetworkResponse -> String
(Int -> CreateNetworkResponse -> ShowS)
-> (CreateNetworkResponse -> String)
-> ([CreateNetworkResponse] -> ShowS)
-> Show CreateNetworkResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateNetworkResponse] -> ShowS
$cshowList :: [CreateNetworkResponse] -> ShowS
show :: CreateNetworkResponse -> String
$cshow :: CreateNetworkResponse -> String
showsPrec :: Int -> CreateNetworkResponse -> ShowS
$cshowsPrec :: Int -> CreateNetworkResponse -> ShowS
Prelude.Show, (forall x. CreateNetworkResponse -> Rep CreateNetworkResponse x)
-> (forall x. Rep CreateNetworkResponse x -> CreateNetworkResponse)
-> Generic CreateNetworkResponse
forall x. Rep CreateNetworkResponse x -> CreateNetworkResponse
forall x. CreateNetworkResponse -> Rep CreateNetworkResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateNetworkResponse x -> CreateNetworkResponse
$cfrom :: forall x. CreateNetworkResponse -> Rep CreateNetworkResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateNetworkResponse' 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:
--
-- 'memberId', 'createNetworkResponse_memberId' - The unique identifier for the first member within the network.
--
-- 'networkId', 'createNetworkResponse_networkId' - The unique identifier for the network.
--
-- 'httpStatus', 'createNetworkResponse_httpStatus' - The response's http status code.
newCreateNetworkResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateNetworkResponse
newCreateNetworkResponse :: Int -> CreateNetworkResponse
newCreateNetworkResponse Int
pHttpStatus_ =
  CreateNetworkResponse' :: Maybe Text -> Maybe Text -> Int -> CreateNetworkResponse
CreateNetworkResponse'
    { $sel:memberId:CreateNetworkResponse' :: Maybe Text
memberId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:networkId:CreateNetworkResponse' :: Maybe Text
networkId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateNetworkResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The unique identifier for the first member within the network.
createNetworkResponse_memberId :: Lens.Lens' CreateNetworkResponse (Prelude.Maybe Prelude.Text)
createNetworkResponse_memberId :: (Maybe Text -> f (Maybe Text))
-> CreateNetworkResponse -> f CreateNetworkResponse
createNetworkResponse_memberId = (CreateNetworkResponse -> Maybe Text)
-> (CreateNetworkResponse -> Maybe Text -> CreateNetworkResponse)
-> Lens
     CreateNetworkResponse
     CreateNetworkResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNetworkResponse' {Maybe Text
memberId :: Maybe Text
$sel:memberId:CreateNetworkResponse' :: CreateNetworkResponse -> Maybe Text
memberId} -> Maybe Text
memberId) (\s :: CreateNetworkResponse
s@CreateNetworkResponse' {} Maybe Text
a -> CreateNetworkResponse
s {$sel:memberId:CreateNetworkResponse' :: Maybe Text
memberId = Maybe Text
a} :: CreateNetworkResponse)

-- | The unique identifier for the network.
createNetworkResponse_networkId :: Lens.Lens' CreateNetworkResponse (Prelude.Maybe Prelude.Text)
createNetworkResponse_networkId :: (Maybe Text -> f (Maybe Text))
-> CreateNetworkResponse -> f CreateNetworkResponse
createNetworkResponse_networkId = (CreateNetworkResponse -> Maybe Text)
-> (CreateNetworkResponse -> Maybe Text -> CreateNetworkResponse)
-> Lens
     CreateNetworkResponse
     CreateNetworkResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateNetworkResponse' {Maybe Text
networkId :: Maybe Text
$sel:networkId:CreateNetworkResponse' :: CreateNetworkResponse -> Maybe Text
networkId} -> Maybe Text
networkId) (\s :: CreateNetworkResponse
s@CreateNetworkResponse' {} Maybe Text
a -> CreateNetworkResponse
s {$sel:networkId:CreateNetworkResponse' :: Maybe Text
networkId = Maybe Text
a} :: CreateNetworkResponse)

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

instance Prelude.NFData CreateNetworkResponse