{-# 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.GetWirelessGatewayFirmwareInformation
-- 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 firmware version and other information about a wireless
-- gateway.
module Amazonka.IoTWireless.GetWirelessGatewayFirmwareInformation
  ( -- * Creating a Request
    GetWirelessGatewayFirmwareInformation (..),
    newGetWirelessGatewayFirmwareInformation,

    -- * Request Lenses
    getWirelessGatewayFirmwareInformation_id,

    -- * Destructuring the Response
    GetWirelessGatewayFirmwareInformationResponse (..),
    newGetWirelessGatewayFirmwareInformationResponse,

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

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

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

instance
  Core.AWSRequest
    GetWirelessGatewayFirmwareInformation
  where
  type
    AWSResponse
      GetWirelessGatewayFirmwareInformation =
      GetWirelessGatewayFirmwareInformationResponse
  request :: GetWirelessGatewayFirmwareInformation
-> Request GetWirelessGatewayFirmwareInformation
request = Service
-> GetWirelessGatewayFirmwareInformation
-> Request GetWirelessGatewayFirmwareInformation
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetWirelessGatewayFirmwareInformation
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse GetWirelessGatewayFirmwareInformation)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either
      String (AWSResponse GetWirelessGatewayFirmwareInformation))
-> Logger
-> Service
-> Proxy GetWirelessGatewayFirmwareInformation
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse GetWirelessGatewayFirmwareInformation)))
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 LoRaWANGatewayCurrentVersion
-> Int -> GetWirelessGatewayFirmwareInformationResponse
GetWirelessGatewayFirmwareInformationResponse'
            (Maybe LoRaWANGatewayCurrentVersion
 -> Int -> GetWirelessGatewayFirmwareInformationResponse)
-> Either String (Maybe LoRaWANGatewayCurrentVersion)
-> Either
     String (Int -> GetWirelessGatewayFirmwareInformationResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Either String (Maybe LoRaWANGatewayCurrentVersion)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"LoRaWAN")
              Either
  String (Int -> GetWirelessGatewayFirmwareInformationResponse)
-> Either String Int
-> Either String GetWirelessGatewayFirmwareInformationResponse
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
    GetWirelessGatewayFirmwareInformation

instance
  Prelude.NFData
    GetWirelessGatewayFirmwareInformation

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

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

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

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

-- |
-- Create a value of 'GetWirelessGatewayFirmwareInformationResponse' 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:
--
-- 'loRaWAN', 'getWirelessGatewayFirmwareInformationResponse_loRaWAN' - Information about the wireless gateway\'s firmware.
--
-- 'httpStatus', 'getWirelessGatewayFirmwareInformationResponse_httpStatus' - The response's http status code.
newGetWirelessGatewayFirmwareInformationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetWirelessGatewayFirmwareInformationResponse
newGetWirelessGatewayFirmwareInformationResponse :: Int -> GetWirelessGatewayFirmwareInformationResponse
newGetWirelessGatewayFirmwareInformationResponse
  Int
pHttpStatus_ =
    GetWirelessGatewayFirmwareInformationResponse' :: Maybe LoRaWANGatewayCurrentVersion
-> Int -> GetWirelessGatewayFirmwareInformationResponse
GetWirelessGatewayFirmwareInformationResponse'
      { $sel:loRaWAN:GetWirelessGatewayFirmwareInformationResponse' :: Maybe LoRaWANGatewayCurrentVersion
loRaWAN =
          Maybe LoRaWANGatewayCurrentVersion
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:GetWirelessGatewayFirmwareInformationResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | Information about the wireless gateway\'s firmware.
getWirelessGatewayFirmwareInformationResponse_loRaWAN :: Lens.Lens' GetWirelessGatewayFirmwareInformationResponse (Prelude.Maybe LoRaWANGatewayCurrentVersion)
getWirelessGatewayFirmwareInformationResponse_loRaWAN :: (Maybe LoRaWANGatewayCurrentVersion
 -> f (Maybe LoRaWANGatewayCurrentVersion))
-> GetWirelessGatewayFirmwareInformationResponse
-> f GetWirelessGatewayFirmwareInformationResponse
getWirelessGatewayFirmwareInformationResponse_loRaWAN = (GetWirelessGatewayFirmwareInformationResponse
 -> Maybe LoRaWANGatewayCurrentVersion)
-> (GetWirelessGatewayFirmwareInformationResponse
    -> Maybe LoRaWANGatewayCurrentVersion
    -> GetWirelessGatewayFirmwareInformationResponse)
-> Lens
     GetWirelessGatewayFirmwareInformationResponse
     GetWirelessGatewayFirmwareInformationResponse
     (Maybe LoRaWANGatewayCurrentVersion)
     (Maybe LoRaWANGatewayCurrentVersion)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWirelessGatewayFirmwareInformationResponse' {Maybe LoRaWANGatewayCurrentVersion
loRaWAN :: Maybe LoRaWANGatewayCurrentVersion
$sel:loRaWAN:GetWirelessGatewayFirmwareInformationResponse' :: GetWirelessGatewayFirmwareInformationResponse
-> Maybe LoRaWANGatewayCurrentVersion
loRaWAN} -> Maybe LoRaWANGatewayCurrentVersion
loRaWAN) (\s :: GetWirelessGatewayFirmwareInformationResponse
s@GetWirelessGatewayFirmwareInformationResponse' {} Maybe LoRaWANGatewayCurrentVersion
a -> GetWirelessGatewayFirmwareInformationResponse
s {$sel:loRaWAN:GetWirelessGatewayFirmwareInformationResponse' :: Maybe LoRaWANGatewayCurrentVersion
loRaWAN = Maybe LoRaWANGatewayCurrentVersion
a} :: GetWirelessGatewayFirmwareInformationResponse)

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

instance
  Prelude.NFData
    GetWirelessGatewayFirmwareInformationResponse