{-# 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.ParticipatingGateways
-- 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.ParticipatingGateways 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.DownlinkMode
import Amazonka.IoTWireless.Types.GatewayListItem
import qualified Amazonka.Prelude as Prelude

-- | Specify the list of gateways to which you want to send downlink data
-- traffic when the wireless device is running in class B or class C mode.
--
-- /See:/ 'newParticipatingGateways' smart constructor.
data ParticipatingGateways = ParticipatingGateways'
  { -- | Indicates whether to send the downlink message in sequential mode or
    -- concurrent mode, or to use only the chosen gateways from the previous
    -- uplink message transmission.
    ParticipatingGateways -> DownlinkMode
downlinkMode :: DownlinkMode,
    -- | The list of gateways that you want to use for sending the downlink data
    -- traffic.
    ParticipatingGateways -> [GatewayListItem]
gatewayList :: [GatewayListItem],
    -- | The duration of time for which AWS IoT Core for LoRaWAN will wait before
    -- transmitting the payload to the next gateway.
    ParticipatingGateways -> Natural
transmissionInterval :: Prelude.Natural
  }
  deriving (ParticipatingGateways -> ParticipatingGateways -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ParticipatingGateways -> ParticipatingGateways -> Bool
$c/= :: ParticipatingGateways -> ParticipatingGateways -> Bool
== :: ParticipatingGateways -> ParticipatingGateways -> Bool
$c== :: ParticipatingGateways -> ParticipatingGateways -> Bool
Prelude.Eq, ReadPrec [ParticipatingGateways]
ReadPrec ParticipatingGateways
Int -> ReadS ParticipatingGateways
ReadS [ParticipatingGateways]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ParticipatingGateways]
$creadListPrec :: ReadPrec [ParticipatingGateways]
readPrec :: ReadPrec ParticipatingGateways
$creadPrec :: ReadPrec ParticipatingGateways
readList :: ReadS [ParticipatingGateways]
$creadList :: ReadS [ParticipatingGateways]
readsPrec :: Int -> ReadS ParticipatingGateways
$creadsPrec :: Int -> ReadS ParticipatingGateways
Prelude.Read, Int -> ParticipatingGateways -> ShowS
[ParticipatingGateways] -> ShowS
ParticipatingGateways -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ParticipatingGateways] -> ShowS
$cshowList :: [ParticipatingGateways] -> ShowS
show :: ParticipatingGateways -> String
$cshow :: ParticipatingGateways -> String
showsPrec :: Int -> ParticipatingGateways -> ShowS
$cshowsPrec :: Int -> ParticipatingGateways -> ShowS
Prelude.Show, forall x. Rep ParticipatingGateways x -> ParticipatingGateways
forall x. ParticipatingGateways -> Rep ParticipatingGateways x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ParticipatingGateways x -> ParticipatingGateways
$cfrom :: forall x. ParticipatingGateways -> Rep ParticipatingGateways x
Prelude.Generic)

-- |
-- Create a value of 'ParticipatingGateways' 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:
--
-- 'downlinkMode', 'participatingGateways_downlinkMode' - Indicates whether to send the downlink message in sequential mode or
-- concurrent mode, or to use only the chosen gateways from the previous
-- uplink message transmission.
--
-- 'gatewayList', 'participatingGateways_gatewayList' - The list of gateways that you want to use for sending the downlink data
-- traffic.
--
-- 'transmissionInterval', 'participatingGateways_transmissionInterval' - The duration of time for which AWS IoT Core for LoRaWAN will wait before
-- transmitting the payload to the next gateway.
newParticipatingGateways ::
  -- | 'downlinkMode'
  DownlinkMode ->
  -- | 'transmissionInterval'
  Prelude.Natural ->
  ParticipatingGateways
newParticipatingGateways :: DownlinkMode -> Natural -> ParticipatingGateways
newParticipatingGateways
  DownlinkMode
pDownlinkMode_
  Natural
pTransmissionInterval_ =
    ParticipatingGateways'
      { $sel:downlinkMode:ParticipatingGateways' :: DownlinkMode
downlinkMode =
          DownlinkMode
pDownlinkMode_,
        $sel:gatewayList:ParticipatingGateways' :: [GatewayListItem]
gatewayList = forall a. Monoid a => a
Prelude.mempty,
        $sel:transmissionInterval:ParticipatingGateways' :: Natural
transmissionInterval = Natural
pTransmissionInterval_
      }

-- | Indicates whether to send the downlink message in sequential mode or
-- concurrent mode, or to use only the chosen gateways from the previous
-- uplink message transmission.
participatingGateways_downlinkMode :: Lens.Lens' ParticipatingGateways DownlinkMode
participatingGateways_downlinkMode :: Lens' ParticipatingGateways DownlinkMode
participatingGateways_downlinkMode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParticipatingGateways' {DownlinkMode
downlinkMode :: DownlinkMode
$sel:downlinkMode:ParticipatingGateways' :: ParticipatingGateways -> DownlinkMode
downlinkMode} -> DownlinkMode
downlinkMode) (\s :: ParticipatingGateways
s@ParticipatingGateways' {} DownlinkMode
a -> ParticipatingGateways
s {$sel:downlinkMode:ParticipatingGateways' :: DownlinkMode
downlinkMode = DownlinkMode
a} :: ParticipatingGateways)

