{-# 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.AssociateDeviceWithRoom
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Associates a device with a given room. This applies all the settings
-- from the room profile to the device, and all the skills in any skill
-- groups added to that room. This operation requires the device to be
-- online, or else a manual sync is required.
module Amazonka.AlexaBusiness.AssociateDeviceWithRoom
  ( -- * Creating a Request
    AssociateDeviceWithRoom (..),
    newAssociateDeviceWithRoom,

    -- * Request Lenses
    associateDeviceWithRoom_deviceArn,
    associateDeviceWithRoom_roomArn,

    -- * Destructuring the Response
    AssociateDeviceWithRoomResponse (..),
    newAssociateDeviceWithRoomResponse,

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

-- |
-- Create a value of 'AssociateDeviceWithRoom' 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', 'associateDeviceWithRoom_deviceArn' - The ARN of the device to associate to a room. Required.
--
-- 'roomArn', 'associateDeviceWithRoom_roomArn' - The ARN of the room with which to associate the device. Required.
newAssociateDeviceWithRoom ::
  AssociateDeviceWithRoom
newAssociateDeviceWithRoom :: AssociateDeviceWithRoom
newAssociateDeviceWithRoom =
  AssociateDeviceWithRoom'
    { $sel:deviceArn:AssociateDeviceWithRoom' :: Maybe Text
deviceArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:roomArn:AssociateDeviceWithRoom' :: Maybe Text
roomArn = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The ARN of the room with which to associate the device. Required.
associateDeviceWithRoom_roomArn :: Lens.Lens' AssociateDeviceWithRoom (Prelude.Maybe Prelude.Text)
associateDeviceWithRoom_roomArn :: Lens' AssociateDeviceWithRoom (Maybe Text)
associateDeviceWithRoom_roomArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateDeviceWithRoom' {Maybe Text
roomArn :: Maybe Text
$sel:roomArn:AssociateDeviceWithRoom' :: AssociateDeviceWithRoom -> Maybe Text
roomArn} -> Maybe Text
roomArn) (\s :: AssociateDeviceWithRoom
s@AssociateDeviceWithRoom' {} Maybe Text
a -> AssociateDeviceWithRoom
s {$sel:roomArn:AssociateDeviceWithRoom' :: Maybe Text
roomArn = Maybe Text
a} :: AssociateDeviceWithRoom)

instance Core.AWSRequest AssociateDeviceWithRoom where
  type
    AWSResponse AssociateDeviceWithRoom =
      AssociateDeviceWithRoomResponse
  request :: (Service -> Service)
-> AssociateDeviceWithRoom -> Request AssociateDeviceWithRoom
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 AssociateDeviceWithRoom
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateDeviceWithRoom)))
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 -> AssociateDeviceWithRoomResponse
AssociateDeviceWithRoomResponse'
            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 AssociateDeviceWithRoom where
  hashWithSalt :: Int -> AssociateDeviceWithRoom -> Int
hashWithSalt Int
_salt AssociateDeviceWithRoom' {Maybe Text
roomArn :: Maybe Text
deviceArn :: Maybe Text
$sel:roomArn:AssociateDeviceWithRoom' :: AssociateDeviceWithRoom -> Maybe Text
$sel:deviceArn:AssociateDeviceWithRoom' :: AssociateDeviceWithRoom -> 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
roomArn

instance Prelude.NFData AssociateDeviceWithRoom where
  rnf :: AssociateDeviceWithRoom -> ()
rnf AssociateDeviceWithRoom' {Maybe Text
roomArn :: Maybe Text
deviceArn :: Maybe Text
$sel:roomArn:AssociateDeviceWithRoom' :: AssociateDeviceWithRoom -> Maybe Text
$sel:deviceArn:AssociateDeviceWithRoom' :: AssociateDeviceWithRoom -> 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
roomArn

instance Data.ToHeaders AssociateDeviceWithRoom where
  toHeaders :: AssociateDeviceWithRoom -> 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.AssociateDeviceWithRoom" ::
                          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 AssociateDeviceWithRoom where
  toJSON :: AssociateDeviceWithRoom -> Value
toJSON AssociateDeviceWithRoom' {Maybe Text
roomArn :: Maybe Text
deviceArn :: Maybe Text
$sel:roomArn:AssociateDeviceWithRoom' :: AssociateDeviceWithRoom -> Maybe Text
$sel:deviceArn:AssociateDeviceWithRoom' :: AssociateDeviceWithRoom -> 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
"RoomArn" 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
roomArn
          ]
      )

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

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

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

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

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

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