Safe Haskell | None |
---|
Implementation of the Ganeti Query2 language.
Synopsis
- data ResultStatus
- resultStatusFromRaw :: forall m. (Monad m, MonadFail m) => Int -> m ResultStatus
- resultStatusToRaw :: ResultStatus -> Int
- checkRS :: MonadFail m => ResultStatus -> a -> m a
- data FieldType
- fieldTypeFromRaw :: forall m. (Monad m, MonadFail m) => String -> m FieldType
- fieldTypeToRaw :: FieldType -> String
- data QueryTypeOp
- queryTypeOpFromRaw :: forall m. (Monad m, MonadFail m) => String -> m QueryTypeOp
- queryTypeOpToRaw :: QueryTypeOp -> String
- data QueryTypeLuxi
- queryTypeLuxiFromRaw :: forall m. (Monad m, MonadFail m) => String -> m QueryTypeLuxi
- queryTypeLuxiToRaw :: QueryTypeLuxi -> String
- data ItemType
- decodeItemType :: MonadFail 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)
- type FilterField = String
- data FilterValue
- = QuotedString String
- | NumericValue Integer
- showFilterValue :: FilterValue -> JSValue
- readFilterValue :: JSValue -> Result FilterValue
- data FilterRegex = FilterRegex {
- stringRegex :: String
- compiledRegex :: RegexType
- mkRegex :: MonadFail 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.
Instances
resultStatusFromRaw :: forall m. (Monad m, MonadFail m) => Int -> m ResultStatus Source #
resultStatusToRaw :: ResultStatus -> Int Source #
checkRS :: MonadFail m => ResultStatus -> a -> m a Source #
Check that ResultStatus is success or fail with descriptive message.
Type of a query field.
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 | |
fieldTypeFromRaw :: forall m. (Monad m, MonadFail m) => String -> m FieldType Source #
fieldTypeToRaw :: FieldType -> String Source #
data QueryTypeOp Source #
Supported items on which Qlang works.
Instances
queryTypeOpFromRaw :: forall m. (Monad m, MonadFail m) => String -> m QueryTypeOp Source #
queryTypeOpToRaw :: QueryTypeOp -> String Source #
data QueryTypeLuxi Source #
Supported items on which Qlang works.
Instances
queryTypeLuxiFromRaw :: forall m. (Monad m, MonadFail m) => String -> m QueryTypeLuxi Source #
queryTypeLuxiToRaw :: QueryTypeLuxi -> String Source #
Overall query type.
decodeItemType :: MonadFail m => JSValue -> m ItemType Source #
Custom JSON decoder for ItemType
.
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 |
|
Instances
Functor Filter # | |
Foldable Filter # | |
Defined in Ganeti.Query.Language fold :: Monoid m => Filter m -> m foldMap :: Monoid m => (a -> m) -> Filter a -> 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) # | |
Show a => Show (Filter a) # | |
JSON a => JSON (Filter a) # | |
Arbitrary (Filter FilterField) | |
Defined in Test.Ganeti.Query.Language arbitrary :: Gen (Filter FilterField) shrink :: Filter FilterField -> [Filter FilterField] |
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 -> JSValue Source #
Serialiser for the Filter
data type.
readFilter :: JSON a => JSValue -> Result (Filter a) Source #
Deserializer for the Filter
data type.
Helper to deserialise an array corresponding to a single filter and return the built filter. Note this looks generic but is (at least currently) only used for the NotFilter.
Helper to deserialise an array corresponding to a single field and return the built filter.
:: (JSON a, JSON b) | |
=> (a -> b -> Filter a) | Constructor |
-> [JSValue] | Arguments array |
-> Result (Filter a) |
Helper to deserialise an array corresponding to a field and value, returning the built filter.
readFilterArray :: JSON a => String -> [JSValue] -> Result (Filter a) Source #
Inner deserialiser for Filter
.
type FilterField = String Source #
Field name to filter on.
data FilterValue Source #
Value to compare the field value to, for filtering purposes.
QuotedString String | |
NumericValue Integer |
Instances
Eq FilterValue # | |
Defined in Ganeti.Query.Language (==) :: FilterValue -> FilterValue -> Bool (/=) :: FilterValue -> FilterValue -> Bool | |
Ord FilterValue # | |
Defined in Ganeti.Query.Language 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 showsPrec :: Int -> FilterValue -> ShowS show :: FilterValue -> String showList :: [FilterValue] -> ShowS | |
JSON FilterValue # | |
Defined in Ganeti.Query.Language 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.
readFilterValue :: JSValue -> Result FilterValue Source #
Decoder for FilterValue
. We have to see what it contains, since
the context doesn't give us hints on what to expect.
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 | |
|
Instances
Eq FilterRegex # |
|
Defined in Ganeti.Query.Language (==) :: FilterRegex -> FilterRegex -> Bool (/=) :: FilterRegex -> FilterRegex -> Bool | |
Ord FilterRegex # |
|
Defined in Ganeti.Query.Language 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 showsPrec :: Int -> FilterRegex -> ShowS show :: FilterRegex -> String showList :: [FilterRegex] -> ShowS | |
JSON FilterRegex # |
|
Defined in Ganeti.Query.Language readJSON :: JSValue -> Result FilterRegex showJSON :: FilterRegex -> JSValue readJSONs :: JSValue -> Result [FilterRegex] showJSONs :: [FilterRegex] -> JSValue | |
Arbitrary FilterRegex | |
Defined in Test.Ganeti.Query.Language arbitrary :: Gen FilterRegex shrink :: FilterRegex -> [FilterRegex] |
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.
Instances
loadFieldDefinition :: JSValue -> Result FieldDefinition Source #
saveFieldDefinition :: FieldDefinition -> JSValue Source #
data ResultEntry Source #
ResultEntry | |
|
Instances
Eq ResultEntry # | |
Defined in Ganeti.Query.Language (==) :: ResultEntry -> ResultEntry -> Bool (/=) :: ResultEntry -> ResultEntry -> Bool | |
Show ResultEntry # | |
Defined in Ganeti.Query.Language showsPrec :: Int -> ResultEntry -> ShowS show :: ResultEntry -> String showList :: [ResultEntry] -> ShowS | |
JSON ResultEntry # | |
Defined in Ganeti.Query.Language readJSON :: JSValue -> Result ResultEntry showJSON :: ResultEntry -> JSValue readJSONs :: JSValue -> Result [ResultEntry] showJSONs :: [ResultEntry] -> JSValue | |
NFData ResultEntry # | |
Defined in Ganeti.Query.Language rnf :: ResultEntry -> () |
type ResultRow = [ResultEntry] Source #
The type of one result row.
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.
QueryResult | |
|
Instances
Eq QueryResult # | |
Defined in Ganeti.Query.Language (==) :: QueryResult -> QueryResult -> Bool (/=) :: QueryResult -> QueryResult -> Bool | |
Show QueryResult # | |
Defined in Ganeti.Query.Language showsPrec :: Int -> QueryResult -> ShowS show :: QueryResult -> String showList :: [QueryResult] -> ShowS | |
JSON QueryResult # | |
Defined in Ganeti.Query.Language readJSON :: JSValue -> Result QueryResult showJSON :: QueryResult -> JSValue readJSONs :: JSValue -> Result [QueryResult] showJSONs :: [QueryResult] -> JSValue | |
ArrayObject QueryResult # | |
Defined in Ganeti.Query.Language toJSArray :: QueryResult -> [JSValue] Source # fromJSArray :: [JSValue] -> Result QueryResult Source # | |
DictObject QueryResult # | |
Defined in Ganeti.Query.Language toDict :: QueryResult -> [(String, JSValue)] Source # fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result QueryResult Source # fromDict :: [(String, JSValue)] -> Result QueryResult Source # |
loadQueryResult :: JSValue -> Result QueryResult Source #
saveQueryResult :: QueryResult -> JSValue Source #
data QueryFields Source #
Query2 Fields query. (to get supported fields names, descriptions, and types)
data QueryFieldsResult Source #
Query2 Fields result.
Instances
loadQueryFieldsResult :: JSValue -> Result QueryFieldsResult Source #
saveQueryFieldsResult :: QueryFieldsResult -> JSValue Source #