{-# 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.PutResourceLogLevel
-- 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)
--
-- Sets the log-level override for a resource-ID and resource-type. This
-- option can be specified for a wireless gateway or a wireless device. A
-- limit of 200 log level override can be set per account.
module Amazonka.IoTWireless.PutResourceLogLevel
  ( -- * Creating a Request
    PutResourceLogLevel (..),
    newPutResourceLogLevel,

    -- * Request Lenses
    putResourceLogLevel_resourceIdentifier,
    putResourceLogLevel_resourceType,
    putResourceLogLevel_logLevel,

    -- * Destructuring the Response
    PutResourceLogLevelResponse (..),
    newPutResourceLogLevelResponse,

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

-- |
-- Create a value of 'PutResourceLogLevel' 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', 'putResourceLogLevel_resourceIdentifier' - Undocumented member.
--
-- 'resourceType', 'putResourceLogLevel_resourceType' - The type of the resource, which can be @WirelessDevice@ or
-- @WirelessGateway@.
--
-- 'logLevel', 'putResourceLogLevel_logLevel' - Undocumented member.
newPutResourceLogLevel ::
  -- | 'resourceIdentifier'
  Prelude.Text ->
  -- | 'resourceType'
  Prelude.Text ->
  -- | 'logLevel'
  LogLevel ->
  PutResourceLogLevel
newPutResourceLogLevel :: Text -> Text -> LogLevel -> PutResourceLogLevel
newPutResourceLogLevel
  Text
pResourceIdentifier_
  Text
pResourceType_
  LogLevel
pLogLevel_ =
    PutResourceLogLevel' :: Text -> Text -> LogLevel -> PutResourceLogLevel
PutResourceLogLevel'
      { $sel:resourceIdentifier:PutResourceLogLevel' :: Text
resourceIdentifier =
          Text
pResourceIdentifier_,
        $sel:resourceType:PutResourceLogLevel' :: Text
resourceType = Text
pResourceType_,
        $sel:logLevel:PutResourceLogLevel' :: LogLevel
logLevel = LogLevel
pLogLevel_
      }

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

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

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

instance Core.AWSRequest PutResourceLogLevel where
  type
    AWSResponse PutResourceLogLevel =
      PutResourceLogLevelResponse
  request :: PutResourceLogLevel -> Request PutResourceLogLevel
request = Service -> PutResourceLogLevel -> Request PutResourceLogLevel
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutResourceLogLevel
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutResourceLogLevel)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse PutResourceLogLevel))
-> Logger
-> Service
-> Proxy PutResourceLogLevel
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutResourceLogLevel)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutResourceLogLevelResponse
PutResourceLogLevelResponse'
            (Int -> PutResourceLogLevelResponse)
-> Either String Int -> Either String PutResourceLogLevelResponse
forall (f :: * -> *) a b. Functor 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 PutResourceLogLevel

instance Prelude.NFData PutResourceLogLevel

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

instance Core.ToJSON PutResourceLogLevel where
  toJSON :: PutResourceLogLevel -> Value
toJSON PutResourceLogLevel' {Text
LogLevel
logLevel :: LogLevel
resourceType :: Text
resourceIdentifier :: Text
$sel:logLevel:PutResourceLogLevel' :: PutResourceLogLevel -> LogLevel
$sel:resourceType:PutResourceLogLevel' :: PutResourceLogLevel -> Text
$sel:resourceIdentifier:PutResourceLogLevel' :: PutResourceLogLevel -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"LogLevel" Text -> LogLevel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= LogLevel
logLevel)]
      )

instance Core.ToPath PutResourceLogLevel where
  toPath :: PutResourceLogLevel -> ByteString
toPath PutResourceLogLevel' {Text
LogLevel
logLevel :: LogLevel
resourceType :: Text
resourceIdentifier :: Text
$sel:logLevel:PutResourceLogLevel' :: PutResourceLogLevel -> LogLevel
$sel:resourceType:PutResourceLogLevel' :: PutResourceLogLevel -> Text
$sel:resourceIdentifier:PutResourceLogLevel' :: PutResourceLogLevel -> 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 PutResourceLogLevel where
  toQuery :: PutResourceLogLevel -> QueryString