-- | The list of gateways that you want to use for sending the downlink data
-- traffic.
participatingGateways_gatewayList :: Lens.Lens' ParticipatingGateways [GatewayListItem]
participatingGateways_gatewayList :: Lens' ParticipatingGateways [GatewayListItem]
participatingGateways_gatewayList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParticipatingGateways' {[GatewayListItem]
gatewayList :: [GatewayListItem]
$sel:gatewayList:ParticipatingGateways' :: ParticipatingGateways -> [GatewayListItem]
gatewayList} -> [GatewayListItem]
gatewayList) (\s :: ParticipatingGateways
s@ParticipatingGateways' {} [GatewayListItem]
a -> ParticipatingGateways
s {$sel:gatewayList:ParticipatingGateways' :: [GatewayListItem]
gatewayList = [GatewayListItem]
a} :: ParticipatingGateways) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The duration of time for which AWS IoT Core for LoRaWAN will wait before
-- transmitting the payload to the next gateway.
participatingGateways_transmissionInterval :: Lens.Lens' ParticipatingGateways Prelude.Natural
participatingGateways_transmissionInterval :: Lens' ParticipatingGateways Natural
participatingGateways_transmissionInterval = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParticipatingGateways' {Natural
transmissionInterval :: Natural
$sel:transmissionInterval:ParticipatingGateways' :: ParticipatingGateways -> Natural
transmissionInterval} -> Natural
transmissionInterval) (\s :: ParticipatingGateways
s@ParticipatingGateways' {} Natural
a -> ParticipatingGateways
s {$sel:transmissionInterval:ParticipatingGateways' :: Natural
transmissionInterval = Natural
a} :: ParticipatingGateways)

instance Data.FromJSON ParticipatingGateways where
  parseJSON :: Value -> Parser ParticipatingGateways
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ParticipatingGateways"
      ( \Object
x ->
          DownlinkMode
-> [GatewayListItem] -> Natural -> ParticipatingGateways
ParticipatingGateways'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"DownlinkMode")
            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
"GatewayList" 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
"TransmissionInterval")
      )

instance Prelude.Hashable ParticipatingGateways where
  hashWithSalt :: Int -> ParticipatingGateways -> Int
hashWithSalt Int
_salt ParticipatingGateways' {Natural
[GatewayListItem]
DownlinkMode
transmissionInterval :: Natural
gatewayList :: [GatewayListItem]
downlinkMode :: DownlinkMode
$sel:transmissionInterval:ParticipatingGateways' :: ParticipatingGateways -> Natural
$sel:gatewayList:ParticipatingGateways' :: ParticipatingGateways -> [GatewayListItem]
$sel:downlinkMode:ParticipatingGateways' :: ParticipatingGateways -> DownlinkMode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` DownlinkMode
downlinkMode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [GatewayListItem]
gatewayList
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
transmissionInterval

instance Prelude.NFData ParticipatingGateways where
  rnf :: ParticipatingGateways -> ()
rnf ParticipatingGateways' {Natural
[GatewayListItem]
DownlinkMode
transmissionInterval :: Natural
gatewayList :: [GatewayListItem]
downlinkMode :: DownlinkMode
$sel:transmissionInterval:ParticipatingGateways' :: ParticipatingGateways -> Natural
$sel:gatewayList:ParticipatingGateways' :: ParticipatingGateways -> [GatewayListItem]
$sel:downlinkMode:ParticipatingGateways' :: ParticipatingGateways -> DownlinkMode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf DownlinkMode
downlinkMode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [GatewayListItem]
gatewayList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
transmissionInterval

instance Data.ToJSON ParticipatingGateways where
  toJSON :: ParticipatingGateways -> Value
toJSON ParticipatingGateways' {Natural
[GatewayListItem]
DownlinkMode
transmissionInterval :: Natural
gatewayList :: [GatewayListItem]
downlinkMode :: DownlinkMode
$sel:transmissionInterval:ParticipatingGateways' :: ParticipatingGateways -> Natural
$sel:gatewayList:ParticipatingGateways' :: ParticipatingGateways -> [GatewayListItem]
$sel:downlinkMode:ParticipatingGateways' :: ParticipatingGateways -> DownlinkMode
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"DownlinkMode" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= DownlinkMode
downlinkMode),
            forall a. a -> Maybe a
Prelude.Just (Key
"GatewayList" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [GatewayListItem]
gatewayList),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"TransmissionInterval"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
transmissionInterval
              )
          ]
      )