{-# 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.IoT.GetLoggingOptions
-- 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 logging options.
--
-- NOTE: use of this command is not recommended. Use @GetV2LoggingOptions@
-- instead.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions GetLoggingOptions>
-- action.
module Amazonka.IoT.GetLoggingOptions
  ( -- * Creating a Request
    GetLoggingOptions (..),
    newGetLoggingOptions,

    -- * Destructuring the Response
    GetLoggingOptionsResponse (..),
    newGetLoggingOptionsResponse,

    -- * Response Lenses
    getLoggingOptionsResponse_logLevel,
    getLoggingOptionsResponse_roleArn,
    getLoggingOptionsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | The input for the GetLoggingOptions operation.
--
-- /See:/ 'newGetLoggingOptions' smart constructor.
data GetLoggingOptions = GetLoggingOptions'
  {
  }
  deriving (GetLoggingOptions -> GetLoggingOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetLoggingOptions -> GetLoggingOptions -> Bool
$c/= :: GetLoggingOptions -> GetLoggingOptions -> Bool
== :: GetLoggingOptions -> GetLoggingOptions -> Bool
$c== :: GetLoggingOptions -> GetLoggingOptions -> Bool
Prelude.Eq, ReadPrec [GetLoggingOptions]
ReadPrec GetLoggingOptions
Int -> ReadS GetLoggingOptions
ReadS [GetLoggingOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetLoggingOptions]
$creadListPrec :: ReadPrec [GetLoggingOptions]
readPrec :: ReadPrec GetLoggingOptions
$creadPrec :: ReadPrec GetLoggingOptions
readList :: ReadS [GetLoggingOptions]
$creadList :: ReadS [GetLoggingOptions]
readsPrec :: Int -> ReadS GetLoggingOptions
$creadsPrec :: Int -> ReadS GetLoggingOptions
Prelude.Read, Int -> GetLoggingOptions -> ShowS
[GetLoggingOptions] -> ShowS
GetLoggingOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetLoggingOptions] -> ShowS
$cshowList :: [GetLoggingOptions] -> ShowS
show :: GetLoggingOptions -> String
$cshow :: GetLoggingOptions -> String
showsPrec :: Int -> GetLoggingOptions -> ShowS
$cshowsPrec :: Int -> GetLoggingOptions -> ShowS
Prelude.Show, forall x. Rep GetLoggingOptions x -> GetLoggingOptions
forall x. GetLoggingOptions -> Rep GetLoggingOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetLoggingOptions x -> GetLoggingOptions
$cfrom :: forall x. GetLoggingOptions -> Rep GetLoggingOptions x
Prelude.Generic)

-- |
-- Create a value of 'GetLoggingOptions' 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.
newGetLoggingOptions ::
  GetLoggingOptions
newGetLoggingOptions :: GetLoggingOptions
newGetLoggingOptions = GetLoggingOptions
GetLoggingOptions'

instance Core.AWSRequest GetLoggingOptions where
  type
    AWSResponse GetLoggingOptions =
      GetLoggingOptionsResponse
  request :: (Service -> Service)
-> GetLoggingOptions -> Request GetLoggingOptions
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 GetLoggingOptions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetLoggingOptions)))
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 LogLevel -> Maybe Text -> Int -> GetLoggingOptionsResponse
GetLoggingOptionsResponse'
            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
"logLevel")
            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
"roleArn")
            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 GetLoggingOptions where
  hashWithSalt :: Int -> GetLoggingOptions -> Int
hashWithSalt Int
_salt GetLoggingOptions
_ =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ()

instance Prelude.NFData GetLoggingOptions where
  rnf :: GetLoggingOptions -> ()
rnf GetLoggingOptions
_ = ()

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

instance Data.ToPath GetLoggingOptions where
  toPath :: GetLoggingOptions -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/loggingOptions"

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