toQuery PutResourceLogLevel' {Text
LogLevel
logLevel :: LogLevel
resourceType :: Text
resourceIdentifier :: Text
$sel:logLevel:PutResourceLogLevel' :: PutResourceLogLevel -> LogLevel
$sel:resourceType:PutResourceLogLevel' :: PutResourceLogLevel -> Text
$sel:resourceIdentifier:PutResourceLogLevel' :: PutResourceLogLevel -> 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:/ 'newPutResourceLogLevelResponse' smart constructor.
data PutResourceLogLevelResponse = PutResourceLogLevelResponse'
  { -- | The response's http status code.
    PutResourceLogLevelResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutResourceLogLevelResponse -> PutResourceLogLevelResponse -> Bool
(PutResourceLogLevelResponse
 -> PutResourceLogLevelResponse -> Bool)
-> (PutResourceLogLevelResponse
    -> PutResourceLogLevelResponse -> Bool)
-> Eq PutResourceLogLevelResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutResourceLogLevelResponse -> PutResourceLogLevelResponse -> Bool
$c/= :: PutResourceLogLevelResponse -> PutResourceLogLevelResponse -> Bool
== :: PutResourceLogLevelResponse -> PutResourceLogLevelResponse -> Bool
$c== :: PutResourceLogLevelResponse -> PutResourceLogLevelResponse -> Bool
Prelude.Eq, ReadPrec [PutResourceLogLevelResponse]
ReadPrec PutResourceLogLevelResponse
Int -> ReadS PutResourceLogLevelResponse
ReadS [PutResourceLogLevelResponse]
(Int -> ReadS PutResourceLogLevelResponse)
-> ReadS [PutResourceLogLevelResponse]
-> ReadPrec PutResourceLogLevelResponse
-> ReadPrec [PutResourceLogLevelResponse]
-> Read PutResourceLogLevelResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutResourceLogLevelResponse]
$creadListPrec :: ReadPrec [PutResourceLogLevelResponse]
readPrec :: ReadPrec PutResourceLogLevelResponse
$creadPrec :: ReadPrec PutResourceLogLevelResponse
readList :: ReadS [PutResourceLogLevelResponse]
$creadList :: ReadS [PutResourceLogLevelResponse]
readsPrec :: Int -> ReadS PutResourceLogLevelResponse
$creadsPrec :: Int -> ReadS PutResourceLogLevelResponse
Prelude.Read, Int -> PutResourceLogLevelResponse -> ShowS
[PutResourceLogLevelResponse] -> ShowS
PutResourceLogLevelResponse -> String
(Int -> PutResourceLogLevelResponse -> ShowS)
-> (PutResourceLogLevelResponse -> String)
-> ([PutResourceLogLevelResponse] -> ShowS)
-> Show PutResourceLogLevelResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutResourceLogLevelResponse] -> ShowS
$cshowList :: [PutResourceLogLevelResponse] -> ShowS
show :: PutResourceLogLevelResponse -> String
$cshow :: PutResourceLogLevelResponse -> String
showsPrec :: Int -> PutResourceLogLevelResponse -> ShowS
$cshowsPrec :: Int -> PutResourceLogLevelResponse -> ShowS
Prelude.Show, (forall x.
 PutResourceLogLevelResponse -> Rep PutResourceLogLevelResponse x)
-> (forall x.
    Rep PutResourceLogLevelResponse x -> PutResourceLogLevelResponse)
-> Generic PutResourceLogLevelResponse
forall x.
Rep PutResourceLogLevelResponse x -> PutResourceLogLevelResponse
forall x.
PutResourceLogLevelResponse -> Rep PutResourceLogLevelResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutResourceLogLevelResponse x -> PutResourceLogLevelResponse
$cfrom :: forall x.
PutResourceLogLevelResponse -> Rep PutResourceLogLevelResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutResourceLogLevelResponse' 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:
--
-- 'httpStatus', 'putResourceLogLevelResponse_httpStatus' - The response's http status code.
newPutResourceLogLevelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutResourceLogLevelResponse
newPutResourceLogLevelResponse :: Int -> PutResourceLogLevelResponse
newPutResourceLogLevelResponse Int
pHttpStatus_ =
  PutResourceLogLevelResponse' :: Int -> PutResourceLogLevelResponse
PutResourceLogLevelResponse'
    { $sel:httpStatus:PutResourceLogLevelResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData PutResourceLogLevelResponse