Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Ganeti.JSON
Contents
Description
JSON utility functions.
Synopsis
- fromJResult :: (Monad m, MonadFail m) => String -> Result a -> m a
- fromJResultE :: (Error e, MonadError e m) => String -> Result a -> m a
- readJSONWithDesc :: JSON a => String -> JSValue -> Result a
- readEitherString :: MonadFail m => JSValue -> m String
- type JSRecord = [JSField]
- loadJSArray :: MonadFail m => String -> String -> m [JSObject JSValue]
- fromObj :: (JSON a, MonadFail m) => JSRecord -> String -> m a
- maybeFromObj :: (JSON a, MonadFail m) => JSRecord -> String -> m (Maybe a)
- fromObjWithDefault :: (JSON a, MonadFail m) => JSRecord -> String -> a -> m a
- fromKeyValue :: (JSON a, MonadFail m) => String -> JSValue -> m a
- fromJVal :: (Monad m, MonadFail m, JSON a) => JSValue -> m a
- fromJValE :: (Error e, MonadError e m, JSON a) => JSValue -> m a
- jsonHead :: JSON b => [a] -> (a -> b) -> JSValue
- getMaybeJsonHead :: JSON b => [a] -> (a -> Maybe b) -> JSValue
- getMaybeJsonElem :: JSON b => [a] -> Int -> (a -> Maybe b) -> JSValue
- asJSObject :: (Monad m, MonadFail m) => JSValue -> m (JSObject JSValue)
- asObjectList :: (Monad m, MonadFail m) => [JSValue] -> m [JSObject JSValue]
- tryFromObj :: JSON a => String -> JSRecord -> String -> Result a
- arrayMaybeFromJVal :: (JSON a, Monad m, MonadFail m) => JSValue -> m [Maybe a]
- tryArrayMaybeFromObj :: JSON a => String -> JSRecord -> String -> Result [Maybe a]
- toArray :: (Monad m, MonadFail m) => JSValue -> m [JSValue]
- optionalJSField :: JSON a => String -> Maybe a -> Maybe JSField
- optFieldsToObj :: [Maybe JSField] -> JSValue
- containerFromList :: Ord a => [(a, b)] -> GenericContainer a b
- lookupContainer :: (Monad m, Ord a) => m b -> a -> GenericContainer a b -> m b
- alterContainerL :: (Functor f, Ord a) => a -> (Maybe b -> f (Maybe b)) -> GenericContainer a b -> f (GenericContainer a b)
- readContainer :: (MonadFail m, HasStringRepr a, Ord a, JSON b) => JSObject JSValue -> m (GenericContainer a b)
- mkUsedKeys :: Set Text -> UsedKeys
- allUsedKeys :: UsedKeys
- class DictObject a where
- toDict :: a -> [(String, JSValue)]
- fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result a
- fromDict :: [(String, JSValue)] -> Result a
- showJSONtoDict :: DictObject a => a -> JSValue
- readJSONfromDict :: DictObject a => JSValue -> Result a
- class ArrayObject a where
- toJSArray :: a -> [JSValue]
- fromJSArray :: [JSValue] -> Result a
- class HasStringRepr a where
- fromStringRepr :: MonadFail m => String -> m a
- toStringRepr :: a -> String
- newtype GenericContainer a b = GenericContainer {
- fromContainer :: Map a b
- emptyContainer :: GenericContainer a b
- type Container = GenericContainer ByteString
- newtype MaybeForJSON a = MaybeForJSON {
- unMaybeForJSON :: Maybe a
- newtype TimeAsDoubleJSON = TimeAsDoubleJSON {
- unTimeAsDoubleJSON :: ClockTime
- newtype Tuple5 a b c d e = Tuple5 {
- unTuple5 :: (a, b, c, d, e)
- nestedAccessByKey :: [String] -> JSValue -> Result JSValue
- nestedAccessByKeyDotted :: String -> JSValue -> Result JSValue
- branchOnField :: String -> (JSValue -> Result a) -> (JSValue -> Result a) -> JSValue -> Result a
- addField :: (String, JSValue) -> JSValue -> JSValue
- maybeParseMap :: JSON a => JSValue -> Maybe (Map String a)
Documentation
fromJResult :: (Monad m, MonadFail m) => String -> Result a -> m a #
Converts a JSON Result into a monadic value.
fromJResultE :: (Error e, MonadError e m) => String -> Result a -> m a #
Converts a JSON Result into a MonadError value.
Arguments
:: JSON a | |
=> String | description of |
-> JSValue | input value |
-> Result a |
Annotate readJSON
error messages with descriptions of what
is being parsed into what.
readEitherString :: MonadFail m => JSValue -> m String #
Tries to read a string from a JSON value.
In case the value was not a string, we fail the read (in the context of the current monad.
Arguments
:: MonadFail m | |
=> String | Operation description (for error reporting) |
-> String | Input message |
-> m [JSObject JSValue] |
Converts a JSON message into an array of JSON objects.
fromObj :: (JSON a, MonadFail m) => JSRecord -> String -> m a #
Reads the value of a key in a JSON object.
maybeFromObj :: (JSON a, MonadFail m) => JSRecord -> String -> m (Maybe a) #
Reads the value of an optional key in a JSON object. Missing
keys, or keys that have a 'null' value, will be returned as
Nothing
, otherwise we attempt deserialisation and return a Just
value.
fromObjWithDefault :: (JSON a, MonadFail m) => JSRecord -> String -> a -> m a #
Reads the value of a key in a JSON object with a default if missing. Note that both missing keys and keys with value 'null' will cause the default value to be returned.
Arguments
:: (JSON a, MonadFail m) | |
=> String | The key name |
-> JSValue | The value to read |
-> m a |
Reads a JValue, that originated from an object key.
fromJValE :: (Error e, MonadError e m, JSON a) => JSValue -> m a #
Small wrapper over readJSON
for MonadError
.
jsonHead :: JSON b => [a] -> (a -> b) -> JSValue #
Helper function that returns Null or first element of the list.
getMaybeJsonHead :: JSON b => [a] -> (a -> Maybe b) -> JSValue #
Helper for extracting Maybe values from a possibly empty list.
getMaybeJsonElem :: JSON b => [a] -> Int -> (a -> Maybe b) -> JSValue #
Helper for extracting Maybe values from a list that might be too short.
asJSObject :: (Monad m, MonadFail m) => JSValue -> m (JSObject JSValue) #
Converts a JSON value into a JSON object.
asObjectList :: (Monad m, MonadFail m) => [JSValue] -> m [JSObject JSValue] #
Coneverts a list of JSON values into a list of JSON objects.
Arguments
:: JSON a | |
=> String | Textual "owner" in error messages |
-> JSRecord | The object array |
-> String | The desired key from the object |
-> Result a |
Try to extract a key from an object with better error reporting than fromObj.
arrayMaybeFromJVal :: (JSON a, Monad m, MonadFail m) => JSValue -> m [Maybe a] #
Arguments
:: JSON a | |
=> String | Textual "owner" in error messages |
-> JSRecord | The object array |
-> String | The desired key from the object |
-> Result [Maybe a] |
Wrapper for arrayMaybeFromObj with better diagnostic
toArray :: (Monad m, MonadFail m) => JSValue -> m [JSValue] #
Ensure a given JSValue is actually a JSArray.
optionalJSField :: JSON a => String -> Maybe a -> Maybe JSField #
Creates a Maybe JSField. If the value string is Nothing, the JSField will be Nothing as well.
optFieldsToObj :: [Maybe JSField] -> JSValue #
Creates an object with all the non-Nothing fields of the given list.
containerFromList :: Ord a => [(a, b)] -> GenericContainer a b #
Creates a GenericContainer from a list of key-value pairs.
lookupContainer :: (Monad m, Ord a) => m b -> a -> GenericContainer a b -> m b #
Looks up a value in a container with a default value.
If a key has no value, a given monadic default is returned.
This allows simple error handling, as the default can be
mzero
, failError
etc.
alterContainerL :: (Functor f, Ord a) => a -> (Maybe b -> f (Maybe b)) -> GenericContainer a b -> f (GenericContainer a b) #
Updates a value inside a container. The signature of the function is crafted so that it can be directly used as a lens.
readContainer :: (MonadFail m, HasStringRepr a, Ord a, JSON b) => JSObject JSValue -> m (GenericContainer a b) #
Container loader.
mkUsedKeys :: Set Text -> UsedKeys #
allUsedKeys :: UsedKeys #
class DictObject a where #
Class of objects that can be converted from and to JSObject
lists-format.
Minimal complete definition
Methods
toDict :: a -> [(String, JSValue)] #
fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result a #
Instances
DictObject ConfdReply # | |
Defined in Ganeti.Confd.Types Methods toDict :: ConfdReply -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result ConfdReply # fromDict :: [(String, JSValue)] -> Result ConfdReply # | |
DictObject ConfdReqQ # | |
Defined in Ganeti.Confd.Types | |
DictObject ConfdRequest # | |
Defined in Ganeti.Confd.Types Methods toDict :: ConfdRequest -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result ConfdRequest # fromDict :: [(String, JSValue)] -> Result ConfdRequest # | |
DictObject SignedMessage # | |
Defined in Ganeti.Confd.Types Methods toDict :: SignedMessage -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result SignedMessage # fromDict :: [(String, JSValue)] -> Result SignedMessage # | |
DictObject CPUavgload # | |
Defined in Ganeti.Cpu.Types Methods toDict :: CPUavgload -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result CPUavgload # fromDict :: [(String, JSValue)] -> Result CPUavgload # | |
DictObject CPUstat # | |
Defined in Ganeti.Cpu.Types | |
DictObject InstStatus # | |
Defined in Ganeti.DataCollectors.InstStatusTypes Methods toDict :: InstStatus -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result InstStatus # fromDict :: [(String, JSValue)] -> Result InstStatus # | |
DictObject ReportData # | |
Defined in Ganeti.DataCollectors.InstStatusTypes Methods toDict :: ReportData -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result ReportData # fromDict :: [(String, JSValue)] -> Result ReportData # | |
DictObject DCReport # | |
Defined in Ganeti.DataCollectors.Types | |
DictObject DCStatus # | |
Defined in Ganeti.DataCollectors.Types | |
DictObject IPolicy # | |
Defined in Ganeti.HTools.Types | |
DictObject ISpec # | |
Defined in Ganeti.HTools.Types | |
DictObject MinMaxISpecs # | |
Defined in Ganeti.HTools.Types Methods toDict :: MinMaxISpecs -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result MinMaxISpecs # fromDict :: [(String, JSValue)] -> Result MinMaxISpecs # | |
DictObject QueuedJob # | |
Defined in Ganeti.JQueue.Objects | |
DictObject QueuedOpCode # | |
Defined in Ganeti.JQueue.Objects Methods toDict :: QueuedOpCode -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result QueuedOpCode # fromDict :: [(String, JSValue)] -> Result QueuedOpCode # | |
DictObject LuxiOp # | |
Defined in Ganeti.Luxi | |
DictObject Cluster # | |
Defined in Ganeti.Objects | |
DictObject ConfigData # | |
Defined in Ganeti.Objects Methods toDict :: ConfigData -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result ConfigData # fromDict :: [(String, JSValue)] -> Result ConfigData # | |
DictObject DataCollectorConfig # | |
Defined in Ganeti.Objects Methods toDict :: DataCollectorConfig -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result DataCollectorConfig # fromDict :: [(String, JSValue)] -> Result DataCollectorConfig # | |
DictObject FilledIPolicy # | |
Defined in Ganeti.Objects Methods toDict :: FilledIPolicy -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result FilledIPolicy # fromDict :: [(String, JSValue)] -> Result FilledIPolicy # | |
DictObject FilledISpecParams # | |
Defined in Ganeti.Objects Methods toDict :: FilledISpecParams -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result FilledISpecParams # fromDict :: [(String, JSValue)] -> Result FilledISpecParams # | |
DictObject FilledNDParams # | |
Defined in Ganeti.Objects Methods toDict :: FilledNDParams -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result FilledNDParams # fromDict :: [(String, JSValue)] -> Result FilledNDParams # | |
DictObject FilterRule # | |
Defined in Ganeti.Objects Methods toDict :: FilterRule -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result FilterRule # fromDict :: [(String, JSValue)] -> Result FilterRule # | |
DictObject MasterNetworkParameters # | |
Defined in Ganeti.Objects Methods toDict :: MasterNetworkParameters -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result MasterNetworkParameters # fromDict :: [(String, JSValue)] -> Result MasterNetworkParameters # | |
DictObject MinMaxISpecs # | |
Defined in Ganeti.Objects Methods toDict :: MinMaxISpecs -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result MinMaxISpecs # fromDict :: [(String, JSValue)] -> Result MinMaxISpecs # | |
DictObject Network # | |
Defined in Ganeti.Objects | |
DictObject Node # | |
Defined in Ganeti.Objects | |
DictObject NodeGroup # | |
Defined in Ganeti.Objects | |
DictObject PartialIPolicy # | |
Defined in Ganeti.Objects Methods toDict :: PartialIPolicy -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result PartialIPolicy # fromDict :: [(String, JSValue)] -> Result PartialIPolicy # | |
DictObject PartialISpecParams # | |
Defined in Ganeti.Objects Methods toDict :: PartialISpecParams -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result PartialISpecParams # fromDict :: [(String, JSValue)] -> Result PartialISpecParams # | |
DictObject PartialNDParams # | |
Defined in Ganeti.Objects Methods toDict :: PartialNDParams -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result PartialNDParams # fromDict :: [(String, JSValue)] -> Result PartialNDParams # | |
DictObject Disk # | |
Defined in Ganeti.Objects.Disk | |
DictObject ForthcomingDiskData # | |
Defined in Ganeti.Objects.Disk Methods toDict :: ForthcomingDiskData -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result ForthcomingDiskData # fromDict :: [(String, JSValue)] -> Result ForthcomingDiskData # | |
DictObject RealDiskData # | |
Defined in Ganeti.Objects.Disk Methods toDict :: RealDiskData -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RealDiskData # fromDict :: [(String, JSValue)] -> Result RealDiskData # | |
DictObject FilledBeParams # | |
Defined in Ganeti.Objects.Instance Methods toDict :: FilledBeParams -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result FilledBeParams # fromDict :: [(String, JSValue)] -> Result FilledBeParams # | |
DictObject ForthcomingInstanceData # | |
Defined in Ganeti.Objects.Instance Methods toDict :: ForthcomingInstanceData -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result ForthcomingInstanceData # fromDict :: [(String, JSValue)] -> Result ForthcomingInstanceData # | |
DictObject Instance # | |
Defined in Ganeti.Objects.Instance | |
DictObject PartialBeParams # | |
Defined in Ganeti.Objects.Instance Methods toDict :: PartialBeParams -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result PartialBeParams # fromDict :: [(String, JSValue)] -> Result PartialBeParams # | |
DictObject RealInstanceData # | |
Defined in Ganeti.Objects.Instance Methods toDict :: RealInstanceData -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RealInstanceData # fromDict :: [(String, JSValue)] -> Result RealInstanceData # | |
DictObject FilledNicParams # | |
Defined in Ganeti.Objects.Nic Methods toDict :: FilledNicParams -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result FilledNicParams # fromDict :: [(String, JSValue)] -> Result FilledNicParams # | |
DictObject PartialNic # | |
Defined in Ganeti.Objects.Nic Methods toDict :: PartialNic -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result PartialNic # fromDict :: [(String, JSValue)] -> Result PartialNic # | |
DictObject PartialNicParams # | |
Defined in Ganeti.Objects.Nic Methods toDict :: PartialNicParams -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result PartialNicParams # fromDict :: [(String, JSValue)] -> Result PartialNicParams # | |
DictObject CommonOpParams # | |
Defined in Ganeti.OpCodes Methods toDict :: CommonOpParams -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result CommonOpParams # fromDict :: [(String, JSValue)] -> Result CommonOpParams # | |
DictObject MetaOpCode # | |
Defined in Ganeti.OpCodes Methods toDict :: MetaOpCode -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result MetaOpCode # fromDict :: [(String, JSValue)] -> Result MetaOpCode # | |
DictObject OpCode # | |
Defined in Ganeti.OpCodes | |
DictObject IDiskParams # | |
Defined in Ganeti.OpParams Methods toDict :: IDiskParams -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result IDiskParams # fromDict :: [(String, JSValue)] -> Result IDiskParams # | |
DictObject INicParams # | |
Defined in Ganeti.OpParams Methods toDict :: INicParams -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result INicParams # fromDict :: [(String, JSValue)] -> Result INicParams # | |
DictObject FieldDefinition # | |
Defined in Ganeti.Query.Language Methods toDict :: FieldDefinition -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result FieldDefinition # fromDict :: [(String, JSValue)] -> Result FieldDefinition # | |
DictObject QueryFieldsResult # | |
Defined in Ganeti.Query.Language Methods toDict :: QueryFieldsResult -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result QueryFieldsResult # fromDict :: [(String, JSValue)] -> Result QueryFieldsResult # | |
DictObject QueryResult # | |
Defined in Ganeti.Query.Language Methods toDict :: QueryResult -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result QueryResult # fromDict :: [(String, JSValue)] -> Result QueryResult # | |
DictObject HvInfo # | |
Defined in Ganeti.Rpc | |
DictObject InstanceConsoleInfo # | |
Defined in Ganeti.Rpc Methods toDict :: InstanceConsoleInfo -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result InstanceConsoleInfo # fromDict :: [(String, JSValue)] -> Result InstanceConsoleInfo # | |
DictObject InstanceConsoleInfoParams # | |
Defined in Ganeti.Rpc Methods toDict :: InstanceConsoleInfoParams -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result InstanceConsoleInfoParams # fromDict :: [(String, JSValue)] -> Result InstanceConsoleInfoParams # | |
DictObject InstanceInfo # | |
Defined in Ganeti.Rpc Methods toDict :: InstanceInfo -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result InstanceInfo # fromDict :: [(String, JSValue)] -> Result InstanceInfo # | |
DictObject RpcCallAllInstancesInfo # | |
Defined in Ganeti.Rpc Methods toDict :: RpcCallAllInstancesInfo -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcCallAllInstancesInfo # fromDict :: [(String, JSValue)] -> Result RpcCallAllInstancesInfo # | |
DictObject RpcCallExportList # | |
Defined in Ganeti.Rpc Methods toDict :: RpcCallExportList -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcCallExportList # fromDict :: [(String, JSValue)] -> Result RpcCallExportList # | |
DictObject RpcCallInstanceConsoleInfo # | |
Defined in Ganeti.Rpc Methods toDict :: RpcCallInstanceConsoleInfo -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcCallInstanceConsoleInfo # fromDict :: [(String, JSValue)] -> Result RpcCallInstanceConsoleInfo # | |
DictObject RpcCallInstanceInfo # | |
Defined in Ganeti.Rpc Methods toDict :: RpcCallInstanceInfo -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcCallInstanceInfo # fromDict :: [(String, JSValue)] -> Result RpcCallInstanceInfo # | |
DictObject RpcCallInstanceList # | |
Defined in Ganeti.Rpc Methods toDict :: RpcCallInstanceList -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcCallInstanceList # fromDict :: [(String, JSValue)] -> Result RpcCallInstanceList # | |
DictObject RpcCallJobqueueRename # | |
Defined in Ganeti.Rpc Methods toDict :: RpcCallJobqueueRename -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcCallJobqueueRename # fromDict :: [(String, JSValue)] -> Result RpcCallJobqueueRename # | |
DictObject RpcCallJobqueueUpdate # | |
Defined in Ganeti.Rpc Methods toDict :: RpcCallJobqueueUpdate -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcCallJobqueueUpdate # fromDict :: [(String, JSValue)] -> Result RpcCallJobqueueUpdate # | |
DictObject RpcCallMasterNodeName # | |
Defined in Ganeti.Rpc Methods toDict :: RpcCallMasterNodeName -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcCallMasterNodeName # fromDict :: [(String, JSValue)] -> Result RpcCallMasterNodeName # | |
DictObject RpcCallNodeActivateMasterIp # | |
Defined in Ganeti.Rpc Methods toDict :: RpcCallNodeActivateMasterIp -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcCallNodeActivateMasterIp # fromDict :: [(String, JSValue)] -> Result RpcCallNodeActivateMasterIp # | |
DictObject RpcCallNodeInfo # | |
Defined in Ganeti.Rpc Methods toDict :: RpcCallNodeInfo -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcCallNodeInfo # fromDict :: [(String, JSValue)] -> Result RpcCallNodeInfo # | |
DictObject RpcCallSetDrainFlag # | |
Defined in Ganeti.Rpc Methods toDict :: RpcCallSetDrainFlag -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcCallSetDrainFlag # fromDict :: [(String, JSValue)] -> Result RpcCallSetDrainFlag # | |
DictObject RpcCallSetWatcherPause # | |
Defined in Ganeti.Rpc Methods toDict :: RpcCallSetWatcherPause -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcCallSetWatcherPause # fromDict :: [(String, JSValue)] -> Result RpcCallSetWatcherPause # | |
DictObject RpcCallStorageList # | |
Defined in Ganeti.Rpc Methods toDict :: RpcCallStorageList -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcCallStorageList # fromDict :: [(String, JSValue)] -> Result RpcCallStorageList # | |
DictObject RpcCallTestDelay # | |
Defined in Ganeti.Rpc Methods toDict :: RpcCallTestDelay -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcCallTestDelay # fromDict :: [(String, JSValue)] -> Result RpcCallTestDelay # | |
DictObject RpcCallUploadFile # | |
Defined in Ganeti.Rpc Methods toDict :: RpcCallUploadFile -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcCallUploadFile # fromDict :: [(String, JSValue)] -> Result RpcCallUploadFile # | |
DictObject RpcCallVersion # | |
Defined in Ganeti.Rpc Methods toDict :: RpcCallVersion -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcCallVersion # fromDict :: [(String, JSValue)] -> Result RpcCallVersion # | |
DictObject RpcCallWriteSsconfFiles # | |
Defined in Ganeti.Rpc Methods toDict :: RpcCallWriteSsconfFiles -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcCallWriteSsconfFiles # fromDict :: [(String, JSValue)] -> Result RpcCallWriteSsconfFiles # | |
DictObject RpcResultAllInstancesInfo # | |
Defined in Ganeti.Rpc Methods toDict :: RpcResultAllInstancesInfo -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcResultAllInstancesInfo # fromDict :: [(String, JSValue)] -> Result RpcResultAllInstancesInfo # | |
DictObject RpcResultExportList # | |
Defined in Ganeti.Rpc Methods toDict :: RpcResultExportList -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcResultExportList # fromDict :: [(String, JSValue)] -> Result RpcResultExportList # | |
DictObject RpcResultInstanceConsoleInfo # | |
Defined in Ganeti.Rpc Methods toDict :: RpcResultInstanceConsoleInfo -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcResultInstanceConsoleInfo # fromDict :: [(String, JSValue)] -> Result RpcResultInstanceConsoleInfo # | |
DictObject RpcResultInstanceInfo # | |
Defined in Ganeti.Rpc Methods toDict :: RpcResultInstanceInfo -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcResultInstanceInfo # fromDict :: [(String, JSValue)] -> Result RpcResultInstanceInfo # | |
DictObject RpcResultInstanceList # | |
Defined in Ganeti.Rpc Methods toDict :: RpcResultInstanceList -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcResultInstanceList # fromDict :: [(String, JSValue)] -> Result RpcResultInstanceList # | |
DictObject RpcResultMasterNodeName # | |
Defined in Ganeti.Rpc Methods toDict :: RpcResultMasterNodeName -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcResultMasterNodeName # fromDict :: [(String, JSValue)] -> Result RpcResultMasterNodeName # | |
DictObject RpcResultNodeActivateMasterIp # | |
Defined in Ganeti.Rpc Methods toDict :: RpcResultNodeActivateMasterIp -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcResultNodeActivateMasterIp # fromDict :: [(String, JSValue)] -> Result RpcResultNodeActivateMasterIp # | |
DictObject RpcResultNodeInfo # | |
Defined in Ganeti.Rpc Methods toDict :: RpcResultNodeInfo -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcResultNodeInfo # fromDict :: [(String, JSValue)] -> Result RpcResultNodeInfo # | |
DictObject RpcResultStorageList # | |
Defined in Ganeti.Rpc Methods toDict :: RpcResultStorageList -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcResultStorageList # fromDict :: [(String, JSValue)] -> Result RpcResultStorageList # | |
DictObject RpcResultVersion # | |
Defined in Ganeti.Rpc Methods toDict :: RpcResultVersion -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result RpcResultVersion # fromDict :: [(String, JSValue)] -> Result RpcResultVersion # | |
DictObject StorageInfo # | |
Defined in Ganeti.Rpc Methods toDict :: StorageInfo -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result StorageInfo # fromDict :: [(String, JSValue)] -> Result StorageInfo # | |
DictObject Diskstats # | |
Defined in Ganeti.Storage.Diskstats.Types | |
DictObject LVInfo # | |
Defined in Ganeti.Storage.Lvm.Types | |
DictObject TempResState # | |
Defined in Ganeti.WConfd.TempRes Methods toDict :: TempResState -> [(String, JSValue)] # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result TempResState # fromDict :: [(String, JSValue)] -> Result TempResState # |
showJSONtoDict :: DictObject a => a -> JSValue #
A default implementation of showJSON
using toDict
.
readJSONfromDict :: DictObject a => JSValue -> Result a #
class ArrayObject a where #
Class of objects that can be converted from and to [JSValue]
with
a fixed length and order.
Instances
class HasStringRepr a where #
Class of types that can be converted from Strings. This is
similar to the Read
class, but it's using a different
serialisation format, so we have to define a separate class. Mostly
useful for custom key types in JSON dictionaries, which have to be
backed by strings.
Instances
HasStringRepr ByteString # | |
Defined in Ganeti.JSON Methods fromStringRepr :: MonadFail m => String -> m ByteString # toStringRepr :: ByteString -> String # | |
HasStringRepr SSKey # | |
Defined in Ganeti.Ssconf | |
HasStringRepr DiskTemplate # | |
Defined in Ganeti.Types Methods fromStringRepr :: MonadFail m => String -> m DiskTemplate # toStringRepr :: DiskTemplate -> String # | |
HasStringRepr Hypervisor # | |
Defined in Ganeti.Types Methods fromStringRepr :: MonadFail m => String -> m Hypervisor # toStringRepr :: Hypervisor -> String # | |
HasStringRepr String # | Trivial instance |
Defined in Ganeti.JSON |
newtype GenericContainer a b #
The container type, a wrapper over Data.Map
Constructors
GenericContainer | |
Fields
|
Instances
Foldable (GenericContainer a) # | |
Defined in Ganeti.JSON Methods fold :: Monoid m => GenericContainer a m -> m foldMap :: Monoid m => (a0 -> m) -> GenericContainer a a0 -> m foldMap' :: Monoid m => (a0 -> m) -> GenericContainer a a0 -> m foldr :: (a0 -> b -> b) -> b -> GenericContainer a a0 -> b foldr' :: (a0 -> b -> b) -> b -> GenericContainer a a0 -> b foldl :: (b -> a0 -> b) -> b -> GenericContainer a a0 -> b foldl' :: (b -> a0 -> b) -> b -> GenericContainer a a0 -> b foldr1 :: (a0 -> a0 -> a0) -> GenericContainer a a0 -> a0 foldl1 :: (a0 -> a0 -> a0) -> GenericContainer a a0 -> a0 toList :: GenericContainer a a0 -> [a0] null :: GenericContainer a a0 -> Bool length :: GenericContainer a a0 -> Int elem :: Eq a0 => a0 -> GenericContainer a a0 -> Bool maximum :: Ord a0 => GenericContainer a a0 -> a0 minimum :: Ord a0 => GenericContainer a a0 -> a0 sum :: Num a0 => GenericContainer a a0 -> a0 product :: Num a0 => GenericContainer a a0 -> a0 | |
Traversable (GenericContainer a) # | |
Defined in Ganeti.JSON Methods traverse :: Applicative f => (a0 -> f b) -> GenericContainer a a0 -> f (GenericContainer a b) sequenceA :: Applicative f => GenericContainer a (f a0) -> f (GenericContainer a a0) mapM :: Monad m => (a0 -> m b) -> GenericContainer a a0 -> m (GenericContainer a b) sequence :: Monad m => GenericContainer a (m a0) -> m (GenericContainer a a0) | |
Functor (GenericContainer a) # | |
Defined in Ganeti.JSON Methods fmap :: (a0 -> b) -> GenericContainer a a0 -> GenericContainer a b (<$) :: a0 -> GenericContainer a b -> GenericContainer a a0 | |
(Show a, Show b) => Show (GenericContainer a b) # | |
Defined in Ganeti.JSON Methods showsPrec :: Int -> GenericContainer a b -> ShowS show :: GenericContainer a b -> String showList :: [GenericContainer a b] -> ShowS | |
(NFData a, NFData b) => NFData (GenericContainer a b) # | |
Defined in Ganeti.JSON Methods rnf :: GenericContainer a b -> () | |
(Eq a, Eq b) => Eq (GenericContainer a b) # | |
Defined in Ganeti.JSON Methods (==) :: GenericContainer a b -> GenericContainer a b -> Bool (/=) :: GenericContainer a b -> GenericContainer a b -> Bool | |
(Ord a, Ord b) => Ord (GenericContainer a b) # | |
Defined in Ganeti.JSON Methods compare :: GenericContainer a b -> GenericContainer a b -> Ordering (<) :: GenericContainer a b -> GenericContainer a b -> Bool (<=) :: GenericContainer a b -> GenericContainer a b -> Bool (>) :: GenericContainer a b -> GenericContainer a b -> Bool (>=) :: GenericContainer a b -> GenericContainer a b -> Bool max :: GenericContainer a b -> GenericContainer a b -> GenericContainer a b min :: GenericContainer a b -> GenericContainer a b -> GenericContainer a b | |
(HasStringRepr a, Ord a, JSON b) => JSON (GenericContainer a b) # | |
Defined in Ganeti.JSON Methods readJSON :: JSValue -> Result (GenericContainer a b) showJSON :: GenericContainer a b -> JSValue readJSONs :: JSValue -> Result [GenericContainer a b] showJSONs :: [GenericContainer a b] -> JSValue |
emptyContainer :: GenericContainer a b #
The empty container.
type Container = GenericContainer ByteString #
Type alias for string keys.
newtype MaybeForJSON a #
A Maybe newtype that allows for serialization more appropriate to the semantics of Maybe and JSON in our calls. Does not produce needless and confusing dictionaries.
In particular, JSNull
corresponds to Nothing
.
This also means that this `Maybe a` newtype should not be used with a
values that themselves can serialize to null
.
Constructors
MaybeForJSON | |
Fields
|
Instances
Show a => Show (MaybeForJSON a) # | |
Defined in Ganeti.JSON Methods showsPrec :: Int -> MaybeForJSON a -> ShowS show :: MaybeForJSON a -> String showList :: [MaybeForJSON a] -> ShowS | |
Eq a => Eq (MaybeForJSON a) # | |
Defined in Ganeti.JSON Methods (==) :: MaybeForJSON a -> MaybeForJSON a -> Bool (/=) :: MaybeForJSON a -> MaybeForJSON a -> Bool | |
Ord a => Ord (MaybeForJSON a) # | |
Defined in Ganeti.JSON Methods compare :: MaybeForJSON a -> MaybeForJSON a -> Ordering (<) :: MaybeForJSON a -> MaybeForJSON a -> Bool (<=) :: MaybeForJSON a -> MaybeForJSON a -> Bool (>) :: MaybeForJSON a -> MaybeForJSON a -> Bool (>=) :: MaybeForJSON a -> MaybeForJSON a -> Bool max :: MaybeForJSON a -> MaybeForJSON a -> MaybeForJSON a min :: MaybeForJSON a -> MaybeForJSON a -> MaybeForJSON a | |
JSON a => JSON (MaybeForJSON a) # | |
Defined in Ganeti.JSON Methods readJSON :: JSValue -> Result (MaybeForJSON a) showJSON :: MaybeForJSON a -> JSValue readJSONs :: JSValue -> Result [MaybeForJSON a] showJSONs :: [MaybeForJSON a] -> JSValue |
newtype TimeAsDoubleJSON #
Constructors
TimeAsDoubleJSON | |
Fields
|
Instances
nestedAccessByKey :: [String] -> JSValue -> Result JSValue #
Look up a value in a JSON object. Accessing ["a", "b", "c"]
on an
object is equivalent as accessing myobject.a.b.c
on a JavaScript object.
An error is returned if the object doesn't have such an accessor or if any value during the nested access is not an object at all.
nestedAccessByKeyDotted :: String -> JSValue -> Result JSValue #
Same as nestedAccessByKey
, but accessing with a dotted string instead
(like nestedAccessByKeyDotted "a.b.c"
).
Arguments
:: String | fieldname to branch on |
-> (JSValue -> Result a) | decoding function if field is present and |
-> (JSValue -> Result a) | decoding function otherwise |
-> JSValue | |
-> Result a |
Branch decoding on a field in a JSON object.
addField :: (String, JSValue) -> JSValue -> JSValue #
Add a field to a JSON object; to nothing, if the argument is not an object.
maybeParseMap :: JSON a => JSValue -> Maybe (Map String a) #
Maybe obtain a map from a JSON object.