{-# 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.Grafana.Types.User where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Grafana.Types.UserType
import qualified Amazonka.Prelude as Prelude
data User = User'
{
User -> Text
id :: Prelude.Text,
User -> UserType
type' :: UserType
}
deriving (User -> User -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: User -> User -> Bool
$c/= :: User -> User -> Bool
== :: User -> User -> Bool
$c== :: User -> User -> Bool
Prelude.Eq, ReadPrec [User]
ReadPrec User
Int -> ReadS User
ReadS [User]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [User]
$creadListPrec :: ReadPrec [User]
readPrec :: ReadPrec User
$creadPrec :: ReadPrec User
readList :: ReadS [User]
$creadList :: ReadS [User]
readsPrec :: Int -> ReadS User
$creadsPrec :: Int -> ReadS User
Prelude.Read, Int -> User -> ShowS
[User] -> ShowS
User -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [User] -> ShowS
$cshowList :: [User] -> ShowS
show :: User -> String
$cshow :: User -> String
showsPrec :: Int -> User -> ShowS
$cshowsPrec :: Int -> User -> ShowS
Prelude.Show, forall x. Rep User x -> User
forall x. User -> Rep User x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep User x -> User
$cfrom :: forall x. User -> Rep User x
Prelude.Generic)
newUser ::
Prelude.Text ->
UserType ->
User
newUser :: Text -> UserType -> User
newUser Text
pId_ UserType
pType_ =
User' {$sel:id:User' :: Text
id = Text
pId_, $sel:type':User' :: UserType
type' = UserType
pType_}
user_id :: Lens.Lens' User Prelude.Text
user_id :: Lens' User Text
user_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\User' {Text
id :: Text
$sel:id:User' :: User -> Text
id} -> Text
id) (\s :: User
s@User' {} Text
a -> User
s {$sel:id:User' :: Text
id = Text
a} :: User)
user_type :: Lens.Lens' User UserType
user_type :: Lens' User UserType
user_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\User' {UserType
type' :: UserType
$sel:type':User' :: User -> UserType
type'} -> UserType
type') (\s :: User
s@User' {} UserType
a -> User
s {$sel:type':User' :: UserType
type' = UserType
a} :: User)
instance Data.FromJSON User where
parseJSON :: Value -> Parser User
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"User"
( \Object
x ->
Text -> UserType -> User
User'
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
"id")
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
"type")
)
instance Prelude.Hashable User where
hashWithSalt :: Int -> User -> Int
hashWithSalt Int
_salt User' {Text
UserType
type' :: UserType
id :: Text
$sel:type':User' :: User -> UserType
$sel:id:User' :: User -> Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` UserType
type'
instance Prelude.NFData User where
rnf :: User -> ()
rnf User' {Text
UserType
type' :: UserType
id :: Text
$sel:type':User' :: User -> UserType
$sel:id:User' :: User -> Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Text
id seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf UserType
type'
instance Data.ToJSON User where
toJSON :: User -> Value
toJSON User' {Text
UserType
type' :: UserType
id :: Text
$sel:type':User' :: User -> UserType
$sel:id:User' :: User -> Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just (Key
"id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id),
forall a. a -> Maybe a
Prelude.Just (Key
"type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= UserType
type')
]
)