{-# 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.JoinEventConfiguration
-- 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.JoinEventConfiguration 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.EventNotificationTopicStatus
import Amazonka.IoTWireless.Types.LoRaWANJoinEventNotificationConfigurations
import qualified Amazonka.Prelude as Prelude

-- | Join event configuration object for enabling or disabling topic.
--
-- /See:/ 'newJoinEventConfiguration' smart constructor.
data JoinEventConfiguration = JoinEventConfiguration'
  { -- | Join event configuration object for enabling or disabling LoRaWAN
    -- related event topics.
    JoinEventConfiguration
-> Maybe LoRaWANJoinEventNotificationConfigurations
loRaWAN :: Prelude.Maybe LoRaWANJoinEventNotificationConfigurations,
    -- | Denotes whether the wireless device ID join event topic is enabled or
    -- disabled.
    JoinEventConfiguration -> Maybe EventNotificationTopicStatus
wirelessDeviceIdEventTopic :: Prelude.Maybe EventNotificationTopicStatus
  }
  deriving (JoinEventConfiguration -> JoinEventConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JoinEventConfiguration -> JoinEventConfiguration -> Bool
$c/= :: JoinEventConfiguration -> JoinEventConfiguration -> Bool
== :: JoinEventConfiguration -> JoinEventConfiguration -> Bool
$c== :: JoinEventConfiguration -> JoinEventConfiguration -> Bool
Prelude.Eq, ReadPrec [JoinEventConfiguration]
ReadPrec JoinEventConfiguration
Int -> ReadS JoinEventConfiguration
ReadS [JoinEventConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JoinEventConfiguration]
$creadListPrec :: ReadPrec [JoinEventConfiguration]
readPrec :: ReadPrec JoinEventConfiguration
$creadPrec :: ReadPrec JoinEventConfiguration
readList :: ReadS [JoinEventConfiguration]
$creadList :: ReadS [JoinEventConfiguration]
readsPrec :: Int -> ReadS JoinEventConfiguration
$creadsPrec :: Int -> ReadS JoinEventConfiguration
Prelude.Read, Int -> JoinEventConfiguration -> ShowS
[JoinEventConfiguration] -> ShowS
JoinEventConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JoinEventConfiguration] -> ShowS
$cshowList :: [JoinEventConfiguration] -> ShowS
show :: JoinEventConfiguration -> String
$cshow :: JoinEventConfiguration -> String
showsPrec :: Int -> JoinEventConfiguration -> ShowS
$cshowsPrec :: Int -> JoinEventConfiguration -> ShowS
Prelude.Show, forall x. Rep JoinEventConfiguration x -> JoinEventConfiguration
forall x. JoinEventConfiguration -> Rep JoinEventConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JoinEventConfiguration x -> JoinEventConfiguration
$cfrom :: forall x. JoinEventConfiguration -> Rep JoinEventConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'JoinEventConfiguration' 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:
--
-- 'loRaWAN', 'joinEventConfiguration_loRaWAN' - Join event configuration object for enabling or disabling LoRaWAN
-- related event topics.
--
-- 'wirelessDeviceIdEventTopic', 'joinEventConfiguration_wirelessDeviceIdEventTopic' - Denotes whether the wireless device ID join event topic is enabled or
-- disabled.
newJoinEventConfiguration ::
  JoinEventConfiguration
newJoinEventConfiguration :: JoinEventConfiguration
newJoinEventConfiguration =
  JoinEventConfiguration'
    { $sel:loRaWAN:JoinEventConfiguration' :: Maybe LoRaWANJoinEventNotificationConfigurations
loRaWAN = forall a. Maybe a
Prelude.Nothing,
      $sel:wirelessDeviceIdEventTopic:JoinEventConfiguration' :: Maybe EventNotificationTopicStatus
wirelessDeviceIdEventTopic = forall a. Maybe a
Prelude.Nothing
    }

-- | Join event configuration object for enabling or disabling LoRaWAN
-- related event topics.
joinEventConfiguration_loRaWAN :: Lens.Lens' JoinEventConfiguration (Prelude.Maybe LoRaWANJoinEventNotificationConfigurations)
joinEventConfiguration_loRaWAN :: Lens'
  JoinEventConfiguration
  (Maybe LoRaWANJoinEventNotificationConfigurations)
joinEventConfiguration_loRaWAN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JoinEventConfiguration' {Maybe LoRaWANJoinEventNotificationConfigurations
loRaWAN :: Maybe LoRaWANJoinEventNotificationConfigurations
$sel:loRaWAN:JoinEventConfiguration' :: JoinEventConfiguration
-> Maybe LoRaWANJoinEventNotificationConfigurations
loRaWAN} -> Maybe LoRaWANJoinEventNotificationConfigurations
loRaWAN) (\s :: JoinEventConfiguration
s@JoinEventConfiguration' {} Maybe LoRaWANJoinEventNotificationConfigurations
a -> JoinEventConfiguration
s {$sel:loRaWAN:JoinEventConfiguration' :: Maybe LoRaWANJoinEventNotificationConfigurations
loRaWAN = Maybe LoRaWANJoinEventNotificationConfigurations
a} :: JoinEventConfiguration)

