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

import qualified Amazonka.Core as Core
import Amazonka.IoTWireless.Types.LogLevel
import Amazonka.IoTWireless.Types.WirelessGatewayEventLogOption
import Amazonka.IoTWireless.Types.WirelessGatewayType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'WirelessGatewayLogOption' 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', 'wirelessGatewayLogOption_events' - Undocumented member.
--
-- 'type'', 'wirelessGatewayLogOption_type' - Undocumented member.
--
-- 'logLevel', 'wirelessGatewayLogOption_logLevel' - Undocumented member.
newWirelessGatewayLogOption ::
  -- | 'type''
  WirelessGatewayType ->
  -- | 'logLevel'
  LogLevel ->
  WirelessGatewayLogOption
newWirelessGatewayLogOption :: WirelessGatewayType -> LogLevel -> WirelessGatewayLogOption
newWirelessGatewayLogOption WirelessGatewayType
pType_ LogLevel
pLogLevel_ =
  WirelessGatewayLogOption' :: Maybe [WirelessGatewayEventLogOption]
-> WirelessGatewayType -> LogLevel -> WirelessGatewayLogOption
WirelessGatewayLogOption'
    { $sel:events:WirelessGatewayLogOption' :: Maybe [WirelessGatewayEventLogOption]
events = Maybe [WirelessGatewayEventLogOption]
forall a. Maybe a
Prelude.Nothing,
      $sel:type':WirelessGatewayLogOption' :: WirelessGatewayType
type' = WirelessGatewayType
pType_,
      $sel:logLevel:WirelessGatewayLogOption' :: LogLevel
logLevel = LogLevel
pLogLevel_
    }

-- | Undocumented member.
wirelessGatewayLogOption_events :: Lens.Lens' WirelessGatewayLogOption (Prelude.Maybe [WirelessGatewayEventLogOption])
wirelessGatewayLogOption_events :: (Maybe [WirelessGatewayEventLogOption]
 -> f (Maybe [WirelessGatewayEventLogOption]))
-> WirelessGatewayLogOption -> f WirelessGatewayLogOption
wirelessGatewayLogOption_events = (WirelessGatewayLogOption -> Maybe [WirelessGatewayEventLogOption])
-> (WirelessGatewayLogOption
    -> Maybe [WirelessGatewayEventLogOption]
    -> WirelessGatewayLogOption)
-> Lens
     WirelessGatewayLogOption
     WirelessGatewayLogOption
     (Maybe [WirelessGatewayEventLogOption])
     (Maybe [WirelessGatewayEventLogOption])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WirelessGatewayLogOption' {Maybe [WirelessGatewayEventLogOption]
events :: Maybe [WirelessGatewayEventLogOption]
$sel:events:WirelessGatewayLogOption' :: WirelessGatewayLogOption -> Maybe [WirelessGatewayEventLogOption]
events} -> Maybe [WirelessGatewayEventLogOption]
events) (\s :: WirelessGatewayLogOption
s@WirelessGatewayLogOption' {} Maybe [WirelessGatewayEventLogOption]
a -> WirelessGatewayLogOption
s {$sel:events:WirelessGatewayLogOption' :: Maybe [WirelessGatewayEventLogOption]
events = Maybe [WirelessGatewayEventLogOption]
a} :: WirelessGatewayLogOption) ((Maybe [WirelessGatewayEventLogOption]
  -> f (Maybe [WirelessGatewayEventLogOption]))
 -> WirelessGatewayLogOption -> f WirelessGatewayLogOption)
-> ((Maybe [WirelessGatewayEventLogOption]
     -> f (Maybe [WirelessGatewayEventLogOption]))
    -> Maybe [WirelessGatewayEventLogOption]
    -> f (Maybe [WirelessGatewayEventLogOption]))
-> (Maybe [WirelessGatewayEventLogOption]
    -> f (Maybe [WirelessGatewayEventLogOption]))
-> WirelessGatewayLogOption
-> f WirelessGatewayLogOption
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [WirelessGatewayEventLogOption]
  [WirelessGatewayEventLogOption]
  [WirelessGatewayEventLogOption]
  [WirelessGatewayEventLogOption]
