module TD.Data.LogVerbosityLevel
(LogVerbosityLevel(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data LogVerbosityLevel
= LogVerbosityLevel
{ LogVerbosityLevel -> Maybe Int
verbosity_level :: Maybe Int
}
deriving (LogVerbosityLevel -> LogVerbosityLevel -> Bool
(LogVerbosityLevel -> LogVerbosityLevel -> Bool)
-> (LogVerbosityLevel -> LogVerbosityLevel -> Bool)
-> Eq LogVerbosityLevel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LogVerbosityLevel -> LogVerbosityLevel -> Bool
== :: LogVerbosityLevel -> LogVerbosityLevel -> Bool
$c/= :: LogVerbosityLevel -> LogVerbosityLevel -> Bool
/= :: LogVerbosityLevel -> LogVerbosityLevel -> Bool
Eq, Int -> LogVerbosityLevel -> ShowS
[LogVerbosityLevel] -> ShowS
LogVerbosityLevel -> String
(Int -> LogVerbosityLevel -> ShowS)
-> (LogVerbosityLevel -> String)
-> ([LogVerbosityLevel] -> ShowS)
-> Show LogVerbosityLevel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LogVerbosityLevel -> ShowS
showsPrec :: Int -> LogVerbosityLevel -> ShowS
$cshow :: LogVerbosityLevel -> String
show :: LogVerbosityLevel -> String
$cshowList :: [LogVerbosityLevel] -> ShowS
showList :: [LogVerbosityLevel] -> ShowS
Show)
instance I.ShortShow LogVerbosityLevel where
shortShow :: LogVerbosityLevel -> String
shortShow LogVerbosityLevel
{ verbosity_level :: LogVerbosityLevel -> Maybe Int
verbosity_level = Maybe Int
verbosity_level_
}
= String
"LogVerbosityLevel"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"verbosity_level" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
verbosity_level_
]
instance AT.FromJSON LogVerbosityLevel where
parseJSON :: Value -> Parser LogVerbosityLevel
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
"logVerbosityLevel" -> Value -> Parser LogVerbosityLevel
parseLogVerbosityLevel Value
v
String
_ -> Parser LogVerbosityLevel
forall a. Monoid a => a
mempty
where
parseLogVerbosityLevel :: A.Value -> AT.Parser LogVerbosityLevel
parseLogVerbosityLevel :: Value -> Parser LogVerbosityLevel
parseLogVerbosityLevel = String
-> (Object -> Parser LogVerbosityLevel)
-> Value
-> Parser LogVerbosityLevel
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"LogVerbosityLevel" ((Object -> Parser LogVerbosityLevel)
-> Value -> Parser LogVerbosityLevel)
-> (Object -> Parser LogVerbosityLevel)
-> Value
-> Parser LogVerbosityLevel
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
verbosity_level_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"verbosity_level"
LogVerbosityLevel -> Parser LogVerbosityLevel
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (LogVerbosityLevel -> Parser LogVerbosityLevel)
-> LogVerbosityLevel -> Parser LogVerbosityLevel
forall a b. (a -> b) -> a -> b
$ LogVerbosityLevel
{ verbosity_level :: Maybe Int
verbosity_level = Maybe Int
verbosity_level_
}
parseJSON Value
_ = Parser LogVerbosityLevel
forall a. Monoid a => a
mempty