{-# 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.GetNode
-- 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)
--
-- Returns detailed information about a node.
--
-- Applies to Hyperledger Fabric and Ethereum.
module Amazonka.ManagedBlockChain.GetNode
  ( -- * Creating a Request
    GetNode (..),
    newGetNode,

    -- * Request Lenses
    getNode_memberId,
    getNode_networkId,
    getNode_nodeId,

    -- * Destructuring the Response
    GetNodeResponse (..),
    newGetNodeResponse,

    -- * Response Lenses
    getNodeResponse_node,
    getNodeResponse_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:/ 'newGetNode' smart constructor.
data GetNode = GetNode'
  { -- | The unique identifier of the member that owns the node.
    --
    -- Applies only to Hyperledger Fabric and is required for Hyperledger
    -- Fabric.
    GetNode -> Maybe Text
memberId :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier of the network that the node is on.
    GetNode -> Text
networkId :: Prelude.Text,
    -- | The unique identifier of the node.
    GetNode -> Text
nodeId :: Prelude.Text
  }
  deriving (GetNode -> GetNode -> Bool
(GetNode -> GetNode -> Bool)
-> (GetNode -> GetNode -> Bool) -> Eq GetNode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetNode -> GetNode -> Bool
$c/= :: GetNode -> GetNode -> Bool
== :: GetNode -> GetNode -> Bool
$c== :: GetNode -> GetNode -> Bool
Prelude.Eq, ReadPrec [GetNode]
ReadPrec GetNode
Int -> ReadS GetNode
ReadS [GetNode]
(Int -> ReadS GetNode)
-> ReadS [GetNode]
-> ReadPrec GetNode
-> ReadPrec [GetNode]
-> Read GetNode
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetNode]
$creadListPrec :: ReadPrec [GetNode]
readPrec :: ReadPrec GetNode
$creadPrec :: ReadPrec GetNode
readList :: ReadS [GetNode]
$creadList :: ReadS [GetNode]
readsPrec :: Int -> ReadS GetNode
$creadsPrec :: Int -> ReadS GetNode
Prelude.Read, Int -> GetNode -> ShowS
[GetNode] -> ShowS
GetNode -> String
(Int -> GetNode -> ShowS)
-> (GetNode -> String) -> ([GetNode] -> ShowS) -> Show GetNode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetNode] -> ShowS
$cshowList :: [GetNode] -> ShowS
show :: GetNode -> String
$cshow :: GetNode -> String
showsPrec :: Int -> GetNode -> ShowS
$cshowsPrec :: Int -> GetNode -> ShowS
Prelude.Show, (forall x. GetNode -> Rep GetNode x)
-> (forall x. Rep GetNode x -> GetNode) -> Generic GetNode
forall x. Rep GetNode x -> GetNode
forall x. GetNode -> Rep GetNode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetNode x -> GetNode
$cfrom :: forall x. GetNode -> Rep GetNode x
Prelude.Generic)

-- |
-- Create a value of 'GetNode' 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', 'getNode_memberId' - The unique identifier of the member that owns the node.
--
-- Applies only to Hyperledger Fabric and is required for Hyperledger
-- Fabric.
--
-- 'networkId', 'getNode_networkId' - The unique identifier of the network that the node is on.
--
-- 'nodeId', 'getNode_nodeId' - The unique identifier of the node.
newGetNode ::
  -- | 'networkId'
  Prelude.Text ->
  -- | 'nodeId'
  Prelude.Text ->
  GetNode
newGetNode :: Text -> Text -> GetNode
newGetNode Text
pNetworkId_ Text
pNodeId_ =
  GetNode' :: Maybe Text -> Text -> Text -> GetNode
GetNode'
    { $sel:memberId:GetNode' :: Maybe Text
memberId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:networkId:GetNode' :: Text
networkId = Text
pNetworkId_,
      $sel:nodeId:GetNode' :: Text
nodeId = Text
pNodeId_
    }

-- | The unique identifier of the member that owns the node.
--
-- Applies only to Hyperledger Fabric and is required for Hyperledger
-- Fabric.
getNode_memberId :: Lens.Lens' GetNode (Prelude.Maybe Prelude.Text)
getNode_memberId :: (Maybe Text -> f (Maybe Text)) -> GetNode -> f GetNode
getNode_memberId = (GetNode -> Maybe Text)
-> (GetNode -> Maybe Text -> GetNode)
-> Lens GetNode GetNode (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetNode' {Maybe Text
memberId :: Maybe Text
$sel:memberId:GetNode' :: GetNode -> Maybe Text
memberId} -> Maybe Text
memberId) (\s :: GetNode
s@GetNode' {} Maybe Text
a -> GetNode
s {$sel:memberId:GetNode' :: Maybe Text
memberId = Maybe Text
a} :: GetNode)

