{-# 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.IoTWireless.AssociateWirelessDeviceWithThing
-- 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 wireless device with a thing.
module Amazonka.IoTWireless.AssociateWirelessDeviceWithThing
  ( -- * Creating a Request
    AssociateWirelessDeviceWithThing (..),
    newAssociateWirelessDeviceWithThing,

    -- * Request Lenses
    associateWirelessDeviceWithThing_id,
    associateWirelessDeviceWithThing_thingArn,

    -- * Destructuring the Response
    AssociateWirelessDeviceWithThingResponse (..),
    newAssociateWirelessDeviceWithThingResponse,

    -- * Response Lenses
    associateWirelessDeviceWithThingResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoTWireless.Types
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:/ 'newAssociateWirelessDeviceWithThing' smart constructor.
data AssociateWirelessDeviceWithThing = AssociateWirelessDeviceWithThing'
  { -- | The ID of the resource to update.
    AssociateWirelessDeviceWithThing -> Text
id :: Prelude.Text,
    -- | The ARN of the thing to associate with the wireless device.
    AssociateWirelessDeviceWithThing -> Text
thingArn :: Prelude.Text
  }
  deriving (AssociateWirelessDeviceWithThing
-> AssociateWirelessDeviceWithThing -> Bool
(AssociateWirelessDeviceWithThing
 -> AssociateWirelessDeviceWithThing -> Bool)
-> (AssociateWirelessDeviceWithThing
    -> AssociateWirelessDeviceWithThing -> Bool)
-> Eq AssociateWirelessDeviceWithThing
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateWirelessDeviceWithThing
-> AssociateWirelessDeviceWithThing -> Bool
$c/= :: AssociateWirelessDeviceWithThing
-> AssociateWirelessDeviceWithThing -> Bool
== :: AssociateWirelessDeviceWithThing
-> AssociateWirelessDeviceWithThing -> Bool
$c== :: AssociateWirelessDeviceWithThing
-> AssociateWirelessDeviceWithThing -> Bool
Prelude.Eq, ReadPrec [AssociateWirelessDeviceWithThing]
ReadPrec AssociateWirelessDeviceWithThing
Int -> ReadS AssociateWirelessDeviceWithThing
ReadS [AssociateWirelessDeviceWithThing]
(Int -> ReadS AssociateWirelessDeviceWithThing)
-> ReadS [AssociateWirelessDeviceWithThing]
-> ReadPrec AssociateWirelessDeviceWithThing
-> ReadPrec [AssociateWirelessDeviceWithThing]
-> Read AssociateWirelessDeviceWithThing
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateWirelessDeviceWithThing]
$creadListPrec :: ReadPrec [AssociateWirelessDeviceWithThing]
readPrec :: ReadPrec AssociateWirelessDeviceWithThing
$creadPrec :: ReadPrec AssociateWirelessDeviceWithThing
readList :: ReadS [AssociateWirelessDeviceWithThing]
$creadList :: ReadS [AssociateWirelessDeviceWithThing]
readsPrec :: Int -> ReadS AssociateWirelessDeviceWithThing
$creadsPrec :: Int -> ReadS AssociateWirelessDeviceWithThing
Prelude.Read, Int -> AssociateWirelessDeviceWithThing -> ShowS
[AssociateWirelessDeviceWithThing] -> ShowS
AssociateWirelessDeviceWithThing -> String
(Int -> AssociateWirelessDeviceWithThing -> ShowS)
-> (AssociateWirelessDeviceWithThing -> String)
-> ([AssociateWirelessDeviceWithThing] -> ShowS)
-> Show AssociateWirelessDeviceWithThing
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateWirelessDeviceWithThing] -> ShowS
$cshowList :: [AssociateWirelessDeviceWithThing] -> ShowS
show :: AssociateWirelessDeviceWithThing -> String
$cshow :: AssociateWirelessDeviceWithThing -> String
showsPrec :: Int -> AssociateWirelessDeviceWithThing -> ShowS
$cshowsPrec :: Int -> AssociateWirelessDeviceWithThing -> ShowS
Prelude.Show, (forall x.
 AssociateWirelessDeviceWithThing
 -> Rep AssociateWirelessDeviceWithThing x)
-> (forall x.
    Rep AssociateWirelessDeviceWithThing x
    -> AssociateWirelessDeviceWithThing)
-> Generic AssociateWirelessDeviceWithThing
forall x.
Rep AssociateWirelessDeviceWithThing x
-> AssociateWirelessDeviceWithThing
forall x.
AssociateWirelessDeviceWithThing
-> Rep AssociateWirelessDeviceWithThing x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateWirelessDeviceWithThing x
-> AssociateWirelessDeviceWithThing
$cfrom :: forall x.
AssociateWirelessDeviceWithThing
-> Rep AssociateWirelessDeviceWithThing x
Prelude.Generic)

-- |
-- Create a value of 'AssociateWirelessDeviceWithThing' 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:
--
-- 'id', 'associateWirelessDeviceWithThing_id' - The ID of the resource to update.
--
-- 'thingArn', 'associateWirelessDeviceWithThing_thingArn' - The ARN of the thing to associate with the wireless device.
newAssociateWirelessDeviceWithThing ::
  -- | 'id'
  Prelude.Text ->
  -- | 'thingArn'
  Prelude.Text ->
  AssociateWirelessDeviceWithThing
