ganeti-3.1: Cluster-based virtualization management software
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ganeti.Query.Language

Description

Implementation of the Ganeti Query2 language.

Synopsis

Documentation

data Filter a #

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

Instances details
Foldable Filter # 
Instance details

Defined in Ganeti.Query.Language

Methods

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

toList :: Filter a -> [a]

null :: Filter a -> Bool

length :: Filter a -> Int

elem :: Eq a => a -> Filter a -> Bool

maximum :: Ord a => Filter a -> a

minimum :: Ord a => Filter a -> a

sum :: Num a => Filter a -> a

product :: Num a => Filter a -> a

Traversable Filter # 
Instance details

Defined in Ganeti.Query.Language

Methods

traverse :: Applicative f => (a -> f b) -> Filter a -> f (Filter b)

sequenceA :: Applicative f => Filter (f a) -> f (Filter a)

mapM :: Monad m => (a -> m b) -> Filter a -> m (Filter b)

sequence :: Monad m => Filter (m a) -> m (Filter a)

Functor Filter # 
Instance details

Defined in Ganeti.Query.Language

Methods

fmap :: (a -> b) -> Filter a -> Filter b

(<$) :: a -> Filter b -> Filter a

Show a => Show (Filter a) # 
Instance details

Defined in Ganeti.Query.Language

Methods

showsPrec :: Int -> Filter a -> ShowS

show :: Filter a -> String

showList :: [Filter a] -> ShowS

Eq a => Eq (Filter a) # 
Instance details

Defined in Ganeti.Query.Language

Methods

(==) :: Filter a -> Filter a -> Bool

(/=) :: Filter a -> Filter a -> Bool

Ord a => Ord (Filter a) # 
Instance details

Defined in Ganeti.Query.Language

Methods

compare :: Filter a -> Filter a -> Ordering

(<) :: Filter a -> Filter a -> Bool

(<=) :: Filter a -> Filter a -> Bool

(>) :: Filter a -> Filter a -> Bool

(>=) :: Filter a -> Filter a -> Bool

max :: Filter a -> Filter a -> Filter a

min :: Filter a -> Filter a -> Filter a

JSON a => JSON (Filter a) # 
Instance details

Defined in Ganeti.Query.Language

Methods

readJSON :: JSValue -> Result (Filter a)

showJSON :: Filter a -> JSValue

readJSONs :: JSValue -> Result [Filter a]

showJSONs :: [Filter a] -> JSValue

filterArguments :: Filter a -> [a] #

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 #

Field name to filter on.

data FilterValue #

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

Constructors

QuotedString String 
NumericValue Integer 

Instances

Instances details
Show FilterValue # 
Instance details

Defined in Ganeti.Query.Language

Methods

showsPrec :: Int -> FilterValue -> ShowS

show :: FilterValue -> String

showList :: [FilterValue] -> ShowS

Eq FilterValue # 
Instance details

Defined in Ganeti.Query.Language

Methods

(==) :: FilterValue -> FilterValue -> Bool

(/=) :: FilterValue -> FilterValue -> Bool

Ord FilterValue # 
Instance details

Defined in Ganeti.Query.Language

JSON FilterValue # 
Instance details

Defined in Ganeti.Query.Language

Methods

readJSON :: JSValue -> Result FilterValue

showJSON :: FilterValue -> JSValue

readJSONs :: JSValue -> Result [FilterValue]

showJSONs :: [FilterValue] -> JSValue

data FilterRegex #

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

Instances details
Show FilterRegex #

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

Instance details

Defined in Ganeti.Query.Language

Methods

showsPrec :: Int -> FilterRegex -> ShowS

show :: FilterRegex -> String

showList :: [FilterRegex] -> ShowS

Eq FilterRegex #

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

Instance details

Defined in Ganeti.Query.Language

Methods

(==) :: FilterRegex -> FilterRegex -> Bool

(/=) :: FilterRegex -> FilterRegex -> Bool

Ord FilterRegex #

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

Instance details

Defined in Ganeti.Query.Language

JSON FilterRegex #

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

Instance details

Defined in Ganeti.Query.Language

Methods

readJSON :: JSValue -> Result FilterRegex

showJSON :: FilterRegex -> JSValue

readJSONs :: JSValue -> Result [FilterRegex]

showJSONs :: [FilterRegex] -> JSValue

mkRegex :: MonadFail m => String -> m FilterRegex #

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.

stringRegex :: FilterRegex -> String #

The string version of the regex

compiledRegex :: FilterRegex -> Regex #

The compiled regex

showFilterValue :: FilterValue -> JSValue #

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

type Fields = [String] #

List of requested fields.

data Query #

Query2 query.

data QueryResult #

Query2 result.

Constructors

QueryResult 

Fields

Instances

Instances details
Show QueryResult # 
Instance details

Defined in Ganeti.Query.Language

Methods

showsPrec :: Int -> QueryResult -> ShowS

show :: QueryResult -> String

showList :: [QueryResult] -> ShowS

ArrayObject QueryResult # 
Instance details

Defined in Ganeti.Query.Language

Methods

toJSArray :: QueryResult -> [JSValue] #

fromJSArray :: [JSValue] -> Result QueryResult #

DictObject QueryResult # 
Instance details

Defined in Ganeti.Query.Language

Methods

toDict :: QueryResult -> [(String, JSValue)] #

fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result QueryResult #

fromDict :: [(String, JSValue)] -> Result QueryResult #

Eq QueryResult # 
Instance details

Defined in Ganeti.Query.Language

Methods

(==) :: QueryResult -> QueryResult -> Bool

(/=) :: QueryResult -> QueryResult -> Bool

JSON QueryResult # 
Instance details

Defined in Ganeti.Query.Language

Methods

readJSON :: JSValue -> Result QueryResult

showJSON :: QueryResult -> JSValue

readJSONs :: JSValue -> Result [QueryResult]

showJSONs :: [QueryResult] -> JSValue

data QueryFields #

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

data QueryFieldsResult #

Query2 Fields result.

Instances

Instances details
Show QueryFieldsResult # 
Instance details

Defined in Ganeti.Query.Language

Methods

showsPrec :: Int -> QueryFieldsResult -> ShowS

show :: QueryFieldsResult -> String

showList :: [QueryFieldsResult] -> ShowS

ArrayObject QueryFieldsResult # 
Instance details

Defined in Ganeti.Query.Language

Methods

toJSArray :: QueryFieldsResult -> [JSValue] #

fromJSArray :: [JSValue] -> Result QueryFieldsResult #

DictObject QueryFieldsResult # 
Instance details

Defined in Ganeti.Query.Language

Methods

toDict :: QueryFieldsResult -> [(String, JSValue)] #

fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result QueryFieldsResult #

fromDict :: [(String, JSValue)] -> Result QueryFieldsResult #

Eq QueryFieldsResult # 
Instance details

Defined in Ganeti.Query.Language

JSON QueryFieldsResult # 
Instance details

Defined in Ganeti.Query.Language

Methods

readJSON :: JSValue -> Result QueryFieldsResult

showJSON :: QueryFieldsResult -> JSValue

readJSONs :: JSValue -> Result [QueryFieldsResult]

showJSONs :: [QueryFieldsResult] -> JSValue

type FieldName = String #

Name of a field.

type FieldTitle = String #

Title of a field, when represented in tabular format.

data FieldType #

Type of a query field.

Instances

Instances details
Bounded FieldType # 
Instance details

Defined in Ganeti.Query.Language

Enum FieldType # 
Instance details

Defined in Ganeti.Query.Language

Show FieldType # 
Instance details

Defined in Ganeti.Query.Language

Methods

showsPrec :: Int -> FieldType -> ShowS

show :: FieldType -> String

