{-# 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-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 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 Amazonka.IoT.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

-- | The input for the GetLoggingOptions operation.
--
-- /See:/ 'newGetLoggingOptions' smart constructor.
data GetLoggingOptions = GetLoggingOptions'
  {
  }
  deriving (GetLoggingOptions -> GetLoggingOptions -> Bool
(GetLoggingOptions -> GetLoggingOptions -> Bool)
-> (GetLoggingOptions -> GetLoggingOptions -> Bool)
-> Eq GetLoggingOptions
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]
(Int -> ReadS GetLoggingOptions)
-> ReadS [GetLoggingOptions]
-> ReadPrec GetLoggingOptions
-> ReadPrec [GetLoggingOptions]
-> Read 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
(Int -> GetLoggingOptions -> ShowS)
-> (GetLoggingOptions -> String)
-> ([GetLoggingOptions] -> ShowS)
-> Show GetLoggingOptions
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. GetLoggingOptions -> Rep GetLoggingOptions x)
-> (forall x. Rep GetLoggingOptions x -> GetLoggingOptions)
-> Generic GetLoggingOptions
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 :: GetLoggingOptions -> Request GetLoggingOptions
request = Service -> GetLoggingOptions -> Request GetLoggingOptions
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetLoggingOptions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetLoggingOptions)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetLoggingOptions))
-> Logger
-> Service
-> Proxy GetLoggingOptions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetLoggingOptions)))
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 -> Maybe Text -> Int -> GetLoggingOptionsResponse
GetLoggingOptionsResponse'
            (Maybe LogLevel -> Maybe Text -> Int -> GetLoggingOptionsResponse)
-> Either String (Maybe LogLevel)
-> Either String (Maybe Text -> Int -> GetLoggingOptionsResponse)
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 (Maybe Text -> Int -> GetLoggingOptionsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetLoggingOptionsResponse)
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
"roleArn")
            Either String (Int -> GetLoggingOptionsResponse)
-> Either String Int -> Either String GetLoggingOptionsResponse
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 GetLoggingOptions

instance Prelude.NFData GetLoggingOptions

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

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

instance Core.ToQuery GetLoggingOptions where
  toQuery :: GetLoggingOptions -> QueryString
toQuery = QueryString -> GetLoggingOptions -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetLoggingOptionsResponse -> GetLoggingOptionsResponse -> Bool)
-> (GetLoggingOptionsResponse -> GetLoggingOptionsResponse -> Bool)
-> Eq GetLoggingOptionsResponse
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]
(Int -> ReadS GetLoggingOptionsResponse)
-> ReadS [GetLoggingOptionsResponse]
-> ReadPrec GetLoggingOptionsResponse
-> ReadPrec [GetLoggingOptionsResponse]
-> Read 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
(Int -> GetLoggingOptionsResponse -> ShowS)
-> (GetLoggingOptionsResponse -> String)
-> ([GetLoggingOptionsResponse] -> ShowS)
-> Show GetLoggingOptionsResponse
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.
 GetLoggingOptionsResponse -> Rep GetLoggingOptionsResponse x)
-> (forall x.
    Rep GetLoggingOptionsResponse x -> GetLoggingOptionsResponse)
-> Generic GetLoggingOptionsResponse
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' :: Maybe LogLevel -> Maybe Text -> Int -> GetLoggingOptionsResponse
GetLoggingOptionsResponse'
    { $sel:logLevel:GetLoggingOptionsResponse' :: Maybe LogLevel
logLevel =
        Maybe LogLevel
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:GetLoggingOptionsResponse' :: Maybe Text
roleArn = Maybe Text
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 :: (Maybe LogLevel -> f (Maybe LogLevel))
-> GetLoggingOptionsResponse -> f GetLoggingOptionsResponse
getLoggingOptionsResponse_logLevel = (GetLoggingOptionsResponse -> Maybe LogLevel)
-> (GetLoggingOptionsResponse
    -> Maybe LogLevel -> GetLoggingOptionsResponse)
-> Lens
     GetLoggingOptionsResponse
     GetLoggingOptionsResponse
     (Maybe LogLevel)
     (Maybe 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 :: (Maybe Text -> f (Maybe Text))
-> GetLoggingOptionsResponse -> f GetLoggingOptionsResponse
getLoggingOptionsResponse_roleArn = (GetLoggingOptionsResponse -> Maybe Text)
-> (GetLoggingOptionsResponse
    -> Maybe Text -> GetLoggingOptionsResponse)
-> Lens
     GetLoggingOptionsResponse
     GetLoggingOptionsResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Int -> f Int)
-> GetLoggingOptionsResponse -> f GetLoggingOptionsResponse
getLoggingOptionsResponse_httpStatus = (GetLoggingOptionsResponse -> Int)
-> (GetLoggingOptionsResponse -> Int -> GetLoggingOptionsResponse)
-> Lens GetLoggingOptionsResponse GetLoggingOptionsResponse Int Int
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