{-# 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.AlexaBusiness.UpdateGateway
-- 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 the details of a gateway. If any optional field is not provided,
-- the existing corresponding value is left unmodified.
module Amazonka.AlexaBusiness.UpdateGateway
  ( -- * Creating a Request
    UpdateGateway (..),
    newUpdateGateway,

    -- * Request Lenses
    updateGateway_description,
    updateGateway_name,
    updateGateway_softwareVersion,
    updateGateway_gatewayArn,

    -- * Destructuring the Response
    UpdateGatewayResponse (..),
    newUpdateGatewayResponse,

    -- * Response Lenses
    updateGatewayResponse_httpStatus,
  )
where

import Amazonka.AlexaBusiness.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:/ 'newUpdateGateway' smart constructor.
data UpdateGateway = UpdateGateway'
  { -- | The updated description of the gateway.
    UpdateGateway -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The updated name of the gateway.
    UpdateGateway -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The updated software version of the gateway. The gateway automatically
    -- updates its software version during normal operation.
    UpdateGateway -> Maybe Text
softwareVersion :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the gateway to update.
    UpdateGateway -> Text
gatewayArn :: Prelude.Text
  }
  deriving (UpdateGateway -> UpdateGateway -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateGateway -> UpdateGateway -> Bool
$c/= :: UpdateGateway -> UpdateGateway -> Bool
== :: UpdateGateway -> UpdateGateway -> Bool
$c== :: UpdateGateway -> UpdateGateway -> Bool
Prelude.Eq, ReadPrec [UpdateGateway]
ReadPrec UpdateGateway
Int -> ReadS UpdateGateway
ReadS [UpdateGateway]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateGateway]
$creadListPrec :: ReadPrec [UpdateGateway]
readPrec :: ReadPrec UpdateGateway
$creadPrec :: ReadPrec UpdateGateway
readList :: ReadS [UpdateGateway]
$creadList :: ReadS [UpdateGateway]
readsPrec :: Int -> ReadS UpdateGateway
$creadsPrec :: Int -> ReadS UpdateGateway
Prelude.Read, Int -> UpdateGateway -> ShowS
[UpdateGateway] -> ShowS
UpdateGateway -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateGateway] -> ShowS
$cshowList :: [UpdateGateway] -> ShowS
show :: UpdateGateway -> String
$cshow :: UpdateGateway -> String
showsPrec :: Int -> UpdateGateway -> ShowS
$cshowsPrec :: Int -> UpdateGateway -> ShowS
Prelude.Show, forall x. Rep UpdateGateway x -> UpdateGateway
forall x. UpdateGateway -> Rep UpdateGateway x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateGateway x -> UpdateGateway
$cfrom :: forall x. UpdateGateway -> Rep UpdateGateway x
Prelude.Generic)

-- |
-- Create a value of 'UpdateGateway' 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', 'updateGateway_description' - The updated description of the gateway.
--
-- 'name', 'updateGateway_name' - The updated name of the gateway.
--
-- 'softwareVersion', 'updateGateway_softwareVersion' - The updated software version of the gateway. The gateway automatically
-- updates its software version during normal operation.
--
-- 'gatewayArn', 'updateGateway_gatewayArn' - The ARN of the gateway to update.
newUpdateGateway ::
  -- | 'gatewayArn'
  Prelude.Text ->
  UpdateGateway
newUpdateGateway :: Text -> UpdateGateway
newUpdateGateway Text
pGatewayArn_ =
  UpdateGateway'
    { $sel:description:UpdateGateway' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateGateway' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:softwareVersion:UpdateGateway' :: Maybe Text
softwareVersion = forall a. Maybe a
Prelude.Nothing,
      $sel:gatewayArn:UpdateGateway' :: Text
gatewayArn = Text
pGatewayArn_
    }

