{-# 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.ApplicationConfig
-- 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.ApplicationConfig 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.ApplicationConfigType
import qualified Amazonka.Prelude as Prelude

-- | LoRaWAN application configuration, which can be used to perform
-- geolocation.
--
-- /See:/ 'newApplicationConfig' smart constructor.
data ApplicationConfig = ApplicationConfig'
  { -- | The name of the position data destination that describes the AWS IoT
    -- rule that processes the device\'s position data for use by AWS IoT Core
    -- for LoRaWAN.
    ApplicationConfig -> Maybe Text
destinationName :: Prelude.Maybe Prelude.Text,
    ApplicationConfig -> Maybe Natural
fPort :: Prelude.Maybe Prelude.Natural,
    -- | Application type, which can be specified to obtain real-time position
    -- information of your LoRaWAN device.
    ApplicationConfig -> Maybe ApplicationConfigType
type' :: Prelude.Maybe ApplicationConfigType
  }
  deriving (ApplicationConfig -> ApplicationConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplicationConfig -> ApplicationConfig -> Bool
$c/= :: ApplicationConfig -> ApplicationConfig -> Bool
== :: ApplicationConfig -> ApplicationConfig -> Bool
$c== :: ApplicationConfig -> ApplicationConfig -> Bool
Prelude.Eq, ReadPrec [ApplicationConfig]
ReadPrec ApplicationConfig
Int -> ReadS ApplicationConfig
ReadS [ApplicationConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApplicationConfig]
$creadListPrec :: ReadPrec [ApplicationConfig]
readPrec :: ReadPrec ApplicationConfig
$creadPrec :: ReadPrec ApplicationConfig
readList :: ReadS [ApplicationConfig]
$creadList :: ReadS [ApplicationConfig]
readsPrec :: Int -> ReadS ApplicationConfig
$creadsPrec :: Int -> ReadS ApplicationConfig
Prelude.Read, Int -> ApplicationConfig -> ShowS
[ApplicationConfig] -> ShowS
ApplicationConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplicationConfig] -> ShowS
$cshowList :: [ApplicationConfig] -> ShowS
show :: ApplicationConfig -> String
$cshow :: ApplicationConfig -> String
showsPrec :: Int -> ApplicationConfig -> ShowS
$cshowsPrec :: Int -> ApplicationConfig -> ShowS
Prelude.Show, forall x. Rep ApplicationConfig x -> ApplicationConfig
forall x. ApplicationConfig -> Rep ApplicationConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ApplicationConfig x -> ApplicationConfig
$cfrom :: forall x. ApplicationConfig -> Rep ApplicationConfig x
Prelude.Generic)

-- |
-- Create a value of 'ApplicationConfig' 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:
--
-- 'destinationName', 'applicationConfig_destinationName' - The name of the position data destination that describes the AWS IoT
-- rule that processes the device\'s position data for use by AWS IoT Core
-- for LoRaWAN.
--
-- 'fPort', 'applicationConfig_fPort' - Undocumented member.
--
-- 'type'', 'applicationConfig_type' - Application type, which can be specified to obtain real-time position
-- information of your LoRaWAN device.
newApplicationConfig ::
  ApplicationConfig
newApplicationConfig :: ApplicationConfig
newApplicationConfig =
  ApplicationConfig'
    { $sel:destinationName:ApplicationConfig' :: Maybe Text
destinationName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:fPort:ApplicationConfig' :: Maybe Natural
fPort = forall a. Maybe a
Prelude.Nothing,
      $sel:type':ApplicationConfig' :: Maybe ApplicationConfigType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the position data destination that describes the AWS IoT
-- rule that processes the device\'s position data for use by AWS IoT Core
-- for LoRaWAN.
applicationConfig_destinationName :: Lens.Lens' ApplicationConfig (Prelude.Maybe Prelude.Text)
applicationConfig_destinationName :: Lens' ApplicationConfig (Maybe Text)
applicationConfig_destinationName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationConfig' {Maybe Text
destinationName :: Maybe Text
$sel:destinationName:ApplicationConfig' :: ApplicationConfig -> Maybe Text
destinationName} -> Maybe Text
destinationName) (\s :: ApplicationConfig
s@ApplicationConfig' {} Maybe Text
a -> ApplicationConfig
s {$sel:destinationName:ApplicationConfig' :: Maybe Text
destinationName = Maybe Text
a} :: ApplicationConfig)

