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

    -- * Request Lenses
    setV2LoggingOptions_disableAllLogs,
    setV2LoggingOptions_defaultLogLevel,
    setV2LoggingOptions_roleArn,

    -- * Destructuring the Response
    SetV2LoggingOptionsResponse (..),
    newSetV2LoggingOptionsResponse,
  )
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:/ 'newSetV2LoggingOptions' smart constructor.
data SetV2LoggingOptions = SetV2LoggingOptions'
  { -- | If true all logs are disabled. The default is false.
    SetV2LoggingOptions -> Maybe Bool
disableAllLogs :: Prelude.Maybe Prelude.Bool,
    -- | The default logging level.
    SetV2LoggingOptions -> Maybe LogLevel
defaultLogLevel :: Prelude.Maybe LogLevel,
    -- | The ARN of the role that allows IoT to write to Cloudwatch logs.
    SetV2LoggingOptions -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text
  }
  deriving (SetV2LoggingOptions -> SetV2LoggingOptions -> Bool
(SetV2LoggingOptions -> SetV2LoggingOptions -> Bool)
-> (SetV2LoggingOptions -> SetV2LoggingOptions -> Bool)
-> Eq SetV2LoggingOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetV2LoggingOptions -> SetV2LoggingOptions -> Bool
$c/= :: SetV2LoggingOptions -> SetV2LoggingOptions -> Bool
== :: SetV2LoggingOptions -> SetV2LoggingOptions -> Bool
$c== :: SetV2LoggingOptions -> SetV2LoggingOptions -> Bool
Prelude.Eq, ReadPrec [SetV2LoggingOptions]
ReadPrec SetV2LoggingOptions
Int -> ReadS SetV2LoggingOptions
ReadS [SetV2LoggingOptions]
(Int -> ReadS SetV2LoggingOptions)
-> ReadS [SetV2LoggingOptions]
-> ReadPrec SetV2LoggingOptions
-> ReadPrec [SetV2LoggingOptions]
-> Read SetV2LoggingOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetV2LoggingOptions]
$creadListPrec :: ReadPrec [SetV2LoggingOptions]
readPrec :: ReadPrec SetV2LoggingOptions
$creadPrec :: ReadPrec SetV2LoggingOptions
readList :: ReadS [SetV2LoggingOptions]
$creadList :: ReadS [SetV2LoggingOptions]
readsPrec :: Int -> ReadS SetV2LoggingOptions
$creadsPrec :: Int -> ReadS SetV2LoggingOptions
Prelude.Read, Int -> SetV2LoggingOptions -> ShowS
[SetV2LoggingOptions] -> ShowS
SetV2LoggingOptions -> String
(Int -> SetV2LoggingOptions -> ShowS)
-> (SetV2LoggingOptions -> String)
-> ([SetV2LoggingOptions] -> ShowS)
-> Show SetV2LoggingOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetV2LoggingOptions] -> ShowS
$cshowList :: [SetV2LoggingOptions] -> ShowS
show :: SetV2LoggingOptions -> String
$cshow :: SetV2LoggingOptions -> String
showsPrec :: Int -> SetV2LoggingOptions -> ShowS
$cshowsPrec :: Int -> SetV2LoggingOptions -> ShowS
Prelude.Show, (forall x. SetV2LoggingOptions -> Rep SetV2LoggingOptions x)
-> (forall x. Rep SetV2LoggingOptions x -> SetV2LoggingOptions)
-> Generic SetV2LoggingOptions
forall x. Rep SetV2LoggingOptions x -> SetV2LoggingOptions
forall x. SetV2LoggingOptions -> Rep SetV2LoggingOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SetV2LoggingOptions x -> SetV2LoggingOptions
$cfrom :: forall x. SetV2LoggingOptions -> Rep SetV2LoggingOptions x
Prelude.Generic)

-- |
-- Create a value of 'SetV2LoggingOptions' 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', 'setV2LoggingOptions_disableAllLogs' - If true all logs are disabled. The default is false.
--
-- 'defaultLogLevel', 'setV2LoggingOptions_defaultLogLevel' - The default logging level.
--
-- 'roleArn', 'setV2LoggingOptions_roleArn' - The ARN of the role that allows IoT to write to Cloudwatch logs.
newSetV2LoggingOptions ::
  SetV2LoggingOptions
newSetV2LoggingOptions :: SetV2LoggingOptions
newSetV2LoggingOptions =
  SetV2LoggingOptions' :: Maybe Bool -> Maybe LogLevel -> Maybe Text -> SetV2LoggingOptions
