{-# 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.BackupGateway.UpdateGatewayInformation
-- 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 gateway\'s name. Specify which gateway to update using the
-- Amazon Resource Name (ARN) of the gateway in your request.
module Amazonka.BackupGateway.UpdateGatewayInformation
  ( -- * Creating a Request
    UpdateGatewayInformation (..),
    newUpdateGatewayInformation,

    -- * Request Lenses
    updateGatewayInformation_gatewayDisplayName,
    updateGatewayInformation_gatewayArn,

    -- * Destructuring the Response
    UpdateGatewayInformationResponse (..),
    newUpdateGatewayInformationResponse,

    -- * Response Lenses
    updateGatewayInformationResponse_gatewayArn,
    updateGatewayInformationResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateGatewayInformation' smart constructor.
data UpdateGatewayInformation = UpdateGatewayInformation'
  { -- | The updated display name of the gateway.
    UpdateGatewayInformation -> Maybe Text
gatewayDisplayName :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the gateway to update.
    UpdateGatewayInformation -> Text
gatewayArn :: Prelude.Text
  }
  deriving (UpdateGatewayInformation -> UpdateGatewayInformation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateGatewayInformation -> UpdateGatewayInformation -> Bool
$c/= :: UpdateGatewayInformation -> UpdateGatewayInformation -> Bool
== :: UpdateGatewayInformation -> UpdateGatewayInformation -> Bool
$c== :: UpdateGatewayInformation -> UpdateGatewayInformation -> Bool
Prelude.Eq, ReadPrec [UpdateGatewayInformation]
ReadPrec UpdateGatewayInformation
Int -> ReadS UpdateGatewayInformation
ReadS [UpdateGatewayInformation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateGatewayInformation]
$creadListPrec :: ReadPrec [UpdateGatewayInformation]
readPrec :: ReadPrec UpdateGatewayInformation
$creadPrec :: ReadPrec UpdateGatewayInformation
readList :: ReadS [UpdateGatewayInformation]
$creadList :: ReadS [UpdateGatewayInformation]
readsPrec :: Int -> ReadS UpdateGatewayInformation
$creadsPrec :: Int -> ReadS UpdateGatewayInformation
Prelude.Read, Int -> UpdateGatewayInformation -> ShowS
[UpdateGatewayInformation] -> ShowS
UpdateGatewayInformation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateGatewayInformation] -> ShowS
$cshowList :: [UpdateGatewayInformation] -> ShowS
show :: UpdateGatewayInformation -> String
$cshow :: UpdateGatewayInformation -> String
showsPrec :: Int -> UpdateGatewayInformation -> ShowS
$cshowsPrec :: Int -> UpdateGatewayInformation -> ShowS
Prelude.Show, forall x.
Rep UpdateGatewayInformation x -> UpdateGatewayInformation
forall x.
UpdateGatewayInformation -> Rep UpdateGatewayInformation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateGatewayInformation x -> UpdateGatewayInformation
$cfrom :: forall x.
UpdateGatewayInformation -> Rep UpdateGatewayInformation x
Prelude.Generic)

-- |
-- Create a value of 'UpdateGatewayInformation' 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:
--
-- 'gatewayDisplayName', 'updateGatewayInformation_gatewayDisplayName' - The updated display name of the gateway.
--
-- 'gatewayArn', 'updateGatewayInformation_gatewayArn' - The Amazon Resource Name (ARN) of the gateway to update.
newUpdateGatewayInformation ::
  -- | 'gatewayArn'
  Prelude.Text ->
  UpdateGatewayInformation
newUpdateGatewayInformation :: Text -> UpdateGatewayInformation
newUpdateGatewayInformation Text
pGatewayArn_ =
  UpdateGatewayInformation'
    { $sel:gatewayDisplayName:UpdateGatewayInformation' :: Maybe Text
gatewayDisplayName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:gatewayArn:UpdateGatewayInformation' :: Text
gatewayArn = Text
pGatewayArn_
    }

-- | The updated display name of the gateway.
updateGatewayInformation_gatewayDisplayName :: Lens.Lens' UpdateGatewayInformation (Prelude.Maybe Prelude.Text)
updateGatewayInformation_gatewayDisplayName :: Lens' UpdateGatewayInformation (Maybe Text)
updateGatewayInformation_gatewayDisplayName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGatewayInformation' {Maybe Text
gatewayDisplayName :: Maybe Text
$sel:gatewayDisplayName:UpdateGatewayInformation' :: UpdateGatewayInformation -> Maybe Text
gatewayDisplayName} -> Maybe Text
gatewayDisplayName) (\s :: UpdateGatewayInformation
s@UpdateGatewayInformation' {} Maybe Text
a -> UpdateGatewayInformation
s {$sel:gatewayDisplayName:UpdateGatewayInformation' :: Maybe Text
gatewayDisplayName = Maybe Text
a} :: UpdateGatewayInformation)

