{-# 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.OtaaV1_1
-- 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.OtaaV1_1 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

-- | OTAA device object for v1.1
--
-- /See:/ 'newOtaaV1_1' smart constructor.
data OtaaV1_1 = OtaaV1_1'
  { -- | The AppKey value.
    OtaaV1_1 -> Maybe Text
appKey :: Prelude.Maybe Prelude.Text,
    -- | The JoinEUI value.
    OtaaV1_1 -> Maybe Text
joinEui :: Prelude.Maybe Prelude.Text,
    -- | The NwkKey value.
    OtaaV1_1 -> Maybe Text
nwkKey :: Prelude.Maybe Prelude.Text
  }
  deriving (OtaaV1_1 -> OtaaV1_1 -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OtaaV1_1 -> OtaaV1_1 -> Bool
$c/= :: OtaaV1_1 -> OtaaV1_1 -> Bool
== :: OtaaV1_1 -> OtaaV1_1 -> Bool
$c== :: OtaaV1_1 -> OtaaV1_1 -> Bool
Prelude.Eq, ReadPrec [OtaaV1_1]
ReadPrec OtaaV1_1
Int -> ReadS OtaaV1_1
ReadS [OtaaV1_1]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OtaaV1_1]
$creadListPrec :: ReadPrec [OtaaV1_1]
readPrec :: ReadPrec OtaaV1_1
$creadPrec :: ReadPrec OtaaV1_1
readList :: ReadS [OtaaV1_1]
$creadList :: ReadS [OtaaV1_1]
readsPrec :: Int -> ReadS OtaaV1_1
$creadsPrec :: Int -> ReadS OtaaV1_1
Prelude.Read, Int -> OtaaV1_1 -> ShowS
[OtaaV1_1] -> ShowS
OtaaV1_1 -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OtaaV1_1] -> ShowS
$cshowList :: [OtaaV1_1] -> ShowS
show :: OtaaV1_1 -> String
$cshow :: OtaaV1_1 -> String
showsPrec :: Int -> OtaaV1_1 -> ShowS
$cshowsPrec :: Int -> OtaaV1_1 -> ShowS
Prelude.Show, forall x. Rep OtaaV1_1 x -> OtaaV1_1
forall x. OtaaV1_1 -> Rep OtaaV1_1 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OtaaV1_1 x -> OtaaV1_1
$cfrom :: forall x. OtaaV1_1 -> Rep OtaaV1_1 x
Prelude.Generic)

-- |
-- Create a value of 'OtaaV1_1' 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:
--
-- 'appKey', 'otaaV1_1_appKey' - The AppKey value.
--
-- 'joinEui', 'otaaV1_1_joinEui' - The JoinEUI value.
--
-- 'nwkKey', 'otaaV1_1_nwkKey' - The NwkKey value.
newOtaaV1_1 ::
  OtaaV1_1
newOtaaV1_1 :: OtaaV1_1
newOtaaV1_1 =
  OtaaV1_1'
    { $sel:appKey:OtaaV1_1' :: Maybe Text
appKey = forall a. Maybe a
Prelude.Nothing,
      $sel:joinEui:OtaaV1_1' :: Maybe Text
joinEui = forall a. Maybe a
Prelude.Nothing,
      $sel:nwkKey:OtaaV1_1' :: Maybe Text
nwkKey = forall a. Maybe a
Prelude.Nothing
    }

-- | The AppKey value.
otaaV1_1_appKey :: Lens.Lens' OtaaV1_1 (Prelude.Maybe Prelude.Text)
otaaV1_1_appKey :: Lens' OtaaV1_1 (Maybe Text)
otaaV1_1_appKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OtaaV1_1' {Maybe Text
appKey :: Maybe Text
$sel:appKey:OtaaV1_1' :: OtaaV1_1 -> Maybe Text
appKey} -> Maybe Text
appKey) (\s :: OtaaV1_1
s@OtaaV1_1' {} Maybe Text
a -> OtaaV1_1
s {$sel:appKey:OtaaV1_1' :: Maybe Text
appKey = Maybe Text
a} :: OtaaV1_1)