-- | Denotes whether the wireless device ID join event topic is enabled or
-- disabled.
joinEventConfiguration_wirelessDeviceIdEventTopic :: Lens.Lens' JoinEventConfiguration (Prelude.Maybe EventNotificationTopicStatus)
joinEventConfiguration_wirelessDeviceIdEventTopic :: Lens' JoinEventConfiguration (Maybe EventNotificationTopicStatus)
joinEventConfiguration_wirelessDeviceIdEventTopic = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JoinEventConfiguration' {Maybe EventNotificationTopicStatus
wirelessDeviceIdEventTopic :: Maybe EventNotificationTopicStatus
$sel:wirelessDeviceIdEventTopic:JoinEventConfiguration' :: JoinEventConfiguration -> Maybe EventNotificationTopicStatus
wirelessDeviceIdEventTopic} -> Maybe EventNotificationTopicStatus
wirelessDeviceIdEventTopic) (\s :: JoinEventConfiguration
s@JoinEventConfiguration' {} Maybe EventNotificationTopicStatus
a -> JoinEventConfiguration
s {$sel:wirelessDeviceIdEventTopic:JoinEventConfiguration' :: Maybe EventNotificationTopicStatus
wirelessDeviceIdEventTopic = Maybe EventNotificationTopicStatus
a} :: JoinEventConfiguration)

instance Data.FromJSON JoinEventConfiguration where
  parseJSON :: Value -> Parser JoinEventConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"JoinEventConfiguration"
      ( \Object
x ->
          Maybe LoRaWANJoinEventNotificationConfigurations
-> Maybe EventNotificationTopicStatus -> JoinEventConfiguration
JoinEventConfiguration'
            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
"LoRaWAN")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"WirelessDeviceIdEventTopic")
      )

instance Prelude.Hashable JoinEventConfiguration where
  hashWithSalt :: Int -> JoinEventConfiguration -> Int
hashWithSalt Int
_salt JoinEventConfiguration' {Maybe EventNotificationTopicStatus
Maybe LoRaWANJoinEventNotificationConfigurations
wirelessDeviceIdEventTopic :: Maybe EventNotificationTopicStatus
loRaWAN :: Maybe LoRaWANJoinEventNotificationConfigurations
$sel:wirelessDeviceIdEventTopic:JoinEventConfiguration' :: JoinEventConfiguration -> Maybe EventNotificationTopicStatus
$sel:loRaWAN:JoinEventConfiguration' :: JoinEventConfiguration
-> Maybe LoRaWANJoinEventNotificationConfigurations
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LoRaWANJoinEventNotificationConfigurations
loRaWAN
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EventNotificationTopicStatus
wirelessDeviceIdEventTopic

instance Prelude.NFData JoinEventConfiguration where
  rnf :: JoinEventConfiguration -> ()
rnf JoinEventConfiguration' {Maybe EventNotificationTopicStatus
Maybe LoRaWANJoinEventNotificationConfigurations
wirelessDeviceIdEventTopic :: Maybe EventNotificationTopicStatus
loRaWAN :: Maybe LoRaWANJoinEventNotificationConfigurations
$sel:wirelessDeviceIdEventTopic:JoinEventConfiguration' :: JoinEventConfiguration -> Maybe EventNotificationTopicStatus
$sel:loRaWAN:JoinEventConfiguration' :: JoinEventConfiguration
-> Maybe LoRaWANJoinEventNotificationConfigurations
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe LoRaWANJoinEventNotificationConfigurations
loRaWAN
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EventNotificationTopicStatus
wirelessDeviceIdEventTopic

instance Data.ToJSON JoinEventConfiguration where
  toJSON :: JoinEventConfiguration -> Value
toJSON JoinEventConfiguration' {Maybe EventNotificationTopicStatus
Maybe LoRaWANJoinEventNotificationConfigurations
wirelessDeviceIdEventTopic :: Maybe EventNotificationTopicStatus
loRaWAN :: Maybe LoRaWANJoinEventNotificationConfigurations
$sel:wirelessDeviceIdEventTopic:JoinEventConfiguration' :: JoinEventConfiguration -> Maybe EventNotificationTopicStatus
$sel:loRaWAN:JoinEventConfiguration' :: JoinEventConfiguration
-> Maybe LoRaWANJoinEventNotificationConfigurations
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"LoRaWAN" 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 LoRaWANJoinEventNotificationConfigurations
loRaWAN,
            (Key
"WirelessDeviceIdEventTopic" 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 EventNotificationTopicStatus
wirelessDeviceIdEventTopic
          ]
      )