-- | The updated description of the gateway.
updateGateway_description :: Lens.Lens' UpdateGateway (Prelude.Maybe Prelude.Text)
updateGateway_description :: Lens' UpdateGateway (Maybe Text)
updateGateway_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGateway' {Maybe Text
description :: Maybe Text
$sel:description:UpdateGateway' :: UpdateGateway -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateGateway
s@UpdateGateway' {} Maybe Text
a -> UpdateGateway
s {$sel:description:UpdateGateway' :: Maybe Text
description = Maybe Text
a} :: UpdateGateway)

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

-- | The updated software version of the gateway. The gateway automatically
-- updates its software version during normal operation.
updateGateway_softwareVersion :: Lens.Lens' UpdateGateway (Prelude.Maybe Prelude.Text)
updateGateway_softwareVersion :: Lens' UpdateGateway (Maybe Text)
updateGateway_softwareVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGateway' {Maybe Text
softwareVersion :: Maybe Text
$sel:softwareVersion:UpdateGateway' :: UpdateGateway -> Maybe Text
softwareVersion} -> Maybe Text
softwareVersion) (\s :: UpdateGateway
s@UpdateGateway' {} Maybe Text
a -> UpdateGateway
s {$sel:softwareVersion:UpdateGateway' :: Maybe Text
softwareVersion = Maybe Text
a} :: UpdateGateway)

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

instance Core.AWSRequest UpdateGateway where
  type
    AWSResponse UpdateGateway =
      UpdateGatewayResponse
  request :: (Service -> Service) -> UpdateGateway -> Request UpdateGateway
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 UpdateGateway
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateGateway)))
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 -> UpdateGatewayResponse
UpdateGatewayResponse'
            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 UpdateGateway where
  hashWithSalt :: Int -> UpdateGateway -> Int
hashWithSalt Int
_salt UpdateGateway' {Maybe Text
Text
gatewayArn :: Text
softwareVersion :: Maybe Text
name :: Maybe Text
description :: Maybe Text
$sel:gatewayArn:UpdateGateway' :: UpdateGateway -> Text
$sel:softwareVersion:UpdateGateway' :: UpdateGateway -> Maybe Text
$sel:name:UpdateGateway' :: UpdateGateway -> Maybe Text
$sel:description:UpdateGateway' :: UpdateGateway -> 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` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
softwareVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
gatewayArn

instance Prelude.NFData UpdateGateway where
  rnf :: UpdateGateway -> ()
rnf UpdateGateway' {Maybe Text
Text
gatewayArn :: Text
softwareVersion :: Maybe Text
name :: Maybe Text
description :: Maybe Text
$sel:gatewayArn:UpdateGateway' :: UpdateGateway -> Text
$sel:softwareVersion:UpdateGateway' :: UpdateGateway -> Maybe Text
$sel:name:UpdateGateway' :: UpdateGateway -> Maybe Text
$sel:description:UpdateGateway' :: UpdateGateway -> 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 Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
softwareVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
gatewayArn

instance Data.ToHeaders UpdateGateway where
  toHeaders :: UpdateGateway -> 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
"AlexaForBusiness.UpdateGateway" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateGateway where
  toJSON :: UpdateGateway -> Value
toJSON UpdateGateway' {Maybe Text
Text
gatewayArn :: Text
softwareVersion :: Maybe Text
name :: Maybe Text
description :: Maybe Text
$sel:gatewayArn:UpdateGateway' :: UpdateGateway -> Text
$sel:softwareVersion:UpdateGateway' :: UpdateGateway -> Maybe Text
$sel:name:UpdateGateway' :: UpdateGateway -> Maybe Text
$sel:description:UpdateGateway' :: UpdateGateway -> 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,
            (Key
"Name" 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
name,
            (Key
"SoftwareVersion" 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
softwareVersion,
            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 UpdateGateway where
  toPath :: UpdateGateway -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

instance Prelude.NFData UpdateGatewayResponse where
  rnf :: UpdateGatewayResponse -> ()
rnf UpdateGatewayResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateGatewayResponse' :: UpdateGatewayResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus