{-# 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.GetResourceLogLevel
-- 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)
--
-- Fetches the log-level override, if any, for a given resource-ID and
-- resource-type. It can be used for a wireless device or a wireless
-- gateway.
module Amazonka.IoTWireless.GetResourceLogLevel
  ( -- * Creating a Request
    GetResourceLogLevel (..),
    newGetResourceLogLevel,

    -- * Request Lenses
    getResourceLogLevel_resourceIdentifier,
    getResourceLogLevel_resourceType,

    -- * Destructuring the Response
    GetResourceLogLevelResponse (..),
    newGetResourceLogLevelResponse,

    -- * Response Lenses
    getResourceLogLevelResponse_logLevel,
    getResourceLogLevelResponse_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:/ 'newGetResourceLogLevel' smart constructor.
data GetResourceLogLevel = GetResourceLogLevel'
  { GetResourceLogLevel -> Text
resourceIdentifier :: Prelude.Text,
    -- | The type of the resource, which can be @WirelessDevice@ or
    -- @WirelessGateway@.
    GetResourceLogLevel -> Text
resourceType :: Prelude.Text
  }
  deriving (GetResourceLogLevel -> GetResourceLogLevel -> Bool
(GetResourceLogLevel -> GetResourceLogLevel -> Bool)
-> (GetResourceLogLevel -> GetResourceLogLevel -> Bool)
-> Eq GetResourceLogLevel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetResourceLogLevel -> GetResourceLogLevel -> Bool
$c/= :: GetResourceLogLevel -> GetResourceLogLevel -> Bool
== :: GetResourceLogLevel -> GetResourceLogLevel -> Bool
$c== :: GetResourceLogLevel -> GetResourceLogLevel -> Bool
Prelude.Eq, ReadPrec [GetResourceLogLevel]
ReadPrec GetResourceLogLevel
Int -> ReadS GetResourceLogLevel
ReadS [GetResourceLogLevel]
(Int -> ReadS GetResourceLogLevel)
-> ReadS [GetResourceLogLevel]
-> ReadPrec GetResourceLogLevel
-> ReadPrec [GetResourceLogLevel]
-> Read GetResourceLogLevel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetResourceLogLevel]
$creadListPrec :: ReadPrec [GetResourceLogLevel]
readPrec :: ReadPrec GetResourceLogLevel
$creadPrec :: ReadPrec GetResourceLogLevel
readList :: ReadS [GetResourceLogLevel]
$creadList :: ReadS [GetResourceLogLevel]
readsPrec :: Int -> ReadS GetResourceLogLevel
$creadsPrec :: Int -> ReadS GetResourceLogLevel
Prelude.Read, Int -> GetResourceLogLevel -> ShowS
[GetResourceLogLevel] -> ShowS
GetResourceLogLevel -> String
(Int -> GetResourceLogLevel -> ShowS)
-> (GetResourceLogLevel -> String)
-> ([GetResourceLogLevel] -> ShowS)
-> Show GetResourceLogLevel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetResourceLogLevel] -> ShowS
$cshowList :: [GetResourceLogLevel] -> ShowS
show :: GetResourceLogLevel -> String
$cshow :: GetResourceLogLevel -> String
showsPrec :: Int -> GetResourceLogLevel -> ShowS
$cshowsPrec :: Int -> GetResourceLogLevel -> ShowS
Prelude.Show, (forall x. GetResourceLogLevel -> Rep GetResourceLogLevel x)
-> (forall x. Rep GetResourceLogLevel x -> GetResourceLogLevel)
-> Generic GetResourceLogLevel
forall x. Rep GetResourceLogLevel x -> GetResourceLogLevel
forall x. GetResourceLogLevel -> Rep GetResourceLogLevel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetResourceLogLevel x -> GetResourceLogLevel
$cfrom :: forall x. GetResourceLogLevel -> Rep GetResourceLogLevel x
Prelude.Generic)

-- |
-- Create a value of 'GetResourceLogLevel' 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:
--
-- 'resourceIdentifier', 'getResourceLogLevel_resourceIdentifier' - Undocumented member.
--
-- 'resourceType', 'getResourceLogLevel_resourceType' - The type of the resource, which can be @WirelessDevice@ or
-- @WirelessGateway@.
newGetResourceLogLevel ::
  -- | 'resourceIdentifier'
  Prelude.Text ->
  -- | 'resourceType'
  Prelude.Text ->
  GetResourceLogLevel
newGetResourceLogLevel :: Text -> Text -> GetResourceLogLevel
newGetResourceLogLevel
  Text
pResourceIdentifier_
  Text
pResourceType_ =
    GetResourceLogLevel' :: Text -> Text -> GetResourceLogLevel
GetResourceLogLevel'
      { $sel:resourceIdentifier:GetResourceLogLevel' :: Text
resourceIdentifier =
          Text
pResourceIdentifier_,
        $sel:resourceType:GetResourceLogLevel' :: Text
resourceType = Text
pResourceType_
      }

-- | Undocumented member.
getResourceLogLevel_resourceIdentifier :: Lens.Lens' GetResourceLogLevel Prelude.Text
getResourceLogLevel_resourceIdentifier :: (Text -> f Text) -> GetResourceLogLevel -> f GetResourceLogLevel
getResourceLogLevel_resourceIdentifier = (GetResourceLogLevel -> Text)
-> (GetResourceLogLevel -> Text -> GetResourceLogLevel)
-> Lens GetResourceLogLevel GetResourceLogLevel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceLogLevel' {Text
resourceIdentifier :: Text
$sel:resourceIdentifier:GetResourceLogLevel' :: GetResourceLogLevel -> Text
resourceIdentifier} -> Text
resourceIdentifier) (\s :: GetResourceLogLevel
s@GetResourceLogLevel' {} Text
a -> GetResourceLogLevel
s {$sel:resourceIdentifier:GetResourceLogLevel' :: Text
resourceIdentifier = Text
a} :: GetResourceLogLevel)

-- | The type of the resource, which can be @WirelessDevice@ or
-- @WirelessGateway@.
getResourceLogLevel_resourceType :: Lens.Lens' GetResourceLogLevel Prelude.Text
getResourceLogLevel_resourceType :: (Text -> f Text) -> GetResourceLogLevel -> f GetResourceLogLevel
getResourceLogLevel_resourceType = (GetResourceLogLevel -> Text)
-> (GetResourceLogLevel -> Text -> GetResourceLogLevel)
-> Lens GetResourceLogLevel GetResourceLogLevel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceLogLevel' {Text
resourceType :: Text
$sel:resourceType:GetResourceLogLevel' :: GetResourceLogLevel -> Text
resourceType} -> Text
resourceType) (\s :: GetResourceLogLevel
s@GetResourceLogLevel' {} Text
a -> GetResourceLogLevel
s {$sel:resourceType:GetResourceLogLevel' :: Text
resourceType = Text
a} :: GetResourceLogLevel)

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

instance Prelude.NFData GetResourceLogLevel

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

instance Core.ToPath GetResourceLogLevel where
  toPath :: GetResourceLogLevel -> ByteString
toPath GetResourceLogLevel' {Text
resourceType :: Text
resourceIdentifier :: Text
$sel:resourceType:GetResourceLogLevel' :: GetResourceLogLevel -> Text
$sel:resourceIdentifier:GetResourceLogLevel' :: GetResourceLogLevel -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/log-levels/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
resourceIdentifier]

instance Core.ToQuery GetResourceLogLevel where
  toQuery :: GetResourceLogLevel -> QueryString
toQuery GetResourceLogLevel' {Text
resourceType :: Text
resourceIdentifier :: Text
$sel:resourceType:GetResourceLogLevel' :: GetResourceLogLevel -> Text
$sel:resourceIdentifier:GetResourceLogLevel' :: GetResourceLogLevel -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"resourceType" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
resourceType]

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

-- |
-- Create a value of 'GetResourceLogLevelResponse' 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:
--
-- 'logLevel', 'getResourceLogLevelResponse_logLevel' - Undocumented member.
--
-- 'httpStatus', 'getResourceLogLevelResponse_httpStatus' - The response's http status code.
newGetResourceLogLevelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetResourceLogLevelResponse
newGetResourceLogLevelResponse :: Int -> GetResourceLogLevelResponse
newGetResourceLogLevelResponse Int
pHttpStatus_ =
  GetResourceLogLevelResponse' :: Maybe LogLevel -> Int -> GetResourceLogLevelResponse
GetResourceLogLevelResponse'
    { $sel:logLevel:GetResourceLogLevelResponse' :: Maybe LogLevel
logLevel =
        Maybe LogLevel
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetResourceLogLevelResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
getResourceLogLevelResponse_logLevel :: Lens.Lens' GetResourceLogLevelResponse (Prelude.Maybe LogLevel)
getResourceLogLevelResponse_logLevel :: (Maybe LogLevel -> f (Maybe LogLevel))
-> GetResourceLogLevelResponse -> f GetResourceLogLevelResponse
getResourceLogLevelResponse_logLevel = (GetResourceLogLevelResponse -> Maybe LogLevel)
-> (GetResourceLogLevelResponse
    -> Maybe LogLevel -> GetResourceLogLevelResponse)
-> Lens
     GetResourceLogLevelResponse
     GetResourceLogLevelResponse
     (Maybe LogLevel)
     (Maybe LogLevel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResourceLogLevelResponse' {Maybe LogLevel
logLevel :: Maybe LogLevel
$sel:logLevel:GetResourceLogLevelResponse' :: GetResourceLogLevelResponse -> Maybe LogLevel
logLevel} -> Maybe LogLevel
logLevel) (\s :: GetResourceLogLevelResponse
s@GetResourceLogLevelResponse' {} Maybe LogLevel
a -> GetResourceLogLevelResponse
s {$sel:logLevel:GetResourceLogLevelResponse' :: Maybe LogLevel
logLevel = Maybe LogLevel
a} :: GetResourceLogLevelResponse)

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

instance Prelude.NFData GetResourceLogLevelResponse