-- | The JoinEUI value.
otaaV1_1_joinEui :: Lens.Lens' OtaaV1_1 (Prelude.Maybe Prelude.Text)
otaaV1_1_joinEui :: Lens' OtaaV1_1 (Maybe Text)
otaaV1_1_joinEui = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OtaaV1_1' {Maybe Text
joinEui :: Maybe Text
$sel:joinEui:OtaaV1_1' :: OtaaV1_1 -> Maybe Text
joinEui} -> Maybe Text
joinEui) (\s :: OtaaV1_1
s@OtaaV1_1' {} Maybe Text
a -> OtaaV1_1
s {$sel:joinEui:OtaaV1_1' :: Maybe Text
joinEui = Maybe Text
a} :: OtaaV1_1)

-- | The NwkKey value.
otaaV1_1_nwkKey :: Lens.Lens' OtaaV1_1 (Prelude.Maybe Prelude.Text)
otaaV1_1_nwkKey :: Lens' OtaaV1_1 (Maybe Text)
otaaV1_1_nwkKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OtaaV1_1' {Maybe Text
nwkKey :: Maybe Text
$sel:nwkKey:OtaaV1_1' :: OtaaV1_1 -> Maybe Text
nwkKey} -> Maybe Text
nwkKey) (\s :: OtaaV1_1
s@OtaaV1_1' {} Maybe Text
a -> OtaaV1_1
s {$sel:nwkKey:OtaaV1_1' :: Maybe Text
nwkKey = Maybe Text
a} :: OtaaV1_1)

instance Data.FromJSON OtaaV1_1 where
  parseJSON :: Value -> Parser OtaaV1_1
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"OtaaV1_1"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> OtaaV1_1
OtaaV1_1'
            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
"AppKey")
            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
"JoinEui")
            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
"NwkKey")
      )

instance Prelude.Hashable OtaaV1_1 where
  hashWithSalt :: Int -> OtaaV1_1 -> Int
hashWithSalt Int
_salt OtaaV1_1' {Maybe Text
nwkKey :: Maybe Text
joinEui :: Maybe Text
appKey :: Maybe Text
$sel:nwkKey:OtaaV1_1' :: OtaaV1_1 -> Maybe Text
$sel:joinEui:OtaaV1_1' :: OtaaV1_1 -> Maybe Text
$sel:appKey:OtaaV1_1' :: OtaaV1_1 -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
appKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
joinEui
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nwkKey

instance Prelude.NFData OtaaV1_1 where
  rnf :: OtaaV1_1 -> ()
rnf OtaaV1_1' {Maybe Text
nwkKey :: Maybe Text
joinEui :: Maybe Text
appKey :: Maybe Text
$sel:nwkKey:OtaaV1_1' :: OtaaV1_1 -> Maybe Text
$sel:joinEui:OtaaV1_1' :: OtaaV1_1 -> Maybe Text
$sel:appKey:OtaaV1_1' :: OtaaV1_1 -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
appKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
joinEui
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nwkKey

instance Data.ToJSON OtaaV1_1 where
  toJSON :: OtaaV1_1 -> Value
toJSON OtaaV1_1' {Maybe Text
nwkKey :: Maybe Text
joinEui :: Maybe Text
appKey :: Maybe Text
$sel:nwkKey:OtaaV1_1' :: OtaaV1_1 -> Maybe Text
$sel:joinEui:OtaaV1_1' :: OtaaV1_1 -> Maybe Text
$sel:appKey:OtaaV1_1' :: OtaaV1_1 -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AppKey" 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
appKey,
            (Key
"JoinEui" 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
joinEui,
            (Key
"NwkKey" 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
nwkKey
          ]
      )