{-# 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.WirelessDeviceLogOption
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoTWireless.Types.WirelessDeviceLogOption where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTWireless.Types.LogLevel
import Amazonka.IoTWireless.Types.WirelessDeviceEventLogOption
import Amazonka.IoTWireless.Types.WirelessDeviceType
import qualified Amazonka.Prelude as Prelude

-- | The log options for wireless devices and can be used to set log levels
-- for a specific type of wireless device.
--
-- /See:/ 'newWirelessDeviceLogOption' smart constructor.
data WirelessDeviceLogOption = WirelessDeviceLogOption'
  { WirelessDeviceLogOption -> Maybe [WirelessDeviceEventLogOption]
events :: Prelude.Maybe [WirelessDeviceEventLogOption],
    -- | The wireless device type.
    WirelessDeviceLogOption -> WirelessDeviceType
type' :: WirelessDeviceType,
    WirelessDeviceLogOption -> LogLevel
logLevel :: LogLevel
  }
  deriving (WirelessDeviceLogOption -> WirelessDeviceLogOption -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WirelessDeviceLogOption -> WirelessDeviceLogOption -> Bool
$c/= :: WirelessDeviceLogOption -> WirelessDeviceLogOption -> Bool
== :: WirelessDeviceLogOption -> WirelessDeviceLogOption -> Bool
$c== :: WirelessDeviceLogOption -> WirelessDeviceLogOption -> Bool
Prelude.Eq, ReadPrec [WirelessDeviceLogOption]
ReadPrec WirelessDeviceLogOption
Int -> ReadS WirelessDeviceLogOption
ReadS [WirelessDeviceLogOption]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WirelessDeviceLogOption]
$creadListPrec :: ReadPrec [WirelessDeviceLogOption]
readPrec :: ReadPrec WirelessDeviceLogOption
$creadPrec :: ReadPrec WirelessDeviceLogOption
readList :: ReadS [WirelessDeviceLogOption]
$creadList :: ReadS [WirelessDeviceLogOption]
readsPrec :: Int -> ReadS WirelessDeviceLogOption
$creadsPrec :: Int -> ReadS WirelessDeviceLogOption
Prelude.Read, Int -> WirelessDeviceLogOption -> ShowS
[WirelessDeviceLogOption] -> ShowS
WirelessDeviceLogOption -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WirelessDeviceLogOption] -> ShowS
$cshowList :: [WirelessDeviceLogOption] -> ShowS
show :: WirelessDeviceLogOption -> String
$cshow :: WirelessDeviceLogOption -> String
showsPrec :: Int -> WirelessDeviceLogOption -> ShowS
$cshowsPrec :: Int -> WirelessDeviceLogOption -> ShowS
Prelude.Show, forall x. Rep WirelessDeviceLogOption x -> WirelessDeviceLogOption
forall x. WirelessDeviceLogOption -> Rep WirelessDeviceLogOption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WirelessDeviceLogOption x -> WirelessDeviceLogOption
$cfrom :: forall x. WirelessDeviceLogOption -> Rep WirelessDeviceLogOption x
Prelude.Generic)

-- |
-- Create a value of 'WirelessDeviceLogOption' 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:
--
-- 'events', 'wirelessDeviceLogOption_events' - Undocumented member.
--
-- 'type'', 'wirelessDeviceLogOption_type' - The wireless device type.
--
-- 'logLevel', 'wirelessDeviceLogOption_logLevel' - Undocumented member.
newWirelessDeviceLogOption ::
  -- | 'type''
  WirelessDeviceType ->
  -- | 'logLevel'
  LogLevel ->
  WirelessDeviceLogOption
newWirelessDeviceLogOption :: WirelessDeviceType -> LogLevel -> WirelessDeviceLogOption
newWirelessDeviceLogOption WirelessDeviceType
pType_ LogLevel
pLogLevel_ =
  WirelessDeviceLogOption'
    { $sel:events:WirelessDeviceLogOption' :: Maybe [WirelessDeviceEventLogOption]
events = forall a. Maybe a
Prelude.Nothing,
      $sel:type':WirelessDeviceLogOption' :: WirelessDeviceType
type' = WirelessDeviceType
pType_,
      $sel:logLevel:WirelessDeviceLogOption' :: LogLevel
logLevel = LogLevel
pLogLevel_
    }

-- | Undocumented member.
wirelessDeviceLogOption_events :: Lens.Lens' WirelessDeviceLogOption (Prelude.Maybe [WirelessDeviceEventLogOption])
wirelessDeviceLogOption_events :: Lens'
  WirelessDeviceLogOption (Maybe [WirelessDeviceEventLogOption])