-- | Undocumented member.
applicationConfig_fPort :: Lens.Lens' ApplicationConfig (Prelude.Maybe Prelude.Natural)
applicationConfig_fPort :: Lens' ApplicationConfig (Maybe Natural)
applicationConfig_fPort = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationConfig' {Maybe Natural
fPort :: Maybe Natural
$sel:fPort:ApplicationConfig' :: ApplicationConfig -> Maybe Natural
fPort} -> Maybe Natural
fPort) (\s :: ApplicationConfig
s@ApplicationConfig' {} Maybe Natural
a -> ApplicationConfig
s {$sel:fPort:ApplicationConfig' :: Maybe Natural
fPort = Maybe Natural
a} :: ApplicationConfig)

-- | Application type, which can be specified to obtain real-time position
-- information of your LoRaWAN device.
applicationConfig_type :: Lens.Lens' ApplicationConfig (Prelude.Maybe ApplicationConfigType)
applicationConfig_type :: Lens' ApplicationConfig (Maybe ApplicationConfigType)
applicationConfig_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationConfig' {Maybe ApplicationConfigType
type' :: Maybe ApplicationConfigType
$sel:type':ApplicationConfig' :: ApplicationConfig -> Maybe ApplicationConfigType
type'} -> Maybe ApplicationConfigType
type') (\s :: ApplicationConfig
s@ApplicationConfig' {} Maybe ApplicationConfigType
a -> ApplicationConfig
s {$sel:type':ApplicationConfig' :: Maybe ApplicationConfigType
type' = Maybe ApplicationConfigType
a} :: ApplicationConfig)

instance Data.FromJSON ApplicationConfig where
  parseJSON :: Value -> Parser ApplicationConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ApplicationConfig"
      ( \Object
x ->
          Maybe Text
-> Maybe Natural
-> Maybe ApplicationConfigType
-> ApplicationConfig
ApplicationConfig'
            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
"DestinationName")
            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
"FPort")
            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
"Type")
      )

instance Prelude.Hashable ApplicationConfig where
  hashWithSalt :: Int -> ApplicationConfig -> Int
hashWithSalt Int
_salt ApplicationConfig' {Maybe Natural
Maybe Text
Maybe ApplicationConfigType
type' :: Maybe ApplicationConfigType
fPort :: Maybe Natural
destinationName :: Maybe Text
$sel:type':ApplicationConfig' :: ApplicationConfig -> Maybe ApplicationConfigType
$sel:fPort:ApplicationConfig' :: ApplicationConfig -> Maybe Natural
$sel:destinationName:ApplicationConfig' :: ApplicationConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
destinationName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
fPort
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ApplicationConfigType
type'

instance Prelude.NFData ApplicationConfig where
  rnf :: ApplicationConfig -> ()
rnf ApplicationConfig' {Maybe Natural
Maybe Text
Maybe ApplicationConfigType
type' :: Maybe ApplicationConfigType
fPort :: Maybe Natural
destinationName :: Maybe Text
$sel:type':ApplicationConfig' :: ApplicationConfig -> Maybe ApplicationConfigType
$sel:fPort:ApplicationConfig' :: ApplicationConfig -> Maybe Natural
$sel:destinationName:ApplicationConfig' :: ApplicationConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
destinationName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
fPort
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ApplicationConfigType
type'

instance Data.ToJSON ApplicationConfig where
  toJSON :: ApplicationConfig -> Value
toJSON ApplicationConfig' {Maybe Natural
Maybe Text
Maybe ApplicationConfigType
type' :: Maybe ApplicationConfigType
fPort :: Maybe Natural
destinationName :: Maybe Text
$sel:type':ApplicationConfig' :: ApplicationConfig -> Maybe ApplicationConfigType
$sel:fPort:ApplicationConfig' :: ApplicationConfig -> Maybe Natural
$sel:destinationName:ApplicationConfig' :: ApplicationConfig -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DestinationName" 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 Text
destinationName,
            (Key
"FPort" 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 Natural
fPort,
            (Key
"Type" 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 ApplicationConfigType
type'
          ]
      )