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

instance
  Prelude.NFData
    AssociateWirelessGatewayWithThing

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

instance
  Core.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
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
    AssociateWirelessGatewayWithThing
  where
  toPath :: AssociateWirelessGatewayWithThing -> ByteString
toPath AssociateWirelessGatewayWithThing' {Text
thingArn :: Text
id :: Text
$sel:thingArn:AssociateWirelessGatewayWithThing' :: AssociateWirelessGatewayWithThing -> Text
$sel:id:AssociateWirelessGatewayWithThing' :: AssociateWirelessGatewayWithThing -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/wireless-gateways/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
id, ByteString
"/thing"]

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

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