-> Iso
     (Maybe [WirelessGatewayEventLogOption])
     (Maybe [WirelessGatewayEventLogOption])
     (Maybe [WirelessGatewayEventLogOption])
     (Maybe [WirelessGatewayEventLogOption])
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 AnIso
  [WirelessGatewayEventLogOption]
  [WirelessGatewayEventLogOption]
  [WirelessGatewayEventLogOption]
  [WirelessGatewayEventLogOption]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Undocumented member.
wirelessGatewayLogOption_type :: Lens.Lens' WirelessGatewayLogOption WirelessGatewayType
wirelessGatewayLogOption_type :: (WirelessGatewayType -> f WirelessGatewayType)
-> WirelessGatewayLogOption -> f WirelessGatewayLogOption
wirelessGatewayLogOption_type = (WirelessGatewayLogOption -> WirelessGatewayType)
-> (WirelessGatewayLogOption
    -> WirelessGatewayType -> WirelessGatewayLogOption)
-> Lens
     WirelessGatewayLogOption
     WirelessGatewayLogOption
     WirelessGatewayType
     WirelessGatewayType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WirelessGatewayLogOption' {WirelessGatewayType
type' :: WirelessGatewayType
$sel:type':WirelessGatewayLogOption' :: WirelessGatewayLogOption -> WirelessGatewayType
type'} -> WirelessGatewayType
type') (\s :: WirelessGatewayLogOption
s@WirelessGatewayLogOption' {} WirelessGatewayType
a -> WirelessGatewayLogOption
s {$sel:type':WirelessGatewayLogOption' :: WirelessGatewayType
type' = WirelessGatewayType
a} :: WirelessGatewayLogOption)

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

instance Core.FromJSON WirelessGatewayLogOption where
  parseJSON :: Value -> Parser WirelessGatewayLogOption
parseJSON =
    String
-> (Object -> Parser WirelessGatewayLogOption)
-> Value
-> Parser WirelessGatewayLogOption
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WirelessGatewayLogOption"
      ( \Object
x ->
          Maybe [WirelessGatewayEventLogOption]
-> WirelessGatewayType -> LogLevel -> WirelessGatewayLogOption
WirelessGatewayLogOption'
            (Maybe [WirelessGatewayEventLogOption]
 -> WirelessGatewayType -> LogLevel -> WirelessGatewayLogOption)
-> Parser (Maybe [WirelessGatewayEventLogOption])
-> Parser
     (WirelessGatewayType -> LogLevel -> WirelessGatewayLogOption)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Parser (Maybe (Maybe [WirelessGatewayEventLogOption]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Events" Parser (Maybe (Maybe [WirelessGatewayEventLogOption]))
-> Maybe [WirelessGatewayEventLogOption]
-> Parser (Maybe [WirelessGatewayEventLogOption])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [WirelessGatewayEventLogOption]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (WirelessGatewayType -> LogLevel -> WirelessGatewayLogOption)
-> Parser WirelessGatewayType
-> Parser (LogLevel -> WirelessGatewayLogOption)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser WirelessGatewayType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type")
            Parser (LogLevel -> WirelessGatewayLogOption)
-> Parser LogLevel -> Parser WirelessGatewayLogOption
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 WirelessGatewayLogOption

instance Prelude.NFData WirelessGatewayLogOption

instance Core.ToJSON WirelessGatewayLogOption where
  toJSON :: WirelessGatewayLogOption -> Value
toJSON WirelessGatewayLogOption' {Maybe [WirelessGatewayEventLogOption]
LogLevel
WirelessGatewayType
logLevel :: LogLevel
type' :: WirelessGatewayType
events :: Maybe [WirelessGatewayEventLogOption]
$sel:logLevel:WirelessGatewayLogOption' :: WirelessGatewayLogOption -> LogLevel
$sel:type':WirelessGatewayLogOption' :: WirelessGatewayLogOption -> WirelessGatewayType
$sel:events:WirelessGatewayLogOption' :: WirelessGatewayLogOption -> Maybe [WirelessGatewayEventLogOption]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Events" Text -> [WirelessGatewayEventLogOption] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([WirelessGatewayEventLogOption] -> Pair)
-> Maybe [WirelessGatewayEventLogOption] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [WirelessGatewayEventLogOption]
events,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> WirelessGatewayType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= WirelessGatewayType
type'),
            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)
          ]
      )