{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.WirelessGatewayEventLogOption
-- 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)
module Amazonka.IoTWireless.Types.WirelessGatewayEventLogOption where

import qualified Amazonka.Core as Core
import Amazonka.IoTWireless.Types.LogLevel
import Amazonka.IoTWireless.Types.WirelessGatewayEvent
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The log options for a wireless gateway event and can be used to set log
-- levels for a specific wireless gateway event.
--
-- For a LoRaWAN gateway, possible events for a log message are
-- @CUPS_Request@ and @Certificate@.
--
-- /See:/ 'newWirelessGatewayEventLogOption' smart constructor.
data WirelessGatewayEventLogOption = WirelessGatewayEventLogOption'
  { WirelessGatewayEventLogOption -> WirelessGatewayEvent
event :: WirelessGatewayEvent,
    WirelessGatewayEventLogOption -> LogLevel
logLevel :: LogLevel
  }
  deriving (WirelessGatewayEventLogOption
-> WirelessGatewayEventLogOption -> Bool
(WirelessGatewayEventLogOption
 -> WirelessGatewayEventLogOption -> Bool)
-> (WirelessGatewayEventLogOption
    -> WirelessGatewayEventLogOption -> Bool)
-> Eq WirelessGatewayEventLogOption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WirelessGatewayEventLogOption
-> WirelessGatewayEventLogOption -> Bool
$c/= :: WirelessGatewayEventLogOption
-> WirelessGatewayEventLogOption -> Bool
== :: WirelessGatewayEventLogOption
-> WirelessGatewayEventLogOption -> Bool
$c== :: WirelessGatewayEventLogOption
-> WirelessGatewayEventLogOption -> Bool
Prelude.Eq, ReadPrec [WirelessGatewayEventLogOption]
ReadPrec WirelessGatewayEventLogOption
Int -> ReadS WirelessGatewayEventLogOption
ReadS [WirelessGatewayEventLogOption]
(Int -> ReadS WirelessGatewayEventLogOption)
-> ReadS [WirelessGatewayEventLogOption]
-> ReadPrec WirelessGatewayEventLogOption
-> ReadPrec [WirelessGatewayEventLogOption]
-> Read WirelessGatewayEventLogOption
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WirelessGatewayEventLogOption]
$creadListPrec :: ReadPrec [WirelessGatewayEventLogOption]
readPrec :: ReadPrec WirelessGatewayEventLogOption
$creadPrec :: ReadPrec WirelessGatewayEventLogOption
readList :: ReadS [WirelessGatewayEventLogOption]
$creadList :: ReadS [WirelessGatewayEventLogOption]
readsPrec :: Int -> ReadS WirelessGatewayEventLogOption
$creadsPrec :: Int -> ReadS WirelessGatewayEventLogOption
Prelude.Read, Int -> WirelessGatewayEventLogOption -> ShowS
[WirelessGatewayEventLogOption] -> ShowS
WirelessGatewayEventLogOption -> String
(Int -> WirelessGatewayEventLogOption -> ShowS)
-> (WirelessGatewayEventLogOption -> String)
-> ([WirelessGatewayEventLogOption] -> ShowS)
-> Show WirelessGatewayEventLogOption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WirelessGatewayEventLogOption] -> ShowS
$cshowList :: [WirelessGatewayEventLogOption] -> ShowS
show :: WirelessGatewayEventLogOption -> String
$cshow :: WirelessGatewayEventLogOption -> String
showsPrec :: Int -> WirelessGatewayEventLogOption -> ShowS
$cshowsPrec :: Int -> WirelessGatewayEventLogOption -> ShowS
Prelude.Show, (forall x.
 WirelessGatewayEventLogOption
 -> Rep WirelessGatewayEventLogOption x)
-> (forall x.
    Rep WirelessGatewayEventLogOption x
    -> WirelessGatewayEventLogOption)
-> Generic WirelessGatewayEventLogOption
forall x.
Rep WirelessGatewayEventLogOption x
-> WirelessGatewayEventLogOption
forall x.
WirelessGatewayEventLogOption
-> Rep WirelessGatewayEventLogOption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep WirelessGatewayEventLogOption x
-> WirelessGatewayEventLogOption
$cfrom :: forall x.
WirelessGatewayEventLogOption
-> Rep WirelessGatewayEventLogOption x
Prelude.Generic)

