ganeti

Safe HaskellNone

Ganeti.Query.Language

Contents

Description

Implementation of the Ganeti Query2 language.

Synopsis

THH declarations, that require ordering.

data ResultStatus Source

Status of a query field.

Instances

Bounded ResultStatus 
Enum ResultStatus 
Eq ResultStatus 
Ord ResultStatus 
Show ResultStatus 
Arbitrary ResultStatus 
NFData ResultStatus

No-op NFData instance for ResultStatus, since it's a single constructor data-type.

JSON ResultStatus 

resultStatusFromRaw :: forall m. Monad m => Int -> m ResultStatusSource

checkRS :: Monad m => ResultStatus -> a -> m aSource

Check that ResultStatus is success or fail with descriptive message.

data FieldType Source

Type of a query field.

Instances

Bounded FieldType 
Enum FieldType 
Eq FieldType 
Ord FieldType 
Show FieldType 
Arbitrary FieldType 
JSON FieldType 

fieldTypeFromRaw :: forall m. Monad m => String -> m FieldTypeSource

data QueryTypeOp Source

Supported items on which Qlang works.

Instances

Bounded QueryTypeOp 
Enum QueryTypeOp 
Eq QueryTypeOp 
Ord QueryTypeOp 
Show QueryTypeOp 
Arbitrary QueryTypeOp 
JSON QueryTypeOp 

queryTypeOpFromRaw :: forall m. Monad m => String -> m QueryTypeOpSource

data QueryTypeLuxi Source

Supported items on which Qlang works.

Constructors

QRLock 
QRJob 
QRFilter 

Instances

queryTypeLuxiFromRaw :: forall m. Monad m => String -> m QueryTypeLuxiSource

data ItemType Source

Overall query type.

Instances

Eq ItemType 
Show ItemType 
Arbitrary ItemType 
JSON ItemType

Custom JSON instance for ItemType since its encoding is not consistent with the data type itself.

decodeItemType :: Monad m => JSValue -> m ItemTypeSource

Sub data types for query2 queries and responses.

type RegexType = RegexSource

type Fields = [String]Source

List of requested fields.

data Filter a Source

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]

& [expression, ...]

OrFilter [Filter a]

| [expression, ...]

NotFilter (Filter a)

! expression

TrueFilter a

? field

EQFilter a FilterValue

(=|!=) field value

LTFilter a FilterValue

< field value

GTFilter a FilterValue

> field value

LEFilter a FilterValue

<= field value

GEFilter a FilterValue

>= field value

RegexpFilter a FilterRegex

=~ field regexp

ContainsFilter a FilterValue

=[] list-field value

Instances

Functor Filter 
Foldable Filter 
Traversable Filter 
Eq a => Eq (Filter a) 
Ord a => Ord (Filter a) 
Show a => Show (Filter a) 
Arbitrary (Filter FilterField) 
JSON a => JSON (Filter a) 

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

type FilterField = StringSource

Field name to filter on.

data FilterValue Source

Value to compare the field value to, for filtering purposes.

Constructors

QuotedString String 
NumericValue Integer 

Instances

showFilterValue :: FilterValue -> JSValueSource

Serialiser for FilterValue. The Python code just sends this to JSON as-is, so we'll do the same.

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.

Constructors

FilterRegex 

Fields

stringRegex :: String

The string version of the regex

compiledRegex :: RegexType

The compiled regex

Instances

Eq FilterRegex

Eq instance: we only compare the string versions of the regexes.

Ord FilterRegex

Ord instance: we only compare the string versions of the regexes.

Show FilterRegex

Show instance: we show the constructor plus the string version of the regex.

Arbitrary FilterRegex 
JSON FilterRegex

JSON instance: like for show and read instances, we work only with the string component.

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 FieldName = StringSource

Name of a field.

type FieldTitle = StringSource

Title of a field, when represented in tabular format.

type FieldDoc = StringSource

Human redable description of a field.

data ResultEntry Source

Constructors

ResultEntry 

Fields

rentryStatus :: ResultStatus

The result status

rentryValue :: Maybe ResultValue

The (optional) result value

Instances

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 Query Source

Query2 query.

loadQueryResult :: JSValue -> Result QueryResultSource

data QueryFields Source

Query2 Fields query. (to get supported fields names, descriptions, and types)