{-# 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.UpdateDevice
-- 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 device name by device ARN.
module Amazonka.AlexaBusiness.UpdateDevice
  ( -- * Creating a Request
    UpdateDevice (..),
    newUpdateDevice,

    -- * Request Lenses
    updateDevice_deviceArn,
    updateDevice_deviceName,

    -- * Destructuring the Response
    UpdateDeviceResponse (..),
    newUpdateDeviceResponse,

    -- * Response Lenses
    updateDeviceResponse_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:/ 'newUpdateDevice' smart constructor.
data UpdateDevice = UpdateDevice'
  { -- | The ARN of the device to update. Required.
    UpdateDevice -> Maybe Text
deviceArn :: Prelude.Maybe Prelude.Text,
    -- | The updated device name. Required.
    UpdateDevice -> Maybe Text
deviceName :: Prelude.Maybe Prelude.Text
  }
  deriving (UpdateDevice -> UpdateDevice -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDevice -> UpdateDevice -> Bool
$c/= :: UpdateDevice -> UpdateDevice -> Bool
== :: UpdateDevice -> UpdateDevice -> Bool
$c== :: UpdateDevice -> UpdateDevice -> Bool
Prelude.Eq, ReadPrec [UpdateDevice]
ReadPrec UpdateDevice
Int -> ReadS UpdateDevice
ReadS [UpdateDevice]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDevice]
$creadListPrec :: ReadPrec [UpdateDevice]
readPrec :: ReadPrec UpdateDevice
$creadPrec :: ReadPrec UpdateDevice
readList :: ReadS [UpdateDevice]
$creadList :: ReadS [UpdateDevice]
readsPrec :: Int -> ReadS UpdateDevice
$creadsPrec :: Int -> ReadS UpdateDevice
Prelude.Read, Int -> UpdateDevice -> ShowS
[UpdateDevice] -> ShowS
UpdateDevice -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDevice] -> ShowS
$cshowList :: [UpdateDevice] -> ShowS
show :: UpdateDevice -> String
$cshow :: UpdateDevice -> String
showsPrec :: Int -> UpdateDevice -> ShowS
$cshowsPrec :: Int -> UpdateDevice -> ShowS
Prelude.Show, forall x. Rep UpdateDevice x -> UpdateDevice
forall x. UpdateDevice -> Rep UpdateDevice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateDevice x -> UpdateDevice
$cfrom :: forall x. UpdateDevice -> Rep UpdateDevice x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDevice' 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:
--
-- 'deviceArn', 'updateDevice_deviceArn' - The ARN of the device to update. Required.
--
-- 'deviceName', 'updateDevice_deviceName' - The updated device name. Required.
newUpdateDevice ::
  UpdateDevice
newUpdateDevice :: UpdateDevice
newUpdateDevice =
  UpdateDevice'
    { $sel:deviceArn:UpdateDevice' :: Maybe Text
deviceArn = forall a. Maybe a
Prelude.Nothing,
      $sel:deviceName:UpdateDevice' :: Maybe Text
deviceName = forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the device to update. Required.
updateDevice_deviceArn :: Lens.Lens' UpdateDevice (Prelude.Maybe Prelude.Text)
updateDevice_deviceArn :: Lens' UpdateDevice (Maybe Text)
updateDevice_deviceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDevice' {Maybe Text
deviceArn :: Maybe Text
$sel:deviceArn:UpdateDevice' :: UpdateDevice -> Maybe Text
deviceArn} -> Maybe Text
deviceArn) (\s :: UpdateDevice
s@UpdateDevice' {} Maybe Text
a -> UpdateDevice
s {$sel:deviceArn:UpdateDevice' :: Maybe Text
deviceArn = Maybe Text
a} :: UpdateDevice)

-- | The updated device name. Required.
updateDevice_deviceName :: Lens.Lens' UpdateDevice (Prelude.Maybe Prelude.Text)
updateDevice_deviceName :: Lens' UpdateDevice (Maybe Text)
updateDevice_deviceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDevice' {Maybe Text
deviceName :: Maybe Text
$sel:deviceName:UpdateDevice' :: UpdateDevice -> Maybe Text
deviceName} -> Maybe Text
deviceName) (\s :: UpdateDevice
s@UpdateDevice' {} Maybe Text
a -> UpdateDevice
s {$sel:deviceName:UpdateDevice' :: Maybe Text
deviceName = Maybe Text
a} :: UpdateDevice)

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

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

instance Data.ToHeaders UpdateDevice where
  toHeaders :: UpdateDevice -> 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.UpdateDevice" ::
                          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 UpdateDevice where
  toJSON :: UpdateDevice -> Value
toJSON UpdateDevice' {Maybe Text
deviceName :: Maybe Text
deviceArn :: Maybe Text
$sel:deviceName:UpdateDevice' :: UpdateDevice -> Maybe Text
$sel:deviceArn:UpdateDevice' :: UpdateDevice -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DeviceArn" 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
deviceArn,
            (Key
"DeviceName" 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
deviceName
          ]
      )

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

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

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

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

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

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