{-# 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-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 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.Lens as Lens
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
(AssociateDeviceWithNetworkProfile
 -> AssociateDeviceWithNetworkProfile -> Bool)
-> (AssociateDeviceWithNetworkProfile
    -> AssociateDeviceWithNetworkProfile -> Bool)
-> Eq AssociateDeviceWithNetworkProfile
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]
(Int -> ReadS AssociateDeviceWithNetworkProfile)
-> ReadS [AssociateDeviceWithNetworkProfile]
-> ReadPrec AssociateDeviceWithNetworkProfile
-> ReadPrec [AssociateDeviceWithNetworkProfile]
-> Read 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
(Int -> AssociateDeviceWithNetworkProfile -> ShowS)
-> (AssociateDeviceWithNetworkProfile -> String)
-> ([AssociateDeviceWithNetworkProfile] -> ShowS)
-> Show AssociateDeviceWithNetworkProfile
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.
 AssociateDeviceWithNetworkProfile
 -> Rep AssociateDeviceWithNetworkProfile x)
-> (forall x.
    Rep AssociateDeviceWithNetworkProfile x
    -> AssociateDeviceWithNetworkProfile)
-> Generic AssociateDeviceWithNetworkProfile
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' :: Text -> Text -> AssociateDeviceWithNetworkProfile
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 :: (Text -> f Text)
-> AssociateDeviceWithNetworkProfile
-> f AssociateDeviceWithNetworkProfile
associateDeviceWithNetworkProfile_deviceArn = (AssociateDeviceWithNetworkProfile -> Text)
-> (AssociateDeviceWithNetworkProfile
    -> Text -> AssociateDeviceWithNetworkProfile)
-> Lens
     AssociateDeviceWithNetworkProfile
     AssociateDeviceWithNetworkProfile
     Text
     Text
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 :: (Text -> f Text)
-> AssociateDeviceWithNetworkProfile
-> f AssociateDeviceWithNetworkProfile
associateDeviceWithNetworkProfile_networkProfileArn = (AssociateDeviceWithNetworkProfile -> Text)
-> (AssociateDeviceWithNetworkProfile
    -> Text -> AssociateDeviceWithNetworkProfile)
-> Lens
     AssociateDeviceWithNetworkProfile
     AssociateDeviceWithNetworkProfile
     Text
     Text
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 :: AssociateDeviceWithNetworkProfile
-> Request AssociateDeviceWithNetworkProfile
request = Service
-> AssociateDeviceWithNetworkProfile
-> Request AssociateDeviceWithNetworkProfile
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociateDeviceWithNetworkProfile
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse AssociateDeviceWithNetworkProfile)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse AssociateDeviceWithNetworkProfile))
-> Logger
-> Service
-> Proxy AssociateDeviceWithNetworkProfile
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse AssociateDeviceWithNetworkProfile)))
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 -> AssociateDeviceWithNetworkProfileResponse
AssociateDeviceWithNetworkProfileResponse'
            (Int -> AssociateDeviceWithNetworkProfileResponse)
-> Either String Int
-> Either String AssociateDeviceWithNetworkProfileResponse
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
    AssociateDeviceWithNetworkProfile

instance
  Prelude.NFData
    AssociateDeviceWithNetworkProfile

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

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

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

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