{-# 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.WirelessDeviceEventLogOption
-- 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.WirelessDeviceEventLogOption where

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

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

-- |
-- Create a value of 'WirelessDeviceEventLogOption' 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', 'wirelessDeviceEventLogOption_event' - Undocumented member.
--
-- 'logLevel', 'wirelessDeviceEventLogOption_logLevel' - Undocumented member.
newWirelessDeviceEventLogOption ::
  -- | 'event'
  WirelessDeviceEvent ->
  -- | 'logLevel'
  LogLevel ->
  WirelessDeviceEventLogOption
newWirelessDeviceEventLogOption :: WirelessDeviceEvent -> LogLevel -> WirelessDeviceEventLogOption
newWirelessDeviceEventLogOption WirelessDeviceEvent
pEvent_ LogLevel
pLogLevel_ =
  WirelessDeviceEventLogOption' :: WirelessDeviceEvent -> LogLevel -> WirelessDeviceEventLogOption
WirelessDeviceEventLogOption'
    { $sel:event:WirelessDeviceEventLogOption' :: WirelessDeviceEvent
event = WirelessDeviceEvent
pEvent_,
      $sel:logLevel:WirelessDeviceEventLogOption' :: LogLevel
logLevel = LogLevel
pLogLevel_
    }

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

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

instance Core.FromJSON WirelessDeviceEventLogOption where
  parseJSON :: Value -> Parser WirelessDeviceEventLogOption
parseJSON =
    String
-> (Object -> Parser WirelessDeviceEventLogOption)
-> Value
-> Parser WirelessDeviceEventLogOption
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WirelessDeviceEventLogOption"
      ( \Object
x ->
          WirelessDeviceEvent -> LogLevel -> WirelessDeviceEventLogOption
WirelessDeviceEventLogOption'
            (WirelessDeviceEvent -> LogLevel -> WirelessDeviceEventLogOption)
-> Parser WirelessDeviceEvent
-> Parser (LogLevel -> WirelessDeviceEventLogOption)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser WirelessDeviceEvent
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Event")
            Parser (LogLevel -> WirelessDeviceEventLogOption)
-> Parser LogLevel -> Parser WirelessDeviceEventLogOption
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
    WirelessDeviceEventLogOption

instance Prelude.NFData WirelessDeviceEventLogOption

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