{-# 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.NetworkManager.UpdateGlobalNetwork
-- 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 an existing global network. To remove information for any of the
-- parameters, specify an empty string.
module Amazonka.NetworkManager.UpdateGlobalNetwork
  ( -- * Creating a Request
    UpdateGlobalNetwork (..),
    newUpdateGlobalNetwork,

    -- * Request Lenses
    updateGlobalNetwork_description,
    updateGlobalNetwork_globalNetworkId,

    -- * Destructuring the Response
    UpdateGlobalNetworkResponse (..),
    newUpdateGlobalNetworkResponse,

    -- * Response Lenses
    updateGlobalNetworkResponse_globalNetwork,
    updateGlobalNetworkResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateGlobalNetwork' smart constructor.
data UpdateGlobalNetwork = UpdateGlobalNetwork'
  { -- | A description of the global network.
    --
    -- Constraints: Maximum length of 256 characters.
    UpdateGlobalNetwork -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The ID of your global network.
    UpdateGlobalNetwork -> Text
globalNetworkId :: Prelude.Text
  }
  deriving (UpdateGlobalNetwork -> UpdateGlobalNetwork -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateGlobalNetwork -> UpdateGlobalNetwork -> Bool
$c/= :: UpdateGlobalNetwork -> UpdateGlobalNetwork -> Bool
== :: UpdateGlobalNetwork -> UpdateGlobalNetwork -> Bool
$c== :: UpdateGlobalNetwork -> UpdateGlobalNetwork -> Bool
Prelude.Eq, ReadPrec [UpdateGlobalNetwork]
ReadPrec UpdateGlobalNetwork
Int -> ReadS UpdateGlobalNetwork
ReadS [UpdateGlobalNetwork]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateGlobalNetwork]
$creadListPrec :: ReadPrec [UpdateGlobalNetwork]
readPrec :: ReadPrec UpdateGlobalNetwork
$creadPrec :: ReadPrec UpdateGlobalNetwork
readList :: ReadS [UpdateGlobalNetwork]
$creadList :: ReadS [UpdateGlobalNetwork]
readsPrec :: Int -> ReadS UpdateGlobalNetwork
$creadsPrec :: Int -> ReadS UpdateGlobalNetwork
Prelude.Read, Int -> UpdateGlobalNetwork -> ShowS
[UpdateGlobalNetwork] -> ShowS
UpdateGlobalNetwork -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateGlobalNetwork] -> ShowS
$cshowList :: [UpdateGlobalNetwork] -> ShowS
show :: UpdateGlobalNetwork -> String
$cshow :: UpdateGlobalNetwork -> String
showsPrec :: Int -> UpdateGlobalNetwork -> ShowS
$cshowsPrec :: Int -> UpdateGlobalNetwork -> ShowS
Prelude.Show, forall x. Rep UpdateGlobalNetwork x -> UpdateGlobalNetwork
forall x. UpdateGlobalNetwork -> Rep UpdateGlobalNetwork x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateGlobalNetwork x -> UpdateGlobalNetwork
$cfrom :: forall x. UpdateGlobalNetwork -> Rep UpdateGlobalNetwork x
Prelude.Generic)

-- |
-- Create a value of 'UpdateGlobalNetwork' 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:
--
-- 'description', 'updateGlobalNetwork_description' - A description of the global network.
--
-- Constraints: Maximum length of 256 characters.
--
-- 'globalNetworkId', 'updateGlobalNetwork_globalNetworkId' - The ID of your global network.
newUpdateGlobalNetwork ::
  -- | 'globalNetworkId'
  Prelude.Text ->
  UpdateGlobalNetwork
newUpdateGlobalNetwork :: Text -> UpdateGlobalNetwork
newUpdateGlobalNetwork Text
pGlobalNetworkId_ =
  UpdateGlobalNetwork'
    { $sel:description:UpdateGlobalNetwork' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:globalNetworkId:UpdateGlobalNetwork' :: Text
globalNetworkId = Text
pGlobalNetworkId_
    }

-- | A description of the global network.
--
-- Constraints: Maximum length of 256 characters.
updateGlobalNetwork_description :: Lens.Lens' UpdateGlobalNetwork (Prelude.Maybe Prelude.Text)
updateGlobalNetwork_description :: Lens' UpdateGlobalNetwork (Maybe Text)
updateGlobalNetwork_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGlobalNetwork' {Maybe Text
description :: Maybe Text
$sel:description:UpdateGlobalNetwork' :: UpdateGlobalNetwork -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateGlobalNetwork
s@UpdateGlobalNetwork' {} Maybe Text
a -> UpdateGlobalNetwork
s {$sel:description:UpdateGlobalNetwork' :: Maybe Text
description = Maybe Text
a} :: UpdateGlobalNetwork)