-- | The output from the GetLoggingOptions operation.
--
-- /See:/ 'newGetLoggingOptionsResponse' smart constructor.
data GetLoggingOptionsResponse = GetLoggingOptionsResponse'
  { -- | The logging level.
    GetLoggingOptionsResponse -> Maybe LogLevel
logLevel :: Prelude.Maybe LogLevel,
    -- | The ARN of the IAM role that grants access.
    GetLoggingOptionsResponse -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetLoggingOptionsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetLoggingOptionsResponse -> GetLoggingOptionsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetLoggingOptionsResponse -> GetLoggingOptionsResponse -> Bool
$c/= :: GetLoggingOptionsResponse -> GetLoggingOptionsResponse -> Bool
== :: GetLoggingOptionsResponse -> GetLoggingOptionsResponse -> Bool
$c== :: GetLoggingOptionsResponse -> GetLoggingOptionsResponse -> Bool
Prelude.Eq, ReadPrec [GetLoggingOptionsResponse]
ReadPrec GetLoggingOptionsResponse
Int -> ReadS GetLoggingOptionsResponse
ReadS [GetLoggingOptionsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetLoggingOptionsResponse]
$creadListPrec :: ReadPrec [GetLoggingOptionsResponse]
readPrec :: ReadPrec GetLoggingOptionsResponse
$creadPrec :: ReadPrec GetLoggingOptionsResponse
readList :: ReadS [GetLoggingOptionsResponse]
$creadList :: ReadS [GetLoggingOptionsResponse]
readsPrec :: Int -> ReadS GetLoggingOptionsResponse
$creadsPrec :: Int -> ReadS GetLoggingOptionsResponse
Prelude.Read, Int -> GetLoggingOptionsResponse -> ShowS
[GetLoggingOptionsResponse] -> ShowS
GetLoggingOptionsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetLoggingOptionsResponse] -> ShowS
$cshowList :: [GetLoggingOptionsResponse] -> ShowS
show :: GetLoggingOptionsResponse -> String
$cshow :: GetLoggingOptionsResponse -> String
showsPrec :: Int -> GetLoggingOptionsResponse -> ShowS
$cshowsPrec :: Int -> GetLoggingOptionsResponse -> ShowS
Prelude.Show, forall x.
Rep GetLoggingOptionsResponse x -> GetLoggingOptionsResponse
forall x.
GetLoggingOptionsResponse -> Rep GetLoggingOptionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetLoggingOptionsResponse x -> GetLoggingOptionsResponse
$cfrom :: forall x.
GetLoggingOptionsResponse -> Rep GetLoggingOptionsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetLoggingOptionsResponse' 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', 'getLoggingOptionsResponse_logLevel' - The logging level.
--
-- 'roleArn', 'getLoggingOptionsResponse_roleArn' - The ARN of the IAM role that grants access.
--
-- 'httpStatus', 'getLoggingOptionsResponse_httpStatus' - The response's http status code.
newGetLoggingOptionsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetLoggingOptionsResponse
newGetLoggingOptionsResponse :: Int -> GetLoggingOptionsResponse
newGetLoggingOptionsResponse Int
pHttpStatus_ =
  GetLoggingOptionsResponse'
    { $sel:logLevel:GetLoggingOptionsResponse' :: Maybe LogLevel
logLevel =
        forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:GetLoggingOptionsResponse' :: Maybe Text
roleArn = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetLoggingOptionsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The logging level.
getLoggingOptionsResponse_logLevel :: Lens.Lens' GetLoggingOptionsResponse (Prelude.Maybe LogLevel)
getLoggingOptionsResponse_logLevel :: Lens' GetLoggingOptionsResponse (Maybe LogLevel)
getLoggingOptionsResponse_logLevel = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLoggingOptionsResponse' {Maybe LogLevel
logLevel :: Maybe LogLevel
$sel:logLevel:GetLoggingOptionsResponse' :: GetLoggingOptionsResponse -> Maybe LogLevel
logLevel} -> Maybe LogLevel
logLevel) (\s :: GetLoggingOptionsResponse
s@GetLoggingOptionsResponse' {} Maybe LogLevel
a -> GetLoggingOptionsResponse
s {$sel:logLevel:GetLoggingOptionsResponse' :: Maybe LogLevel
logLevel = Maybe LogLevel
a} :: GetLoggingOptionsResponse)

-- | The ARN of the IAM role that grants access.
getLoggingOptionsResponse_roleArn :: Lens.Lens' GetLoggingOptionsResponse (Prelude.Maybe Prelude.Text)
getLoggingOptionsResponse_roleArn :: Lens' GetLoggingOptionsResponse (Maybe Text)
getLoggingOptionsResponse_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLoggingOptionsResponse' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:GetLoggingOptionsResponse' :: GetLoggingOptionsResponse -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: GetLoggingOptionsResponse
s@GetLoggingOptionsResponse' {} Maybe Text
a -> GetLoggingOptionsResponse
s {$sel:roleArn:GetLoggingOptionsResponse' :: Maybe Text
roleArn = Maybe Text
a} :: GetLoggingOptionsResponse)

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

instance Prelude.NFData GetLoggingOptionsResponse where
  rnf :: GetLoggingOptionsResponse -> ()
rnf GetLoggingOptionsResponse' {Int
Maybe Text
Maybe LogLevel
httpStatus :: Int
roleArn :: Maybe Text
logLevel :: Maybe LogLevel
$sel:httpStatus:GetLoggingOptionsResponse' :: GetLoggingOptionsResponse -> Int
$sel:roleArn:GetLoggingOptionsResponse' :: GetLoggingOptionsResponse -> Maybe Text
$sel:logLevel:GetLoggingOptionsResponse' :: GetLoggingOptionsResponse -> Maybe LogLevel
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe LogLevel
logLevel
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
roleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus