{-# 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.GetNetwork
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns detailed information about a network.
--
-- Applies to Hyperledger Fabric and Ethereum.
module Amazonka.ManagedBlockChain.GetNetwork
  ( -- * Creating a Request
    GetNetwork (..),
    newGetNetwork,

    -- * Request Lenses
    getNetwork_networkId,

    -- * Destructuring the Response
    GetNetworkResponse (..),
    newGetNetworkResponse,

    -- * Response Lenses
    getNetworkResponse_network,
    getNetworkResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ManagedBlockChain.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetNetwork' smart constructor.
data GetNetwork = GetNetwork'
  { -- | The unique identifier of the network to get information about.
    GetNetwork -> Text
networkId :: Prelude.Text
  }
  deriving (GetNetwork -> GetNetwork -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetNetwork -> GetNetwork -> Bool
$c/= :: GetNetwork -> GetNetwork -> Bool
== :: GetNetwork -> GetNetwork -> Bool
$c== :: GetNetwork -> GetNetwork -> Bool
Prelude.Eq, ReadPrec [GetNetwork]
ReadPrec GetNetwork
Int -> ReadS GetNetwork
ReadS [GetNetwork]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetNetwork]
$creadListPrec :: ReadPrec [GetNetwork]
readPrec :: ReadPrec GetNetwork
$creadPrec :: ReadPrec GetNetwork
readList :: ReadS [GetNetwork]
$creadList :: ReadS [GetNetwork]
readsPrec :: Int -> ReadS GetNetwork
$creadsPrec :: Int -> ReadS GetNetwork
Prelude.Read, Int -> GetNetwork -> ShowS
[GetNetwork] -> ShowS
GetNetwork -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetNetwork] -> ShowS
$cshowList :: [GetNetwork] -> ShowS
show :: GetNetwork -> String
$cshow :: GetNetwork -> String
showsPrec :: Int -> GetNetwork -> ShowS
$cshowsPrec :: Int -> GetNetwork -> ShowS
Prelude.Show, forall x. Rep GetNetwork x -> GetNetwork
forall x. GetNetwork -> Rep GetNetwork x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetNetwork x -> GetNetwork
$cfrom :: forall x. GetNetwork -> Rep GetNetwork x
Prelude.Generic)

-- |
-- Create a value of 'GetNetwork' 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:
--
-- 'networkId', 'getNetwork_networkId' - The unique identifier of the network to get information about.
newGetNetwork ::
  -- | 'networkId'
  Prelude.Text ->
  GetNetwork
newGetNetwork :: Text -> GetNetwork
newGetNetwork Text
pNetworkId_ =
  GetNetwork' {$sel:networkId:GetNetwork' :: Text
networkId = Text
pNetworkId_}

-- | The unique identifier of the network to get information about.
getNetwork_networkId :: Lens.Lens' GetNetwork Prelude.Text
getNetwork_networkId :: Lens' GetNetwork Text
getNetwork_networkId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetNetwork' {Text
networkId :: Text
$sel:networkId:GetNetwork' :: GetNetwork -> Text
networkId} -> Text
networkId) (\s :: GetNetwork
s@GetNetwork' {} Text
a -> GetNetwork
s {$sel:networkId:GetNetwork' :: Text
networkId = Text
a} :: GetNetwork)

instance Core.AWSRequest GetNetwork where
  type AWSResponse GetNetwork = GetNetworkResponse
  request :: (Service -> Service) -> GetNetwork -> Request GetNetwork
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetNetwork
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetNetwork)))
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 Network -> Int -> GetNetworkResponse
GetNetworkResponse'
            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
"Network")
            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))
      )

instance Prelude.Hashable GetNetwork where
  hashWithSalt :: Int -> GetNetwork -> Int
hashWithSalt Int
_salt GetNetwork' {Text
networkId :: Text
$sel:networkId:GetNetwork' :: GetNetwork -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
networkId

instance Prelude.NFData GetNetwork where
  rnf :: GetNetwork -> ()
rnf GetNetwork' {Text
networkId :: Text
$sel:networkId:GetNetwork' :: GetNetwork -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
networkId

