Statistics
| Branch: | Tag: | Revision:

root / htools / Ganeti / Query / Types.hs @ 046fe3f5

History | View | Annotate | Download (1.8 kB)

1
{-| Implementation of the Ganeti Query2 basic types.
2

    
3
These are types internal to the library, and for example clients that
4
use the library should not need to import it.
5

    
6
 -}
7

    
8
{-
9

    
10
Copyright (C) 2012 Google Inc.
11

    
12
This program is free software; you can redistribute it and/or modify
13
it under the terms of the GNU General Public License as published by
14
the Free Software Foundation; either version 2 of the License, or
15
(at your option) any later version.
16

    
17
This program is distributed in the hope that it will be useful, but
18
WITHOUT ANY WARRANTY; without even the implied warranty of
19
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20
General Public License for more details.
21

    
22
You should have received a copy of the GNU General Public License
23
along with this program; if not, write to the Free Software
24
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25
02110-1301, USA.
26

    
27
-}
28

    
29
module Ganeti.Query.Types where
30

    
31
import qualified Data.Map as Map
32

    
33
import Ganeti.Qlang
34
import Ganeti.Objects
35

    
36
-- | The type of field getters. The \"a\" type represents the type
37
-- we're querying, whereas the \"b\" type represents the \'runtime\'
38
-- data for that type (if any). Note that we don't support multiple
39
-- runtime sources, and we always consider the entire configuration as
40
-- a given (so no equivalent for Python's /*_CONFIG/ and /*_GROUP/;
41
-- configuration accesses are cheap for us).
42
data FieldGetter a b = FieldSimple  (a -> ResultEntry)
43
                     | FieldRuntime (b -> a -> ResultEntry)
44
                     | FieldConfig  (ConfigData -> a -> ResultEntry)
45
                     | FieldUnknown
46

    
47
-- | Alias for a field data (definition and getter).
48
type FieldData a b = (FieldDefinition, FieldGetter a b)
49

    
50
-- | Alias for a field data list.
51
type FieldList a b = [FieldData a b]
52

    
53
-- | Alias for field maps.
54
type FieldMap a b = Map.Map String (FieldData a b)