{-# 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.UserProperty 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
data UserProperty = UserProperty'
{
UserProperty -> Text
key :: Prelude.Text,
UserProperty -> Text
value :: Prelude.Text
}
deriving (UserProperty -> UserProperty -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserProperty -> UserProperty -> Bool
$c/= :: UserProperty -> UserProperty -> Bool
== :: UserProperty -> UserProperty -> Bool
$c== :: UserProperty -> UserProperty -> Bool
Prelude.Eq, ReadPrec [UserProperty]
ReadPrec UserProperty
Int -> ReadS UserProperty
ReadS [UserProperty]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserProperty]
$creadListPrec :: ReadPrec [UserProperty]
readPrec :: ReadPrec UserProperty
$creadPrec :: ReadPrec UserProperty
readList :: ReadS [UserProperty]
$creadList :: ReadS [UserProperty]
readsPrec :: Int -> ReadS UserProperty
$creadsPrec :: Int -> ReadS UserProperty
Prelude.Read, Int -> UserProperty -> ShowS
[UserProperty] -> ShowS
UserProperty -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserProperty] -> ShowS
$cshowList :: [UserProperty] -> ShowS
show :: UserProperty -> String
$cshow :: UserProperty -> String
showsPrec :: Int -> UserProperty -> ShowS
$cshowsPrec :: Int -> UserProperty -> ShowS
Prelude.Show, forall x. Rep UserProperty x -> UserProperty
forall x. UserProperty -> Rep UserProperty x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserProperty x -> UserProperty
$cfrom :: forall x. UserProperty -> Rep UserProperty x
Prelude.Generic)
newUserProperty ::
Prelude.Text ->
Prelude.Text ->
UserProperty
newUserProperty :: Text -> Text -> UserProperty
newUserProperty Text
pKey_ Text
pValue_ =
UserProperty' {$sel:key:UserProperty' :: Text
key = Text
pKey_, $sel:value:UserProperty' :: Text
value = Text
pValue_}
userProperty_key :: Lens.Lens' UserProperty Prelude.Text
userProperty_key :: Lens' UserProperty Text
userProperty_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserProperty' {Text
key :: Text
$sel:key:UserProperty' :: UserProperty -> Text
key} -> Text
key) (\s :: UserProperty
s@UserProperty' {} Text
a -> UserProperty
s {$sel:key:UserProperty' :: Text
key = Text
a} :: UserProperty)
userProperty_value :: Lens.Lens' UserProperty Prelude.Text
userProperty_value :: Lens' UserProperty Text
userProperty_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserProperty' {Text
value :: Text
$sel:value:UserProperty' :: UserProperty -> Text
value} -> Text
value) (\s :: UserProperty
s@UserProperty' {} Text
a -> UserProperty
s {$sel:value:UserProperty' :: Text
value = Text
a} :: UserProperty)
instance Data.FromJSON UserProperty where
parseJSON :: Value -> Parser UserProperty
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"UserProperty"
( \Object
x ->
Text -> Text -> UserProperty
UserProperty'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"key")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"value")
)
instance Prelude.Hashable UserProperty where
hashWithSalt :: Int -> UserProperty -> Int
hashWithSalt Int
_salt UserProperty' {Text
value :: Text
key :: Text
$sel:value:UserProperty' :: UserProperty -> Text
$sel:key:UserProperty' :: UserProperty -> Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
key
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value
instance Prelude.NFData UserProperty where
rnf :: UserProperty -> ()
rnf UserProperty' {Text
value :: Text
key :: Text
$sel:value:UserProperty' :: UserProperty -> Text
$sel:key:UserProperty' :: UserProperty -> Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Text
key seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
value
instance Data.ToJSON UserProperty where
toJSON :: UserProperty -> Value
toJSON UserProperty' {Text
value :: Text
key :: Text
$sel:value:UserProperty' :: UserProperty -> Text
$sel:key:UserProperty' :: UserProperty -> Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just (Key
"key" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
key),
forall a. a -> Maybe a
Prelude.Just (Key
"value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
value)
]
)