instance Data.ToHeaders GetNetwork where
  toHeaders :: GetNetwork -> 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.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath GetNetwork where
  toPath :: GetNetwork -> ByteString
toPath GetNetwork' {Text
networkId :: Text
$sel:networkId:GetNetwork' :: GetNetwork -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/networks/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
networkId]

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

-- | /See:/ 'newGetNetworkResponse' smart constructor.
data GetNetworkResponse = GetNetworkResponse'
  { -- | An object containing network configuration parameters.
    GetNetworkResponse -> Maybe Network
network :: Prelude.Maybe Network,
    -- | The response's http status code.
    GetNetworkResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetNetworkResponse -> GetNetworkResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetNetworkResponse -> GetNetworkResponse -> Bool
$c/= :: GetNetworkResponse -> GetNetworkResponse -> Bool
== :: GetNetworkResponse -> GetNetworkResponse -> Bool
$c== :: GetNetworkResponse -> GetNetworkResponse -> Bool
Prelude.Eq, ReadPrec [GetNetworkResponse]
ReadPrec GetNetworkResponse
Int -> ReadS GetNetworkResponse
ReadS [GetNetworkResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetNetworkResponse]
$creadListPrec :: ReadPrec [GetNetworkResponse]
readPrec :: ReadPrec GetNetworkResponse
$creadPrec :: ReadPrec GetNetworkResponse
readList :: ReadS [GetNetworkResponse]
$creadList :: ReadS [GetNetworkResponse]
readsPrec :: Int -> ReadS GetNetworkResponse
$creadsPrec :: Int -> ReadS GetNetworkResponse
Prelude.Read, Int -> GetNetworkResponse -> ShowS
[GetNetworkResponse] -> ShowS
GetNetworkResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetNetworkResponse] -> ShowS
$cshowList :: [GetNetworkResponse] -> ShowS
show :: GetNetworkResponse -> String
$cshow :: GetNetworkResponse -> String
showsPrec :: Int -> GetNetworkResponse -> ShowS
$cshowsPrec :: Int -> GetNetworkResponse -> ShowS
Prelude.Show, forall x. Rep GetNetworkResponse x -> GetNetworkResponse
forall x. GetNetworkResponse -> Rep GetNetworkResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetNetworkResponse x -> GetNetworkResponse
$cfrom :: forall x. GetNetworkResponse -> Rep GetNetworkResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetNetworkResponse' 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:
--
-- 'network', 'getNetworkResponse_network' - An object containing network configuration parameters.
--
-- 'httpStatus', 'getNetworkResponse_httpStatus' - The response's http status code.
newGetNetworkResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetNetworkResponse
newGetNetworkResponse :: Int -> GetNetworkResponse
newGetNetworkResponse Int
pHttpStatus_ =
  GetNetworkResponse'
    { $sel:network:GetNetworkResponse' :: Maybe Network
network = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetNetworkResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An object containing network configuration parameters.
getNetworkResponse_network :: Lens.Lens' GetNetworkResponse (Prelude.Maybe Network)
getNetworkResponse_network :: Lens' GetNetworkResponse (Maybe Network)
getNetworkResponse_network = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetNetworkResponse' {Maybe Network
network :: Maybe Network
$sel:network:GetNetworkResponse' :: GetNetworkResponse -> Maybe Network
network} -> Maybe Network
network) (\s :: GetNetworkResponse
s@GetNetworkResponse' {} Maybe Network
a -> GetNetworkResponse
s {$sel:network:GetNetworkResponse' :: Maybe Network
network = Maybe Network
a} :: GetNetworkResponse)

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

instance Prelude.NFData GetNetworkResponse where
  rnf :: GetNetworkResponse -> ()
rnf GetNetworkResponse' {Int
Maybe Network
httpStatus :: Int
network :: Maybe Network
$sel:httpStatus:GetNetworkResponse' :: GetNetworkResponse -> Int
$sel:network:GetNetworkResponse' :: GetNetworkResponse -> Maybe Network
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Network
network
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus