{-# 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.GetWirelessGatewayCertificate
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets the ID of the certificate that is currently associated with a
-- wireless gateway.
module Amazonka.IoTWireless.GetWirelessGatewayCertificate
  ( -- * Creating a Request
    GetWirelessGatewayCertificate (..),
    newGetWirelessGatewayCertificate,

    -- * Request Lenses
    getWirelessGatewayCertificate_id,

    -- * Destructuring the Response
    GetWirelessGatewayCertificateResponse (..),
    newGetWirelessGatewayCertificateResponse,

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

-- |
-- Create a value of 'GetWirelessGatewayCertificate' 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', 'getWirelessGatewayCertificate_id' - The ID of the resource to get.
newGetWirelessGatewayCertificate ::
  -- | 'id'
  Prelude.Text ->
  GetWirelessGatewayCertificate
newGetWirelessGatewayCertificate :: Text -> GetWirelessGatewayCertificate
newGetWirelessGatewayCertificate Text
pId_ =
  GetWirelessGatewayCertificate' {$sel:id:GetWirelessGatewayCertificate' :: Text
id = Text
pId_}

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

instance
  Core.AWSRequest
    GetWirelessGatewayCertificate
  where
  type
    AWSResponse GetWirelessGatewayCertificate =
      GetWirelessGatewayCertificateResponse
  request :: (Service -> Service)
-> GetWirelessGatewayCertificate
-> Request GetWirelessGatewayCertificate
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetWirelessGatewayCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetWirelessGatewayCertificate)))
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
-> Maybe Text -> Int -> GetWirelessGatewayCertificateResponse
GetWirelessGatewayCertificateResponse'
            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.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"LoRaWANNetworkServerCertificateId")
            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
    GetWirelessGatewayCertificate
  where
  hashWithSalt :: Int -> GetWirelessGatewayCertificate -> Int
hashWithSalt Int
_salt GetWirelessGatewayCertificate' {Text
id :: Text
$sel:id:GetWirelessGatewayCertificate' :: GetWirelessGatewayCertificate -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance Prelude.NFData GetWirelessGatewayCertificate where
  rnf :: GetWirelessGatewayCertificate -> ()
rnf GetWirelessGatewayCertificate' {Text
id :: Text
$sel:id:GetWirelessGatewayCertificate' :: GetWirelessGatewayCertificate -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
id

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

instance Data.ToPath GetWirelessGatewayCertificate where
  toPath :: GetWirelessGatewayCertificate -> ByteString
toPath GetWirelessGatewayCertificate' {Text
id :: Text
$sel:id:GetWirelessGatewayCertificate' :: GetWirelessGatewayCertificate -> 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 GetWirelessGatewayCertificate where
  toQuery :: GetWirelessGatewayCertificate -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'GetWirelessGatewayCertificateResponse' 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', 'getWirelessGatewayCertificateResponse_iotCertificateId' - The ID of the certificate associated with the wireless gateway.
--
-- 'loRaWANNetworkServerCertificateId', 'getWirelessGatewayCertificateResponse_loRaWANNetworkServerCertificateId' - The ID of the certificate that is associated with the wireless gateway
-- and used for the LoRaWANNetworkServer endpoint.
--
-- 'httpStatus', 'getWirelessGatewayCertificateResponse_httpStatus' - The response's http status code.
newGetWirelessGatewayCertificateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetWirelessGatewayCertificateResponse
newGetWirelessGatewayCertificateResponse :: Int -> GetWirelessGatewayCertificateResponse
newGetWirelessGatewayCertificateResponse Int
pHttpStatus_ =
  GetWirelessGatewayCertificateResponse'
    { $sel:iotCertificateId:GetWirelessGatewayCertificateResponse' :: Maybe Text
iotCertificateId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:loRaWANNetworkServerCertificateId:GetWirelessGatewayCertificateResponse' :: Maybe Text
loRaWANNetworkServerCertificateId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetWirelessGatewayCertificateResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

-- | The ID of the certificate that is associated with the wireless gateway
-- and used for the LoRaWANNetworkServer endpoint.
getWirelessGatewayCertificateResponse_loRaWANNetworkServerCertificateId :: Lens.Lens' GetWirelessGatewayCertificateResponse (Prelude.Maybe Prelude.Text)
getWirelessGatewayCertificateResponse_loRaWANNetworkServerCertificateId :: Lens' GetWirelessGatewayCertificateResponse (Maybe Text)
getWirelessGatewayCertificateResponse_loRaWANNetworkServerCertificateId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWirelessGatewayCertificateResponse' {Maybe Text
loRaWANNetworkServerCertificateId :: Maybe Text
$sel:loRaWANNetworkServerCertificateId:GetWirelessGatewayCertificateResponse' :: GetWirelessGatewayCertificateResponse -> Maybe Text
loRaWANNetworkServerCertificateId} -> Maybe Text
loRaWANNetworkServerCertificateId) (\s :: GetWirelessGatewayCertificateResponse
s@GetWirelessGatewayCertificateResponse' {} Maybe Text
a -> GetWirelessGatewayCertificateResponse
s {$sel:loRaWANNetworkServerCertificateId:GetWirelessGatewayCertificateResponse' :: Maybe Text
loRaWANNetworkServerCertificateId = Maybe Text
a} :: GetWirelessGatewayCertificateResponse)

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

instance
  Prelude.NFData
    GetWirelessGatewayCertificateResponse
  where
  rnf :: GetWirelessGatewayCertificateResponse -> ()
rnf GetWirelessGatewayCertificateResponse' {Int
Maybe Text
httpStatus :: Int
loRaWANNetworkServerCertificateId :: Maybe Text
iotCertificateId :: Maybe Text
$sel:httpStatus:GetWirelessGatewayCertificateResponse' :: GetWirelessGatewayCertificateResponse -> Int
$sel:loRaWANNetworkServerCertificateId:GetWirelessGatewayCertificateResponse' :: GetWirelessGatewayCertificateResponse -> Maybe Text
$sel:iotCertificateId:GetWirelessGatewayCertificateResponse' :: GetWirelessGatewayCertificateResponse -> 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 Maybe Text
loRaWANNetworkServerCertificateId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus