{-# 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.AssociateWirelessGatewayWithCertificate
-- 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 certificate.
module Amazonka.IoTWireless.AssociateWirelessGatewayWithCertificate
  ( -- * Creating a Request
    AssociateWirelessGatewayWithCertificate (..),
    newAssociateWirelessGatewayWithCertificate,

    -- * Request Lenses
    associateWirelessGatewayWithCertificate_id,
    associateWirelessGatewayWithCertificate_iotCertificateId,

    -- * Destructuring the Response
    AssociateWirelessGatewayWithCertificateResponse (..),
    newAssociateWirelessGatewayWithCertificateResponse,

    -- * Response Lenses
    associateWirelessGatewayWithCertificateResponse_iotCertificateId,
    associateWirelessGatewayWithCertificateResponse_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:/ 'newAssociateWirelessGatewayWithCertificate' smart constructor.
data AssociateWirelessGatewayWithCertificate = AssociateWirelessGatewayWithCertificate'
  { -- | The ID of the resource to update.
    AssociateWirelessGatewayWithCertificate -> Text
id :: Prelude.Text,
    -- | The ID of the certificate to associate with the wireless gateway.
    AssociateWirelessGatewayWithCertificate -> Text
iotCertificateId :: Prelude.Text
  }
  deriving (AssociateWirelessGatewayWithCertificate
-> AssociateWirelessGatewayWithCertificate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateWirelessGatewayWithCertificate
-> AssociateWirelessGatewayWithCertificate -> Bool
$c/= :: AssociateWirelessGatewayWithCertificate
-> AssociateWirelessGatewayWithCertificate -> Bool
== :: AssociateWirelessGatewayWithCertificate
-> AssociateWirelessGatewayWithCertificate -> Bool
$c== :: AssociateWirelessGatewayWithCertificate
-> AssociateWirelessGatewayWithCertificate -> Bool
Prelude.Eq, ReadPrec [AssociateWirelessGatewayWithCertificate]
ReadPrec AssociateWirelessGatewayWithCertificate
Int -> ReadS AssociateWirelessGatewayWithCertificate
ReadS [AssociateWirelessGatewayWithCertificate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateWirelessGatewayWithCertificate]
$creadListPrec :: ReadPrec [AssociateWirelessGatewayWithCertificate]
readPrec :: ReadPrec AssociateWirelessGatewayWithCertificate
$creadPrec :: ReadPrec AssociateWirelessGatewayWithCertificate
readList :: ReadS [AssociateWirelessGatewayWithCertificate]
$creadList :: ReadS [AssociateWirelessGatewayWithCertificate]
readsPrec :: Int -> ReadS AssociateWirelessGatewayWithCertificate
$creadsPrec :: Int -> ReadS AssociateWirelessGatewayWithCertificate
Prelude.Read, Int -> AssociateWirelessGatewayWithCertificate -> ShowS
[AssociateWirelessGatewayWithCertificate] -> ShowS
AssociateWirelessGatewayWithCertificate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateWirelessGatewayWithCertificate] -> ShowS
$cshowList :: [AssociateWirelessGatewayWithCertificate] -> ShowS
show :: AssociateWirelessGatewayWithCertificate -> String
$cshow :: AssociateWirelessGatewayWithCertificate -> String
showsPrec :: Int -> AssociateWirelessGatewayWithCertificate -> ShowS
$cshowsPrec :: Int -> AssociateWirelessGatewayWithCertificate -> ShowS
Prelude.Show, forall x.
Rep AssociateWirelessGatewayWithCertificate x
-> AssociateWirelessGatewayWithCertificate
forall x.
AssociateWirelessGatewayWithCertificate
-> Rep AssociateWirelessGatewayWithCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociateWirelessGatewayWithCertificate x
-> AssociateWirelessGatewayWithCertificate
$cfrom :: forall x.
AssociateWirelessGatewayWithCertificate
-> Rep AssociateWirelessGatewayWithCertificate x
Prelude.Generic)

-- |
-- Create a value of 'AssociateWirelessGatewayWithCertificate' 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', 'associateWirelessGatewayWithCertificate_id' - The ID of the resource to update.
--
-- 'iotCertificateId', 'associateWirelessGatewayWithCertificate_iotCertificateId' - The ID of the certificate to associate with the wireless gateway.
newAssociateWirelessGatewayWithCertificate ::
  -- | 'id'
  Prelude.Text ->
  -- | 'iotCertificateId'
  Prelude.Text ->
  AssociateWirelessGatewayWithCertificate
newAssociateWirelessGatewayWithCertificate :: Text -> Text -> AssociateWirelessGatewayWithCertificate
newAssociateWirelessGatewayWithCertificate
  Text
pId_
  Text
pIotCertificateId_ =
    AssociateWirelessGatewayWithCertificate'
      { $sel:id:AssociateWirelessGatewayWithCertificate' :: Text
id = Text
pId_,
        $sel:iotCertificateId:AssociateWirelessGatewayWithCertificate' :: Text
iotCertificateId =
          Text
pIotCertificateId_
      }

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

-- | The ID of the certificate to associate with the wireless gateway.
associateWirelessGatewayWithCertificate_iotCertificateId :: Lens.Lens' AssociateWirelessGatewayWithCertificate Prelude.Text
associateWirelessGatewayWithCertificate_iotCertificateId :: Lens' AssociateWirelessGatewayWithCertificate Text
associateWirelessGatewayWithCertificate_iotCertificateId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateWirelessGatewayWithCertificate' {Text
iotCertificateId :: Text
$sel:iotCertificateId:AssociateWirelessGatewayWithCertificate' :: AssociateWirelessGatewayWithCertificate -> Text
iotCertificateId} -> Text
iotCertificateId) (\s :: AssociateWirelessGatewayWithCertificate
s@AssociateWirelessGatewayWithCertificate' {} Text
a -> AssociateWirelessGatewayWithCertificate
s {$sel:iotCertificateId:AssociateWirelessGatewayWithCertificate' :: Text
iotCertificateId = Text
a} :: AssociateWirelessGatewayWithCertificate)

