{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.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:/ '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
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]
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
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. 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'
    { $sel:logPublishingConfiguration:UpdateNode' :: Maybe NodeLogPublishingConfiguration
logPublishingConfiguration =
        forall a. Maybe a
Prelude.Nothing,
      $sel:memberId:UpdateNode' :: Maybe Text
memberId = 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 :: Lens' UpdateNode (Maybe NodeLogPublishingConfiguration)
updateNode_logPublishingConfiguration = 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 :: Lens' UpdateNode (Maybe Text)
updateNode_memberId = 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 :: Lens' UpdateNode Text
updateNode_networkId = 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 :: Lens' UpdateNode Text
updateNode_nodeId = 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 :: (Service -> Service) -> UpdateNode -> Request UpdateNode
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateNode
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateNode)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateNodeResponse
UpdateNodeResponse'
            forall (f :: * -> *) a b. Functor 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 UpdateNode where
  hashWithSalt :: Int -> UpdateNode -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NodeLogPublishingConfiguration
logPublishingConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
memberId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
networkId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
nodeId

instance Prelude.NFData UpdateNode where
  rnf :: UpdateNode -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe NodeLogPublishingConfiguration
logPublishingConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
memberId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
networkId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
nodeId

instance Data.ToHeaders UpdateNode where
  toHeaders :: UpdateNode -> 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.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"LogPublishingConfiguration" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NodeLogPublishingConfiguration
logPublishingConfiguration,
            (Key
"MemberId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
memberId
          ]
      )

instance Data.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
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/networks/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
networkId,
        ByteString
"/nodes/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
nodeId
      ]

instance Data.ToQuery UpdateNode where
  toQuery :: UpdateNode -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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' {$sel:httpStatus:UpdateNodeResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
updateNodeResponse_httpStatus :: Lens.Lens' UpdateNodeResponse Prelude.Int
updateNodeResponse_httpStatus :: Lens' UpdateNodeResponse Int
updateNodeResponse_httpStatus = 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 where
  rnf :: UpdateNodeResponse -> ()
rnf UpdateNodeResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateNodeResponse' :: UpdateNodeResponse -> Int
..} = forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus