Safe Haskell | None |
---|
Implementation of the Ganeti Query2 language.
- data ResultStatus
- resultStatusFromRaw :: forall m. Monad m => Int -> m ResultStatus
- resultStatusToRaw :: ResultStatus -> Int
- checkRS :: Monad m => ResultStatus -> a -> m a
- data FieldType
- = QFTUnknown
- | QFTText
- | QFTBool
- | QFTNumber
- | QFTNumberFloat
- | QFTUnit
- | QFTTimestamp
- | QFTOther
- fieldTypeFromRaw :: forall m. Monad m => String -> m FieldType
- fieldTypeToRaw :: FieldType -> String
- data QueryTypeOp
- queryTypeOpFromRaw :: forall m. Monad m => String -> m QueryTypeOp
- queryTypeOpToRaw :: QueryTypeOp -> String
- data QueryTypeLuxi
- queryTypeLuxiFromRaw :: forall m. Monad m => String -> m QueryTypeLuxi
- queryTypeLuxiToRaw :: QueryTypeLuxi -> String
- data ItemType
- decodeItemType :: Monad m => JSValue -> m ItemType
- type RegexType = Regex
- type Fields = [String]
- data Filter a
- = EmptyFilter
- | AndFilter [Filter a]
- | OrFilter [Filter a]
- | NotFilter (Filter a)
- | TrueFilter a
- | EQFilter a FilterValue
- | LTFilter a FilterValue
- | GTFilter a FilterValue
- | LEFilter a FilterValue
- | GEFilter a FilterValue
- | RegexpFilter a FilterRegex
- | ContainsFilter a FilterValue
- filterArguments :: Filter a -> [a]
- showFilter :: JSON a => Filter a -> JSValue
- readFilter :: JSON a => JSValue -> Result (Filter a)
- readFilterArg :: JSON a => (Filter a -> Filter a) -> [JSValue] -> Result (Filter a)
- readFilterField :: JSON a => (a -> Filter a) -> [JSValue] -> Result (Filter a)
- readFilterFieldValue :: (JSON a, JSON b) => (a -> b -> Filter a) -> [JSValue] -> Result (Filter a)
- readFilterArray :: JSON a => String -> [JSValue] -> Result (Filter a)
- traverseFlt :: Applicative f => (a -> f b) -> Filter a -> f (Filter b)
- type FilterField = String
- data FilterValue
- = QuotedString String
- | NumericValue Integer
- showFilterValue :: FilterValue -> JSValue
- readFilterValue :: JSValue -> Result FilterValue
- data FilterRegex = FilterRegex {
- stringRegex :: String
- compiledRegex :: RegexType
- mkRegex :: Monad m => String -> m FilterRegex
- type FieldName = String
- type FieldTitle = String
- type FieldDoc = String
- data FieldDefinition = FieldDefinition {}
- loadFieldDefinition :: JSValue -> Result FieldDefinition
- saveFieldDefinition :: FieldDefinition -> JSValue
- data ResultEntry = ResultEntry {
- rentryStatus :: ResultStatus
- rentryValue :: Maybe ResultValue
- type ResultRow = [ResultEntry]
- type ResultValue = JSValue
- data Query = Query ItemType Fields (Filter FilterField)
- data QueryResult = QueryResult {
- qresFields :: [FieldDefinition]
- qresData :: [ResultRow]
- loadQueryResult :: JSValue -> Result QueryResult
- saveQueryResult :: QueryResult -> JSValue
- data QueryFields = QueryFields ItemType Fields
- data QueryFieldsResult = QueryFieldsResult {}
- loadQueryFieldsResult :: JSValue -> Result QueryFieldsResult
- saveQueryFieldsResult :: QueryFieldsResult -> JSValue
THH declarations, that require ordering.
data ResultStatus Source
Status of a query field.
Bounded ResultStatus | |
Enum ResultStatus | |
Eq ResultStatus | |
Ord ResultStatus | |
Show ResultStatus | |
Arbitrary ResultStatus | |
NFData ResultStatus | No-op |
JSON ResultStatus |
resultStatusFromRaw :: forall m. Monad m => Int -> m ResultStatusSource
resultStatusToRaw :: ResultStatus -> IntSource
checkRS :: Monad m => ResultStatus -> a -> m aSource
Check that ResultStatus is success or fail with descriptive message.
Type of a query field.
fieldTypeFromRaw :: forall m. Monad m => String -> m FieldTypeSource
fieldTypeToRaw :: FieldType -> StringSource
data QueryTypeOp Source
Supported items on which Qlang works.
Bounded QueryTypeOp | |
Enum QueryTypeOp | |
Eq QueryTypeOp | |
Ord QueryTypeOp | |
Show QueryTypeOp | |
Arbitrary QueryTypeOp | |
JSON QueryTypeOp |
queryTypeOpFromRaw :: forall m. Monad m => String -> m QueryTypeOpSource
queryTypeOpToRaw :: QueryTypeOp -> StringSource
data QueryTypeLuxi Source
Supported items on which Qlang works.
Bounded QueryTypeLuxi | |
Enum QueryTypeLuxi | |
Eq QueryTypeLuxi | |
Ord QueryTypeLuxi | |
Show QueryTypeLuxi | |
Arbitrary QueryTypeLuxi | |
JSON QueryTypeLuxi |
queryTypeLuxiFromRaw :: forall m. Monad m => String -> m QueryTypeLuxiSource
queryTypeLuxiToRaw :: QueryTypeLuxi -> StringSource
Overall query type.
decodeItemType :: Monad m => JSValue -> m ItemTypeSource
Sub data types for query2 queries and responses.
Query2 filter expression. It's a parameteric type since we can filter different "things"; e.g. field names, or actual field getters, etc.
EmptyFilter | No filter at all |
AndFilter [Filter a] |
|
OrFilter [Filter a] |
|
NotFilter (Filter a) |
|
TrueFilter a |
|
EQFilter a FilterValue |
|
LTFilter a FilterValue |
|
GTFilter a FilterValue |
|
LEFilter a FilterValue |
|
GEFilter a FilterValue |
|
RegexpFilter a FilterRegex |
|
ContainsFilter a FilterValue |
|
filterArguments :: Filter a -> [a]Source
Get the "things" a filter talks about. This is useful, e.g., to decide which additional fields to fetch in a query depending on live data.
showFilter :: JSON a => Filter a -> JSValueSource
readFilter :: JSON a => JSValue -> Result (Filter a)Source
readFilterArg :: JSON a => (Filter a -> Filter a) -> [JSValue] -> Result (Filter a)Source
readFilterField :: JSON a => (a -> Filter a) -> [JSValue] -> Result (Filter a)Source
readFilterFieldValue :: (JSON a, JSON b) => (a -> b -> Filter a) -> [JSValue] -> Result (Filter a)Source
readFilterArray :: JSON a => String -> [JSValue] -> Result (Filter a)Source
traverseFlt :: Applicative f => (a -> f b) -> Filter a -> f (Filter b)Source
type FilterField = StringSource
Field name to filter on.
data FilterValue Source
Value to compare the field value to, for filtering purposes.
QuotedString String | |
NumericValue Integer |
Eq FilterValue | |
Show FilterValue | |
JSON FilterValue |
showFilterValue :: FilterValue -> JSValueSource
readFilterValue :: JSValue -> Result FilterValueSource
data FilterRegex Source
Regexp to apply to the filter value, for filtering purposes. It holds both the string format, and the "compiled" format, so that we don't re-compile the regex at each match attempt.
FilterRegex | |
|
Eq FilterRegex |
|
Show FilterRegex |
|
Arbitrary FilterRegex | |
JSON FilterRegex |
|
mkRegex :: Monad m => String -> m FilterRegexSource
Builder for FilterRegex
. We always attempt to compile the
regular expression on the initialisation of the data structure;
this might fail, if the RE is not well-formed.
type FieldTitle = StringSource
Title of a field, when represented in tabular format.
data FieldDefinition Source
Definition of a field.
Eq FieldDefinition | |
Show FieldDefinition | |
Arbitrary FieldDefinition | |
JSON FieldDefinition | |
ArrayObject FieldDefinition | |
DictObject FieldDefinition |
loadFieldDefinition :: JSValue -> Result FieldDefinitionSource
saveFieldDefinition :: FieldDefinition -> JSValueSource
data ResultEntry Source
ResultEntry | |
|
Eq ResultEntry | |
Show ResultEntry | |
NFData ResultEntry | |
JSON ResultEntry |
type ResultRow = [ResultEntry]Source
type ResultValue = JSValueSource
Value of a field, in json encoding. (its type will be depending on ResultStatus and FieldType)
Main Qlang queries and responses.
data QueryResult Source
Query2 result.
QueryResult | |
|
Eq QueryResult | |
Show QueryResult | |
JSON QueryResult | |
ArrayObject QueryResult | |
DictObject QueryResult |
loadQueryResult :: JSValue -> Result QueryResultSource
saveQueryResult :: QueryResult -> JSValueSource
data QueryFields Source
Query2 Fields query. (to get supported fields names, descriptions, and types)
data QueryFieldsResult Source
Query2 Fields result.
loadQueryFieldsResult :: JSValue -> Result QueryFieldsResultSource
saveQueryFieldsResult :: QueryFieldsResult -> JSValueSource