{-# 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.UpdateNode
-- 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)
--
-- Updates a node configuration with new parameters.
--
-- Applies only to Hyperledger Fabric.
module Amazonka.ManagedBlockChain.UpdateNode
  ( -- * Creating a Request
    UpdateNode (..),
    newUpdateNode,

    -- * Request Lenses
    updateNode_logPublishingConfiguration,
    updateNode_memberId,
    updateNode_networkId,
    updateNode_nodeId,

    -- * Destructuring the Response
    UpdateNodeResponse (..),
    newUpdateNodeResponse,

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

-- |
-- Create a value of 'UpdateNode' 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:
--
-- 'logPublishingConfiguration', 'updateNode_logPublishingConfiguration' - Configuration properties for publishing to Amazon CloudWatch Logs.
--
-- 'memberId', 'updateNode_memberId' - The unique identifier of the member that owns the node.
--
-- Applies only to Hyperledger Fabric.
--
-- 'networkId', 'updateNode_networkId' - The unique identifier of the network that the node is on.
--
-- 'nodeId', 'updateNode_nodeId' - The unique identifier of the node.
newUpdateNode ::
  -- | 'networkId'
  Prelude.Text ->
  -- | 'nodeId'
  Prelude.Text ->
  UpdateNode
newUpdateNode :: Text -> Text -> UpdateNode
newUpdateNode Text
pNetworkId_ Text
pNodeId_ =
  UpdateNode' :: Maybe NodeLogPublishingConfiguration
-> Maybe Text -> Text -> Text -> UpdateNode
UpdateNode'
    { $sel:logPublishingConfiguration:UpdateNode' :: Maybe NodeLogPublishingConfiguration
logPublishingConfiguration =
        Maybe NodeLogPublishingConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:memberId:UpdateNode' :: Maybe Text
memberId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:networkId:UpdateNode' :: Text
networkId = Text
pNetworkId_,
      $sel:nodeId:UpdateNode' :: Text
nodeId = Text
pNodeId_
    }

-- | Configuration properties for publishing to Amazon CloudWatch Logs.
updateNode_logPublishingConfiguration :: Lens.Lens' UpdateNode (Prelude.Maybe NodeLogPublishingConfiguration)
updateNode_logPublishingConfiguration :: (Maybe NodeLogPublishingConfiguration
 -> f (Maybe NodeLogPublishingConfiguration))
-> UpdateNode -> f UpdateNode
updateNode_logPublishingConfiguration = (UpdateNode -> Maybe NodeLogPublishingConfiguration)
-> (UpdateNode
    -> Maybe NodeLogPublishingConfiguration -> UpdateNode)
-> Lens
     UpdateNode
     UpdateNode
     (Maybe NodeLogPublishingConfiguration)
     (Maybe NodeLogPublishingConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateNode' {Maybe NodeLogPublishingConfiguration
logPublishingConfiguration :: Maybe NodeLogPublishingConfiguration
$sel:logPublishingConfiguration:UpdateNode' :: UpdateNode -> Maybe NodeLogPublishingConfiguration
logPublishingConfiguration} -> Maybe NodeLogPublishingConfiguration
logPublishingConfiguration) (\s :: UpdateNode
s@UpdateNode' {} Maybe NodeLogPublishingConfiguration
a -> UpdateNode
s {$sel:logPublishingConfiguration:UpdateNode' :: Maybe NodeLogPublishingConfiguration
logPublishingConfiguration = Maybe NodeLogPublishingConfiguration
a} :: UpdateNode)

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

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

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

instance Core.AWSRequest UpdateNode where
  type AWSResponse UpdateNode = UpdateNodeResponse
  request :: UpdateNode -> Request UpdateNode
request = Service -> UpdateNode -> Request UpdateNode
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateNode
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateNode)))
response =
    (Int
 -> ResponseHeaders -> () -> Either String (AWSResponse UpdateNode))
-> Logger
-> Service
-> Proxy UpdateNode
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateNode)))
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 -> UpdateNodeResponse
UpdateNodeResponse'
            (Int -> UpdateNodeResponse)
-> Either String Int -> Either String UpdateNodeResponse
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 UpdateNode

instance Prelude.NFData UpdateNode

instance Core.ToHeaders UpdateNode where
  toHeaders :: UpdateNode -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateNode -> 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 UpdateNode where
  toJSON :: UpdateNode -> Value
toJSON UpdateNode' {Maybe Text
Maybe NodeLogPublishingConfiguration
Text
nodeId :: Text
networkId :: Text
memberId :: Maybe Text
logPublishingConfiguration :: Maybe NodeLogPublishingConfiguration
$sel:nodeId:UpdateNode' :: UpdateNode -> Text
$sel:networkId:UpdateNode' :: UpdateNode -> Text
$sel:memberId:UpdateNode' :: UpdateNode -> Maybe Text
$sel:logPublishingConfiguration:UpdateNode' :: UpdateNode -> Maybe NodeLogPublishingConfiguration
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"LogPublishingConfiguration" Text -> NodeLogPublishingConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NodeLogPublishingConfiguration -> Pair)
-> Maybe NodeLogPublishingConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NodeLogPublishingConfiguration
logPublishingConfiguration,
            (Text
"MemberId" 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
memberId
          ]
      )

instance Core.ToPath UpdateNode where
  toPath :: UpdateNode -> ByteString
toPath UpdateNode' {Maybe Text
Maybe NodeLogPublishingConfiguration
Text
nodeId :: Text
networkId :: Text
memberId :: Maybe Text
logPublishingConfiguration :: Maybe NodeLogPublishingConfiguration
$sel:nodeId:UpdateNode' :: UpdateNode -> Text
$sel:networkId:UpdateNode' :: UpdateNode -> Text
$sel:memberId:UpdateNode' :: UpdateNode -> Maybe Text
$sel:logPublishingConfiguration:UpdateNode' :: UpdateNode -> Maybe NodeLogPublishingConfiguration
..} =
    [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 UpdateNode where
  toQuery :: UpdateNode -> QueryString
toQuery = QueryString -> UpdateNode -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

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

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

instance Prelude.NFData UpdateNodeResponse