{-# 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-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 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.Lens as Lens
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
(UpdateDevice -> UpdateDevice -> Bool)
-> (UpdateDevice -> UpdateDevice -> Bool) -> Eq UpdateDevice
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]
(Int -> ReadS UpdateDevice)
-> ReadS [UpdateDevice]
-> ReadPrec UpdateDevice
-> ReadPrec [UpdateDevice]
-> Read 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
(Int -> UpdateDevice -> ShowS)
-> (UpdateDevice -> String)
-> ([UpdateDevice] -> ShowS)
-> Show UpdateDevice
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. UpdateDevice -> Rep UpdateDevice x)
-> (forall x. Rep UpdateDevice x -> UpdateDevice)
-> Generic UpdateDevice
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' :: Maybe Text -> Maybe Text -> UpdateDevice
UpdateDevice'
    { $sel:deviceArn:UpdateDevice' :: Maybe Text
deviceArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceName:UpdateDevice' :: Maybe Text
deviceName = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> UpdateDevice -> f UpdateDevice
updateDevice_deviceArn = (UpdateDevice -> Maybe Text)
-> (UpdateDevice -> Maybe Text -> UpdateDevice)
-> Lens UpdateDevice UpdateDevice (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> UpdateDevice -> f UpdateDevice
updateDevice_deviceName = (UpdateDevice -> Maybe Text)
-> (UpdateDevice -> Maybe Text -> UpdateDevice)
-> Lens UpdateDevice UpdateDevice (Maybe Text) (Maybe Text)
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 :: UpdateDevice -> Request UpdateDevice
request = Service -> UpdateDevice -> Request UpdateDevice
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateDevice
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateDevice)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateDevice))
-> Logger
-> Service
-> Proxy UpdateDevice
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateDevice)))
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 -> UpdateDeviceResponse
UpdateDeviceResponse'
            (Int -> UpdateDeviceResponse)
-> Either String Int -> Either String UpdateDeviceResponse
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 UpdateDevice

instance Prelude.NFData UpdateDevice

instance Core.ToHeaders UpdateDevice where
  toHeaders :: UpdateDevice -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateDevice -> 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.UpdateDevice" ::
                          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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DeviceArn" 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
deviceArn,
            (Text
"DeviceName" 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
deviceName
          ]
      )

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

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

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