module TD.Data.DatabaseStatistics
(DatabaseStatistics(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified Data.Text as T
data DatabaseStatistics
= DatabaseStatistics
{ DatabaseStatistics -> Maybe Text
statistics :: Maybe T.Text
}
deriving (DatabaseStatistics -> DatabaseStatistics -> Bool
(DatabaseStatistics -> DatabaseStatistics -> Bool)
-> (DatabaseStatistics -> DatabaseStatistics -> Bool)
-> Eq DatabaseStatistics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DatabaseStatistics -> DatabaseStatistics -> Bool
== :: DatabaseStatistics -> DatabaseStatistics -> Bool
$c/= :: DatabaseStatistics -> DatabaseStatistics -> Bool
/= :: DatabaseStatistics -> DatabaseStatistics -> Bool
Eq, Int -> DatabaseStatistics -> ShowS
[DatabaseStatistics] -> ShowS
DatabaseStatistics -> String
(Int -> DatabaseStatistics -> ShowS)
-> (DatabaseStatistics -> String)
-> ([DatabaseStatistics] -> ShowS)
-> Show DatabaseStatistics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DatabaseStatistics -> ShowS
showsPrec :: Int -> DatabaseStatistics -> ShowS
$cshow :: DatabaseStatistics -> String
show :: DatabaseStatistics -> String
$cshowList :: [DatabaseStatistics] -> ShowS
showList :: [DatabaseStatistics] -> ShowS
Show)
instance I.ShortShow DatabaseStatistics where
shortShow :: DatabaseStatistics -> String
shortShow DatabaseStatistics
{ statistics :: DatabaseStatistics -> Maybe Text
statistics = Maybe Text
statistics_
}
= String
"DatabaseStatistics"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"statistics" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
statistics_
]
instance AT.FromJSON DatabaseStatistics where
parseJSON :: Value -> Parser DatabaseStatistics
parseJSON v :: Value
v@(AT.Object Object
obj) = do
String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String
case String
t of
String
"databaseStatistics" -> Value -> Parser DatabaseStatistics
parseDatabaseStatistics Value
v
String
_ -> Parser DatabaseStatistics
forall a. Monoid a => a
mempty
where
parseDatabaseStatistics :: A.Value -> AT.Parser DatabaseStatistics
parseDatabaseStatistics :: Value -> Parser DatabaseStatistics
parseDatabaseStatistics = String
-> (Object -> Parser DatabaseStatistics)
-> Value
-> Parser DatabaseStatistics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"DatabaseStatistics" ((Object -> Parser DatabaseStatistics)
-> Value -> Parser DatabaseStatistics)
-> (Object -> Parser DatabaseStatistics)
-> Value
-> Parser DatabaseStatistics
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
statistics_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"statistics"
DatabaseStatistics -> Parser DatabaseStatistics
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DatabaseStatistics -> Parser DatabaseStatistics)
-> DatabaseStatistics -> Parser DatabaseStatistics
forall a b. (a -> b) -> a -> b
$ DatabaseStatistics
{ statistics :: Maybe Text
statistics = Maybe Text
statistics_
}
parseJSON Value
_ = Parser DatabaseStatistics
forall a. Monoid a => a
mempty