Is this what we wanted? :)

Signed-off-by: Guido Trotter <ultrot...@google.com>
---
 htools/Ganeti/Query2.hs |   81 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 htools/Ganeti/Query2.hs

diff --git a/htools/Ganeti/Query2.hs b/htools/Ganeti/Query2.hs
new file mode 100644
index 0000000..50b445e
--- /dev/null
+++ b/htools/Ganeti/Query2.hs
@@ -0,0 +1,81 @@
+{-| Implementation of the Ganeti Query2 language.
+
+ -}
+
+{-
+
+Copyright (C) 2012 Google Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA.
+
+-}
+
+module Ganeti.Query2
+    ( Filter
+    ) where
+
+-- Main Query2 queries and responses
+data Query = Query ItemType Fields (Maybe Filter)
+
+data QueryResult = QueryResult [ FieldDefinition ] [ ResultEntry ]
+
+data QueryFields = QueryFields ItemType Fields
+
+data QueryFieldsResult = QueryFieldsResult [ FieldDefinition ]
+
+-- Sub data types for query2 queries and responses
+data ItemType
+    = Instance
+    | Node
+    | Group
+    | Job
+    | Lock
+    | Os
+
+type Fields = [ String ]
+
+data Filter
+    = AndFilter [ Filter] -- & [<expression>, ...]
+    | OrFilter [ Filter ] -- | [<expression>, ...]
+    | NotFilter Filter -- ! <expression>
+    | TrueFilter FilterField -- ? <field>
+    | EqualFilter FilterField FilterValue -- (=|!=) <field> <value>
+    | RegexpFilter FilterField FilterRegexp -- =~ <field> <regexp>
+    | ContainsFilter FilterField FilterValue -- =[] <list-field> <value>
+
+type FilterField = String
+type FilterValue = String
+type FilterRegexp = String
+
+data FieldDefinition = FieldDefinition FieldName FieldTitle FieldKind FieldDoc
+
+type FieldName = String
+type FieldTitle = String
+type FieldDoc = String
+
+data FieldKind
+    = KindUnknown
+    | KindText
+    | KindBool
+    | KindNumber
+    | KindUnit
+    | KindTimestamp
+    | KindOther
+
+data ResultEntry = ResultEntry Integer (Maybe ResultValue)
+
+data ResultValue = Integer | String | Bool
+
-- 
1.7.10

Reply via email to