{-# 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.GetV2LoggingOptions
-- 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 fine grained logging options.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions GetV2LoggingOptions>
-- action.
module Amazonka.IoT.GetV2LoggingOptions
  ( -- * Creating a Request
    GetV2LoggingOptions (..),
    newGetV2LoggingOptions,

    -- * Destructuring the Response
    GetV2LoggingOptionsResponse (..),
    newGetV2LoggingOptionsResponse,

    -- * Response Lenses
    getV2LoggingOptionsResponse_disableAllLogs,
    getV2LoggingOptionsResponse_defaultLogLevel,
    getV2LoggingOptionsResponse_roleArn,
    getV2LoggingOptionsResponse_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

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

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

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

instance Prelude.NFData GetV2LoggingOptions

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

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

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

-- | /See:/ 'newGetV2LoggingOptionsResponse' smart constructor.
data GetV2LoggingOptionsResponse = GetV2LoggingOptionsResponse'
  { -- | Disables all logs.
    GetV2LoggingOptionsResponse -> Maybe Bool
disableAllLogs :: Prelude.Maybe Prelude.Bool,
    -- | The default log level.
    GetV2LoggingOptionsResponse -> Maybe LogLevel
defaultLogLevel :: Prelude.Maybe LogLevel,
    -- | The IAM role ARN IoT uses to write to your CloudWatch logs.
    GetV2LoggingOptionsResponse -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetV2LoggingOptionsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetV2LoggingOptionsResponse -> GetV2LoggingOptionsResponse -> Bool
(GetV2LoggingOptionsResponse
 -> GetV2LoggingOptionsResponse -> Bool)
-> (GetV2LoggingOptionsResponse
    -> GetV2LoggingOptionsResponse -> Bool)
-> Eq GetV2LoggingOptionsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetV2LoggingOptionsResponse -> GetV2LoggingOptionsResponse -> Bool
$c/= :: GetV2LoggingOptionsResponse -> GetV2LoggingOptionsResponse -> Bool
== :: GetV2LoggingOptionsResponse -> GetV2LoggingOptionsResponse -> Bool
$c== :: GetV2LoggingOptionsResponse -> GetV2LoggingOptionsResponse -> Bool
Prelude.Eq, ReadPrec [GetV2LoggingOptionsResponse]
ReadPrec GetV2LoggingOptionsResponse
Int -> ReadS GetV2LoggingOptionsResponse
ReadS [GetV2LoggingOptionsResponse]
(Int -> ReadS GetV2LoggingOptionsResponse)
-> ReadS [GetV2LoggingOptionsResponse]
-> ReadPrec GetV2LoggingOptionsResponse
-> ReadPrec [GetV2LoggingOptionsResponse]
-> Read GetV2LoggingOptionsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetV2LoggingOptionsResponse]
$creadListPrec :: ReadPrec [GetV2LoggingOptionsResponse]
readPrec :: ReadPrec GetV2LoggingOptionsResponse
$creadPrec :: ReadPrec GetV2LoggingOptionsResponse
readList :: ReadS [GetV2LoggingOptionsResponse]
$creadList :: ReadS [GetV2LoggingOptionsResponse]
readsPrec :: Int -> ReadS GetV2LoggingOptionsResponse
$creadsPrec :: Int -> ReadS GetV2LoggingOptionsResponse
Prelude.Read, Int -> GetV2LoggingOptionsResponse -> ShowS
[GetV2LoggingOptionsResponse] -> ShowS
GetV2LoggingOptionsResponse -> String
(Int -> GetV2LoggingOptionsResponse -> ShowS)
-> (GetV2LoggingOptionsResponse -> String)
-> ([GetV2LoggingOptionsResponse] -> ShowS)
-> Show GetV2LoggingOptionsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetV2LoggingOptionsResponse] -> ShowS
$cshowList :: [GetV2LoggingOptionsResponse] -> ShowS
show :: GetV2LoggingOptionsResponse -> String
$cshow :: GetV2LoggingOptionsResponse -> String
showsPrec :: Int -> GetV2LoggingOptionsResponse -> ShowS
$cshowsPrec :: Int -> GetV2LoggingOptionsResponse -> ShowS
Prelude.Show, (forall x.
 GetV2LoggingOptionsResponse -> Rep GetV2LoggingOptionsResponse x)
-> (forall x.
    Rep GetV2LoggingOptionsResponse x -> GetV2LoggingOptionsResponse)
-> Generic GetV2LoggingOptionsResponse
forall x.
Rep GetV2LoggingOptionsResponse x -> GetV2LoggingOptionsResponse
forall x.
GetV2LoggingOptionsResponse -> Rep GetV2LoggingOptionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetV2LoggingOptionsResponse x -> GetV2LoggingOptionsResponse
$cfrom :: forall x.
GetV2LoggingOptionsResponse -> Rep GetV2LoggingOptionsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetV2LoggingOptionsResponse' 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:
--
-- 'disableAllLogs', 'getV2LoggingOptionsResponse_disableAllLogs' - Disables all logs.
--
-- 'defaultLogLevel', 'getV2LoggingOptionsResponse_defaultLogLevel' - The default log level.
--
-- 'roleArn', 'getV2LoggingOptionsResponse_roleArn' - The IAM role ARN IoT uses to write to your CloudWatch logs.
--
-- 'httpStatus', 'getV2LoggingOptionsResponse_httpStatus' - The response's http status code.
newGetV2LoggingOptionsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetV2LoggingOptionsResponse
newGetV2LoggingOptionsResponse :: Int -> GetV2LoggingOptionsResponse
newGetV2LoggingOptionsResponse Int
pHttpStatus_ =
  GetV2LoggingOptionsResponse' :: Maybe Bool
-> Maybe LogLevel
-> Maybe Text
-> Int
-> GetV2LoggingOptionsResponse
GetV2LoggingOptionsResponse'
    { $sel:disableAllLogs:GetV2LoggingOptionsResponse' :: Maybe Bool
disableAllLogs =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultLogLevel:GetV2LoggingOptionsResponse' :: Maybe LogLevel
defaultLogLevel = Maybe LogLevel
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:GetV2LoggingOptionsResponse' :: Maybe Text
roleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetV2LoggingOptionsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Disables all logs.
getV2LoggingOptionsResponse_disableAllLogs :: Lens.Lens' GetV2LoggingOptionsResponse (Prelude.Maybe Prelude.Bool)
getV2LoggingOptionsResponse_disableAllLogs :: (Maybe Bool -> f (Maybe Bool))
-> GetV2LoggingOptionsResponse -> f GetV2LoggingOptionsResponse
getV2LoggingOptionsResponse_disableAllLogs = (GetV2LoggingOptionsResponse -> Maybe Bool)
-> (GetV2LoggingOptionsResponse
    -> Maybe Bool -> GetV2LoggingOptionsResponse)
-> Lens
     GetV2LoggingOptionsResponse
     GetV2LoggingOptionsResponse
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetV2LoggingOptionsResponse' {Maybe Bool
disableAllLogs :: Maybe Bool
$sel:disableAllLogs:GetV2LoggingOptionsResponse' :: GetV2LoggingOptionsResponse -> Maybe Bool
disableAllLogs} -> Maybe Bool
disableAllLogs) (\s :: GetV2LoggingOptionsResponse
s@GetV2LoggingOptionsResponse' {} Maybe Bool
a -> GetV2LoggingOptionsResponse
s {$sel:disableAllLogs:GetV2LoggingOptionsResponse' :: Maybe Bool
disableAllLogs = Maybe Bool
a} :: GetV2LoggingOptionsResponse)