-- | The Amazon Resource Name (ARN) of the gateway to update.
updateGatewayInformation_gatewayArn :: Lens.Lens' UpdateGatewayInformation Prelude.Text
updateGatewayInformation_gatewayArn :: Lens' UpdateGatewayInformation Text
updateGatewayInformation_gatewayArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGatewayInformation' {Text
gatewayArn :: Text
$sel:gatewayArn:UpdateGatewayInformation' :: UpdateGatewayInformation -> Text
gatewayArn} -> Text
gatewayArn) (\s :: UpdateGatewayInformation
s@UpdateGatewayInformation' {} Text
a -> UpdateGatewayInformation
s {$sel:gatewayArn:UpdateGatewayInformation' :: Text
gatewayArn = Text
a} :: UpdateGatewayInformation)

instance Core.AWSRequest UpdateGatewayInformation where
  type
    AWSResponse UpdateGatewayInformation =
      UpdateGatewayInformationResponse
  request :: (Service -> Service)
-> UpdateGatewayInformation -> Request UpdateGatewayInformation
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateGatewayInformation
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateGatewayInformation)))
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 Text -> Int -> UpdateGatewayInformationResponse
UpdateGatewayInformationResponse'
            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
"GatewayArn")
            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 UpdateGatewayInformation where
  hashWithSalt :: Int -> UpdateGatewayInformation -> Int
hashWithSalt Int
_salt UpdateGatewayInformation' {Maybe Text
Text
gatewayArn :: Text
gatewayDisplayName :: Maybe Text
$sel:gatewayArn:UpdateGatewayInformation' :: UpdateGatewayInformation -> Text
$sel:gatewayDisplayName:UpdateGatewayInformation' :: UpdateGatewayInformation -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
gatewayDisplayName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
gatewayArn

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

instance Data.ToHeaders UpdateGatewayInformation where
  toHeaders :: UpdateGatewayInformation -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"BackupOnPremises_v20210101.UpdateGatewayInformation" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateGatewayInformation where
  toJSON :: UpdateGatewayInformation -> Value
toJSON UpdateGatewayInformation' {Maybe Text
Text
gatewayArn :: Text
gatewayDisplayName :: Maybe Text
$sel:gatewayArn:UpdateGatewayInformation' :: UpdateGatewayInformation -> Text
$sel:gatewayDisplayName:UpdateGatewayInformation' :: UpdateGatewayInformation -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"GatewayDisplayName" 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
gatewayDisplayName,
            forall a. a -> Maybe a
Prelude.Just (Key
"GatewayArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
gatewayArn)
          ]
      )

instance Data.ToPath UpdateGatewayInformation where
  toPath :: UpdateGatewayInformation -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newUpdateGatewayInformationResponse' smart constructor.
data UpdateGatewayInformationResponse = UpdateGatewayInformationResponse'
  { -- | The Amazon Resource Name (ARN) of the gateway you updated.
    UpdateGatewayInformationResponse -> Maybe Text
gatewayArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    UpdateGatewayInformationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateGatewayInformationResponse
-> UpdateGatewayInformationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateGatewayInformationResponse
-> UpdateGatewayInformationResponse -> Bool
$c/= :: UpdateGatewayInformationResponse
-> UpdateGatewayInformationResponse -> Bool
== :: UpdateGatewayInformationResponse
-> UpdateGatewayInformationResponse -> Bool
$c== :: UpdateGatewayInformationResponse
-> UpdateGatewayInformationResponse -> Bool
Prelude.Eq, ReadPrec [UpdateGatewayInformationResponse]
ReadPrec UpdateGatewayInformationResponse
Int -> ReadS UpdateGatewayInformationResponse
ReadS [UpdateGatewayInformationResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateGatewayInformationResponse]
$creadListPrec :: ReadPrec [UpdateGatewayInformationResponse]
readPrec :: ReadPrec UpdateGatewayInformationResponse
$creadPrec :: ReadPrec UpdateGatewayInformationResponse
readList :: ReadS [UpdateGatewayInformationResponse]
$creadList :: ReadS [UpdateGatewayInformationResponse]
readsPrec :: Int -> ReadS UpdateGatewayInformationResponse
$creadsPrec :: Int -> ReadS UpdateGatewayInformationResponse
Prelude.Read, Int -> UpdateGatewayInformationResponse -> ShowS
[UpdateGatewayInformationResponse] -> ShowS
UpdateGatewayInformationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateGatewayInformationResponse] -> ShowS
$cshowList :: [UpdateGatewayInformationResponse] -> ShowS
show :: UpdateGatewayInformationResponse -> String
$cshow :: UpdateGatewayInformationResponse -> String
showsPrec :: Int -> UpdateGatewayInformationResponse -> ShowS
$cshowsPrec :: Int -> UpdateGatewayInformationResponse -> ShowS
Prelude.Show, forall x.
Rep UpdateGatewayInformationResponse x
-> UpdateGatewayInformationResponse
forall x.
UpdateGatewayInformationResponse
-> Rep UpdateGatewayInformationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateGatewayInformationResponse x
-> UpdateGatewayInformationResponse
$cfrom :: forall x.
UpdateGatewayInformationResponse
-> Rep UpdateGatewayInformationResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateGatewayInformationResponse' 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:
--
-- 'gatewayArn', 'updateGatewayInformationResponse_gatewayArn' - The Amazon Resource Name (ARN) of the gateway you updated.
--
-- 'httpStatus', 'updateGatewayInformationResponse_httpStatus' - The response's http status code.
newUpdateGatewayInformationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateGatewayInformationResponse
newUpdateGatewayInformationResponse :: Int -> UpdateGatewayInformationResponse
newUpdateGatewayInformationResponse Int
pHttpStatus_ =
  UpdateGatewayInformationResponse'
    { $sel:gatewayArn:UpdateGatewayInformationResponse' :: Maybe Text
gatewayArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateGatewayInformationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the gateway you updated.
updateGatewayInformationResponse_gatewayArn :: Lens.Lens' UpdateGatewayInformationResponse (Prelude.Maybe Prelude.Text)
updateGatewayInformationResponse_gatewayArn :: Lens' UpdateGatewayInformationResponse (Maybe Text)
updateGatewayInformationResponse_gatewayArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGatewayInformationResponse' {Maybe Text
gatewayArn :: Maybe Text
$sel:gatewayArn:UpdateGatewayInformationResponse' :: UpdateGatewayInformationResponse -> Maybe Text
gatewayArn} -> Maybe Text
gatewayArn) (\s :: UpdateGatewayInformationResponse
s@UpdateGatewayInformationResponse' {} Maybe Text
a -> UpdateGatewayInformationResponse
s {$sel:gatewayArn:UpdateGatewayInformationResponse' :: Maybe Text
gatewayArn = Maybe Text
a} :: UpdateGatewayInformationResponse)

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

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