{-# 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-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 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_name,
    updateGateway_softwareVersion,
    updateGateway_description,
    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.Lens as Lens
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 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 updated description of the gateway.
    UpdateGateway -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the gateway to update.
    UpdateGateway -> Text
gatewayArn :: Prelude.Text
  }
  deriving (UpdateGateway -> UpdateGateway -> Bool
(UpdateGateway -> UpdateGateway -> Bool)
-> (UpdateGateway -> UpdateGateway -> Bool) -> Eq UpdateGateway
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]
(Int -> ReadS UpdateGateway)
-> ReadS [UpdateGateway]
-> ReadPrec UpdateGateway
-> ReadPrec [UpdateGateway]
-> Read 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
(Int -> UpdateGateway -> ShowS)
-> (UpdateGateway -> String)
-> ([UpdateGateway] -> ShowS)
-> Show UpdateGateway
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. UpdateGateway -> Rep UpdateGateway x)
-> (forall x. Rep UpdateGateway x -> UpdateGateway)
-> Generic UpdateGateway
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:
--
-- '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.
--
-- 'description', 'updateGateway_description' - The updated description of the gateway.
--
-- 'gatewayArn', 'updateGateway_gatewayArn' - The ARN of the gateway to update.
newUpdateGateway ::
  -- | 'gatewayArn'
  Prelude.Text ->
  UpdateGateway
newUpdateGateway :: Text -> UpdateGateway
newUpdateGateway Text
pGatewayArn_ =
  UpdateGateway' :: Maybe Text -> Maybe Text -> Maybe Text -> Text -> UpdateGateway
UpdateGateway'
    { $sel:name:UpdateGateway' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:softwareVersion:UpdateGateway' :: Maybe Text
softwareVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:UpdateGateway' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:gatewayArn:UpdateGateway' :: Text
gatewayArn = Text
pGatewayArn_
    }

-- | The updated name of the gateway.
updateGateway_name :: Lens.Lens' UpdateGateway (Prelude.Maybe Prelude.Text)
updateGateway_name :: (Maybe Text -> f (Maybe Text)) -> UpdateGateway -> f UpdateGateway
updateGateway_name = (UpdateGateway -> Maybe Text)
-> (UpdateGateway -> Maybe Text -> UpdateGateway)
-> Lens UpdateGateway UpdateGateway (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> UpdateGateway -> f UpdateGateway
updateGateway_softwareVersion = (UpdateGateway -> Maybe Text)
-> (UpdateGateway -> Maybe Text -> UpdateGateway)
-> Lens UpdateGateway UpdateGateway (Maybe Text) (Maybe Text)
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 updated description of the gateway.
updateGateway_description :: Lens.Lens' UpdateGateway (Prelude.Maybe Prelude.Text)
updateGateway_description :: (Maybe Text -> f (Maybe Text)) -> UpdateGateway -> f UpdateGateway
updateGateway_description = (UpdateGateway -> Maybe Text)
-> (UpdateGateway -> Maybe Text -> UpdateGateway)
-> Lens UpdateGateway UpdateGateway (Maybe Text) (Maybe Text)
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 ARN of the gateway to update.
updateGateway_gatewayArn :: Lens.Lens' UpdateGateway Prelude.Text
updateGateway_gatewayArn :: (Text -> f Text) -> UpdateGateway -> f UpdateGateway
updateGateway_gatewayArn = (UpdateGateway -> Text)
-> (UpdateGateway -> Text -> UpdateGateway)
-> Lens UpdateGateway UpdateGateway Text Text
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 :: UpdateGateway -> Request UpdateGateway
request = Service -> UpdateGateway -> Request UpdateGateway
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateGateway
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateGateway)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateGateway))
-> Logger
-> Service
-> Proxy UpdateGateway
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateGateway)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateGatewayResponse
UpdateGatewayResponse'
            (Int -> UpdateGatewayResponse)
-> Either String Int -> Either String UpdateGatewayResponse
forall (f :: * -> *) a b. Functor 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 UpdateGateway

instance Prelude.NFData UpdateGateway

instance Core.ToHeaders UpdateGateway where
  toHeaders :: UpdateGateway -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateGateway -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AlexaForBusiness.UpdateGateway" ::
                          Prelude.ByteString
                      ),
            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 UpdateGateway where
  toJSON :: UpdateGateway -> Value
toJSON UpdateGateway' {Maybe Text
Text
gatewayArn :: Text
description :: Maybe Text
softwareVersion :: Maybe Text
name :: Maybe Text
$sel:gatewayArn:UpdateGateway' :: UpdateGateway -> Text
$sel:description:UpdateGateway' :: UpdateGateway -> Maybe Text
$sel:softwareVersion:UpdateGateway' :: UpdateGateway -> Maybe Text
$sel:name:UpdateGateway' :: UpdateGateway -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Name" 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
name,
            (Text
"SoftwareVersion" 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
softwareVersion,
            (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,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"GatewayArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
gatewayArn)
          ]
      )

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

instance Core.ToQuery UpdateGateway where
  toQuery :: UpdateGateway -> QueryString
toQuery = QueryString -> UpdateGateway -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(UpdateGatewayResponse -> UpdateGatewayResponse -> Bool)
-> (UpdateGatewayResponse -> UpdateGatewayResponse -> Bool)
-> Eq UpdateGatewayResponse
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]
(Int -> ReadS UpdateGatewayResponse)
-> ReadS [UpdateGatewayResponse]
-> ReadPrec UpdateGatewayResponse
-> ReadPrec [UpdateGatewayResponse]
-> Read 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
(Int -> UpdateGatewayResponse -> ShowS)
-> (UpdateGatewayResponse -> String)
-> ([UpdateGatewayResponse] -> ShowS)
-> Show UpdateGatewayResponse
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. UpdateGatewayResponse -> Rep UpdateGatewayResponse x)
-> (forall x. Rep UpdateGatewayResponse x -> UpdateGatewayResponse)
-> Generic UpdateGatewayResponse
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' :: Int -> UpdateGatewayResponse
UpdateGatewayResponse' {$sel:httpStatus:UpdateGatewayResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
updateGatewayResponse_httpStatus :: Lens.Lens' UpdateGatewayResponse Prelude.Int
updateGatewayResponse_httpStatus :: (Int -> f Int) -> UpdateGatewayResponse -> f UpdateGatewayResponse
updateGatewayResponse_httpStatus = (UpdateGatewayResponse -> Int)
-> (UpdateGatewayResponse -> Int -> UpdateGatewayResponse)
-> Lens UpdateGatewayResponse UpdateGatewayResponse Int Int
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