{-# 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.DeleteNode
-- 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)
--
-- Deletes a node that your AWS account owns. All data on the node is lost
-- and cannot be recovered.
--
-- Applies to Hyperledger Fabric and Ethereum.
module Amazonka.ManagedBlockChain.DeleteNode
  ( -- * Creating a Request
    DeleteNode (..),
    newDeleteNode,

    -- * Request Lenses
    deleteNode_memberId,
    deleteNode_networkId,
    deleteNode_nodeId,

    -- * Destructuring the Response
    DeleteNodeResponse (..),
    newDeleteNodeResponse,

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

-- |
-- Create a value of 'DeleteNode' 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', 'deleteNode_memberId' - The unique identifier of the member that owns this node.
--
-- Applies only to Hyperledger Fabric and is required for Hyperledger
-- Fabric.
--
-- 'networkId', 'deleteNode_networkId' - The unique identifier of the network that the node is on.
--
-- Ethereum public networks have the following @NetworkId@s:
--
-- -   @n-ethereum-mainnet@
--
-- -   @n-ethereum-rinkeby@
--
-- -   @n-ethereum-ropsten@
--
-- 'nodeId', 'deleteNode_nodeId' - The unique identifier of the node.
newDeleteNode ::
  -- | 'networkId'
  Prelude.Text ->
  -- | 'nodeId'
  Prelude.Text ->
  DeleteNode
newDeleteNode :: Text -> Text -> DeleteNode
newDeleteNode Text
pNetworkId_ Text
pNodeId_ =
  DeleteNode' :: Maybe Text -> Text -> Text -> DeleteNode
DeleteNode'
    { $sel:memberId:DeleteNode' :: Maybe Text
memberId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:networkId:DeleteNode' :: Text
networkId = Text
pNetworkId_,
      $sel:nodeId:DeleteNode' :: Text
nodeId = Text
pNodeId_
    }

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

-- | The unique identifier of the network that the node is on.
--
-- Ethereum public networks have the following @NetworkId@s:
--
-- -   @n-ethereum-mainnet@
--
-- -   @n-ethereum-rinkeby@
--
-- -   @n-ethereum-ropsten@
deleteNode_networkId :: Lens.Lens' DeleteNode Prelude.Text
deleteNode_networkId :: (Text -> f Text) -> DeleteNode -> f DeleteNode
deleteNode_networkId = (DeleteNode -> Text)
-> (DeleteNode -> Text -> DeleteNode)
-> Lens DeleteNode DeleteNode Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteNode' {Text
networkId :: Text
$sel:networkId:DeleteNode' :: DeleteNode -> Text
networkId} -> Text
networkId) (\s :: DeleteNode
s@DeleteNode' {} Text
a -> DeleteNode
s {$sel:networkId:DeleteNode' :: Text
networkId = Text
a} :: DeleteNode)

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

instance Core.AWSRequest DeleteNode where
  type AWSResponse DeleteNode = DeleteNodeResponse
  request :: DeleteNode -> Request DeleteNode
request = Service -> DeleteNode -> Request DeleteNode
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteNode
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteNode)))
response =
    (Int
 -> ResponseHeaders -> () -> Either String (AWSResponse DeleteNode))
-> Logger
-> Service
-> Proxy DeleteNode
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteNode)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteNodeResponse
DeleteNodeResponse'
            (Int -> DeleteNodeResponse)
-> Either String Int -> Either String DeleteNodeResponse
forall (f :: * -> *) a b. Functor 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 DeleteNode

instance Prelude.NFData DeleteNode

instance Core.ToHeaders DeleteNode where
  toHeaders :: DeleteNode -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteNode -> 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 DeleteNode where
  toPath :: DeleteNode -> ByteString
