{-# 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 #-}
module Amazonka.IoT.Types.MqttContext where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data MqttContext = MqttContext'
{
MqttContext -> Maybe Text
clientId :: Prelude.Maybe Prelude.Text,
MqttContext -> Maybe Text
username :: Prelude.Maybe Prelude.Text,
MqttContext -> Maybe Base64
password :: Prelude.Maybe Core.Base64
}
deriving (MqttContext -> MqttContext -> Bool
(MqttContext -> MqttContext -> Bool)
-> (MqttContext -> MqttContext -> Bool) -> Eq MqttContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MqttContext -> MqttContext -> Bool
$c/= :: MqttContext -> MqttContext -> Bool
== :: MqttContext -> MqttContext -> Bool
$c== :: MqttContext -> MqttContext -> Bool
Prelude.Eq, ReadPrec [MqttContext]
ReadPrec MqttContext
Int -> ReadS MqttContext
ReadS [MqttContext]
(Int -> ReadS MqttContext)
-> ReadS [MqttContext]
-> ReadPrec MqttContext
-> ReadPrec [MqttContext]
-> Read MqttContext
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MqttContext]
$creadListPrec :: ReadPrec [MqttContext]
readPrec :: ReadPrec MqttContext
$creadPrec :: ReadPrec MqttContext
readList :: ReadS [MqttContext]
$creadList :: ReadS [MqttContext]
readsPrec :: Int -> ReadS MqttContext
$creadsPrec :: Int -> ReadS MqttContext
Prelude.Read, Int -> MqttContext -> ShowS
[MqttContext] -> ShowS
MqttContext -> String
(Int -> MqttContext -> ShowS)
-> (MqttContext -> String)
-> ([MqttContext] -> ShowS)
-> Show MqttContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MqttContext] -> ShowS
$cshowList :: [MqttContext] -> ShowS
show :: MqttContext -> String
$cshow :: MqttContext -> String
showsPrec :: Int -> MqttContext -> ShowS
$cshowsPrec :: Int -> MqttContext -> ShowS
Prelude.Show, (forall x. MqttContext -> Rep MqttContext x)
-> (forall x. Rep MqttContext x -> MqttContext)
-> Generic MqttContext
forall x. Rep MqttContext x -> MqttContext
forall x. MqttContext -> Rep MqttContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MqttContext x -> MqttContext
$cfrom :: forall x. MqttContext -> Rep MqttContext x
Prelude.Generic)
newMqttContext ::
MqttContext
newMqttContext :: MqttContext
newMqttContext =
MqttContext' :: Maybe Text -> Maybe Text -> Maybe Base64 -> MqttContext
MqttContext'
{ $sel:clientId:MqttContext' :: Maybe Text
clientId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:username:MqttContext' :: Maybe Text
username = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:password:MqttContext' :: Maybe Base64
password = Maybe Base64
forall a. Maybe a
Prelude.Nothing
}
mqttContext_clientId :: Lens.Lens' MqttContext (Prelude.Maybe Prelude.Text)
mqttContext_clientId :: (Maybe Text -> f (Maybe Text)) -> MqttContext -> f MqttContext
mqttContext_clientId = (MqttContext -> Maybe Text)
-> (MqttContext -> Maybe Text -> MqttContext)
-> Lens MqttContext MqttContext (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MqttContext' {Maybe Text
clientId :: Maybe Text
$sel:clientId:MqttContext' :: MqttContext -> Maybe Text
clientId} -> Maybe Text
clientId) (\s :: MqttContext
s@MqttContext' {} Maybe Text
a -> MqttContext
s {$sel:clientId:MqttContext' :: Maybe Text
clientId = Maybe Text
a} :: MqttContext)
mqttContext_username :: Lens.Lens' MqttContext (Prelude.Maybe Prelude.Text)
mqttContext_username :: (Maybe Text -> f (Maybe Text)) -> MqttContext -> f MqttContext
mqttContext_username = (MqttContext -> Maybe Text)
-> (MqttContext -> Maybe Text -> MqttContext)
-> Lens MqttContext MqttContext (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MqttContext' {Maybe Text
username :: Maybe Text
$sel:username:MqttContext' :: MqttContext -> Maybe Text
username} -> Maybe Text
username) (\s :: MqttContext
s@MqttContext' {} Maybe Text
a -> MqttContext
s {$sel:username:MqttContext' :: Maybe Text
username = Maybe Text
a} :: MqttContext)
mqttContext_password :: Lens.Lens' MqttContext (Prelude.Maybe Prelude.ByteString)
mqttContext_password :: (Maybe ByteString -> f (Maybe ByteString))
-> MqttContext -> f MqttContext
mqttContext_password = (MqttContext -> Maybe Base64)
-> (MqttContext -> Maybe Base64 -> MqttContext)
-> Lens MqttContext MqttContext (Maybe Base64) (Maybe Base64)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MqttContext' {Maybe Base64
password :: Maybe Base64
$sel:password:MqttContext' :: MqttContext -> Maybe Base64
password} -> Maybe Base64
password) (\s :: MqttContext
s@MqttContext' {} Maybe Base64
a -> MqttContext
s {$sel:password:MqttContext' :: Maybe Base64
password = Maybe Base64
a} :: MqttContext) ((Maybe Base64 -> f (Maybe Base64))
-> MqttContext -> f MqttContext)
-> ((Maybe ByteString -> f (Maybe ByteString))
-> Maybe Base64 -> f (Maybe Base64))
-> (Maybe ByteString -> f (Maybe ByteString))
-> MqttContext
-> f MqttContext
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso Base64 Base64 ByteString ByteString
-> Iso
(Maybe Base64) (Maybe Base64) (Maybe ByteString) (Maybe ByteString)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso Base64 Base64 ByteString ByteString
Iso' Base64 ByteString
Core._Base64
instance Prelude.Hashable MqttContext
instance Prelude.NFData MqttContext
instance Core.ToJSON MqttContext where
toJSON :: MqttContext -> Value
toJSON MqttContext' {Maybe Text
Maybe Base64
password :: Maybe Base64
username :: Maybe Text
clientId :: Maybe Text
$sel:password:MqttContext' :: MqttContext -> Maybe Base64
$sel:username:MqttContext' :: MqttContext -> Maybe Text
$sel:clientId:MqttContext' :: MqttContext -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"clientId" 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
clientId,
(Text
"username" 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
username,
(Text
"password" Text -> Base64 -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Base64 -> Pair) -> Maybe Base64 -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Base64
password
]
)