{-# 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_0_x
-- 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_0_x where

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

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

-- |
-- Create a value of 'OtaaV1_0_x' 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:
--
-- 'appEui', 'otaaV1_0_x_appEui' - The AppEUI value.
--
-- 'appKey', 'otaaV1_0_x_appKey' - The AppKey value.
newOtaaV1_0_x ::
  OtaaV1_0_x
newOtaaV1_0_x :: OtaaV1_0_x
newOtaaV1_0_x =
  OtaaV1_0_x' :: Maybe Text -> Maybe Text -> OtaaV1_0_x
OtaaV1_0_x'
    { $sel:appEui:OtaaV1_0_x' :: Maybe Text
appEui = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:appKey:OtaaV1_0_x' :: Maybe Text
appKey = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The AppEUI value.
otaaV1_0_x_appEui :: Lens.Lens' OtaaV1_0_x (Prelude.Maybe Prelude.Text)
otaaV1_0_x_appEui :: (Maybe Text -> f (Maybe Text)) -> OtaaV1_0_x -> f OtaaV1_0_x
otaaV1_0_x_appEui = (OtaaV1_0_x -> Maybe Text)
-> (OtaaV1_0_x -> Maybe Text -> OtaaV1_0_x)
-> Lens OtaaV1_0_x OtaaV1_0_x (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OtaaV1_0_x' {Maybe Text
appEui :: Maybe Text
$sel:appEui:OtaaV1_0_x' :: OtaaV1_0_x -> Maybe Text
appEui} -> Maybe Text
appEui) (\s :: OtaaV1_0_x
s@OtaaV1_0_x' {} Maybe Text
a -> OtaaV1_0_x
s {$sel:appEui:OtaaV1_0_x' :: Maybe Text
appEui = Maybe Text
a} :: OtaaV1_0_x)

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

instance Core.FromJSON OtaaV1_0_x where
  parseJSON :: Value -> Parser OtaaV1_0_x
parseJSON =
    String
-> (Object -> Parser OtaaV1_0_x) -> Value -> Parser OtaaV1_0_x
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"OtaaV1_0_x"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> OtaaV1_0_x
OtaaV1_0_x'
            (Maybe Text -> Maybe Text -> OtaaV1_0_x)
-> Parser (Maybe Text) -> Parser (Maybe Text -> OtaaV1_0_x)
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
"AppEui")
            Parser (Maybe Text -> OtaaV1_0_x)
-> Parser (Maybe Text) -> Parser OtaaV1_0_x
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_0_x

instance Prelude.NFData OtaaV1_0_x

instance Core.ToJSON OtaaV1_0_x where
  toJSON :: OtaaV1_0_x -> Value
toJSON OtaaV1_0_x' {Maybe Text
appKey :: Maybe Text
appEui :: Maybe Text
$sel:appKey:OtaaV1_0_x' :: OtaaV1_0_x -> Maybe Text
$sel:appEui:OtaaV1_0_x' :: OtaaV1_0_x -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AppEui" 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
appEui,
            (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
          ]
      )