toPath DeleteNode' {Maybe Text
Text
nodeId :: Text
networkId :: Text
memberId :: Maybe Text
$sel:nodeId:DeleteNode' :: DeleteNode -> Text
$sel:networkId:DeleteNode' :: DeleteNode -> Text
$sel:memberId:DeleteNode' :: DeleteNode -> 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 DeleteNode where
  toQuery :: DeleteNode -> QueryString
toQuery DeleteNode' {Maybe Text
Text
nodeId :: Text
networkId :: Text
memberId :: Maybe Text
$sel:nodeId:DeleteNode' :: DeleteNode -> Text
$sel:networkId:DeleteNode' :: DeleteNode -> Text
$sel:memberId:DeleteNode' :: DeleteNode -> 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:/ 'newDeleteNodeResponse' smart constructor.
data DeleteNodeResponse = DeleteNodeResponse'
  { -- | The response's http status code.
    DeleteNodeResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteNodeResponse -> DeleteNodeResponse -> Bool
(DeleteNodeResponse -> DeleteNodeResponse -> Bool)
-> (DeleteNodeResponse -> DeleteNodeResponse -> Bool)
-> Eq DeleteNodeResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteNodeResponse -> DeleteNodeResponse -> Bool
$c/= :: DeleteNodeResponse -> DeleteNodeResponse -> Bool
== :: DeleteNodeResponse -> DeleteNodeResponse -> Bool
$c== :: DeleteNodeResponse -> DeleteNodeResponse -> Bool
Prelude.Eq, ReadPrec [DeleteNodeResponse]
ReadPrec DeleteNodeResponse
Int -> ReadS DeleteNodeResponse
ReadS [DeleteNodeResponse]
(Int -> ReadS DeleteNodeResponse)
-> ReadS [DeleteNodeResponse]
-> ReadPrec DeleteNodeResponse
-> ReadPrec [DeleteNodeResponse]
-> Read DeleteNodeResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteNodeResponse]
$creadListPrec :: ReadPrec [DeleteNodeResponse]
readPrec :: ReadPrec DeleteNodeResponse
$creadPrec :: ReadPrec DeleteNodeResponse
readList :: ReadS [DeleteNodeResponse]
$creadList :: ReadS [DeleteNodeResponse]
readsPrec :: Int -> ReadS DeleteNodeResponse
$creadsPrec :: Int -> ReadS DeleteNodeResponse
Prelude.Read, Int -> DeleteNodeResponse -> ShowS
[DeleteNodeResponse] -> ShowS
DeleteNodeResponse -> String
(Int -> DeleteNodeResponse -> ShowS)
-> (DeleteNodeResponse -> String)
-> ([DeleteNodeResponse] -> ShowS)
-> Show DeleteNodeResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteNodeResponse] -> ShowS
$cshowList :: [DeleteNodeResponse] -> ShowS
show :: DeleteNodeResponse -> String
$cshow :: DeleteNodeResponse -> String
showsPrec :: Int -> DeleteNodeResponse -> ShowS
$cshowsPrec :: Int -> DeleteNodeResponse -> ShowS
Prelude.Show, (forall x. DeleteNodeResponse -> Rep DeleteNodeResponse x)
-> (forall x. Rep DeleteNodeResponse x -> DeleteNodeResponse)
-> Generic DeleteNodeResponse
forall x. Rep DeleteNodeResponse x -> DeleteNodeResponse
forall x. DeleteNodeResponse -> Rep DeleteNodeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteNodeResponse x -> DeleteNodeResponse
$cfrom :: forall x. DeleteNodeResponse -> Rep DeleteNodeResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteNodeResponse' 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:
--
-- 'httpStatus', 'deleteNodeResponse_httpStatus' - The response's http status code.
newDeleteNodeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteNodeResponse
newDeleteNodeResponse :: Int -> DeleteNodeResponse
newDeleteNodeResponse Int
pHttpStatus_ =
  DeleteNodeResponse' :: Int -> DeleteNodeResponse
DeleteNodeResponse' {$sel:httpStatus:DeleteNodeResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData DeleteNodeResponse