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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Gateway list item object that specifies the frequency and list of
-- gateways for which the downlink message should be sent.
--
-- /See:/ 'newGatewayListItem' smart constructor.
data GatewayListItem = GatewayListItem'
  { -- | The ID of the wireless gateways that you want to add to the list of
    -- gateways when sending downlink messages.
    GatewayListItem -> Text
gatewayId :: Prelude.Text,
    -- | The frequency to use for the gateways when sending a downlink message to
    -- the wireless device.
    GatewayListItem -> Natural
downlinkFrequency :: Prelude.Natural
  }
  deriving (GatewayListItem -> GatewayListItem -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GatewayListItem -> GatewayListItem -> Bool
$c/= :: GatewayListItem -> GatewayListItem -> Bool
== :: GatewayListItem -> GatewayListItem -> Bool
$c== :: GatewayListItem -> GatewayListItem -> Bool
Prelude.Eq, ReadPrec [GatewayListItem]
ReadPrec GatewayListItem
Int -> ReadS GatewayListItem
ReadS [GatewayListItem]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GatewayListItem]
$creadListPrec :: ReadPrec [GatewayListItem]
readPrec :: ReadPrec GatewayListItem
$creadPrec :: ReadPrec GatewayListItem
readList :: ReadS [GatewayListItem]
$creadList :: ReadS [GatewayListItem]
readsPrec :: Int -> ReadS GatewayListItem
$creadsPrec :: Int -> ReadS GatewayListItem
Prelude.Read, Int -> GatewayListItem -> ShowS
[GatewayListItem] -> ShowS
GatewayListItem -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GatewayListItem] -> ShowS
$cshowList :: [GatewayListItem] -> ShowS
show :: GatewayListItem -> String
$cshow :: GatewayListItem -> String
showsPrec :: Int -> GatewayListItem -> ShowS
$cshowsPrec :: Int -> GatewayListItem -> ShowS
Prelude.Show, forall x. Rep GatewayListItem x -> GatewayListItem
forall x. GatewayListItem -> Rep GatewayListItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GatewayListItem x -> GatewayListItem
$cfrom :: forall x. GatewayListItem -> Rep GatewayListItem x
Prelude.Generic)

-- |
-- Create a value of 'GatewayListItem' 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:
--
-- 'gatewayId', 'gatewayListItem_gatewayId' - The ID of the wireless gateways that you want to add to the list of
-- gateways when sending downlink messages.
--
-- 'downlinkFrequency', 'gatewayListItem_downlinkFrequency' - The frequency to use for the gateways when sending a downlink message to
-- the wireless device.
newGatewayListItem ::
  -- | 'gatewayId'
  Prelude.Text ->
  -- | 'downlinkFrequency'
  Prelude.Natural ->
  GatewayListItem
newGatewayListItem :: Text -> Natural -> GatewayListItem
newGatewayListItem Text
pGatewayId_ Natural
pDownlinkFrequency_ =
  GatewayListItem'
    { $sel:gatewayId:GatewayListItem' :: Text
gatewayId = Text
pGatewayId_,
      $sel:downlinkFrequency:GatewayListItem' :: Natural
downlinkFrequency = Natural
pDownlinkFrequency_
    }

-- | The ID of the wireless gateways that you want to add to the list of
-- gateways when sending downlink messages.
gatewayListItem_gatewayId :: Lens.Lens' GatewayListItem Prelude.Text
gatewayListItem_gatewayId :: Lens' GatewayListItem Text
gatewayListItem_gatewayId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GatewayListItem' {Text
gatewayId :: Text
$sel:gatewayId:GatewayListItem' :: GatewayListItem -> Text
gatewayId} -> Text
gatewayId) (\s :: GatewayListItem
s@GatewayListItem' {} Text
a -> GatewayListItem
s {$sel:gatewayId:GatewayListItem' :: Text
gatewayId = Text
a} :: GatewayListItem)

-- | The frequency to use for the gateways when sending a downlink message to
-- the wireless device.
gatewayListItem_downlinkFrequency :: Lens.Lens' GatewayListItem Prelude.Natural
gatewayListItem_downlinkFrequency :: Lens' GatewayListItem Natural
gatewayListItem_downlinkFrequency = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GatewayListItem' {Natural
downlinkFrequency :: Natural
$sel:downlinkFrequency:GatewayListItem' :: GatewayListItem -> Natural
downlinkFrequency} -> Natural
downlinkFrequency) (\s :: GatewayListItem
s@GatewayListItem' {} Natural
a -> GatewayListItem
s {$sel:downlinkFrequency:GatewayListItem' :: Natural
downlinkFrequency = Natural
a} :: GatewayListItem)

instance Data.FromJSON GatewayListItem where
  parseJSON :: Value -> Parser GatewayListItem
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GatewayListItem"
      ( \Object
x ->
          Text -> Natural -> GatewayListItem
GatewayListItem'
            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
"GatewayId")
            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
"DownlinkFrequency")
      )

instance Prelude.Hashable GatewayListItem where
  hashWithSalt :: Int -> GatewayListItem -> Int
hashWithSalt Int
_salt GatewayListItem' {Natural
Text
downlinkFrequency :: Natural
gatewayId :: Text
$sel:downlinkFrequency:GatewayListItem' :: GatewayListItem -> Natural
$sel:gatewayId:GatewayListItem' :: GatewayListItem -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
gatewayId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
downlinkFrequency

instance Prelude.NFData GatewayListItem where
  rnf :: GatewayListItem -> ()
rnf GatewayListItem' {Natural
Text
downlinkFrequency :: Natural
gatewayId :: Text
$sel:downlinkFrequency:GatewayListItem' :: GatewayListItem -> Natural
$sel:gatewayId:GatewayListItem' :: GatewayListItem -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
gatewayId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
downlinkFrequency

instance Data.ToJSON GatewayListItem where
  toJSON :: GatewayListItem -> Value
toJSON GatewayListItem' {Natural
Text
downlinkFrequency :: Natural
gatewayId :: Text
$sel:downlinkFrequency:GatewayListItem' :: GatewayListItem -> Natural
$sel:gatewayId:GatewayListItem' :: GatewayListItem -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"GatewayId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
gatewayId),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"DownlinkFrequency" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
downlinkFrequency)
          ]
      )