SetV2LoggingOptions'
    { $sel:disableAllLogs:SetV2LoggingOptions' :: Maybe Bool
disableAllLogs =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultLogLevel:SetV2LoggingOptions' :: Maybe LogLevel
defaultLogLevel = Maybe LogLevel
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:SetV2LoggingOptions' :: Maybe Text
roleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | If true all logs are disabled. The default is false.
setV2LoggingOptions_disableAllLogs :: Lens.Lens' SetV2LoggingOptions (Prelude.Maybe Prelude.Bool)
setV2LoggingOptions_disableAllLogs :: (Maybe Bool -> f (Maybe Bool))
-> SetV2LoggingOptions -> f SetV2LoggingOptions
setV2LoggingOptions_disableAllLogs = (SetV2LoggingOptions -> Maybe Bool)
-> (SetV2LoggingOptions -> Maybe Bool -> SetV2LoggingOptions)
-> Lens
     SetV2LoggingOptions SetV2LoggingOptions (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetV2LoggingOptions' {Maybe Bool
disableAllLogs :: Maybe Bool
$sel:disableAllLogs:SetV2LoggingOptions' :: SetV2LoggingOptions -> Maybe Bool
disableAllLogs} -> Maybe Bool
disableAllLogs) (\s :: SetV2LoggingOptions
s@SetV2LoggingOptions' {} Maybe Bool
a -> SetV2LoggingOptions
s {$sel:disableAllLogs:SetV2LoggingOptions' :: Maybe Bool
disableAllLogs = Maybe Bool
a} :: SetV2LoggingOptions)

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

-- | The ARN of the role that allows IoT to write to Cloudwatch logs.
setV2LoggingOptions_roleArn :: Lens.Lens' SetV2LoggingOptions (Prelude.Maybe Prelude.Text)
setV2LoggingOptions_roleArn :: (Maybe Text -> f (Maybe Text))
-> SetV2LoggingOptions -> f SetV2LoggingOptions
setV2LoggingOptions_roleArn = (SetV2LoggingOptions -> Maybe Text)
-> (SetV2LoggingOptions -> Maybe Text -> SetV2LoggingOptions)
-> Lens
     SetV2LoggingOptions SetV2LoggingOptions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetV2LoggingOptions' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:SetV2LoggingOptions' :: SetV2LoggingOptions -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: SetV2LoggingOptions
s@SetV2LoggingOptions' {} Maybe Text
a -> SetV2LoggingOptions
s {$sel:roleArn:SetV2LoggingOptions' :: Maybe Text
roleArn = Maybe Text
a} :: SetV2LoggingOptions)

instance Core.AWSRequest SetV2LoggingOptions where
  type
    AWSResponse SetV2LoggingOptions =
      SetV2LoggingOptionsResponse
  request :: SetV2LoggingOptions -> Request SetV2LoggingOptions
request = Service -> SetV2LoggingOptions -> Request SetV2LoggingOptions
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy SetV2LoggingOptions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SetV2LoggingOptions)))
response =
    AWSResponse SetV2LoggingOptions
-> Logger
-> Service
-> Proxy SetV2LoggingOptions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SetV2LoggingOptions)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse SetV2LoggingOptions
SetV2LoggingOptionsResponse
SetV2LoggingOptionsResponse'

instance Prelude.Hashable SetV2LoggingOptions

instance Prelude.NFData SetV2LoggingOptions

instance Core.ToHeaders SetV2LoggingOptions where
  toHeaders :: SetV2LoggingOptions -> [Header]
toHeaders = [Header] -> SetV2LoggingOptions -> [Header]
forall a b. a -> b -> a
Prelude.const [Header]
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON SetV2LoggingOptions where
  toJSON :: SetV2LoggingOptions -> Value
toJSON SetV2LoggingOptions' {Maybe Bool
Maybe Text
Maybe LogLevel
roleArn :: Maybe Text
defaultLogLevel :: Maybe LogLevel
disableAllLogs :: Maybe Bool
$sel:roleArn:SetV2LoggingOptions' :: SetV2LoggingOptions -> Maybe Text
$sel:defaultLogLevel:SetV2LoggingOptions' :: SetV2LoggingOptions -> Maybe LogLevel
$sel:disableAllLogs:SetV2LoggingOptions' :: SetV2LoggingOptions -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"disableAllLogs" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
disableAllLogs,
            (Text
"defaultLogLevel" Text -> LogLevel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (LogLevel -> Pair) -> Maybe LogLevel -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LogLevel
defaultLogLevel,
            (Text
"roleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
roleArn
          ]
      )

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

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

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

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

instance Prelude.NFData SetV2LoggingOptionsResponse