wirelessDeviceLogOption_events = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WirelessDeviceLogOption' {Maybe [WirelessDeviceEventLogOption]
events :: Maybe [WirelessDeviceEventLogOption]
$sel:events:WirelessDeviceLogOption' :: WirelessDeviceLogOption -> Maybe [WirelessDeviceEventLogOption]
events} -> Maybe [WirelessDeviceEventLogOption]
events) (\s :: WirelessDeviceLogOption
s@WirelessDeviceLogOption' {} Maybe [WirelessDeviceEventLogOption]
a -> WirelessDeviceLogOption
s {$sel:events:WirelessDeviceLogOption' :: Maybe [WirelessDeviceEventLogOption]
events = Maybe [WirelessDeviceEventLogOption]
a} :: WirelessDeviceLogOption) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The wireless device type.
wirelessDeviceLogOption_type :: Lens.Lens' WirelessDeviceLogOption WirelessDeviceType
wirelessDeviceLogOption_type :: Lens' WirelessDeviceLogOption WirelessDeviceType
wirelessDeviceLogOption_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WirelessDeviceLogOption' {WirelessDeviceType
type' :: WirelessDeviceType
$sel:type':WirelessDeviceLogOption' :: WirelessDeviceLogOption -> WirelessDeviceType
type'} -> WirelessDeviceType
type') (\s :: WirelessDeviceLogOption
s@WirelessDeviceLogOption' {} WirelessDeviceType
a -> WirelessDeviceLogOption
s {$sel:type':WirelessDeviceLogOption' :: WirelessDeviceType
type' = WirelessDeviceType
a} :: WirelessDeviceLogOption)

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

instance Data.FromJSON WirelessDeviceLogOption where
  parseJSON :: Value -> Parser WirelessDeviceLogOption
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"WirelessDeviceLogOption"
      ( \Object
x ->
          Maybe [WirelessDeviceEventLogOption]
-> WirelessDeviceType -> LogLevel -> WirelessDeviceLogOption
WirelessDeviceLogOption'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Events" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Type")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"LogLevel")
      )

instance Prelude.Hashable WirelessDeviceLogOption where
  hashWithSalt :: Int -> WirelessDeviceLogOption -> Int
hashWithSalt Int
_salt WirelessDeviceLogOption' {Maybe [WirelessDeviceEventLogOption]
LogLevel
WirelessDeviceType
logLevel :: LogLevel
type' :: WirelessDeviceType
events :: Maybe [WirelessDeviceEventLogOption]
$sel:logLevel:WirelessDeviceLogOption' :: WirelessDeviceLogOption -> LogLevel
$sel:type':WirelessDeviceLogOption' :: WirelessDeviceLogOption -> WirelessDeviceType
$sel:events:WirelessDeviceLogOption' :: WirelessDeviceLogOption -> Maybe [WirelessDeviceEventLogOption]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [WirelessDeviceEventLogOption]
events
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` WirelessDeviceType
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` LogLevel
logLevel

instance Prelude.NFData WirelessDeviceLogOption where
  rnf :: WirelessDeviceLogOption -> ()
rnf WirelessDeviceLogOption' {Maybe [WirelessDeviceEventLogOption]
LogLevel
WirelessDeviceType
logLevel :: LogLevel
type' :: WirelessDeviceType
events :: Maybe [WirelessDeviceEventLogOption]
$sel:logLevel:WirelessDeviceLogOption' :: WirelessDeviceLogOption -> LogLevel
$sel:type':WirelessDeviceLogOption' :: WirelessDeviceLogOption -> WirelessDeviceType
$sel:events:WirelessDeviceLogOption' :: WirelessDeviceLogOption -> Maybe [WirelessDeviceEventLogOption]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [WirelessDeviceEventLogOption]
events
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf WirelessDeviceType
type'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf LogLevel
logLevel

instance Data.ToJSON WirelessDeviceLogOption where
  toJSON :: WirelessDeviceLogOption -> Value
toJSON WirelessDeviceLogOption' {Maybe [WirelessDeviceEventLogOption]
LogLevel
WirelessDeviceType
logLevel :: LogLevel
type' :: WirelessDeviceType
events :: Maybe [WirelessDeviceEventLogOption]
$sel:logLevel:WirelessDeviceLogOption' :: WirelessDeviceLogOption -> LogLevel
$sel:type':WirelessDeviceLogOption' :: WirelessDeviceLogOption -> WirelessDeviceType
$sel:events:WirelessDeviceLogOption' :: WirelessDeviceLogOption -> Maybe [WirelessDeviceEventLogOption]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Events" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [WirelessDeviceEventLogOption]
events,
            forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= WirelessDeviceType
type'),
            forall a. a -> Maybe a
Prelude.Just (Key
"LogLevel" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= LogLevel
logLevel)
          ]
      )