Revision 54c7dff7 src/Ganeti/DataCollectors/Types.hs

b/src/Ganeti/DataCollectors/Types.hs
28 28
module Ganeti.DataCollectors.Types
29 29
  ( DCReport(..)
30 30
  , DCCategory(..)
31
  , DCKind(..)
31 32
  , DCVersion(..)
32 33
  , buildReport
33 34
  ) where
......
48 49
  readJSON =
49 50
    error "JSON read instance not implemented for type DCCategory"
50 51

  
52
-- | The type representing the kind of the collector.
53
data DCKind = DCKPerf   -- ^ Performance reporting collector
54
            | DCKStatus -- ^ Status reporting collector
55
            deriving (Show, Eq)
56

  
57
-- | The JSON instance for CollectorKind.
58
instance JSON DCKind where
59
  showJSON DCKPerf   = showJSON (0 :: Int)
60
  showJSON DCKStatus = showJSON (1 :: Int)
61
  readJSON = error "JSON read instance not implemented for type DCKind"
62

  
51 63
-- | Type representing the version number of a data collector.
52 64
data DCVersion = DCVerBuiltin | DCVersion String deriving (Show, Eq)
53 65

  
......
65 77
  , simpleField "timestamp"      [t| Integer |]
66 78
  , optionalNullSerField $
67 79
      simpleField "category"     [t| DCCategory |]
80
  , simpleField "kind"           [t| DCKind |]
68 81
  , simpleField "data"           [t| JSValue |]
69 82
  ])
70 83

  
......
72 85
-- timestamp (rounded up to seconds).
73 86
-- If the version is not specified, it will be set to the value indicating
74 87
-- a builtin collector.
75
buildReport :: String -> DCVersion -> Int -> Maybe DCCategory -> JSValue
76
            -> IO DCReport
77
buildReport name version format_version category jsonData = do
88
buildReport :: String -> DCVersion -> Int -> Maybe DCCategory -> DCKind
89
            -> JSValue -> IO DCReport
90
buildReport name version format_version category kind jsonData = do
78 91
  now <- getCurrentTime
79 92
  let timestamp = now * 1000000000 :: Integer
80
  return $ DCReport name version format_version timestamp category jsonData
93
  return $
94
    DCReport name version format_version timestamp category kind
95
      jsonData

Also available in: Unified diff