{-# 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-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 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.Lens as Lens
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.
    --
    -- Length 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
(UpdateGlobalNetwork -> UpdateGlobalNetwork -> Bool)
-> (UpdateGlobalNetwork -> UpdateGlobalNetwork -> Bool)
-> Eq UpdateGlobalNetwork
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]
(Int -> ReadS UpdateGlobalNetwork)
-> ReadS [UpdateGlobalNetwork]
-> ReadPrec UpdateGlobalNetwork
-> ReadPrec [UpdateGlobalNetwork]
-> Read 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
(Int -> UpdateGlobalNetwork -> ShowS)
-> (UpdateGlobalNetwork -> String)
-> ([UpdateGlobalNetwork] -> ShowS)
-> Show UpdateGlobalNetwork
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. UpdateGlobalNetwork -> Rep UpdateGlobalNetwork x)
-> (forall x. Rep UpdateGlobalNetwork x -> UpdateGlobalNetwork)
-> Generic UpdateGlobalNetwork
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.
--
-- Length 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' :: Maybe Text -> Text -> UpdateGlobalNetwork
UpdateGlobalNetwork'
    { $sel:description:UpdateGlobalNetwork' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:globalNetworkId:UpdateGlobalNetwork' :: Text
globalNetworkId = Text
pGlobalNetworkId_
    }

-- | A description of the global network.
--
-- Length Constraints: Maximum length of 256 characters.
updateGlobalNetwork_description :: Lens.Lens' UpdateGlobalNetwork (Prelude.Maybe Prelude.Text)
updateGlobalNetwork_description :: (Maybe Text -> f (Maybe Text))
-> UpdateGlobalNetwork -> f UpdateGlobalNetwork
updateGlobalNetwork_description = (UpdateGlobalNetwork -> Maybe Text)
-> (UpdateGlobalNetwork -> Maybe Text -> UpdateGlobalNetwork)
-> Lens
     UpdateGlobalNetwork UpdateGlobalNetwork (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> UpdateGlobalNetwork -> f UpdateGlobalNetwork
updateGlobalNetwork_globalNetworkId = (UpdateGlobalNetwork -> Text)
-> (UpdateGlobalNetwork -> Text -> UpdateGlobalNetwork)
-> Lens UpdateGlobalNetwork UpdateGlobalNetwork Text Text
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 :: UpdateGlobalNetwork -> Request UpdateGlobalNetwork
request = Service -> UpdateGlobalNetwork -> Request UpdateGlobalNetwork
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateGlobalNetwork
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateGlobalNetwork)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateGlobalNetwork))
-> Logger
-> Service
-> Proxy UpdateGlobalNetwork
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateGlobalNetwork)))
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 GlobalNetwork -> Int -> UpdateGlobalNetworkResponse
UpdateGlobalNetworkResponse'
            (Maybe GlobalNetwork -> Int -> UpdateGlobalNetworkResponse)
-> Either String (Maybe GlobalNetwork)
-> Either String (Int -> UpdateGlobalNetworkResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe GlobalNetwork)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"GlobalNetwork")
            Either String (Int -> UpdateGlobalNetworkResponse)
-> Either String Int -> Either String UpdateGlobalNetworkResponse
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 UpdateGlobalNetwork

instance Prelude.NFData UpdateGlobalNetwork

instance Core.ToHeaders UpdateGlobalNetwork where
  toHeaders :: UpdateGlobalNetwork -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateGlobalNetwork -> 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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Description" 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
description]
      )

instance Core.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
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/global-networks/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
globalNetworkId]

instance Core.ToQuery UpdateGlobalNetwork where
  toQuery :: UpdateGlobalNetwork -> QueryString
toQuery = QueryString -> UpdateGlobalNetwork -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(UpdateGlobalNetworkResponse
 -> UpdateGlobalNetworkResponse -> Bool)
-> (UpdateGlobalNetworkResponse
    -> UpdateGlobalNetworkResponse -> Bool)
-> Eq UpdateGlobalNetworkResponse
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]
(Int -> ReadS UpdateGlobalNetworkResponse)
-> ReadS [UpdateGlobalNetworkResponse]
-> ReadPrec UpdateGlobalNetworkResponse
-> ReadPrec [UpdateGlobalNetworkResponse]
-> Read 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
(Int -> UpdateGlobalNetworkResponse -> ShowS)
-> (UpdateGlobalNetworkResponse -> String)
-> ([UpdateGlobalNetworkResponse] -> ShowS)
-> Show UpdateGlobalNetworkResponse
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.
 UpdateGlobalNetworkResponse -> Rep UpdateGlobalNetworkResponse x)
-> (forall x.
    Rep UpdateGlobalNetworkResponse x -> UpdateGlobalNetworkResponse)
-> Generic UpdateGlobalNetworkResponse
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' :: Maybe GlobalNetwork -> Int -> UpdateGlobalNetworkResponse
UpdateGlobalNetworkResponse'
    { $sel:globalNetwork:UpdateGlobalNetworkResponse' :: Maybe GlobalNetwork
globalNetwork =
        Maybe 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 :: (Maybe GlobalNetwork -> f (Maybe GlobalNetwork))
-> UpdateGlobalNetworkResponse -> f UpdateGlobalNetworkResponse
updateGlobalNetworkResponse_globalNetwork = (UpdateGlobalNetworkResponse -> Maybe GlobalNetwork)
-> (UpdateGlobalNetworkResponse
    -> Maybe GlobalNetwork -> UpdateGlobalNetworkResponse)
-> Lens
     UpdateGlobalNetworkResponse
     UpdateGlobalNetworkResponse
     (Maybe GlobalNetwork)
     (Maybe 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 :: (Int -> f Int)
-> UpdateGlobalNetworkResponse -> f UpdateGlobalNetworkResponse
updateGlobalNetworkResponse_httpStatus = (UpdateGlobalNetworkResponse -> Int)
-> (UpdateGlobalNetworkResponse
    -> Int -> UpdateGlobalNetworkResponse)
-> Lens
     UpdateGlobalNetworkResponse UpdateGlobalNetworkResponse Int Int
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