-- | The unique identifier of the network that the node is on.
getNode_networkId :: Lens.Lens' GetNode Prelude.Text
getNode_networkId :: (Text -> f Text) -> GetNode -> f GetNode
getNode_networkId = (GetNode -> Text)
-> (GetNode -> Text -> GetNode) -> Lens GetNode GetNode Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetNode' {Text
networkId :: Text
$sel:networkId:GetNode' :: GetNode -> Text
networkId} -> Text
networkId) (\s :: GetNode
s@GetNode' {} Text
a -> GetNode
s {$sel:networkId:GetNode' :: Text
networkId = Text
a} :: GetNode)

-- | The unique identifier of the node.
getNode_nodeId :: Lens.Lens' GetNode Prelude.Text
getNode_nodeId :: (Text -> f Text) -> GetNode -> f GetNode
getNode_nodeId = (GetNode -> Text)
-> (GetNode -> Text -> GetNode) -> Lens GetNode GetNode Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetNode' {Text
nodeId :: Text
$sel:nodeId:GetNode' :: GetNode -> Text
nodeId} -> Text
nodeId) (\s :: GetNode
s@GetNode' {} Text
a -> GetNode
s {$sel:nodeId:GetNode' :: Text
nodeId = Text
a} :: GetNode)

instance Core.AWSRequest GetNode where
  type AWSResponse GetNode = GetNodeResponse
  request :: GetNode -> Request GetNode
request = Service -> GetNode -> Request GetNode
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetNode
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetNode)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetNode))
-> Logger
-> Service
-> Proxy GetNode
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetNode)))
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 Node -> Int -> GetNodeResponse
GetNodeResponse'
            (Maybe Node -> Int -> GetNodeResponse)
-> Either String (Maybe Node)
-> Either String (Int -> GetNodeResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Node)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Node")
            Either String (Int -> GetNodeResponse)
-> Either String Int -> Either String GetNodeResponse
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 GetNode

instance Prelude.NFData GetNode

instance Core.ToHeaders GetNode where
  toHeaders :: GetNode -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetNode -> 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.ToPath GetNode where
  toPath :: GetNode -> ByteString
toPath GetNode' {Maybe Text
Text
nodeId :: Text
networkId :: Text
memberId :: Maybe Text
$sel:nodeId:GetNode' :: GetNode -> Text
$sel:networkId:GetNode' :: GetNode -> Text
$sel:memberId:GetNode' :: GetNode -> 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/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
nodeId
      ]

instance Core.ToQuery GetNode where
  toQuery :: GetNode -> QueryString
toQuery GetNode' {Maybe Text
Text
nodeId :: Text
networkId :: Text
memberId :: Maybe Text
$sel:nodeId:GetNode' :: GetNode -> Text
$sel:networkId:GetNode' :: GetNode -> Text
$sel:memberId:GetNode' :: GetNode -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"memberId" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
memberId]

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

-- |
-- Create a value of 'GetNodeResponse' 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:
--
-- 'node', 'getNodeResponse_node' - Properties of the node configuration.
--
-- 'httpStatus', 'getNodeResponse_httpStatus' - The response's http status code.
newGetNodeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetNodeResponse
newGetNodeResponse :: Int -> GetNodeResponse
newGetNodeResponse Int
pHttpStatus_ =
  GetNodeResponse' :: Maybe Node -> Int -> GetNodeResponse
GetNodeResponse'
    { $sel:node:GetNodeResponse' :: Maybe Node
node = Maybe Node
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetNodeResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Properties of the node configuration.
getNodeResponse_node :: Lens.Lens' GetNodeResponse (Prelude.Maybe Node)
getNodeResponse_node :: (Maybe Node -> f (Maybe Node))
-> GetNodeResponse -> f GetNodeResponse
getNodeResponse_node = (GetNodeResponse -> Maybe Node)
-> (GetNodeResponse -> Maybe Node -> GetNodeResponse)
-> Lens GetNodeResponse GetNodeResponse (Maybe Node) (Maybe Node)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetNodeResponse' {Maybe Node
node :: Maybe Node
$sel:node:GetNodeResponse' :: GetNodeResponse -> Maybe Node
node} -> Maybe Node
node) (\s :: GetNodeResponse
s@GetNodeResponse' {} Maybe Node
a -> GetNodeResponse
s {$sel:node:GetNodeResponse' :: Maybe Node
node = Maybe Node
a} :: GetNodeResponse)

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

instance Prelude.NFData GetNodeResponse