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

instance Prelude.NFData AssociateDeviceWithRoom

instance Core.ToHeaders AssociateDeviceWithRoom where
  toHeaders :: AssociateDeviceWithRoom -> ResponseHeaders
toHeaders =
    ResponseHeaders -> AssociateDeviceWithRoom -> 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.AssociateDeviceWithRoom" ::
                          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 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
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
"RoomArn" 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
roomArn
          ]
      )

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

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

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