mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-22 17:43:14 +00:00
Add definitions for standard messages to pass through pulig api
This commit is contained in:
parent
ec58c47bff
commit
bb8c65fc34
0
confluent/__init__.py
Normal file
0
confluent/__init__.py
Normal file
34
confluent/messages.py
Normal file
34
confluent/messages.py
Normal file
@ -0,0 +1,34 @@
|
||||
#Copyright 2013 IBM All rights reserved
|
||||
|
||||
# This module implements client/server messages emitted from plugins.
|
||||
# Things are defined here to 'encourage' developers to coordinate information
|
||||
# format. This is also how different data formats are supported
|
||||
import json
|
||||
|
||||
class ConfluentMessage(object):
|
||||
|
||||
def __init__(self):
|
||||
raise NotImplementedError("Must be subclassed!")
|
||||
|
||||
def json(self):
|
||||
# This will create the canonical json representation of this message
|
||||
return json.dumps(self.kvpairs, separators=(',', ':'))
|
||||
|
||||
def strip_node(self, node):
|
||||
self.kvpairs = self.kvpairs[node]
|
||||
|
||||
def html(self):
|
||||
#this is used to facilitate the api explorer feature
|
||||
pass
|
||||
|
||||
|
||||
class PowerState(ConfluentMessage):
|
||||
|
||||
def __init__(self, node, state):
|
||||
self.kvpairs = {
|
||||
node: {
|
||||
'powerstate': state,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user