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

    -- * Request Lenses
    associateWirelessGatewayWithThing_id,
    associateWirelessGatewayWithThing_thingArn,

    -- * Destructuring the Response
    AssociateWirelessGatewayWithThingResponse (..),
    newAssociateWirelessGatewayWithThingResponse,

    -- * Response Lenses
    associateWirelessGatewayWithThingResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTWireless.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newAssociateWirelessGatewayWithThing' smart constructor.
data AssociateWirelessGatewayWithThing = AssociateWirelessGatewayWithThing'
  { -- | The ID of the resource to update.
    AssociateWirelessGatewayWithThing -> Text
id :: Prelude.Text,
    -- | The ARN of the thing to associate with the wireless gateway.
    AssociateWirelessGatewayWithThing -> Text
thingArn :: Prelude.Text
  }
  deriving (AssociateWirelessGatewayWithThing
-> AssociateWirelessGatewayWithThing -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateWirelessGatewayWithThing
-> AssociateWirelessGatewayWithThing -> Bool
$c/= :: AssociateWirelessGatewayWithThing
-> AssociateWirelessGatewayWithThing -> Bool
== :: AssociateWirelessGatewayWithThing
-> AssociateWirelessGatewayWithThing -> Bool
$c== :: AssociateWirelessGatewayWithThing
-> AssociateWirelessGatewayWithThing -> Bool
Prelude.Eq, ReadPrec [AssociateWirelessGatewayWithThing]
ReadPrec AssociateWirelessGatewayWithThing
Int -> ReadS AssociateWirelessGatewayWithThing
ReadS [AssociateWirelessGatewayWithThing]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateWirelessGatewayWithThing]
$creadListPrec :: ReadPrec [AssociateWirelessGatewayWithThing]
readPrec :: ReadPrec AssociateWirelessGatewayWithThing
$creadPrec :: ReadPrec AssociateWirelessGatewayWithThing
readList :: ReadS [AssociateWirelessGatewayWithThing]
$creadList :: ReadS [AssociateWirelessGatewayWithThing]
readsPrec :: Int -> ReadS AssociateWirelessGatewayWithThing
$creadsPrec :: Int -> ReadS AssociateWirelessGatewayWithThing
Prelude.Read, Int -> AssociateWirelessGatewayWithThing -> ShowS
[AssociateWirelessGatewayWithThing] -> ShowS
AssociateWirelessGatewayWithThing -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateWirelessGatewayWithThing] -> ShowS
$cshowList :: [AssociateWirelessGatewayWithThing] -> ShowS
show :: AssociateWirelessGatewayWithThing -> String
$cshow :: AssociateWirelessGatewayWithThing -> String
showsPrec :: Int -> AssociateWirelessGatewayWithThing -> ShowS
$cshowsPrec :: Int -> AssociateWirelessGatewayWithThing -> ShowS
Prelude.Show, forall x.
Rep AssociateWirelessGatewayWithThing x
-> AssociateWirelessGatewayWithThing
forall x.
AssociateWirelessGatewayWithThing
-> Rep AssociateWirelessGatewayWithThing x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateWirelessGatewayWithThing x
-> AssociateWirelessGatewayWithThing
$cfrom :: forall x.
AssociateWirelessGatewayWithThing
-> Rep AssociateWirelessGatewayWithThing x
Prelude.Generic)

-- |
-- Create a value of 'AssociateWirelessGatewayWithThing' 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', 'associateWirelessGatewayWithThing_id' - The ID of the resource to update.
--
-- 'thingArn', 'associateWirelessGatewayWithThing_thingArn' - The ARN of the thing to associate with the wireless gateway.
newAssociateWirelessGatewayWithThing ::
  -- | 'id'
  Prelude.Text ->
  -- | 'thingArn'
  Prelude.Text ->
  AssociateWirelessGatewayWithThing
newAssociateWirelessGatewayWithThing :: Text -> Text -> AssociateWirelessGatewayWithThing
newAssociateWirelessGatewayWithThing Text
pId_ Text
pThingArn_ =
  AssociateWirelessGatewayWithThing'
    { $sel:id:AssociateWirelessGatewayWithThing' :: Text
id = Text
pId_,
      $sel:thingArn:AssociateWirelessGatewayWithThing' :: Text
thingArn = Text
pThingArn_
    }

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

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

instance
  Core.AWSRequest
    AssociateWirelessGatewayWithThing
  where
  type
    AWSResponse AssociateWirelessGatewayWithThing =
      AssociateWirelessGatewayWithThingResponse
  request :: (Service -> Service)
-> AssociateWirelessGatewayWithThing
-> Request AssociateWirelessGatewayWithThing
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy AssociateWirelessGatewayWithThing
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse AssociateWirelessGatewayWithThing)))
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 -> AssociateWirelessGatewayWithThingResponse
AssociateWirelessGatewayWithThingResponse'
            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
    AssociateWirelessGatewayWithThing
  where
  hashWithSalt :: Int -> AssociateWirelessGatewayWithThing -> Int
hashWithSalt
    Int
_salt
    AssociateWirelessGatewayWithThing' {Text
thingArn :: Text
id :: Text
$sel:thingArn:AssociateWirelessGatewayWithThing' :: AssociateWirelessGatewayWithThing -> Text
$sel:id:AssociateWirelessGatewayWithThing' :: AssociateWirelessGatewayWithThing -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
thingArn

instance
  Prelude.NFData
    AssociateWirelessGatewayWithThing
  where
  rnf :: AssociateWirelessGatewayWithThing -> ()
rnf AssociateWirelessGatewayWithThing' {Text
thingArn :: Text
id :: Text
$sel:thingArn:AssociateWirelessGatewayWithThing' :: AssociateWirelessGatewayWithThing -> Text
$sel:id:AssociateWirelessGatewayWithThing' :: AssociateWirelessGatewayWithThing -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
id seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
thingArn

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

instance
  Data.ToJSON
    AssociateWirelessGatewayWithThing
  where
  toJSON :: AssociateWirelessGatewayWithThing -> Value
toJSON AssociateWirelessGatewayWithThing' {Text
thingArn :: Text
id :: Text
$sel:thingArn:AssociateWirelessGatewayWithThing' :: AssociateWirelessGatewayWithThing -> Text
$sel:id:AssociateWirelessGatewayWithThing' :: AssociateWirelessGatewayWithThing -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"ThingArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
thingArn)]
      )

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

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

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

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

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

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