-- | The ID of your global network.
updateGlobalNetwork_globalNetworkId :: Lens.Lens' UpdateGlobalNetwork Prelude.Text
updateGlobalNetwork_globalNetworkId :: Lens' UpdateGlobalNetwork Text
updateGlobalNetwork_globalNetworkId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGlobalNetwork' {Text
globalNetworkId :: Text
$sel:globalNetworkId:UpdateGlobalNetwork' :: UpdateGlobalNetwork -> Text
globalNetworkId} -> Text
globalNetworkId) (\s :: UpdateGlobalNetwork
s@UpdateGlobalNetwork' {} Text
a -> UpdateGlobalNetwork
s {$sel:globalNetworkId:UpdateGlobalNetwork' :: Text
globalNetworkId = Text
a} :: UpdateGlobalNetwork)

instance Core.AWSRequest UpdateGlobalNetwork where
  type
    AWSResponse UpdateGlobalNetwork =
      UpdateGlobalNetworkResponse
  request :: (Service -> Service)
-> UpdateGlobalNetwork -> Request UpdateGlobalNetwork
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 UpdateGlobalNetwork
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateGlobalNetwork)))
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 GlobalNetwork -> Int -> UpdateGlobalNetworkResponse
UpdateGlobalNetworkResponse'
            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
"GlobalNetwork")
            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 UpdateGlobalNetwork where
  hashWithSalt :: Int -> UpdateGlobalNetwork -> Int
hashWithSalt Int
_salt UpdateGlobalNetwork' {Maybe Text
Text
globalNetworkId :: Text
description :: Maybe Text
$sel:globalNetworkId:UpdateGlobalNetwork' :: UpdateGlobalNetwork -> Text
$sel:description:UpdateGlobalNetwork' :: UpdateGlobalNetwork -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
globalNetworkId

instance Prelude.NFData UpdateGlobalNetwork where
  rnf :: UpdateGlobalNetwork -> ()
rnf UpdateGlobalNetwork' {Maybe Text
Text
globalNetworkId :: Text
description :: Maybe Text
$sel:globalNetworkId:UpdateGlobalNetwork' :: UpdateGlobalNetwork -> Text
$sel:description:UpdateGlobalNetwork' :: UpdateGlobalNetwork -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
globalNetworkId

instance Data.ToHeaders UpdateGlobalNetwork where
  toHeaders :: UpdateGlobalNetwork -> 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 UpdateGlobalNetwork where
  toJSON :: UpdateGlobalNetwork -> Value
toJSON UpdateGlobalNetwork' {Maybe Text
Text
globalNetworkId :: Text
description :: Maybe Text
$sel:globalNetworkId:UpdateGlobalNetwork' :: UpdateGlobalNetwork -> Text
$sel:description:UpdateGlobalNetwork' :: UpdateGlobalNetwork -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"Description" 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
description]
      )

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

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

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

-- |
-- Create a value of 'UpdateGlobalNetworkResponse' 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:
--
-- 'globalNetwork', 'updateGlobalNetworkResponse_globalNetwork' - Information about the global network object.
--
-- 'httpStatus', 'updateGlobalNetworkResponse_httpStatus' - The response's http status code.
newUpdateGlobalNetworkResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateGlobalNetworkResponse
newUpdateGlobalNetworkResponse :: Int -> UpdateGlobalNetworkResponse
newUpdateGlobalNetworkResponse Int
pHttpStatus_ =
  UpdateGlobalNetworkResponse'
    { $sel:globalNetwork:UpdateGlobalNetworkResponse' :: Maybe GlobalNetwork
globalNetwork =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateGlobalNetworkResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the global network object.
updateGlobalNetworkResponse_globalNetwork :: Lens.Lens' UpdateGlobalNetworkResponse (Prelude.Maybe GlobalNetwork)
updateGlobalNetworkResponse_globalNetwork :: Lens' UpdateGlobalNetworkResponse (Maybe GlobalNetwork)
updateGlobalNetworkResponse_globalNetwork = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGlobalNetworkResponse' {Maybe GlobalNetwork
globalNetwork :: Maybe GlobalNetwork
$sel:globalNetwork:UpdateGlobalNetworkResponse' :: UpdateGlobalNetworkResponse -> Maybe GlobalNetwork
globalNetwork} -> Maybe GlobalNetwork
globalNetwork) (\s :: UpdateGlobalNetworkResponse
s@UpdateGlobalNetworkResponse' {} Maybe GlobalNetwork
a -> UpdateGlobalNetworkResponse
s {$sel:globalNetwork:UpdateGlobalNetworkResponse' :: Maybe GlobalNetwork
globalNetwork = Maybe GlobalNetwork
a} :: UpdateGlobalNetworkResponse)

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

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