-- | The default log level.
getV2LoggingOptionsResponse_defaultLogLevel :: Lens.Lens' GetV2LoggingOptionsResponse (Prelude.Maybe LogLevel)
getV2LoggingOptionsResponse_defaultLogLevel :: (Maybe LogLevel -> f (Maybe LogLevel))
-> GetV2LoggingOptionsResponse -> f GetV2LoggingOptionsResponse
getV2LoggingOptionsResponse_defaultLogLevel = (GetV2LoggingOptionsResponse -> Maybe LogLevel)
-> (GetV2LoggingOptionsResponse
    -> Maybe LogLevel -> GetV2LoggingOptionsResponse)
-> Lens
     GetV2LoggingOptionsResponse
     GetV2LoggingOptionsResponse
     (Maybe LogLevel)
     (Maybe LogLevel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetV2LoggingOptionsResponse' {Maybe LogLevel
defaultLogLevel :: Maybe LogLevel
$sel:defaultLogLevel:GetV2LoggingOptionsResponse' :: GetV2LoggingOptionsResponse -> Maybe LogLevel
defaultLogLevel} -> Maybe LogLevel
defaultLogLevel) (\s :: GetV2LoggingOptionsResponse
s@GetV2LoggingOptionsResponse' {} Maybe LogLevel
a -> GetV2LoggingOptionsResponse
s {$sel:defaultLogLevel:GetV2LoggingOptionsResponse' :: Maybe LogLevel
defaultLogLevel = Maybe LogLevel
a} :: GetV2LoggingOptionsResponse)

-- | The IAM role ARN IoT uses to write to your CloudWatch logs.
getV2LoggingOptionsResponse_roleArn :: Lens.Lens' GetV2LoggingOptionsResponse (Prelude.Maybe Prelude.Text)
getV2LoggingOptionsResponse_roleArn :: (Maybe Text -> f (Maybe Text))
-> GetV2LoggingOptionsResponse -> f GetV2LoggingOptionsResponse
getV2LoggingOptionsResponse_roleArn = (GetV2LoggingOptionsResponse -> Maybe Text)
-> (GetV2LoggingOptionsResponse
    -> Maybe Text -> GetV2LoggingOptionsResponse)
-> Lens
     GetV2LoggingOptionsResponse
     GetV2LoggingOptionsResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetV2LoggingOptionsResponse' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:GetV2LoggingOptionsResponse' :: GetV2LoggingOptionsResponse -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: GetV2LoggingOptionsResponse
s@GetV2LoggingOptionsResponse' {} Maybe Text
a -> GetV2LoggingOptionsResponse
s {$sel:roleArn:GetV2LoggingOptionsResponse' :: Maybe Text
roleArn = Maybe Text
a} :: GetV2LoggingOptionsResponse)

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

instance Prelude.NFData GetV2LoggingOptionsResponse