instance
  Core.AWSRequest
    AssociateWirelessGatewayWithCertificate
  where
  type
    AWSResponse
      AssociateWirelessGatewayWithCertificate =
      AssociateWirelessGatewayWithCertificateResponse
  request :: (Service -> Service)
-> AssociateWirelessGatewayWithCertificate
-> Request AssociateWirelessGatewayWithCertificate
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 AssociateWirelessGatewayWithCertificate
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse AssociateWirelessGatewayWithCertificate)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Int -> AssociateWirelessGatewayWithCertificateResponse
AssociateWirelessGatewayWithCertificateResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"IotCertificateId")
            forall (f :: * -> *) a b. Applicative f => 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
    AssociateWirelessGatewayWithCertificate
  where
  hashWithSalt :: Int -> AssociateWirelessGatewayWithCertificate -> Int
hashWithSalt
    Int
_salt
    AssociateWirelessGatewayWithCertificate' {Text
iotCertificateId :: Text
id :: Text
$sel:iotCertificateId:AssociateWirelessGatewayWithCertificate' :: AssociateWirelessGatewayWithCertificate -> Text
$sel:id:AssociateWirelessGatewayWithCertificate' :: AssociateWirelessGatewayWithCertificate -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
iotCertificateId

instance
  Prelude.NFData
    AssociateWirelessGatewayWithCertificate
  where
  rnf :: AssociateWirelessGatewayWithCertificate -> ()
rnf AssociateWirelessGatewayWithCertificate' {Text
iotCertificateId :: Text
id :: Text
$sel:iotCertificateId:AssociateWirelessGatewayWithCertificate' :: AssociateWirelessGatewayWithCertificate -> Text
$sel:id:AssociateWirelessGatewayWithCertificate' :: AssociateWirelessGatewayWithCertificate -> 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
iotCertificateId

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

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

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

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

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

-- |
-- Create a value of 'AssociateWirelessGatewayWithCertificateResponse' 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:
--
-- 'iotCertificateId', 'associateWirelessGatewayWithCertificateResponse_iotCertificateId' - The ID of the certificate associated with the wireless gateway.
--
-- 'httpStatus', 'associateWirelessGatewayWithCertificateResponse_httpStatus' - The response's http status code.
newAssociateWirelessGatewayWithCertificateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AssociateWirelessGatewayWithCertificateResponse
newAssociateWirelessGatewayWithCertificateResponse :: Int -> AssociateWirelessGatewayWithCertificateResponse
newAssociateWirelessGatewayWithCertificateResponse
  Int
pHttpStatus_ =
    AssociateWirelessGatewayWithCertificateResponse'
      { $sel:iotCertificateId:AssociateWirelessGatewayWithCertificateResponse' :: Maybe Text
iotCertificateId =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:AssociateWirelessGatewayWithCertificateResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The ID of the certificate associated with the wireless gateway.
associateWirelessGatewayWithCertificateResponse_iotCertificateId :: Lens.Lens' AssociateWirelessGatewayWithCertificateResponse (Prelude.Maybe Prelude.Text)
associateWirelessGatewayWithCertificateResponse_iotCertificateId :: Lens' AssociateWirelessGatewayWithCertificateResponse (Maybe Text)
associateWirelessGatewayWithCertificateResponse_iotCertificateId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateWirelessGatewayWithCertificateResponse' {Maybe Text
iotCertificateId :: Maybe Text
$sel:iotCertificateId:AssociateWirelessGatewayWithCertificateResponse' :: AssociateWirelessGatewayWithCertificateResponse -> Maybe Text
iotCertificateId} -> Maybe Text
iotCertificateId) (\s :: AssociateWirelessGatewayWithCertificateResponse
s@AssociateWirelessGatewayWithCertificateResponse' {} Maybe Text
a -> AssociateWirelessGatewayWithCertificateResponse
s {$sel:iotCertificateId:AssociateWirelessGatewayWithCertificateResponse' :: Maybe Text
iotCertificateId = Maybe Text
a} :: AssociateWirelessGatewayWithCertificateResponse)

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

instance
  Prelude.NFData
    AssociateWirelessGatewayWithCertificateResponse
  where
  rnf :: AssociateWirelessGatewayWithCertificateResponse -> ()
rnf
    AssociateWirelessGatewayWithCertificateResponse' {Int
Maybe Text
httpStatus :: Int
iotCertificateId :: Maybe Text
$sel:httpStatus:AssociateWirelessGatewayWithCertificateResponse' :: AssociateWirelessGatewayWithCertificateResponse -> Int
$sel:iotCertificateId:AssociateWirelessGatewayWithCertificateResponse' :: AssociateWirelessGatewayWithCertificateResponse -> Maybe Text
..} =
      forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
iotCertificateId
        seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus