{-# 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-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)
--
-- 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 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:/ 'newGetWirelessGatewayCertificate' smart constructor.
data GetWirelessGatewayCertificate = GetWirelessGatewayCertificate'
  { -- | The ID of the resource to get.
    GetWirelessGatewayCertificate -> Text
id :: Prelude.Text
  }
  deriving (GetWirelessGatewayCertificate
-> GetWirelessGatewayCertificate -> Bool
(GetWirelessGatewayCertificate
 -> GetWirelessGatewayCertificate -> Bool)
-> (GetWirelessGatewayCertificate
    -> GetWirelessGatewayCertificate -> Bool)
-> Eq GetWirelessGatewayCertificate
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]
(Int -> ReadS GetWirelessGatewayCertificate)
-> ReadS [GetWirelessGatewayCertificate]
-> ReadPrec GetWirelessGatewayCertificate
-> ReadPrec [GetWirelessGatewayCertificate]
-> Read 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
(Int -> GetWirelessGatewayCertificate -> ShowS)
-> (GetWirelessGatewayCertificate -> String)
-> ([GetWirelessGatewayCertificate] -> ShowS)
-> Show GetWirelessGatewayCertificate
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.
 GetWirelessGatewayCertificate
 -> Rep GetWirelessGatewayCertificate x)
-> (forall x.
    Rep GetWirelessGatewayCertificate x
    -> GetWirelessGatewayCertificate)
-> Generic GetWirelessGatewayCertificate
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' :: Text -> GetWirelessGatewayCertificate
GetWirelessGatewayCertificate' {$sel:id:GetWirelessGatewayCertificate' :: Text
id = Text
pId_}

-- | The ID of the resource to get.
getWirelessGatewayCertificate_id :: Lens.Lens' GetWirelessGatewayCertificate Prelude.Text
getWirelessGatewayCertificate_id :: (Text -> f Text)
-> GetWirelessGatewayCertificate -> f GetWirelessGatewayCertificate
getWirelessGatewayCertificate_id = (GetWirelessGatewayCertificate -> Text)
-> (GetWirelessGatewayCertificate
    -> Text -> GetWirelessGatewayCertificate)
-> Lens
     GetWirelessGatewayCertificate
     GetWirelessGatewayCertificate
     Text
     Text
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 :: GetWirelessGatewayCertificate
-> Request GetWirelessGatewayCertificate
request = Service
-> GetWirelessGatewayCertificate
-> Request GetWirelessGatewayCertificate
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetWirelessGatewayCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetWirelessGatewayCertificate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetWirelessGatewayCertificate))
-> Logger
-> Service
-> Proxy GetWirelessGatewayCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetWirelessGatewayCertificate)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> 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'
            (Maybe Text
 -> Maybe Text -> Int -> GetWirelessGatewayCertificateResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Int -> GetWirelessGatewayCertificateResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"IotCertificateId")
            Either
  String (Maybe Text -> Int -> GetWirelessGatewayCertificateResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetWirelessGatewayCertificateResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"LoRaWANNetworkServerCertificateId")
            Either String (Int -> GetWirelessGatewayCertificateResponse)
-> Either String Int
-> Either String GetWirelessGatewayCertificateResponse
forall (f :: * -> *) a b. Applicative f => 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
    GetWirelessGatewayCertificate

instance Prelude.NFData GetWirelessGatewayCertificate

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

instance Core.ToPath GetWirelessGatewayCertificate where
  toPath :: GetWirelessGatewayCertificate -> ByteString
toPath GetWirelessGatewayCertificate' {Text
id :: Text
$sel:id:GetWirelessGatewayCertificate' :: GetWirelessGatewayCertificate -> 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
"/certificate"]

instance Core.ToQuery GetWirelessGatewayCertificate where
  toQuery :: GetWirelessGatewayCertificate -> QueryString
toQuery = QueryString -> GetWirelessGatewayCertificate -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetWirelessGatewayCertificateResponse
 -> GetWirelessGatewayCertificateResponse -> Bool)
-> (GetWirelessGatewayCertificateResponse
    -> GetWirelessGatewayCertificateResponse -> Bool)
-> Eq GetWirelessGatewayCertificateResponse
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]
(Int -> ReadS GetWirelessGatewayCertificateResponse)
-> ReadS [GetWirelessGatewayCertificateResponse]
-> ReadPrec GetWirelessGatewayCertificateResponse
-> ReadPrec [GetWirelessGatewayCertificateResponse]
-> Read 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
(Int -> GetWirelessGatewayCertificateResponse -> ShowS)
-> (GetWirelessGatewayCertificateResponse -> String)
-> ([GetWirelessGatewayCertificateResponse] -> ShowS)
-> Show GetWirelessGatewayCertificateResponse
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.
 GetWirelessGatewayCertificateResponse
 -> Rep GetWirelessGatewayCertificateResponse x)
-> (forall x.
    Rep GetWirelessGatewayCertificateResponse x
    -> GetWirelessGatewayCertificateResponse)
-> Generic GetWirelessGatewayCertificateResponse
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' :: Maybe Text
-> Maybe Text -> Int -> GetWirelessGatewayCertificateResponse
GetWirelessGatewayCertificateResponse'
    { $sel:iotCertificateId:GetWirelessGatewayCertificateResponse' :: Maybe Text
iotCertificateId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:loRaWANNetworkServerCertificateId:GetWirelessGatewayCertificateResponse' :: Maybe Text
loRaWANNetworkServerCertificateId =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> GetWirelessGatewayCertificateResponse
-> f GetWirelessGatewayCertificateResponse
getWirelessGatewayCertificateResponse_iotCertificateId = (GetWirelessGatewayCertificateResponse -> Maybe Text)
-> (GetWirelessGatewayCertificateResponse
    -> Maybe Text -> GetWirelessGatewayCertificateResponse)
-> Lens
     GetWirelessGatewayCertificateResponse
     GetWirelessGatewayCertificateResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> GetWirelessGatewayCertificateResponse
-> f GetWirelessGatewayCertificateResponse
getWirelessGatewayCertificateResponse_loRaWANNetworkServerCertificateId = (GetWirelessGatewayCertificateResponse -> Maybe Text)
-> (GetWirelessGatewayCertificateResponse
    -> Maybe Text -> GetWirelessGatewayCertificateResponse)
-> Lens
     GetWirelessGatewayCertificateResponse
     GetWirelessGatewayCertificateResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Int -> f Int)
-> GetWirelessGatewayCertificateResponse
-> f GetWirelessGatewayCertificateResponse
getWirelessGatewayCertificateResponse_httpStatus = (GetWirelessGatewayCertificateResponse -> Int)
-> (GetWirelessGatewayCertificateResponse
    -> Int -> GetWirelessGatewayCertificateResponse)
-> Lens
     GetWirelessGatewayCertificateResponse
     GetWirelessGatewayCertificateResponse
     Int
     Int
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