newAssociateWirelessDeviceWithThing :: Text -> Text -> AssociateWirelessDeviceWithThing
newAssociateWirelessDeviceWithThing Text
pId_ Text
pThingArn_ =
  AssociateWirelessDeviceWithThing' :: Text -> Text -> AssociateWirelessDeviceWithThing
AssociateWirelessDeviceWithThing'
    { $sel:id:AssociateWirelessDeviceWithThing' :: Text
id = Text
pId_,
      $sel:thingArn:AssociateWirelessDeviceWithThing' :: Text
thingArn = Text
pThingArn_
    }

-- | The ID of the resource to update.
associateWirelessDeviceWithThing_id :: Lens.Lens' AssociateWirelessDeviceWithThing Prelude.Text
associateWirelessDeviceWithThing_id :: (Text -> f Text)
-> AssociateWirelessDeviceWithThing
-> f AssociateWirelessDeviceWithThing
associateWirelessDeviceWithThing_id = (AssociateWirelessDeviceWithThing -> Text)
-> (AssociateWirelessDeviceWithThing
    -> Text -> AssociateWirelessDeviceWithThing)
-> Lens
     AssociateWirelessDeviceWithThing
     AssociateWirelessDeviceWithThing
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateWirelessDeviceWithThing' {Text
id :: Text
$sel:id:AssociateWirelessDeviceWithThing' :: AssociateWirelessDeviceWithThing -> Text
id} -> Text
id) (\s :: AssociateWirelessDeviceWithThing
s@AssociateWirelessDeviceWithThing' {} Text
a -> AssociateWirelessDeviceWithThing
s {$sel:id:AssociateWirelessDeviceWithThing' :: Text
id = Text
a} :: AssociateWirelessDeviceWithThing)

-- | The ARN of the thing to associate with the wireless device.
associateWirelessDeviceWithThing_thingArn :: Lens.Lens' AssociateWirelessDeviceWithThing Prelude.Text
associateWirelessDeviceWithThing_thingArn :: (Text -> f Text)
-> AssociateWirelessDeviceWithThing
-> f AssociateWirelessDeviceWithThing
associateWirelessDeviceWithThing_thingArn = (AssociateWirelessDeviceWithThing -> Text)
-> (AssociateWirelessDeviceWithThing
    -> Text -> AssociateWirelessDeviceWithThing)
-> Lens
     AssociateWirelessDeviceWithThing
     AssociateWirelessDeviceWithThing
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateWirelessDeviceWithThing' {Text
thingArn :: Text
$sel:thingArn:AssociateWirelessDeviceWithThing' :: AssociateWirelessDeviceWithThing -> Text
thingArn} -> Text
thingArn) (\s :: AssociateWirelessDeviceWithThing
s@AssociateWirelessDeviceWithThing' {} Text
a -> AssociateWirelessDeviceWithThing
s {$sel:thingArn:AssociateWirelessDeviceWithThing' :: Text
thingArn = Text
a} :: AssociateWirelessDeviceWithThing)

instance
  Core.AWSRequest
    AssociateWirelessDeviceWithThing
  where
  type
    AWSResponse AssociateWirelessDeviceWithThing =
      AssociateWirelessDeviceWithThingResponse
  request :: AssociateWirelessDeviceWithThing
-> Request AssociateWirelessDeviceWithThing
request = Service
-> AssociateWirelessDeviceWithThing
-> Request AssociateWirelessDeviceWithThing
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociateWirelessDeviceWithThing
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse AssociateWirelessDeviceWithThing)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse AssociateWirelessDeviceWithThing))
-> Logger
-> Service
-> Proxy AssociateWirelessDeviceWithThing
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse AssociateWirelessDeviceWithThing)))
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 -> AssociateWirelessDeviceWithThingResponse
AssociateWirelessDeviceWithThingResponse'
            (Int -> AssociateWirelessDeviceWithThingResponse)
-> Either String Int
-> Either String AssociateWirelessDeviceWithThingResponse
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
    AssociateWirelessDeviceWithThing

instance
  Prelude.NFData
    AssociateWirelessDeviceWithThing

instance
  Core.ToHeaders
    AssociateWirelessDeviceWithThing
  where
  toHeaders :: AssociateWirelessDeviceWithThing -> ResponseHeaders
toHeaders = ResponseHeaders
-> AssociateWirelessDeviceWithThing -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON AssociateWirelessDeviceWithThing where
  toJSON :: AssociateWirelessDeviceWithThing -> Value
toJSON AssociateWirelessDeviceWithThing' {Text
thingArn :: Text
id :: Text
$sel:thingArn:AssociateWirelessDeviceWithThing' :: AssociateWirelessDeviceWithThing -> Text
$sel:id:AssociateWirelessDeviceWithThing' :: AssociateWirelessDeviceWithThing -> 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
"ThingArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
thingArn)]
      )

instance Core.ToPath AssociateWirelessDeviceWithThing where
  toPath :: AssociateWirelessDeviceWithThing -> ByteString
toPath AssociateWirelessDeviceWithThing' {Text
thingArn :: Text
id :: Text
$sel:thingArn:AssociateWirelessDeviceWithThing' :: AssociateWirelessDeviceWithThing -> Text
$sel:id:AssociateWirelessDeviceWithThing' :: AssociateWirelessDeviceWithThing -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/wireless-devices/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
id, ByteString
"/thing"]

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

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

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

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

instance
  Prelude.NFData
    AssociateWirelessDeviceWithThingResponse