showList :: [FieldType] -> ShowS

Eq FieldType # 
Instance details

Defined in Ganeti.Query.Language

Methods

(==) :: FieldType -> FieldType -> Bool

(/=) :: FieldType -> FieldType -> Bool

Ord FieldType # 
Instance details

Defined in Ganeti.Query.Language

Methods

compare :: FieldType -> FieldType -> Ordering

(<) :: FieldType -> FieldType -> Bool

(<=) :: FieldType -> FieldType -> Bool

(>) :: FieldType -> FieldType -> Bool

(>=) :: FieldType -> FieldType -> Bool

max :: FieldType -> FieldType -> FieldType

min :: FieldType -> FieldType -> FieldType

JSON FieldType # 
Instance details

Defined in Ganeti.Query.Language

Methods

readJSON :: JSValue -> Result FieldType

showJSON :: FieldType -> JSValue

readJSONs :: JSValue -> Result [FieldType]

showJSONs :: [FieldType] -> JSValue

type FieldDoc = String #

Human redable description of a field.

data FieldDefinition #

Definition of a field.

Instances

Instances details
Show FieldDefinition # 
Instance details

Defined in Ganeti.Query.Language

Methods

showsPrec :: Int -> FieldDefinition -> ShowS

show :: FieldDefinition -> String

showList :: [FieldDefinition] -> ShowS

ArrayObject FieldDefinition # 
Instance details

Defined in Ganeti.Query.Language

Methods

toJSArray :: FieldDefinition -> [JSValue] #

fromJSArray :: [JSValue] -> Result FieldDefinition #

DictObject FieldDefinition # 
Instance details

Defined in Ganeti.Query.Language

Methods

toDict :: FieldDefinition -> [(String, JSValue)] #

fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result FieldDefinition #

fromDict :: [(String, JSValue)] -> Result FieldDefinition #

Eq FieldDefinition # 
Instance details

Defined in Ganeti.Query.Language

JSON FieldDefinition # 
Instance details

Defined in Ganeti.Query.Language

Methods

readJSON :: JSValue -> Result FieldDefinition

showJSON :: FieldDefinition -> JSValue

readJSONs :: JSValue -> Result [FieldDefinition]

showJSONs :: [FieldDefinition] -> JSValue

data ResultEntry #

Constructors

ResultEntry 

Fields

Instances

Instances details
Show ResultEntry # 
Instance details

Defined in Ganeti.Query.Language

Methods

showsPrec :: Int -> ResultEntry -> ShowS

show :: ResultEntry -> String

showList :: [ResultEntry] -> ShowS

NFData ResultEntry # 
Instance details

Defined in Ganeti.Query.Language

Methods

rnf :: ResultEntry -> ()

Eq ResultEntry # 
Instance details

Defined in Ganeti.Query.Language

Methods

(==) :: ResultEntry -> ResultEntry -> Bool

(/=) :: ResultEntry -> ResultEntry -> Bool

JSON ResultEntry # 
Instance details

Defined in Ganeti.Query.Language

Methods

readJSON :: JSValue -> Result ResultEntry

showJSON :: ResultEntry -> JSValue

readJSONs :: JSValue -> Result [ResultEntry]

showJSONs :: [ResultEntry] -> JSValue

data ResultStatus #

Status of a query field.

Instances

Instances details
Bounded ResultStatus # 
Instance details

Defined in Ganeti.Query.Language

Enum ResultStatus # 
Instance details

Defined in Ganeti.Query.Language

Show ResultStatus # 
Instance details

Defined in Ganeti.Query.Language

Methods

showsPrec :: Int -> ResultStatus -> ShowS

show :: ResultStatus -> String

showList :: [ResultStatus] -> ShowS

NFData ResultStatus #

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

Instance details

Defined in Ganeti.Query.Language

Methods

rnf :: ResultStatus -> ()

Eq ResultStatus # 
Instance details

Defined in Ganeti.Query.Language

Methods

(==) :: ResultStatus -> ResultStatus -> Bool

(/=) :: ResultStatus -> ResultStatus -> Bool

Ord ResultStatus # 
Instance details

Defined in Ganeti.Query.Language

JSON ResultStatus # 
Instance details

Defined in Ganeti.Query.Language

Methods

readJSON :: JSValue -> Result ResultStatus

showJSON :: ResultStatus -> JSValue

readJSONs :: JSValue -> Result [ResultStatus]

showJSONs :: [ResultStatus] -> JSValue

type ResultValue = JSValue #

Value of a field, in json encoding. (its type will be depending on ResultStatus and FieldType)

data ItemType #

Overall query type.

Instances

Instances details
Show ItemType # 
Instance details

Defined in Ganeti.Query.Language

Methods

showsPrec :: Int -> ItemType -> ShowS

show :: ItemType -> String

showList :: [ItemType] -> ShowS

Eq ItemType # 
Instance details

Defined in Ganeti.Query.Language

Methods

(==) :: ItemType -> ItemType -> Bool

(/=) :: ItemType -> ItemType -> Bool

JSON ItemType #

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

Instance details

Defined in Ganeti.Query.Language

Methods

readJSON :: JSValue -> Result ItemType

showJSON :: ItemType -> JSValue

readJSONs :: JSValue -> Result [ItemType]

showJSONs :: [ItemType] -> JSValue

data QueryTypeOp #

Supported items on which Qlang works.

Instances

Instances details
Bounded QueryTypeOp # 
Instance details

Defined in Ganeti.Query.Language

Enum QueryTypeOp # 
Instance details

Defined in Ganeti.Query.Language

Show QueryTypeOp # 
Instance details

Defined in Ganeti.Query.Language

Methods

showsPrec :: Int -> QueryTypeOp -> ShowS

show :: QueryTypeOp -> String

showList :: [QueryTypeOp] -> ShowS

Eq QueryTypeOp # 
Instance details

Defined in Ganeti.Query.Language

Methods

(==) :: QueryTypeOp -> QueryTypeOp -> Bool

(/=) :: QueryTypeOp -> QueryTypeOp -> Bool

Ord QueryTypeOp # 
Instance details

Defined in Ganeti.Query.Language

JSON QueryTypeOp # 
Instance details

Defined in Ganeti.Query.Language

Methods

readJSON :: JSValue -> Result QueryTypeOp

showJSON :: QueryTypeOp -> JSValue

readJSONs :: JSValue -> Result [QueryTypeOp]

showJSONs :: [QueryTypeOp] -> JSValue

data QueryTypeLuxi #

Supported items on which Qlang works.

Constructors

QRLock 
QRJob 
QRFilter 

Instances

Instances details
Bounded QueryTypeLuxi # 
Instance details

Defined in Ganeti.Query.Language

Enum QueryTypeLuxi # 
Instance details

Defined in Ganeti.Query.Language

Show QueryTypeLuxi # 
Instance details

Defined in Ganeti.Query.Language

Methods

showsPrec :: Int -> QueryTypeLuxi -> ShowS

show :: QueryTypeLuxi -> String

showList :: [QueryTypeLuxi] -> ShowS

Eq QueryTypeLuxi # 
Instance details

Defined in Ganeti.Query.Language

Ord QueryTypeLuxi # 
Instance details

Defined in Ganeti.Query.Language

JSON QueryTypeLuxi # 
Instance details

Defined in Ganeti.Query.Language

Methods

readJSON :: JSValue -> Result QueryTypeLuxi

showJSON :: QueryTypeLuxi -> JSValue

readJSONs :: JSValue -> Result [QueryTypeLuxi]

showJSONs :: [QueryTypeLuxi] -> JSValue

checkRS :: MonadFail m => ResultStatus -> a -> m a #

Check that ResultStatus is success or fail with descriptive message.