Safe Haskell | None |
---|
Ganeti.Query.Language
Contents
Description
Implementation of the Ganeti Query2 language.
Synopsis
- data ResultStatus
- checkRS :: MonadFail m => ResultStatus -> a -> m a
- data FieldType
- data QueryTypeOp
- queryTypeOpToRaw :: QueryTypeOp -> String
- data QueryTypeLuxi
- data ItemType
- 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]
- type FilterField = String
- data FilterValue
- = QuotedString String
- | NumericValue Integer
- showFilterValue :: FilterValue -> JSValue
- data FilterRegex
- mkRegex :: MonadFail m => String -> m FilterRegex
- type FieldName = String
- type FieldTitle = String
- type FieldDoc = String
- data FieldDefinition = FieldDefinition {}
- data ResultEntry = ResultEntry {
- rentryStatus :: ResultStatus
- rentryValue :: Maybe ResultValue
- type ResultValue = JSValue
- data Query = Query ItemType Fields (Filter FilterField)
- data QueryResult = QueryResult {
- qresFields :: [FieldDefinition]
- qresData :: [ResultRow]
- data QueryFields = QueryFields ItemType Fields
- data QueryFieldsResult = QueryFieldsResult {}
THH declarations, that require ordering.
data ResultStatus Source #
Status of a query field.
Instances
checkRS :: MonadFail m => ResultStatus -> a -> m a Source #
Check that ResultStatus is success or fail with descriptive message.
Type of a query field.
Constructors
QFTUnknown | |
QFTText | |
QFTBool | |
QFTNumber | |
QFTNumberFloat | |
QFTUnit | |
QFTTimestamp | |
QFTOther |
Instances
Bounded FieldType # | |
Defined in Ganeti.Query.Language | |
Enum FieldType # | |
Defined in Ganeti.Query.Language | |
Eq FieldType # | |
Ord FieldType # | |
Defined in Ganeti.Query.Language | |
Show FieldType # | |
JSON FieldType # | |
Arbitrary FieldType | |
data QueryTypeOp Source #
Supported items on which Qlang works.
Instances
queryTypeOpToRaw :: QueryTypeOp -> String Source #
data QueryTypeLuxi Source #
Supported items on which Qlang works.
Instances
Overall query type.
Constructors
ItemTypeLuxi QueryTypeLuxi | |
ItemTypeOpCode QueryTypeOp |
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.
Constructors
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 |
|
Instances
Functor Filter # | |
Foldable Filter # | |
Defined in Ganeti.Query.Language Methods fold :: Monoid m => Filter m -> m foldMap :: Monoid m => (a -> m) -> Filter a -> m foldr :: (a -> b -> b) -> b -> Filter a -> b foldr' :: (a -> b -> b) -> b -> Filter a -> b foldl :: (b -> a -> b) -> b -> Filter a -> b foldl' :: (b -> a -> b) -> b -> Filter a -> b foldr1 :: (a -> a -> a) -> Filter a -> a foldl1 :: (a -> a -> a) -> Filter a -> a elem :: Eq a => a -> Filter a -> Bool maximum :: Ord a => Filter a -> a | |
Traversable Filter # | |
Eq a => Eq (Filter a) # | |
Ord a => Ord (Filter a) # | |
Defined in Ganeti.Query.Language | |
Show a => Show (Filter a) # | |
JSON a => JSON (Filter a) # | |
Arbitrary (Filter FilterField) | |
Defined in Test.Ganeti.Query.Language |
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.
type FilterField = String Source #
Field name to filter on.
data FilterValue Source #
Value to compare the field value to, for filtering purposes.
Constructors
QuotedString String | |
NumericValue Integer |
Instances
Eq FilterValue # | |
Defined in Ganeti.Query.Language | |
Ord FilterValue # | |
Defined in Ganeti.Query.Language Methods compare :: FilterValue -> FilterValue -> Ordering (<) :: FilterValue -> FilterValue -> Bool (<=) :: FilterValue -> FilterValue -> Bool (>) :: FilterValue -> FilterValue -> Bool (>=) :: FilterValue -> FilterValue -> Bool max :: FilterValue -> FilterValue -> FilterValue min :: FilterValue -> FilterValue -> FilterValue | |
Show FilterValue # | |
Defined in Ganeti.Query.Language Methods showsPrec :: Int -> FilterValue -> ShowS show :: FilterValue -> String showList :: [FilterValue] -> ShowS | |
JSON FilterValue # | |
Defined in Ganeti.Query.Language Methods readJSON :: JSValue -> Result FilterValue showJSON :: FilterValue -> JSValue readJSONs :: JSValue -> Result [FilterValue] showJSONs :: [FilterValue] -> JSValue |
showFilterValue :: FilterValue -> JSValue Source #
Serialiser for FilterValue
. The Python code just sends this to
JSON as-is, so we'll do the same.
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.
Instances
Eq FilterRegex # |
|
Defined in Ganeti.Query.Language | |
Ord FilterRegex # |
|
Defined in Ganeti.Query.Language Methods compare :: FilterRegex -> FilterRegex -> Ordering (<) :: FilterRegex -> FilterRegex -> Bool (<=) :: FilterRegex -> FilterRegex -> Bool (>) :: FilterRegex -> FilterRegex -> Bool (>=) :: FilterRegex -> FilterRegex -> Bool max :: FilterRegex -> FilterRegex -> FilterRegex min :: FilterRegex -> FilterRegex -> FilterRegex | |
Show FilterRegex # |
|
Defined in Ganeti.Query.Language Methods showsPrec :: Int -> FilterRegex -> ShowS show :: FilterRegex -> String showList :: [FilterRegex] -> ShowS | |
JSON FilterRegex # |
|
Defined in Ganeti.Query.Language Methods readJSON :: JSValue -> Result FilterRegex showJSON :: FilterRegex -> JSValue readJSONs :: JSValue -> Result [FilterRegex] showJSONs :: [FilterRegex] -> JSValue | |
Arbitrary FilterRegex | |
Defined in Test.Ganeti.Query.Language |
mkRegex :: MonadFail m => String -> m FilterRegex Source #
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 = String Source #
Title of a field, when represented in tabular format.
data FieldDefinition Source #
Definition of a field.
Constructors
FieldDefinition | |
Instances
data ResultEntry Source #
Constructors
ResultEntry | |
Fields
|
Instances
Eq ResultEntry # | |
Defined in Ganeti.Query.Language | |
Show ResultEntry # | |
Defined in Ganeti.Query.Language Methods showsPrec :: Int -> ResultEntry -> ShowS show :: ResultEntry -> String showList :: [ResultEntry] -> ShowS | |
JSON ResultEntry # | |
Defined in Ganeti.Query.Language Methods readJSON :: JSValue -> Result ResultEntry showJSON :: ResultEntry -> JSValue readJSONs :: JSValue -> Result [ResultEntry] showJSONs :: [ResultEntry] -> JSValue | |
NFData ResultEntry # | |
Defined in Ganeti.Query.Language Methods rnf :: ResultEntry -> () |
type ResultValue = JSValue Source #
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.
Constructors
QueryResult | |
Fields
|
Instances
Eq QueryResult # | |
Defined in Ganeti.Query.Language | |
Show QueryResult # | |
Defined in Ganeti.Query.Language Methods showsPrec :: Int -> QueryResult -> ShowS show :: QueryResult -> String showList :: [QueryResult] -> ShowS | |
JSON QueryResult # | |
Defined in Ganeti.Query.Language Methods readJSON :: JSValue -> Result QueryResult showJSON :: QueryResult -> JSValue readJSONs :: JSValue -> Result [QueryResult] showJSONs :: [QueryResult] -> JSValue | |
ArrayObject QueryResult # | |
Defined in Ganeti.Query.Language Methods toJSArray :: QueryResult -> [JSValue] Source # fromJSArray :: [JSValue] -> Result QueryResult Source # | |
DictObject QueryResult # | |
Defined in Ganeti.Query.Language Methods toDict :: QueryResult -> [(String, JSValue)] Source # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result QueryResult Source # fromDict :: [(String, JSValue)] -> Result QueryResult Source # |
data QueryFields Source #
Query2 Fields query. (to get supported fields names, descriptions, and types)
Constructors
QueryFields ItemType Fields |
data QueryFieldsResult Source #
Query2 Fields result.
Constructors
QueryFieldsResult | |
Fields |