class Node(model.Model): """ Stores the lightweight data associated with a node, and an index of heavy data (which has to be downloaded separately). This includes: - ``id``: self-descriptive. The ID of a node cannot be changed. - ``parent``: the node parent's ID. - ``pos_start`` and ``pos_end``: for nodes where it makes sense (mostly chunka), the range of positions occupied by this object. ``pos_start`` is inclusive, while ``pos_end`` is exclusive. - ``tags``: an unordered set of tags, which are simple strings. - ``attr``: a string-keyed dict of attributes with arbitrary data. - ``data``: an unordered set of keys with non-null heavyweight data. The data has to be downloaded separately. - ``bindata``: a dict with an index of available bindata. The keys in this dict correspond to bindata keys, and the values are size of the corresponding binary data in bytes. The actual bindata has to be downloaded separately. - ``triggers``: a dict containing active triggers for the given node. The keys are trigger names, and they are mapped to the state of the given trigger. """ id = fields.NodeID() parent = fields.NodeID(default=NodeID.root_id) pos_start = fields.Integer(optional=True) pos_end = fields.Integer(optional=True) tags = fields.Set(fields.String()) attr = fields.Map(fields.String(), fields.Any()) data = fields.Set(fields.String()) bindata = fields.Map(fields.String(), fields.SmallUnsignedInteger()) triggers = fields.Map(fields.String(), fields.Enum(TriggerState))
class MsgGetList(MsgpackMsg): """ Sent by client, requests a list of children of the given node matching the given filters. Children can be filtered by tags (the set of tags in the query must be a subset of the node's tags for it to match) and by a position filter. If sub is False, server will reply with a single MsgGetListReply with gone=[], or with a single MsgQueryError. If sub is True, the first reply will be like for sub=False, but subsequent replies will only mention changed nodes - nodes that are new on the list, along with changed nodes remaining on the list are sent in the objs field of the reply, while the IDs of nodes no longer on the list are sent in the gone field of the reply. The list may fail with ObjectGoneErro if the parent node is gone. If it reappears in the future, a MsgGetListReply will be sent with a complete list of children. """ object_type = 'get_list' qid = fields.SmallUnsignedInteger() parent = fields.NodeID(default=NodeID.root_id) tags = fields.Set(fields.String()) pos_filter = fields.Object(PosFilter, default=PosFilter()) sub = fields.Boolean(default=False)
class MsgPluginHandlerUnregistered(MsgpackMsg): """ Sent by the server to confirm MsgPluginHandlerUnregister. """ object_type = 'plugin_handler_unregistered' phid = fields.SmallUnsignedInteger()
class ChunkDataItemField(ChunkDataItem): pos_start = fields.Integer() pos_end = fields.Integer() name = fields.String() repack = fields.Object(Repacker) num_elements = fields.SmallUnsignedInteger() type = fields.Object(FieldType) raw_value = fields.BinData()
class MsgRequestAck(MsgpackMsg): """ Sent by the server in reply to modification requests. """ object_type = 'request_ack' rid = fields.SmallUnsignedInteger()
class MsgSubscriptionCancelled(MsgpackMsg): """ Sent by the server in reply to MsgCancelSubscription. """ object_type = 'subscription_cancelled' qid = fields.SmallUnsignedInteger()
class MsgGetQuery(MsgpackMsg): object_type = 'get_query' qid = fields.SmallUnsignedInteger() node = fields.NodeID() query = fields.String() params = fields.Any(optional=True) trace = fields.Boolean(default=False) sub = fields.Boolean(default=False)
class MsgGetBinDataReply(MsgpackMsg): """ Sent by server in reply to MsgGetBinData. """ object_type = 'get_bindata_reply' qid = fields.SmallUnsignedInteger() data = fields.Binary()
class MsgMethodResult(MsgpackMsg): """ Sent by the server in reply to MsgMethodRun. """ object_type = 'method_result' mid = fields.SmallUnsignedInteger() result = fields.Any(optional=True)
class MsgGetDataReply(MsgpackMsg): """ Sent by server in reply to MsgGetData. """ object_type = 'get_data_reply' qid = fields.SmallUnsignedInteger() data = fields.Any(optional=True)
class MsgPluginMethodResult(MsgpackMsg): """ Sent by the client in reply to MsgPluginMethodRun. """ object_type = 'plugin_method_result' pmid = fields.SmallUnsignedInteger() result = fields.Any(optional=True)
class MsgPluginMethodError(MsgpackMsg): """ Sent by the client in reply to MsgPluginMethodRun. """ object_type = 'plugin_method_error' pmid = fields.SmallUnsignedInteger() err = fields.Object(VelesException)
class MsgPluginHandlerUnregister(MsgpackMsg): """ Sent by the client to unregister a handler. Server replies with MsgPluginHandlerUnregistered. """ object_type = 'plugin_handler_unregister' phid = fields.SmallUnsignedInteger()
class MsgPluginTriggerDone(MsgpackMsg): """ Sent by the client in reply to MsgPluginTriggerRun. """ object_type = 'plugin_trigger_done' ptid = fields.SmallUnsignedInteger() checks = fields.List(fields.Object(Check))
class MsgPluginBroadcastResult(MsgpackMsg): """ Sent by the client in reply to MsgPluginBroadcastRun. """ object_type = 'plugin_broadcast_result' pbid = fields.SmallUnsignedInteger() results = fields.List(fields.Any(optional=True))
class MsgMethodError(MsgpackMsg): """ Sent by the server in reply to MsgMethodRun. """ object_type = 'method_error' mid = fields.SmallUnsignedInteger() err = fields.Object(VelesException)
class MsgBroadcastResult(MsgpackMsg): """ Sent by the server in reply to MsgBroadcastRun. """ object_type = 'broadcast_result' bid = fields.SmallUnsignedInteger() results = fields.List(fields.Any(optional=True))
class MsgGetReply(MsgpackMsg): """ Sent by server in reply to MsgGet. """ object_type = 'get_reply' qid = fields.SmallUnsignedInteger() obj = fields.Object(Node)
class MsgRequestError(MsgpackMsg): """ Sent by the server in reply to modification requests. """ object_type = 'request_error' rid = fields.SmallUnsignedInteger() err = fields.Object(VelesException)
class MsgPluginTriggerError(MsgpackMsg): """ Sent by the client in reply to MsgPluginTriggerRun. """ object_type = 'plugin_trigger_error' ptid = fields.SmallUnsignedInteger() err = fields.Object(VelesException) checks = fields.List(fields.Object(Check))
class MsgPluginQueryError(MsgpackMsg): """ Sent by the client in reply to MsgPluginQueryGet. """ object_type = 'plugin_query_error' pqid = fields.SmallUnsignedInteger() err = fields.Object(VelesException) checks = fields.List(fields.Object(Check))
class MsgPluginQueryResult(MsgpackMsg): """ Sent by the client in reply to MsgPluginQueryGet. """ object_type = 'plugin_query_result' pqid = fields.SmallUnsignedInteger() result = fields.Any(optional=True) checks = fields.List(fields.Object(Check))
class MsgSetBinData(MsgpackMsg): """ Sets a range of bindata on a given node. Server replies with MsgRequestAck or MsgRequestError. The bindata is modified starting from a given start position - it is an error if the position is after the current end of bindata (but not if it's equal). The bindata is expanded if necessary to hold the new data. If truncate is set, the bindata is truncated after the end of the new data. If bindata would become 0-length, it is deleted. """ object_type = 'set_bindata' rid = fields.SmallUnsignedInteger() id = fields.NodeID() key = fields.String() start = fields.SmallUnsignedInteger(default=0) data = fields.Binary() truncate = fields.Boolean(default=False)
class MsgGetBinData(MsgpackMsg): """ Sent by client, requests a range of bindata associated with the given node and key. Works like MsgGet, but replies with MsgGetBinData. The range is left-inclusive and right-exclusive. It is not an error if the key doesn't exist - empty bytestring will be returned in this case. It is also not an error if the range is out of bounds for the bindata - it will be truncated if it's partially in range, or an empty bytestring will be returned if it's completely out of range. """ object_type = 'get_bindata' qid = fields.SmallUnsignedInteger() id = fields.NodeID() key = fields.String() start = fields.SmallUnsignedInteger() end = fields.SmallUnsignedInteger(optional=True) sub = fields.Boolean(default=False)
class MsgGetListReply(MsgpackMsg): """ Sent by server in reply to MsgGetList. """ object_type = 'get_list_reply' qid = fields.SmallUnsignedInteger() objs = fields.List(fields.Object(Node)) gone = fields.List(fields.NodeID())
class MsgPluginBroadcastRegister(MsgpackMsg): """ Sent by the client to register a broadcast handler. Has no reply. ``phid`` is an arbitrary number chosen by the client to identify this broadcast handler. """ object_type = 'plugin_broadcast_register' phid = fields.SmallUnsignedInteger() name = fields.String()
class MsgPluginTriggerRegister(MsgpackMsg): """ Sent by the client to register a trigger handler. Has no reply. ``phid`` is an arbitrary number chosen by the client to identify this method handler. """ object_type = 'plugin_trigger_register' phid = fields.SmallUnsignedInteger() name = fields.String() tags = fields.Set(fields.String())
class MsgTransaction(MsgpackMsg): """ Sent by the client to request a list of database-modifying operations. The operations are executed atomically, and only if the attached checks are still valid. """ object_type = 'transaction' rid = fields.SmallUnsignedInteger() checks = fields.List(fields.Object(Check)) operations = fields.List(fields.Object(Operation))
class MsgBroadcastRun(MsgpackMsg): """ Sent by the client to request running a given broadcast. ``bid`` is an arbitrary number selected by the client to associate replies to this request. """ object_type = 'broadcast_run' bid = fields.SmallUnsignedInteger() broadcast = fields.String() params = fields.Any(optional=True)
class MsgDelTag(MsgpackMsg): """ Removes a tag from a given node. Server replies with MsgRequestAck or MsgRequestError. If the node doesn't have the given tag, nothing happens. """ object_type = 'del_tag' rid = fields.SmallUnsignedInteger() id = fields.NodeID() tag = fields.String()