{-# 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.AssociateDeviceWithNetworkProfile
-- 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 the specified network profile.
module Amazonka.AlexaBusiness.AssociateDeviceWithNetworkProfile
  ( -- * Creating a Request
    AssociateDeviceWithNetworkProfile (..),
    newAssociateDeviceWithNetworkProfile,

    -- * Request Lenses
    associateDeviceWithNetworkProfile_deviceArn,
    associateDeviceWithNetworkProfile_networkProfileArn,

    -- * Destructuring the Response
    AssociateDeviceWithNetworkProfileResponse (..),
    newAssociateDeviceWithNetworkProfileResponse,

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

-- |
-- Create a value of 'AssociateDeviceWithNetworkProfile' 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', 'associateDeviceWithNetworkProfile_deviceArn' - The device ARN.
--
-- 'networkProfileArn', 'associateDeviceWithNetworkProfile_networkProfileArn' - The ARN of the network profile to associate with a device.
newAssociateDeviceWithNetworkProfile ::
  -- | 'deviceArn'
  Prelude.Text ->
  -- | 'networkProfileArn'
  Prelude.Text ->
  AssociateDeviceWithNetworkProfile
newAssociateDeviceWithNetworkProfile :: Text -> Text -> AssociateDeviceWithNetworkProfile
newAssociateDeviceWithNetworkProfile
  Text
pDeviceArn_
  Text
pNetworkProfileArn_ =
    AssociateDeviceWithNetworkProfile'
      { $sel:deviceArn:AssociateDeviceWithNetworkProfile' :: Text
deviceArn =
          Text
pDeviceArn_,
        $sel:networkProfileArn:AssociateDeviceWithNetworkProfile' :: Text
networkProfileArn = Text
pNetworkProfileArn_
      }

-- | The device ARN.
associateDeviceWithNetworkProfile_deviceArn :: Lens.Lens' AssociateDeviceWithNetworkProfile Prelude.Text
associateDeviceWithNetworkProfile_deviceArn :: Lens' AssociateDeviceWithNetworkProfile Text
associateDeviceWithNetworkProfile_deviceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateDeviceWithNetworkProfile' {Text
deviceArn :: Text
$sel:deviceArn:AssociateDeviceWithNetworkProfile' :: AssociateDeviceWithNetworkProfile -> Text
deviceArn} -> Text
deviceArn) (\s :: AssociateDeviceWithNetworkProfile
s@AssociateDeviceWithNetworkProfile' {} Text
a -> AssociateDeviceWithNetworkProfile
s {$sel:deviceArn:AssociateDeviceWithNetworkProfile' :: Text
deviceArn = Text
a} :: AssociateDeviceWithNetworkProfile)

-- | The ARN of the network profile to associate with a device.
associateDeviceWithNetworkProfile_networkProfileArn :: Lens.Lens' AssociateDeviceWithNetworkProfile Prelude.Text
associateDeviceWithNetworkProfile_networkProfileArn :: Lens' AssociateDeviceWithNetworkProfile Text
associateDeviceWithNetworkProfile_networkProfileArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateDeviceWithNetworkProfile' {Text
networkProfileArn :: Text
$sel:networkProfileArn:AssociateDeviceWithNetworkProfile' :: AssociateDeviceWithNetworkProfile -> Text
networkProfileArn} -> Text
networkProfileArn) (\s :: AssociateDeviceWithNetworkProfile
s@AssociateDeviceWithNetworkProfile' {} Text
a -> AssociateDeviceWithNetworkProfile
s {$sel:networkProfileArn:AssociateDeviceWithNetworkProfile' :: Text
networkProfileArn = Text
a} :: AssociateDeviceWithNetworkProfile)

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

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

instance
  Data.ToHeaders
    AssociateDeviceWithNetworkProfile
  where
  toHeaders :: AssociateDeviceWithNetworkProfile -> 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.AssociateDeviceWithNetworkProfile" ::
                          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
    AssociateDeviceWithNetworkProfile
  where
  toJSON :: AssociateDeviceWithNetworkProfile -> Value
toJSON AssociateDeviceWithNetworkProfile' {Text
networkProfileArn :: Text
deviceArn :: Text
$sel:networkProfileArn:AssociateDeviceWithNetworkProfile' :: AssociateDeviceWithNetworkProfile -> Text
$sel:deviceArn:AssociateDeviceWithNetworkProfile' :: AssociateDeviceWithNetworkProfile -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"DeviceArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
deviceArn),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"NetworkProfileArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
networkProfileArn)
          ]
      )

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

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

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

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

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

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