{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoTWireless.Types.OtaaV1_1 where

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

-- | OTAA device object for v1.1
--
-- /See:/ 'newOtaaV1_1' smart constructor.
data OtaaV1_1 = OtaaV1_1'
  { -- | The JoinEUI value.
    OtaaV1_1 -> Maybe Text
joinEui :: Prelude.Maybe Prelude.Text,
    -- | The NwkKey value.
    OtaaV1_1 -> Maybe Text
nwkKey :: Prelude.Maybe Prelude.Text,
    -- | The AppKey value.
    OtaaV1_1 -> Maybe Text
appKey :: Prelude.Maybe Prelude.Text
  }
  deriving (OtaaV1_1 -> OtaaV1_1 -> Bool
(OtaaV1_1 -> OtaaV1_1 -> Bool)
-> (OtaaV1_1 -> OtaaV1_1 -> Bool) -> Eq OtaaV1_1
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]
(Int -> ReadS OtaaV1_1)
-> ReadS [OtaaV1_1]
-> ReadPrec OtaaV1_1
-> ReadPrec [OtaaV1_1]
-> Read 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
(Int -> OtaaV1_1 -> ShowS)
-> (OtaaV1_1 -> String) -> ([OtaaV1_1] -> ShowS) -> Show OtaaV1_1
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. OtaaV1_1 -> Rep OtaaV1_1 x)
-> (forall x. Rep OtaaV1_1 x -> OtaaV1_1) -> Generic OtaaV1_1
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:
--
-- 'joinEui', 'otaaV1_1_joinEui' - The JoinEUI value.
--
-- 'nwkKey', 'otaaV1_1_nwkKey' - The NwkKey value.
--
-- 'appKey', 'otaaV1_1_appKey' - The AppKey value.
newOtaaV1_1 ::
  OtaaV1_1
newOtaaV1_1 :: OtaaV1_1
newOtaaV1_1 =
  OtaaV1_1' :: Maybe Text -> Maybe Text -> Maybe Text -> OtaaV1_1
OtaaV1_1'
    { $sel:joinEui:OtaaV1_1' :: Maybe Text
joinEui = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nwkKey:OtaaV1_1' :: Maybe Text
nwkKey = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:appKey:OtaaV1_1' :: Maybe Text
appKey = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The JoinEUI value.
otaaV1_1_joinEui :: Lens.Lens' OtaaV1_1 (Prelude.Maybe Prelude.Text)
otaaV1_1_joinEui :: (Maybe Text -> f (Maybe Text)) -> OtaaV1_1 -> f OtaaV1_1
otaaV1_1_joinEui = (OtaaV1_1 -> Maybe Text)
-> (OtaaV1_1 -> Maybe Text -> OtaaV1_1)
-> Lens OtaaV1_1 OtaaV1_1 (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> OtaaV1_1 -> f OtaaV1_1
otaaV1_1_nwkKey = (OtaaV1_1 -> Maybe Text)
-> (OtaaV1_1 -> Maybe Text -> OtaaV1_1)
-> Lens OtaaV1_1 OtaaV1_1 (Maybe Text) (Maybe Text)
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)

-- | The AppKey value.
otaaV1_1_appKey :: Lens.Lens' OtaaV1_1 (Prelude.Maybe Prelude.Text)
otaaV1_1_appKey :: (Maybe Text -> f (Maybe Text)) -> OtaaV1_1 -> f OtaaV1_1
otaaV1_1_appKey = (OtaaV1_1 -> Maybe Text)
-> (OtaaV1_1 -> Maybe Text -> OtaaV1_1)
-> Lens OtaaV1_1 OtaaV1_1 (Maybe Text) (Maybe Text)
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)

instance Core.FromJSON OtaaV1_1 where
  parseJSON :: Value -> Parser OtaaV1_1
parseJSON =
    String -> (Object -> Parser OtaaV1_1) -> Value -> Parser OtaaV1_1
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"OtaaV1_1"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> OtaaV1_1
OtaaV1_1'
            (Maybe Text -> Maybe Text -> Maybe Text -> OtaaV1_1)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> OtaaV1_1)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"JoinEui")
            Parser (Maybe Text -> Maybe Text -> OtaaV1_1)
-> Parser (Maybe Text) -> Parser (Maybe Text -> OtaaV1_1)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NwkKey")
            Parser (Maybe Text -> OtaaV1_1)
-> Parser (Maybe Text) -> Parser OtaaV1_1
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AppKey")
      )

instance Prelude.Hashable OtaaV1_1

instance Prelude.NFData OtaaV1_1

instance Core.ToJSON OtaaV1_1 where
  toJSON :: OtaaV1_1 -> Value
toJSON OtaaV1_1' {Maybe Text
appKey :: Maybe Text
nwkKey :: Maybe Text
joinEui :: Maybe Text
$sel:appKey:OtaaV1_1' :: OtaaV1_1 -> Maybe Text
$sel:nwkKey:OtaaV1_1' :: OtaaV1_1 -> Maybe Text
$sel:joinEui:OtaaV1_1' :: OtaaV1_1 -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"JoinEui" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
joinEui,
            (Text
"NwkKey" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nwkKey,
            (Text
"AppKey" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
appKey
          ]
      )