-- |
-- Create a value of 'WirelessGatewayEventLogOption' 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:
--
-- 'event', 'wirelessGatewayEventLogOption_event' - Undocumented member.
--
-- 'logLevel', 'wirelessGatewayEventLogOption_logLevel' - Undocumented member.
newWirelessGatewayEventLogOption ::
  -- | 'event'
  WirelessGatewayEvent ->
  -- | 'logLevel'
  LogLevel ->
  WirelessGatewayEventLogOption
newWirelessGatewayEventLogOption :: WirelessGatewayEvent -> LogLevel -> WirelessGatewayEventLogOption
newWirelessGatewayEventLogOption WirelessGatewayEvent
pEvent_ LogLevel
pLogLevel_ =
  WirelessGatewayEventLogOption' :: WirelessGatewayEvent -> LogLevel -> WirelessGatewayEventLogOption
WirelessGatewayEventLogOption'
    { $sel:event:WirelessGatewayEventLogOption' :: WirelessGatewayEvent
event = WirelessGatewayEvent
pEvent_,
      $sel:logLevel:WirelessGatewayEventLogOption' :: LogLevel
logLevel = LogLevel
pLogLevel_
    }

-- | Undocumented member.
wirelessGatewayEventLogOption_event :: Lens.Lens' WirelessGatewayEventLogOption WirelessGatewayEvent
wirelessGatewayEventLogOption_event :: (WirelessGatewayEvent -> f WirelessGatewayEvent)
-> WirelessGatewayEventLogOption -> f WirelessGatewayEventLogOption
wirelessGatewayEventLogOption_event = (WirelessGatewayEventLogOption -> WirelessGatewayEvent)
-> (WirelessGatewayEventLogOption
    -> WirelessGatewayEvent -> WirelessGatewayEventLogOption)
-> Lens
     WirelessGatewayEventLogOption
     WirelessGatewayEventLogOption
     WirelessGatewayEvent
     WirelessGatewayEvent
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WirelessGatewayEventLogOption' {WirelessGatewayEvent
event :: WirelessGatewayEvent
$sel:event:WirelessGatewayEventLogOption' :: WirelessGatewayEventLogOption -> WirelessGatewayEvent
event} -> WirelessGatewayEvent
event) (\s :: WirelessGatewayEventLogOption
s@WirelessGatewayEventLogOption' {} WirelessGatewayEvent
a -> WirelessGatewayEventLogOption
s {$sel:event:WirelessGatewayEventLogOption' :: WirelessGatewayEvent
event = WirelessGatewayEvent
a} :: WirelessGatewayEventLogOption)

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

instance Core.FromJSON WirelessGatewayEventLogOption where
  parseJSON :: Value -> Parser WirelessGatewayEventLogOption
parseJSON =
    String
-> (Object -> Parser WirelessGatewayEventLogOption)
-> Value
-> Parser WirelessGatewayEventLogOption
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WirelessGatewayEventLogOption"
      ( \Object
x ->
          WirelessGatewayEvent -> LogLevel -> WirelessGatewayEventLogOption
WirelessGatewayEventLogOption'
            (WirelessGatewayEvent -> LogLevel -> WirelessGatewayEventLogOption)
-> Parser WirelessGatewayEvent
-> Parser (LogLevel -> WirelessGatewayEventLogOption)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser WirelessGatewayEvent
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Event")
            Parser (LogLevel -> WirelessGatewayEventLogOption)
-> Parser LogLevel -> Parser WirelessGatewayEventLogOption
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser LogLevel
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"LogLevel")
      )

instance
  Prelude.Hashable
    WirelessGatewayEventLogOption

instance Prelude.NFData WirelessGatewayEventLogOption

instance Core.ToJSON WirelessGatewayEventLogOption where
  toJSON :: WirelessGatewayEventLogOption -> Value
toJSON WirelessGatewayEventLogOption' {LogLevel
WirelessGatewayEvent
logLevel :: LogLevel
event :: WirelessGatewayEvent
$sel:logLevel:WirelessGatewayEventLogOption' :: WirelessGatewayEventLogOption -> LogLevel
$sel:event:WirelessGatewayEventLogOption' :: WirelessGatewayEventLogOption -> WirelessGatewayEvent
..} =
    [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
"Event" Text -> WirelessGatewayEvent -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= WirelessGatewayEvent
event),
            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)
          ]
      )