desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Returns string representation of this message.'
def __str__(self):
return u'Authenticate(signature={0}, extra={1})'.format(self.signature, self.extra)
':param reason: Optional WAMP or application error URI for closing reason. :type reason: str :param message: Optional human-readable closing message, e.g. for logging purposes. :type message: str or None :param resumable: From the server: Whether the session is able to be resumed (true) or destroyed (false). From the client: Whether it should be resumable (true) or destroyed (false). :type resumable: bool or None'
def __init__(self, reason=DEFAULT_REASON, message=None, resumable=None):
assert (type(reason) == six.text_type) assert ((message is None) or (type(message) == six.text_type)) assert ((resumable is None) or (type(resumable) == bool)) Message.__init__(self) self.reason = reason self.message = message self.resumable = resumable
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Goodbye.MESSAGE_TYPE)) if (len(wmsg) != 3): raise ProtocolError('invalid message length {0} for GOODBYE'.format(len(wmsg))) details = check_or_raise_extra(wmsg[1], u"'details' in GOODBYE") reason = check_or_raise_uri(wmsg[2], u"'reason' in GOODBYE") message = None resumable = None if (u'message' in details): details_message = details[u'message'] if (type(details_message) != six.text_type): raise ProtocolError("invalid type {0} for 'message' detail in GOODBYE".format(type(details_message))) message = details_message if (u'resumable' in details): resumable = details[u'resumable'] if (type(resumable) != bool): raise ProtocolError("invalid type {0} for 'resumable' detail in GOODBYE".format(type(resumable))) obj = Goodbye(reason=reason, message=message, resumable=resumable) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
details = {} if self.message: details[u'message'] = self.message if self.resumable: details[u'resumable'] = self.resumable return [Goodbye.MESSAGE_TYPE, details, self.reason]
'Returns string representation of this message.'
def __str__(self):
return u'Goodbye(message={}, reason={}, resumable={})'.format(self.message, self.reason, self.resumable)
':param request_type: The WAMP message type code for the original request. :type request_type: int :param request: The WAMP request ID of the original request (`Call`, `Subscribe`, ...) this error occurred for. :type request: int :param error: The WAMP or application error URI for the error that occurred. :type error: str :param args: Positional values for application-defined exception. Must be serializable using any serializers in use. :type args: list or None :param kwargs: Keyword values for application-defined exception. Must be serializable using any serializers in use. :type kwargs: dict or None :param payload: Alternative, transparent payload. If given, ``args`` and ``kwargs`` must be left unset. :type payload: bytes or None :param enc_algo: If using payload transparency, the encoding algorithm that was used to encode the payload. :type enc_algo: str or None :param enc_key: If using payload transparency with an encryption algorithm, the payload encryption key. :type enc_key: str or None :param enc_serializer: If using payload transparency, the payload object serializer that was used encoding the payload. :type enc_serializer: str or None'
def __init__(self, request_type, request, error, args=None, kwargs=None, payload=None, enc_algo=None, enc_key=None, enc_serializer=None):
assert (type(request_type) in six.integer_types) assert (type(request) in six.integer_types) assert (type(error) == six.text_type) assert ((args is None) or (type(args) in [list, tuple])) assert ((kwargs is None) or (type(kwargs) == dict)) assert ((payload is None) or (type(payload) == six.binary_type)) assert ((payload is None) or ((payload is not None) and (args is None) and (kwargs is None))) assert ((enc_algo is None) or is_valid_enc_algo(enc_algo)) assert (((enc_algo is None) and (enc_key is None) and (enc_serializer is None)) or ((payload is not None) and (enc_algo is not None))) assert ((enc_key is None) or (type(enc_key) == six.text_type)) assert ((enc_serializer is None) or is_valid_enc_serializer(enc_serializer)) Message.__init__(self) self.request_type = request_type self.request = request self.error = error self.args = args self.kwargs = kwargs self.payload = payload self.enc_algo = enc_algo self.enc_key = enc_key self.enc_serializer = enc_serializer
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Error.MESSAGE_TYPE)) if (len(wmsg) not in (5, 6, 7)): raise ProtocolError('invalid message length {0} for ERROR'.format(len(wmsg))) request_type = wmsg[1] if (type(request_type) not in six.integer_types): raise ProtocolError("invalid type {0} for 'request_type' in ERROR".format(request_type)) if (request_type not in [Subscribe.MESSAGE_TYPE, Unsubscribe.MESSAGE_TYPE, Publish.MESSAGE_TYPE, Register.MESSAGE_TYPE, Unregister.MESSAGE_TYPE, Call.MESSAGE_TYPE, Invocation.MESSAGE_TYPE]): raise ProtocolError("invalid value {0} for 'request_type' in ERROR".format(request_type)) request = check_or_raise_id(wmsg[2], u"'request' in ERROR") details = check_or_raise_extra(wmsg[3], u"'details' in ERROR") error = check_or_raise_uri(wmsg[4], u"'error' in ERROR") args = None kwargs = None payload = None enc_algo = None enc_key = None enc_serializer = None if ((len(wmsg) == 6) and (type(wmsg[5]) == six.binary_type)): payload = wmsg[5] enc_algo = details.get(u'enc_algo', None) if (enc_algo and (not is_valid_enc_algo(enc_algo))): raise ProtocolError("invalid value {0} for 'enc_algo' detail in EVENT".format(enc_algo)) enc_key = details.get(u'enc_key', None) if (enc_key and (type(enc_key) != six.text_type)): raise ProtocolError("invalid type {0} for 'enc_key' detail in EVENT".format(type(enc_key))) enc_serializer = details.get(u'enc_serializer', None) if (enc_serializer and (not is_valid_enc_serializer(enc_serializer))): raise ProtocolError("invalid value {0} for 'enc_serializer' detail in EVENT".format(enc_serializer)) else: if (len(wmsg) > 5): args = wmsg[5] if ((args is not None) and (type(args) != list)): raise ProtocolError("invalid type {0} for 'args' in ERROR".format(type(args))) if (len(wmsg) > 6): kwargs = wmsg[6] if (type(kwargs) != dict): raise ProtocolError("invalid type {0} for 'kwargs' in ERROR".format(type(kwargs))) obj = Error(request_type, request, error, args=args, kwargs=kwargs, payload=payload, enc_algo=enc_algo, enc_key=enc_key, enc_serializer=enc_serializer) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
details = {} if self.payload: if (self.enc_algo is not None): details[u'enc_algo'] = self.enc_algo if (self.enc_key is not None): details[u'enc_key'] = self.enc_key if (self.enc_serializer is not None): details[u'enc_serializer'] = self.enc_serializer return [self.MESSAGE_TYPE, self.request_type, self.request, details, self.error, self.payload] elif self.kwargs: return [self.MESSAGE_TYPE, self.request_type, self.request, details, self.error, self.args, self.kwargs] elif self.args: return [self.MESSAGE_TYPE, self.request_type, self.request, details, self.error, self.args] else: return [self.MESSAGE_TYPE, self.request_type, self.request, details, self.error]
'Returns string representation of this message.'
def __str__(self):
return u'Error(request_type={0}, request={1}, error={2}, args={3}, kwargs={4}, enc_algo={5}, enc_key={6}, enc_serializer={7}, payload={8})'.format(self.request_type, self.request, self.error, self.args, self.kwargs, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
':param request: The WAMP request ID of this request. :type request: int :param topic: The WAMP or application URI of the PubSub topic the event should be published to. :type topic: str :param args: Positional values for application-defined event payload. Must be serializable using any serializers in use. :type args: list or tuple or None :param kwargs: Keyword values for application-defined event payload. Must be serializable using any serializers in use. :type kwargs: dict or None :param payload: Alternative, transparent payload. If given, ``args`` and ``kwargs`` must be left unset. :type payload: bytes or None :param acknowledge: If True, acknowledge the publication with a success or error response. :type acknowledge: bool or None :param exclude_me: If ``True``, exclude the publisher from receiving the event, even if he is subscribed (and eligible). :type exclude_me: bool or None :param exclude: List of WAMP session IDs to exclude from receiving this event. :type exclude: list of int or None :param exclude_authid: List of WAMP authids to exclude from receiving this event. :type exclude_authid: list of str or None :param exclude_authrole: List of WAMP authroles to exclude from receiving this event. :type exclude_authrole: list of str or None :param eligible: List of WAMP session IDs eligible to receive this event. :type eligible: list of int or None :param eligible_authid: List of WAMP authids eligible to receive this event. :type eligible_authid: list of str or None :param eligible_authrole: List of WAMP authroles eligible to receive this event. :type eligible_authrole: list of str or None :param retain: If ``True``, request the broker retain this event. :type retain: bool or None :param enc_algo: If using payload transparency, the encoding algorithm that was used to encode the payload. :type enc_algo: str or None :param enc_key: If using payload transparency with an encryption algorithm, the payload encryption key. :type enc_key: str or None :param enc_serializer: If using payload transparency, the payload object serializer that was used encoding the payload. :type enc_serializer: str or None or None'
def __init__(self, request, topic, args=None, kwargs=None, payload=None, acknowledge=None, exclude_me=None, exclude=None, exclude_authid=None, exclude_authrole=None, eligible=None, eligible_authid=None, eligible_authrole=None, retain=None, enc_algo=None, enc_key=None, enc_serializer=None):
assert (type(request) in six.integer_types) assert (type(topic) == six.text_type) assert ((args is None) or (type(args) in [list, tuple, six.text_type, six.binary_type])) assert ((kwargs is None) or (type(kwargs) in [dict, six.text_type, six.binary_type])) assert ((payload is None) or (type(payload) == six.binary_type)) assert ((payload is None) or ((payload is not None) and (args is None) and (kwargs is None))) assert ((acknowledge is None) or (type(acknowledge) == bool)) assert ((retain is None) or (type(retain) == bool)) assert ((exclude_me is None) or (type(exclude_me) == bool)) assert ((exclude is None) or (type(exclude) == list)) if exclude: for sessionid in exclude: assert (type(sessionid) in six.integer_types) assert ((exclude_authid is None) or (type(exclude_authid) == list)) if exclude_authid: for authid in exclude_authid: assert (type(authid) == six.text_type) assert ((exclude_authrole is None) or (type(exclude_authrole) == list)) if exclude_authrole: for authrole in exclude_authrole: assert (type(authrole) == six.text_type) assert ((eligible is None) or (type(eligible) == list)) if eligible: for sessionid in eligible: assert (type(sessionid) in six.integer_types) assert ((eligible_authid is None) or (type(eligible_authid) == list)) if eligible_authid: for authid in eligible_authid: assert (type(authid) == six.text_type) assert ((eligible_authrole is None) or (type(eligible_authrole) == list)) if eligible_authrole: for authrole in eligible_authrole: assert (type(authrole) == six.text_type) assert ((enc_algo is None) or is_valid_enc_algo(enc_algo)) assert (((enc_algo is None) and (enc_key is None) and (enc_serializer is None)) or ((payload is not None) and (enc_algo is not None))) assert ((enc_key is None) or (type(enc_key) == six.text_type)) assert ((enc_serializer is None) or is_valid_enc_serializer(enc_serializer)) Message.__init__(self) self.request = request self.topic = topic self.args = args self.kwargs = kwargs self.payload = payload self.acknowledge = acknowledge self.exclude_me = exclude_me self.exclude = exclude self.exclude_authid = exclude_authid self.exclude_authrole = exclude_authrole self.eligible = eligible self.eligible_authid = eligible_authid self.eligible_authrole = eligible_authrole self.retain = retain self.enc_algo = enc_algo self.enc_key = enc_key self.enc_serializer = enc_serializer
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Publish.MESSAGE_TYPE)) if (len(wmsg) not in (4, 5, 6)): raise ProtocolError('invalid message length {0} for PUBLISH'.format(len(wmsg))) request = check_or_raise_id(wmsg[1], u"'request' in PUBLISH") options = check_or_raise_extra(wmsg[2], u"'options' in PUBLISH") topic = check_or_raise_uri(wmsg[3], u"'topic' in PUBLISH") args = None kwargs = None payload = None if ((len(wmsg) == 5) and (type(wmsg[4]) in [six.text_type, six.binary_type])): payload = wmsg[4] enc_algo = options.get(u'enc_algo', None) if (enc_algo and (not is_valid_enc_algo(enc_algo))): raise ProtocolError("invalid value {0} for 'enc_algo' option in PUBLISH".format(enc_algo)) enc_key = options.get(u'enc_key', None) if (enc_key and (type(enc_key) != six.text_type)): raise ProtocolError("invalid type {0} for 'enc_key' option in PUBLISH".format(type(enc_key))) enc_serializer = options.get(u'enc_serializer', None) if (enc_serializer and (not is_valid_enc_serializer(enc_serializer))): raise ProtocolError("invalid value {0} for 'enc_serializer' option in PUBLISH".format(enc_serializer)) else: if (len(wmsg) > 4): args = wmsg[4] if (type(args) not in [list, six.text_type, six.binary_type]): raise ProtocolError("invalid type {0} for 'args' in PUBLISH".format(type(args))) if (len(wmsg) > 5): kwargs = wmsg[5] if (type(kwargs) not in [dict, six.text_type, six.binary_type]): raise ProtocolError("invalid type {0} for 'kwargs' in PUBLISH".format(type(kwargs))) enc_algo = None enc_key = None enc_serializer = None acknowledge = None exclude_me = None exclude = None exclude_authid = None exclude_authrole = None eligible = None eligible_authid = None eligible_authrole = None retain = None if (u'acknowledge' in options): option_acknowledge = options[u'acknowledge'] if (type(option_acknowledge) != bool): raise ProtocolError("invalid type {0} for 'acknowledge' option in PUBLISH".format(type(option_acknowledge))) acknowledge = option_acknowledge if (u'exclude_me' in options): option_exclude_me = options[u'exclude_me'] if (type(option_exclude_me) != bool): raise ProtocolError("invalid type {0} for 'exclude_me' option in PUBLISH".format(type(option_exclude_me))) exclude_me = option_exclude_me if (u'exclude' in options): option_exclude = options[u'exclude'] if (type(option_exclude) != list): raise ProtocolError("invalid type {0} for 'exclude' option in PUBLISH".format(type(option_exclude))) for _sessionid in option_exclude: if (type(_sessionid) not in six.integer_types): raise ProtocolError("invalid type {0} for value in 'exclude' option in PUBLISH".format(type(_sessionid))) exclude = option_exclude if (u'exclude_authid' in options): option_exclude_authid = options[u'exclude_authid'] if (type(option_exclude_authid) != list): raise ProtocolError("invalid type {0} for 'exclude_authid' option in PUBLISH".format(type(option_exclude_authid))) for _authid in option_exclude_authid: if (type(_authid) != six.text_type): raise ProtocolError("invalid type {0} for value in 'exclude_authid' option in PUBLISH".format(type(_authid))) exclude_authid = option_exclude_authid if (u'exclude_authrole' in options): option_exclude_authrole = options[u'exclude_authrole'] if (type(option_exclude_authrole) != list): raise ProtocolError("invalid type {0} for 'exclude_authrole' option in PUBLISH".format(type(option_exclude_authrole))) for _authrole in option_exclude_authrole: if (type(_authrole) != six.text_type): raise ProtocolError("invalid type {0} for value in 'exclude_authrole' option in PUBLISH".format(type(_authrole))) exclude_authrole = option_exclude_authrole if (u'eligible' in options): option_eligible = options[u'eligible'] if (type(option_eligible) != list): raise ProtocolError("invalid type {0} for 'eligible' option in PUBLISH".format(type(option_eligible))) for sessionId in option_eligible: if (type(sessionId) not in six.integer_types): raise ProtocolError("invalid type {0} for value in 'eligible' option in PUBLISH".format(type(sessionId))) eligible = option_eligible if (u'eligible_authid' in options): option_eligible_authid = options[u'eligible_authid'] if (type(option_eligible_authid) != list): raise ProtocolError("invalid type {0} for 'eligible_authid' option in PUBLISH".format(type(option_eligible_authid))) for _authid in option_eligible_authid: if (type(_authid) != six.text_type): raise ProtocolError("invalid type {0} for value in 'eligible_authid' option in PUBLISH".format(type(_authid))) eligible_authid = option_eligible_authid if (u'eligible_authrole' in options): option_eligible_authrole = options[u'eligible_authrole'] if (type(option_eligible_authrole) != list): raise ProtocolError("invalid type {0} for 'eligible_authrole' option in PUBLISH".format(type(option_eligible_authrole))) for _authrole in option_eligible_authrole: if (type(_authrole) != six.text_type): raise ProtocolError("invalid type {0} for value in 'eligible_authrole' option in PUBLISH".format(type(_authrole))) eligible_authrole = option_eligible_authrole if (u'retain' in options): retain = options[u'retain'] if (type(retain) != bool): raise ProtocolError("invalid type {0} for 'retain' option in PUBLISH".format(type(retain))) obj = Publish(request, topic, args=args, kwargs=kwargs, payload=payload, acknowledge=acknowledge, exclude_me=exclude_me, exclude=exclude, exclude_authid=exclude_authid, exclude_authrole=exclude_authrole, eligible=eligible, eligible_authid=eligible_authid, eligible_authrole=eligible_authrole, retain=retain, enc_algo=enc_algo, enc_key=enc_key, enc_serializer=enc_serializer) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
options = self.marshal_options() if self.payload: return [Publish.MESSAGE_TYPE, self.request, options, self.topic, self.payload] elif self.kwargs: return [Publish.MESSAGE_TYPE, self.request, options, self.topic, self.args, self.kwargs] elif self.args: return [Publish.MESSAGE_TYPE, self.request, options, self.topic, self.args] else: return [Publish.MESSAGE_TYPE, self.request, options, self.topic]
'Returns string representation of this message.'
def __str__(self):
return u'Publish(request={}, topic={}, args={}, kwargs={}, acknowledge={}, exclude_me={}, exclude={}, exclude_authid={}, exclude_authrole={}, eligible={}, eligible_authid={}, eligible_authrole={}, retain={}, enc_algo={}, enc_key={}, enc_serializer={}, payload={})'.format(self.request, self.topic, self.args, self.kwargs, self.acknowledge, self.exclude_me, self.exclude, self.exclude_authid, self.exclude_authrole, self.eligible, self.eligible_authid, self.eligible_authrole, self.retain, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
':param request: The request ID of the original `PUBLISH` request. :type request: int :param publication: The publication ID for the published event. :type publication: int'
def __init__(self, request, publication):
assert (type(request) in six.integer_types) assert (type(publication) in six.integer_types) Message.__init__(self) self.request = request self.publication = publication
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Published.MESSAGE_TYPE)) if (len(wmsg) != 3): raise ProtocolError('invalid message length {0} for PUBLISHED'.format(len(wmsg))) request = check_or_raise_id(wmsg[1], u"'request' in PUBLISHED") publication = check_or_raise_id(wmsg[2], u"'publication' in PUBLISHED") obj = Published(request, publication) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
return [Published.MESSAGE_TYPE, self.request, self.publication]
'Returns string representation of this message.'
def __str__(self):
return u'Published(request={0}, publication={1})'.format(self.request, self.publication)
':param request: The WAMP request ID of this request. :type request: int :param topic: The WAMP or application URI of the PubSub topic to subscribe to. :type topic: str :param match: The topic matching method to be used for the subscription. :type match: str :param get_retained: Whether the client wants the retained message we may have along with the subscription. :type get_retained: bool or None'
def __init__(self, request, topic, match=None, get_retained=None):
assert (type(request) in six.integer_types) assert (type(topic) == six.text_type) assert ((match is None) or (type(match) == six.text_type)) assert ((match is None) or (match in [Subscribe.MATCH_EXACT, Subscribe.MATCH_PREFIX, Subscribe.MATCH_WILDCARD])) assert ((get_retained is None) or (type(get_retained) is bool)) Message.__init__(self) self.request = request self.topic = topic self.match = (match or Subscribe.MATCH_EXACT) self.get_retained = get_retained
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Subscribe.MESSAGE_TYPE)) if (len(wmsg) != 4): raise ProtocolError('invalid message length {0} for SUBSCRIBE'.format(len(wmsg))) request = check_or_raise_id(wmsg[1], u"'request' in SUBSCRIBE") options = check_or_raise_extra(wmsg[2], u"'options' in SUBSCRIBE") topic = check_or_raise_uri(wmsg[3], u"'topic' in SUBSCRIBE", allow_empty_components=True) match = Subscribe.MATCH_EXACT get_retained = None if (u'match' in options): option_match = options[u'match'] if (type(option_match) != six.text_type): raise ProtocolError("invalid type {0} for 'match' option in SUBSCRIBE".format(type(option_match))) if (option_match not in [Subscribe.MATCH_EXACT, Subscribe.MATCH_PREFIX, Subscribe.MATCH_WILDCARD]): raise ProtocolError("invalid value {0} for 'match' option in SUBSCRIBE".format(option_match)) match = option_match if (u'get_retained' in options): get_retained = options[u'get_retained'] if (type(get_retained) != bool): raise ProtocolError("invalid type {0} for 'get_retained' option in SUBSCRIBE".format(type(get_retained))) obj = Subscribe(request, topic, match=match, get_retained=get_retained) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
return [Subscribe.MESSAGE_TYPE, self.request, self.marshal_options(), self.topic]
'Returns string representation of this message.'
def __str__(self):
return u'Subscribe(request={0}, topic={1}, match={2}, get_retained={3})'.format(self.request, self.topic, self.match, self.get_retained)
':param request: The request ID of the original ``SUBSCRIBE`` request. :type request: int :param subscription: The subscription ID for the subscribed topic (or topic pattern). :type subscription: int'
def __init__(self, request, subscription):
assert (type(request) in six.integer_types) assert (type(subscription) in six.integer_types) Message.__init__(self) self.request = request self.subscription = subscription
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Subscribed.MESSAGE_TYPE)) if (len(wmsg) != 3): raise ProtocolError('invalid message length {0} for SUBSCRIBED'.format(len(wmsg))) request = check_or_raise_id(wmsg[1], u"'request' in SUBSCRIBED") subscription = check_or_raise_id(wmsg[2], u"'subscription' in SUBSCRIBED") obj = Subscribed(request, subscription) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
return [Subscribed.MESSAGE_TYPE, self.request, self.subscription]
'Returns string representation of this message.'
def __str__(self):
return u'Subscribed(request={0}, subscription={1})'.format(self.request, self.subscription)
':param request: The WAMP request ID of this request. :type request: int :param subscription: The subscription ID for the subscription to unsubscribe from. :type subscription: int'
def __init__(self, request, subscription):
assert (type(request) in six.integer_types) assert (type(subscription) in six.integer_types) Message.__init__(self) self.request = request self.subscription = subscription
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Unsubscribe.MESSAGE_TYPE)) if (len(wmsg) != 3): raise ProtocolError('invalid message length {0} for WAMP UNSUBSCRIBE'.format(len(wmsg))) request = check_or_raise_id(wmsg[1], u"'request' in UNSUBSCRIBE") subscription = check_or_raise_id(wmsg[2], u"'subscription' in UNSUBSCRIBE") obj = Unsubscribe(request, subscription) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
return [Unsubscribe.MESSAGE_TYPE, self.request, self.subscription]
'Returns string representation of this message.'
def __str__(self):
return u'Unsubscribe(request={0}, subscription={1})'.format(self.request, self.subscription)
':param request: The request ID of the original ``UNSUBSCRIBE`` request or ``0`` is router triggered unsubscribe ("router revocation signaling"). :type request: int :param subscription: If unsubscribe was actively triggered by router, the ID of the subscription revoked. :type subscription: int or None :param reason: The reason (an URI) for revocation. :type reason: str or None.'
def __init__(self, request, subscription=None, reason=None):
assert (type(request) in six.integer_types) assert ((subscription is None) or (type(subscription) in six.integer_types)) assert ((reason is None) or (type(reason) == six.text_type)) assert (((request != 0) and (subscription is None)) or ((request == 0) and (subscription != 0))) Message.__init__(self) self.request = request self.subscription = subscription self.reason = reason
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Unsubscribed.MESSAGE_TYPE)) if (len(wmsg) not in [2, 3]): raise ProtocolError('invalid message length {0} for UNSUBSCRIBED'.format(len(wmsg))) request = check_or_raise_id(wmsg[1], u"'request' in UNSUBSCRIBED") subscription = None reason = None if (len(wmsg) > 2): details = check_or_raise_extra(wmsg[2], u"'details' in UNSUBSCRIBED") if (u'subscription' in details): details_subscription = details[u'subscription'] if (type(details_subscription) not in six.integer_types): raise ProtocolError("invalid type {0} for 'subscription' detail in UNSUBSCRIBED".format(type(details_subscription))) subscription = details_subscription if (u'reason' in details): reason = check_or_raise_uri(details[u'reason'], u"'reason' in UNSUBSCRIBED") obj = Unsubscribed(request, subscription, reason) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
if ((self.reason is not None) or (self.subscription is not None)): details = {} if (self.reason is not None): details[u'reason'] = self.reason if (self.subscription is not None): details[u'subscription'] = self.subscription return [Unsubscribed.MESSAGE_TYPE, self.request, details] else: return [Unsubscribed.MESSAGE_TYPE, self.request]
'Returns string representation of this message.'
def __str__(self):
return u'Unsubscribed(request={0}, reason={1}, subscription={2})'.format(self.request, self.reason, self.subscription)
':param subscription: The subscription ID this event is dispatched under. :type subscription: int :param publication: The publication ID of the dispatched event. :type publication: int :param args: Positional values for application-defined exception. Must be serializable using any serializers in use. :type args: list or tuple or None :param kwargs: Keyword values for application-defined exception. Must be serializable using any serializers in use. :type kwargs: dict or None :param payload: Alternative, transparent payload. If given, ``args`` and ``kwargs`` must be left unset. :type payload: bytes or None :param publisher: The WAMP session ID of the pubisher. Only filled if pubisher is disclosed. :type publisher: None or int :param publisher_authid: The WAMP authid of the pubisher. Only filled if pubisher is disclosed. :type publisher_authid: None or unicode :param publisher_authrole: The WAMP authrole of the pubisher. Only filled if pubisher is disclosed. :type publisher_authrole: None or unicode :param topic: For pattern-based subscriptions, the event MUST contain the actual topic published to. :type topic: str or None :param retained: Whether the message was retained by the broker on the topic, rather than just published. :type retained: bool or None :param x_acknowledged_delivery: Whether this Event should be acknowledged. :type x_acknowledged_delivery: bool or None :param enc_algo: If using payload transparency, the encoding algorithm that was used to encode the payload. :type enc_algo: str or None :param enc_key: If using payload transparency with an encryption algorithm, the payload encryption key. :type enc_key: str or None :param enc_serializer: If using payload transparency, the payload object serializer that was used encoding the payload. :type enc_serializer: str or None'
def __init__(self, subscription, publication, args=None, kwargs=None, payload=None, publisher=None, publisher_authid=None, publisher_authrole=None, topic=None, retained=None, x_acknowledged_delivery=None, enc_algo=None, enc_key=None, enc_serializer=None):
assert (type(subscription) in six.integer_types) assert (type(publication) in six.integer_types) assert ((args is None) or (type(args) in [list, tuple])) assert ((kwargs is None) or (type(kwargs) == dict)) assert ((payload is None) or (type(payload) == six.binary_type)) assert ((payload is None) or ((payload is not None) and (args is None) and (kwargs is None))) assert ((publisher is None) or (type(publisher) in six.integer_types)) assert ((publisher_authid is None) or (type(publisher_authid) == six.text_type)) assert ((publisher_authrole is None) or (type(publisher_authrole) == six.text_type)) assert ((topic is None) or (type(topic) == six.text_type)) assert ((retained is None) or (type(retained) == bool)) assert ((x_acknowledged_delivery is None) or (type(x_acknowledged_delivery) == bool)) assert ((enc_algo is None) or is_valid_enc_algo(enc_algo)) assert (((enc_algo is None) and (enc_key is None) and (enc_serializer is None)) or ((payload is not None) and (enc_algo is not None))) assert ((enc_key is None) or (type(enc_key) == six.text_type)) assert ((enc_serializer is None) or is_valid_enc_serializer(enc_serializer)) Message.__init__(self) self.subscription = subscription self.publication = publication self.args = args self.kwargs = kwargs self.payload = payload self.publisher = publisher self.publisher_authid = publisher_authid self.publisher_authrole = publisher_authrole self.topic = topic self.retained = retained self.x_acknowledged_delivery = x_acknowledged_delivery self.enc_algo = enc_algo self.enc_key = enc_key self.enc_serializer = enc_serializer
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Event.MESSAGE_TYPE)) if (len(wmsg) not in (4, 5, 6)): raise ProtocolError('invalid message length {0} for EVENT'.format(len(wmsg))) subscription = check_or_raise_id(wmsg[1], u"'subscription' in EVENT") publication = check_or_raise_id(wmsg[2], u"'publication' in EVENT") details = check_or_raise_extra(wmsg[3], u"'details' in EVENT") args = None kwargs = None payload = None enc_algo = None enc_key = None enc_serializer = None if ((len(wmsg) == 5) and (type(wmsg[4]) == six.binary_type)): payload = wmsg[4] enc_algo = details.get(u'enc_algo', None) if (enc_algo and (not is_valid_enc_algo(enc_algo))): raise ProtocolError("invalid value {0} for 'enc_algo' detail in EVENT".format(enc_algo)) enc_key = details.get(u'enc_key', None) if (enc_key and (type(enc_key) != six.text_type)): raise ProtocolError("invalid type {0} for 'enc_key' detail in EVENT".format(type(enc_key))) enc_serializer = details.get(u'enc_serializer', None) if (enc_serializer and (not is_valid_enc_serializer(enc_serializer))): raise ProtocolError("invalid value {0} for 'enc_serializer' detail in EVENT".format(enc_serializer)) else: if (len(wmsg) > 4): args = wmsg[4] if ((args is not None) and (type(args) != list)): raise ProtocolError("invalid type {0} for 'args' in EVENT".format(type(args))) if (len(wmsg) > 5): kwargs = wmsg[5] if (type(kwargs) != dict): raise ProtocolError("invalid type {0} for 'kwargs' in EVENT".format(type(kwargs))) publisher = None publisher_authid = None publisher_authrole = None topic = None retained = None x_acknowledged_delivery = None if (u'publisher' in details): detail_publisher = details[u'publisher'] if (type(detail_publisher) not in six.integer_types): raise ProtocolError("invalid type {0} for 'publisher' detail in EVENT".format(type(detail_publisher))) publisher = detail_publisher if (u'publisher_authid' in details): detail_publisher_authid = details[u'publisher_authid'] if (type(detail_publisher_authid) != six.text_type): raise ProtocolError("invalid type {0} for 'publisher_authid' detail in INVOCATION".format(type(detail_publisher_authid))) publisher_authid = detail_publisher_authid if (u'publisher_authrole' in details): detail_publisher_authrole = details[u'publisher_authrole'] if (type(detail_publisher_authrole) != six.text_type): raise ProtocolError("invalid type {0} for 'publisher_authrole' detail in INVOCATION".format(type(detail_publisher_authrole))) publisher_authrole = detail_publisher_authrole if (u'topic' in details): detail_topic = details[u'topic'] if (type(detail_topic) != six.text_type): raise ProtocolError("invalid type {0} for 'topic' detail in EVENT".format(type(detail_topic))) topic = detail_topic if (u'retained' in details): retained = details[u'retained'] if (type(retained) != bool): raise ProtocolError("invalid type {0} for 'retained' detail in EVENT".format(type(retained))) if (u'x_acknowledged_delivery' in details): x_acknowledged_delivery = details[u'x_acknowledged_delivery'] if (type(x_acknowledged_delivery) != bool): raise ProtocolError("invalid type {0} for 'x_acknowledged_delivery' detail in EVENT".format(type(x_acknowledged_delivery))) obj = Event(subscription, publication, args=args, kwargs=kwargs, payload=payload, publisher=publisher, publisher_authid=publisher_authid, publisher_authrole=publisher_authrole, topic=topic, retained=retained, x_acknowledged_delivery=x_acknowledged_delivery, enc_algo=enc_algo, enc_key=enc_key, enc_serializer=enc_serializer) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
details = {} if (self.publisher is not None): details[u'publisher'] = self.publisher if (self.publisher_authid is not None): details[u'publisher_authid'] = self.publisher_authid if (self.publisher_authrole is not None): details[u'publisher_authrole'] = self.publisher_authrole if (self.topic is not None): details[u'topic'] = self.topic if (self.retained is not None): details[u'retained'] = self.retained if (self.x_acknowledged_delivery is not None): details[u'x_acknowledged_delivery'] = self.x_acknowledged_delivery if self.payload: if (self.enc_algo is not None): details[u'enc_algo'] = self.enc_algo if (self.enc_key is not None): details[u'enc_key'] = self.enc_key if (self.enc_serializer is not None): details[u'enc_serializer'] = self.enc_serializer return [Event.MESSAGE_TYPE, self.subscription, self.publication, details, self.payload] elif self.kwargs: return [Event.MESSAGE_TYPE, self.subscription, self.publication, details, self.args, self.kwargs] elif self.args: return [Event.MESSAGE_TYPE, self.subscription, self.publication, details, self.args] else: return [Event.MESSAGE_TYPE, self.subscription, self.publication, details]
'Returns string representation of this message.'
def __str__(self):
return u'Event(subscription={}, publication={}, args={}, kwargs={}, publisher={}, publisher_authid={}, publisher_authrole={}, topic={}, retained={}, enc_algo={}, enc_key={}, enc_serializer={}, payload={})'.format(self.subscription, self.publication, self.args, self.kwargs, self.publisher, self.publisher_authid, self.publisher_authrole, self.topic, self.retained, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
':param publication: The publication ID for the sent event. :type publication: int'
def __init__(self, publication):
assert (type(publication) in six.integer_types) Message.__init__(self) self.publication = publication
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == EventReceived.MESSAGE_TYPE)) if (len(wmsg) != 2): raise ProtocolError('invalid message length {0} for EVENT_RECEIVED'.format(len(wmsg))) publication = check_or_raise_id(wmsg[1], u"'publication' in EVENT_RECEIVED") obj = EventReceived(publication) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
return [EventReceived.MESSAGE_TYPE, self.publication]
'Returns string representation of this message.'
def __str__(self):
return u'EventReceived(publication={})'.format(self.publication)
':param request: The WAMP request ID of this request. :type request: int :param procedure: The WAMP or application URI of the procedure which should be called. :type procedure: str :param args: Positional values for application-defined call arguments. Must be serializable using any serializers in use. :type args: list or tuple or None :param kwargs: Keyword values for application-defined call arguments. Must be serializable using any serializers in use. :type kwargs: dict or None :param payload: Alternative, transparent payload. If given, ``args`` and ``kwargs`` must be left unset. :type payload: bytes or None :param timeout: If present, let the callee automatically cancel the call after this ms. :type timeout: int or None :param receive_progress: If ``True``, indicates that the caller wants to receive progressive call results. :type receive_progress: bool or None :param enc_algo: If using payload transparency, the encoding algorithm that was used to encode the payload. :type enc_algo: str or None :param enc_key: If using payload transparency with an encryption algorithm, the payload encryption key. :type enc_key: str or None :param enc_serializer: If using payload transparency, the payload object serializer that was used encoding the payload. :type enc_serializer: str or None'
def __init__(self, request, procedure, args=None, kwargs=None, payload=None, timeout=None, receive_progress=None, enc_algo=None, enc_key=None, enc_serializer=None):
assert (type(request) in six.integer_types) assert (type(procedure) == six.text_type) assert ((args is None) or (type(args) in [list, tuple])) assert ((kwargs is None) or (type(kwargs) == dict)) assert ((payload is None) or (type(payload) == six.binary_type)) assert ((payload is None) or ((payload is not None) and (args is None) and (kwargs is None))) assert ((timeout is None) or (type(timeout) in six.integer_types)) assert ((receive_progress is None) or (type(receive_progress) == bool)) assert ((enc_algo is None) or is_valid_enc_algo(enc_algo)) assert ((enc_key is None) or (type(enc_key) == six.text_type)) assert ((enc_serializer is None) or is_valid_enc_serializer(enc_serializer)) assert (((enc_algo is None) and (enc_key is None) and (enc_serializer is None)) or ((payload is not None) and (enc_algo is not None))) Message.__init__(self) self.request = request self.procedure = procedure self.args = args self.kwargs = kwargs self.payload = payload self.timeout = timeout self.receive_progress = receive_progress self.enc_algo = enc_algo self.enc_key = enc_key self.enc_serializer = enc_serializer
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Call.MESSAGE_TYPE)) if (len(wmsg) not in (4, 5, 6)): raise ProtocolError('invalid message length {0} for CALL'.format(len(wmsg))) request = check_or_raise_id(wmsg[1], u"'request' in CALL") options = check_or_raise_extra(wmsg[2], u"'options' in CALL") procedure = check_or_raise_uri(wmsg[3], u"'procedure' in CALL") args = None kwargs = None payload = None enc_algo = None enc_key = None enc_serializer = None if ((len(wmsg) == 5) and (type(wmsg[4]) in [six.text_type, six.binary_type])): payload = wmsg[4] enc_algo = options.get(u'enc_algo', None) if (enc_algo and (not is_valid_enc_algo(enc_algo))): raise ProtocolError("invalid value {0} for 'enc_algo' detail in CALL".format(enc_algo)) enc_key = options.get(u'enc_key', None) if (enc_key and (type(enc_key) != six.text_type)): raise ProtocolError("invalid type {0} for 'enc_key' detail in CALL".format(type(enc_key))) enc_serializer = options.get(u'enc_serializer', None) if (enc_serializer and (not is_valid_enc_serializer(enc_serializer))): raise ProtocolError("invalid value {0} for 'enc_serializer' detail in CALL".format(enc_serializer)) else: if (len(wmsg) > 4): args = wmsg[4] if ((args is not None) and (type(args) != list)): raise ProtocolError("invalid type {0} for 'args' in CALL".format(type(args))) if (len(wmsg) > 5): kwargs = wmsg[5] if (type(kwargs) != dict): raise ProtocolError("invalid type {0} for 'kwargs' in CALL".format(type(kwargs))) timeout = None receive_progress = None if (u'timeout' in options): option_timeout = options[u'timeout'] if (type(option_timeout) not in six.integer_types): raise ProtocolError("invalid type {0} for 'timeout' option in CALL".format(type(option_timeout))) if (option_timeout < 0): raise ProtocolError("invalid value {0} for 'timeout' option in CALL".format(option_timeout)) timeout = option_timeout if (u'receive_progress' in options): option_receive_progress = options[u'receive_progress'] if (type(option_receive_progress) != bool): raise ProtocolError("invalid type {0} for 'receive_progress' option in CALL".format(type(option_receive_progress))) receive_progress = option_receive_progress obj = Call(request, procedure, args=args, kwargs=kwargs, payload=payload, timeout=timeout, receive_progress=receive_progress, enc_algo=enc_algo, enc_key=enc_key, enc_serializer=enc_serializer) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
options = self.marshal_options() if self.payload: return [Call.MESSAGE_TYPE, self.request, options, self.procedure, self.payload] elif self.kwargs: return [Call.MESSAGE_TYPE, self.request, options, self.procedure, self.args, self.kwargs] elif self.args: return [Call.MESSAGE_TYPE, self.request, options, self.procedure, self.args] else: return [Call.MESSAGE_TYPE, self.request, options, self.procedure]
'Returns string representation of this message.'
def __str__(self):
return u'Call(request={0}, procedure={1}, args={2}, kwargs={3}, timeout={4}, receive_progress={5}, enc_algo={6}, enc_key={7}, enc_serializer={8}, payload={9})'.format(self.request, self.procedure, self.args, self.kwargs, self.timeout, self.receive_progress, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
':param request: The WAMP request ID of the original `CALL` to cancel. :type request: int :param mode: Specifies how to cancel the call (``"skip"``, ``"abort"`` or ``"kill"``). :type mode: str or None'
def __init__(self, request, mode=None):
assert (type(request) in six.integer_types) assert ((mode is None) or (type(mode) == six.text_type)) assert (mode in [None, self.SKIP, self.ABORT, self.KILL]) Message.__init__(self) self.request = request self.mode = mode
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Cancel.MESSAGE_TYPE)) if (len(wmsg) != 3): raise ProtocolError('invalid message length {0} for CANCEL'.format(len(wmsg))) request = check_or_raise_id(wmsg[1], u"'request' in CANCEL") options = check_or_raise_extra(wmsg[2], u"'options' in CANCEL") mode = None if (u'mode' in options): option_mode = options[u'mode'] if (type(option_mode) != six.text_type): raise ProtocolError("invalid type {0} for 'mode' option in CANCEL".format(type(option_mode))) if (option_mode not in [Cancel.SKIP, Cancel.ABORT, Cancel.KILL]): raise ProtocolError("invalid value '{0}' for 'mode' option in CANCEL".format(option_mode)) mode = option_mode obj = Cancel(request, mode=mode) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
options = {} if (self.mode is not None): options[u'mode'] = self.mode return [Cancel.MESSAGE_TYPE, self.request, options]
'Returns string representation of this message.'
def __str__(self):
return u'Cancel(request={0}, mode={1})'.format(self.request, self.mode)
':param request: The request ID of the original `CALL` request. :type request: int :param args: Positional values for application-defined event payload. Must be serializable using any serializers in use. :type args: list or tuple or None :param kwargs: Keyword values for application-defined event payload. Must be serializable using any serializers in use. :type kwargs: dict or None :param payload: Alternative, transparent payload. If given, ``args`` and ``kwargs`` must be left unset. :type payload: bytes or None :param progress: If ``True``, this result is a progressive call result, and subsequent results (or a final error) will follow. :type progress: bool or None :param enc_algo: If using payload transparency, the encoding algorithm that was used to encode the payload. :type enc_algo: str or None :param enc_key: If using payload transparency with an encryption algorithm, the payload encryption key. :type enc_key: str or None :param enc_serializer: If using payload transparency, the payload object serializer that was used encoding the payload. :type enc_serializer: str or None'
def __init__(self, request, args=None, kwargs=None, payload=None, progress=None, enc_algo=None, enc_key=None, enc_serializer=None):
assert (type(request) in six.integer_types) assert ((args is None) or (type(args) in [list, tuple])) assert ((kwargs is None) or (type(kwargs) == dict)) assert ((payload is None) or (type(payload) == six.binary_type)) assert ((payload is None) or ((payload is not None) and (args is None) and (kwargs is None))) assert ((progress is None) or (type(progress) == bool)) assert ((enc_algo is None) or is_valid_enc_algo(enc_algo)) assert ((enc_key is None) or (type(enc_key) == six.text_type)) assert ((enc_serializer is None) or is_valid_enc_serializer(enc_serializer)) assert (((enc_algo is None) and (enc_key is None) and (enc_serializer is None)) or ((payload is not None) and (enc_algo is not None))) Message.__init__(self) self.request = request self.args = args self.kwargs = kwargs self.payload = payload self.progress = progress self.enc_algo = enc_algo self.enc_key = enc_key self.enc_serializer = enc_serializer
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Result.MESSAGE_TYPE)) if (len(wmsg) not in (3, 4, 5)): raise ProtocolError('invalid message length {0} for RESULT'.format(len(wmsg))) request = check_or_raise_id(wmsg[1], u"'request' in RESULT") details = check_or_raise_extra(wmsg[2], u"'details' in RESULT") args = None kwargs = None payload = None enc_algo = None enc_key = None enc_serializer = None if ((len(wmsg) == 4) and (type(wmsg[3]) in [six.text_type, six.binary_type])): payload = wmsg[3] enc_algo = details.get(u'enc_algo', None) if (enc_algo and (not is_valid_enc_algo(enc_algo))): raise ProtocolError("invalid value {0} for 'enc_algo' detail in RESULT".format(enc_algo)) enc_key = details.get(u'enc_key', None) if (enc_key and (type(enc_key) != six.text_type)): raise ProtocolError("invalid type {0} for 'enc_key' detail in RESULT".format(type(enc_key))) enc_serializer = details.get(u'enc_serializer', None) if (enc_serializer and (not is_valid_enc_serializer(enc_serializer))): raise ProtocolError("invalid value {0} for 'enc_serializer' detail in RESULT".format(enc_serializer)) else: if (len(wmsg) > 3): args = wmsg[3] if ((args is not None) and (type(args) != list)): raise ProtocolError("invalid type {0} for 'args' in RESULT".format(type(args))) if (len(wmsg) > 4): kwargs = wmsg[4] if (type(kwargs) != dict): raise ProtocolError("invalid type {0} for 'kwargs' in RESULT".format(type(kwargs))) progress = None if (u'progress' in details): detail_progress = details[u'progress'] if (type(detail_progress) != bool): raise ProtocolError("invalid type {0} for 'progress' option in RESULT".format(type(detail_progress))) progress = detail_progress obj = Result(request, args=args, kwargs=kwargs, payload=payload, progress=progress, enc_algo=enc_algo, enc_key=enc_key, enc_serializer=enc_serializer) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
details = {} if (self.progress is not None): details[u'progress'] = self.progress if self.payload: if (self.enc_algo is not None): details[u'enc_algo'] = self.enc_algo if (self.enc_key is not None): details[u'enc_key'] = self.enc_key if (self.enc_serializer is not None): details[u'enc_serializer'] = self.enc_serializer return [Result.MESSAGE_TYPE, self.request, details, self.payload] elif self.kwargs: return [Result.MESSAGE_TYPE, self.request, details, self.args, self.kwargs] elif self.args: return [Result.MESSAGE_TYPE, self.request, details, self.args] else: return [Result.MESSAGE_TYPE, self.request, details]
'Returns string representation of this message.'
def __str__(self):
return u'Result(request={0}, args={1}, kwargs={2}, progress={3}, enc_algo={4}, enc_key={5}, enc_serializer={6}, payload={7})'.format(self.request, self.args, self.kwargs, self.progress, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
':param request: The WAMP request ID of this request. :type request: int :param procedure: The WAMP or application URI of the RPC endpoint provided. :type procedure: str :param match: The procedure matching policy to be used for the registration. :type match: str :param invoke: The procedure invocation policy to be used for the registration. :type invoke: str :param concurrency: The (maximum) concurrency to be used for the registration. :type concurrency: int'
def __init__(self, request, procedure, match=None, invoke=None, concurrency=None, force_reregister=None):
assert (type(request) in six.integer_types) assert (type(procedure) == six.text_type) assert ((match is None) or (type(match) == six.text_type)) assert ((match is None) or (match in [Register.MATCH_EXACT, Register.MATCH_PREFIX, Register.MATCH_WILDCARD])) assert ((invoke is None) or (type(invoke) == six.text_type)) assert ((invoke is None) or (invoke in [Register.INVOKE_SINGLE, Register.INVOKE_FIRST, Register.INVOKE_LAST, Register.INVOKE_ROUNDROBIN, Register.INVOKE_RANDOM])) assert ((concurrency is None) or ((type(concurrency) in six.integer_types) and (concurrency > 0))) assert (force_reregister in [None, True, False]) Message.__init__(self) self.request = request self.procedure = procedure self.match = (match or Register.MATCH_EXACT) self.invoke = (invoke or Register.INVOKE_SINGLE) self.concurrency = concurrency self.force_reregister = force_reregister
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Register.MESSAGE_TYPE)) if (len(wmsg) != 4): raise ProtocolError('invalid message length {0} for REGISTER'.format(len(wmsg))) request = check_or_raise_id(wmsg[1], u"'request' in REGISTER") options = check_or_raise_extra(wmsg[2], u"'options' in REGISTER") match = Register.MATCH_EXACT invoke = Register.INVOKE_SINGLE concurrency = None force_reregister = None if (u'match' in options): option_match = options[u'match'] if (type(option_match) != six.text_type): raise ProtocolError("invalid type {0} for 'match' option in REGISTER".format(type(option_match))) if (option_match not in [Register.MATCH_EXACT, Register.MATCH_PREFIX, Register.MATCH_WILDCARD]): raise ProtocolError("invalid value {0} for 'match' option in REGISTER".format(option_match)) match = option_match if (match == Register.MATCH_EXACT): allow_empty_components = False allow_last_empty = False elif (match == Register.MATCH_PREFIX): allow_empty_components = False allow_last_empty = True elif (match == Register.MATCH_WILDCARD): allow_empty_components = True allow_last_empty = False else: raise Exception('logic error') procedure = check_or_raise_uri(wmsg[3], u"'procedure' in REGISTER", allow_empty_components=allow_empty_components, allow_last_empty=allow_last_empty) if (u'invoke' in options): option_invoke = options[u'invoke'] if (type(option_invoke) != six.text_type): raise ProtocolError("invalid type {0} for 'invoke' option in REGISTER".format(type(option_invoke))) if (option_invoke not in [Register.INVOKE_SINGLE, Register.INVOKE_FIRST, Register.INVOKE_LAST, Register.INVOKE_ROUNDROBIN, Register.INVOKE_RANDOM]): raise ProtocolError("invalid value {0} for 'invoke' option in REGISTER".format(option_invoke)) invoke = option_invoke if (u'concurrency' in options): options_concurrency = options[u'concurrency'] if (type(options_concurrency) not in six.integer_types): raise ProtocolError("invalid type {0} for 'concurrency' option in REGISTER".format(type(options_concurrency))) if (options_concurrency < 1): raise ProtocolError("invalid value {0} for 'concurrency' option in REGISTER".format(options_concurrency)) concurrency = options_concurrency options_reregister = options.get(u'force_reregister', None) if (options_reregister not in [True, False, None]): raise ProtocolError("invalid type {0} for 'force_reregister option in REGISTER".format(type(options_reregister))) if (options_reregister is not None): force_reregister = options_reregister obj = Register(request, procedure, match=match, invoke=invoke, concurrency=concurrency, force_reregister=force_reregister) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
return [Register.MESSAGE_TYPE, self.request, self.marshal_options(), self.procedure]
'Returns string representation of this message.'
def __str__(self):
return u'Register(request={0}, procedure={1}, match={2}, invoke={3}, concurrency={4}, force_reregister={5})'.format(self.request, self.procedure, self.match, self.invoke, self.concurrency, self.force_reregister)
':param request: The request ID of the original ``REGISTER`` request. :type request: int :param registration: The registration ID for the registered procedure (or procedure pattern). :type registration: int'
def __init__(self, request, registration):
assert (type(request) in six.integer_types) assert (type(registration) in six.integer_types) Message.__init__(self) self.request = request self.registration = registration
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Registered.MESSAGE_TYPE)) if (len(wmsg) != 3): raise ProtocolError('invalid message length {0} for REGISTERED'.format(len(wmsg))) request = check_or_raise_id(wmsg[1], u"'request' in REGISTERED") registration = check_or_raise_id(wmsg[2], u"'registration' in REGISTERED") obj = Registered(request, registration) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
return [Registered.MESSAGE_TYPE, self.request, self.registration]
'Returns string representation of this message.'
def __str__(self):
return u'Registered(request={0}, registration={1})'.format(self.request, self.registration)
':param request: The WAMP request ID of this request. :type request: int :param registration: The registration ID for the registration to unregister. :type registration: int'
def __init__(self, request, registration):
assert (type(request) in six.integer_types) assert (type(registration) in six.integer_types) Message.__init__(self) self.request = request self.registration = registration
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Unregister.MESSAGE_TYPE)) if (len(wmsg) != 3): raise ProtocolError('invalid message length {0} for WAMP UNREGISTER'.format(len(wmsg))) request = check_or_raise_id(wmsg[1], u"'request' in UNREGISTER") registration = check_or_raise_id(wmsg[2], u"'registration' in UNREGISTER") obj = Unregister(request, registration) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
return [Unregister.MESSAGE_TYPE, self.request, self.registration]
'Returns string representation of this message.'
def __str__(self):
return u'Unregister(request={0}, registration={1})'.format(self.request, self.registration)
':param request: The request ID of the original ``UNREGISTER`` request. :type request: int :param registration: If unregister was actively triggered by router, the ID of the registration revoked. :type registration: int or None :param reason: The reason (an URI) for revocation. :type reason: str or None.'
def __init__(self, request, registration=None, reason=None):
assert (type(request) in six.integer_types) assert ((registration is None) or (type(registration) in six.integer_types)) assert ((reason is None) or (type(reason) == six.text_type)) assert (((request != 0) and (registration is None)) or ((request == 0) and (registration != 0))) Message.__init__(self) self.request = request self.registration = registration self.reason = reason
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Unregistered.MESSAGE_TYPE)) if (len(wmsg) not in [2, 3]): raise ProtocolError('invalid message length {0} for UNREGISTERED'.format(len(wmsg))) request = check_or_raise_id(wmsg[1], u"'request' in UNREGISTERED") registration = None reason = None if (len(wmsg) > 2): details = check_or_raise_extra(wmsg[2], u"'details' in UNREGISTERED") if (u'registration' in details): details_registration = details[u'registration'] if (type(details_registration) not in six.integer_types): raise ProtocolError("invalid type {0} for 'registration' detail in UNREGISTERED".format(type(details_registration))) registration = details_registration if (u'reason' in details): reason = check_or_raise_uri(details[u'reason'], u"'reason' in UNREGISTERED") obj = Unregistered(request, registration, reason) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
if ((self.reason is not None) or (self.registration is not None)): details = {} if (self.reason is not None): details[u'reason'] = self.reason if (self.registration is not None): details[u'registration'] = self.registration return [Unregistered.MESSAGE_TYPE, self.request, details] else: return [Unregistered.MESSAGE_TYPE, self.request]
'Returns string representation of this message.'
def __str__(self):
return u'Unregistered(request={0}, reason={1}, registration={2})'.format(self.request, self.reason, self.registration)
':param request: The WAMP request ID of this request. :type request: int :param registration: The registration ID of the endpoint to be invoked. :type registration: int :param args: Positional values for application-defined event payload. Must be serializable using any serializers in use. :type args: list or tuple or None :param kwargs: Keyword values for application-defined event payload. Must be serializable using any serializers in use. :type kwargs: dict or None :param payload: Alternative, transparent payload. If given, ``args`` and ``kwargs`` must be left unset. :type payload: bytes or None :param timeout: If present, let the callee automatically cancels the invocation after this ms. :type timeout: int or None :param receive_progress: Indicates if the callee should produce progressive results. :type receive_progress: bool or None :param caller: The WAMP session ID of the caller. Only filled if caller is disclosed. :type caller: None or int :param caller_authid: The WAMP authid of the caller. Only filled if caller is disclosed. :type caller_authid: None or unicode :param caller_authrole: The WAMP authrole of the caller. Only filled if caller is disclosed. :type caller_authrole: None or unicode :param procedure: For pattern-based registrations, the invocation MUST include the actual procedure being called. :type procedure: str or None :param enc_algo: If using payload transparency, the encoding algorithm that was used to encode the payload. :type enc_algo: str or None :param enc_key: If using payload transparency with an encryption algorithm, the payload encryption key. :type enc_key: str or None :param enc_serializer: If using payload transparency, the payload object serializer that was used encoding the payload. :type enc_serializer: str or None'
def __init__(self, request, registration, args=None, kwargs=None, payload=None, timeout=None, receive_progress=None, caller=None, caller_authid=None, caller_authrole=None, procedure=None, enc_algo=None, enc_key=None, enc_serializer=None):
assert (type(request) in six.integer_types) assert (type(registration) in six.integer_types) assert ((args is None) or (type(args) in [list, tuple])) assert ((kwargs is None) or (type(kwargs) == dict)) assert ((payload is None) or (type(payload) == six.binary_type)) assert ((payload is None) or ((payload is not None) and (args is None) and (kwargs is None))) assert ((timeout is None) or (type(timeout) in six.integer_types)) assert ((receive_progress is None) or (type(receive_progress) == bool)) assert ((caller is None) or (type(caller) in six.integer_types)) assert ((caller_authid is None) or (type(caller_authid) == six.text_type)) assert ((caller_authrole is None) or (type(caller_authrole) == six.text_type)) assert ((procedure is None) or (type(procedure) == six.text_type)) assert ((enc_algo is None) or is_valid_enc_algo(enc_algo)) assert ((enc_key is None) or (type(enc_key) == six.text_type)) assert ((enc_serializer is None) or is_valid_enc_serializer(enc_serializer)) assert (((enc_algo is None) and (enc_key is None) and (enc_serializer is None)) or ((payload is not None) and (enc_algo is not None))) Message.__init__(self) self.request = request self.registration = registration self.args = args self.kwargs = kwargs self.payload = payload self.timeout = timeout self.receive_progress = receive_progress self.caller = caller self.caller_authid = caller_authid self.caller_authrole = caller_authrole self.procedure = procedure self.enc_algo = enc_algo self.enc_key = enc_key self.enc_serializer = enc_serializer
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Invocation.MESSAGE_TYPE)) if (len(wmsg) not in (4, 5, 6)): raise ProtocolError('invalid message length {0} for INVOCATION'.format(len(wmsg))) request = check_or_raise_id(wmsg[1], u"'request' in INVOCATION") registration = check_or_raise_id(wmsg[2], u"'registration' in INVOCATION") details = check_or_raise_extra(wmsg[3], u"'details' in INVOCATION") args = None kwargs = None payload = None enc_algo = None enc_key = None enc_serializer = None if ((len(wmsg) == 5) and (type(wmsg[4]) == six.binary_type)): payload = wmsg[4] enc_algo = details.get(u'enc_algo', None) if (enc_algo and (not is_valid_enc_algo(enc_algo))): raise ProtocolError("invalid value {0} for 'enc_algo' detail in INVOCATION".format(enc_algo)) enc_key = details.get(u'enc_key', None) if (enc_key and (type(enc_key) != six.text_type)): raise ProtocolError("invalid type {0} for 'enc_key' detail in INVOCATION".format(type(enc_key))) enc_serializer = details.get(u'enc_serializer', None) if (enc_serializer and (not is_valid_enc_serializer(enc_serializer))): raise ProtocolError("invalid value {0} for 'enc_serializer' detail in INVOCATION".format(enc_serializer)) else: if (len(wmsg) > 4): args = wmsg[4] if ((args is not None) and (type(args) != list)): raise ProtocolError("invalid type {0} for 'args' in INVOCATION".format(type(args))) if (len(wmsg) > 5): kwargs = wmsg[5] if (type(kwargs) != dict): raise ProtocolError("invalid type {0} for 'kwargs' in INVOCATION".format(type(kwargs))) timeout = None receive_progress = None caller = None caller_authid = None caller_authrole = None procedure = None if (u'timeout' in details): detail_timeout = details[u'timeout'] if (type(detail_timeout) not in six.integer_types): raise ProtocolError("invalid type {0} for 'timeout' detail in INVOCATION".format(type(detail_timeout))) if (detail_timeout < 0): raise ProtocolError("invalid value {0} for 'timeout' detail in INVOCATION".format(detail_timeout)) timeout = detail_timeout if (u'receive_progress' in details): detail_receive_progress = details[u'receive_progress'] if (type(detail_receive_progress) != bool): raise ProtocolError("invalid type {0} for 'receive_progress' detail in INVOCATION".format(type(detail_receive_progress))) receive_progress = detail_receive_progress if (u'caller' in details): detail_caller = details[u'caller'] if (type(detail_caller) not in six.integer_types): raise ProtocolError("invalid type {0} for 'caller' detail in INVOCATION".format(type(detail_caller))) caller = detail_caller if (u'caller_authid' in details): detail_caller_authid = details[u'caller_authid'] if (type(detail_caller_authid) != six.text_type): raise ProtocolError("invalid type {0} for 'caller_authid' detail in INVOCATION".format(type(detail_caller_authid))) caller_authid = detail_caller_authid if (u'caller_authrole' in details): detail_caller_authrole = details[u'caller_authrole'] if (type(detail_caller_authrole) != six.text_type): raise ProtocolError("invalid type {0} for 'caller_authrole' detail in INVOCATION".format(type(detail_caller_authrole))) caller_authrole = detail_caller_authrole if (u'procedure' in details): detail_procedure = details[u'procedure'] if (type(detail_procedure) != six.text_type): raise ProtocolError("invalid type {0} for 'procedure' detail in INVOCATION".format(type(detail_procedure))) procedure = detail_procedure obj = Invocation(request, registration, args=args, kwargs=kwargs, payload=payload, timeout=timeout, receive_progress=receive_progress, caller=caller, caller_authid=caller_authid, caller_authrole=caller_authrole, procedure=procedure, enc_algo=enc_algo, enc_key=enc_key, enc_serializer=enc_serializer) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
options = {} if (self.timeout is not None): options[u'timeout'] = self.timeout if (self.receive_progress is not None): options[u'receive_progress'] = self.receive_progress if (self.caller is not None): options[u'caller'] = self.caller if (self.caller_authid is not None): options[u'caller_authid'] = self.caller_authid if (self.caller_authrole is not None): options[u'caller_authrole'] = self.caller_authrole if (self.procedure is not None): options[u'procedure'] = self.procedure if self.payload: if (self.enc_algo is not None): options[u'enc_algo'] = self.enc_algo if (self.enc_key is not None): options[u'enc_key'] = self.enc_key if (self.enc_serializer is not None): options[u'enc_serializer'] = self.enc_serializer return [Invocation.MESSAGE_TYPE, self.request, self.registration, options, self.payload] elif self.kwargs: return [Invocation.MESSAGE_TYPE, self.request, self.registration, options, self.args, self.kwargs] elif self.args: return [Invocation.MESSAGE_TYPE, self.request, self.registration, options, self.args] else: return [Invocation.MESSAGE_TYPE, self.request, self.registration, options]
'Returns string representation of this message.'
def __str__(self):
return u'Invocation(request={0}, registration={1}, args={2}, kwargs={3}, timeout={4}, receive_progress={5}, caller={6}, caller_authid={7}, caller_authrole={8}, procedure={9}, enc_algo={10}, enc_key={11}, enc_serializer={12}, payload={13})'.format(self.request, self.registration, self.args, self.kwargs, self.timeout, self.receive_progress, self.caller, self.caller_authid, self.caller_authrole, self.procedure, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
':param request: The WAMP request ID of the original ``INVOCATION`` to interrupt. :type request: int :param mode: Specifies how to interrupt the invocation (``"abort"`` or ``"kill"``). :type mode: str or None'
def __init__(self, request, mode=None):
assert (type(request) in six.integer_types) assert ((mode is None) or (type(mode) == six.text_type)) assert ((mode is None) or (mode in [self.ABORT, self.KILL])) Message.__init__(self) self.request = request self.mode = mode
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Interrupt.MESSAGE_TYPE)) if (len(wmsg) != 3): raise ProtocolError('invalid message length {0} for INTERRUPT'.format(len(wmsg))) request = check_or_raise_id(wmsg[1], u"'request' in INTERRUPT") options = check_or_raise_extra(wmsg[2], u"'options' in INTERRUPT") mode = None if (u'mode' in options): option_mode = options[u'mode'] if (type(option_mode) != six.text_type): raise ProtocolError("invalid type {0} for 'mode' option in INTERRUPT".format(type(option_mode))) if (option_mode not in [Interrupt.ABORT, Interrupt.KILL]): raise ProtocolError("invalid value '{0}' for 'mode' option in INTERRUPT".format(option_mode)) mode = option_mode obj = Interrupt(request, mode=mode) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
options = {} if (self.mode is not None): options[u'mode'] = self.mode return [Interrupt.MESSAGE_TYPE, self.request, options]
'Returns string representation of this message.'
def __str__(self):
return u'Interrupt(request={0}, mode={1})'.format(self.request, self.mode)
':param request: The WAMP request ID of the original call. :type request: int :param args: Positional values for application-defined event payload. Must be serializable using any serializers in use. :type args: list or tuple or None :param kwargs: Keyword values for application-defined event payload. Must be serializable using any serializers in use. :type kwargs: dict or None :param payload: Alternative, transparent payload. If given, ``args`` and ``kwargs`` must be left unset. :type payload: bytes or None :param progress: If ``True``, this result is a progressive invocation result, and subsequent results (or a final error) will follow. :type progress: bool or None :param enc_algo: If using payload transparency, the encoding algorithm that was used to encode the payload. :type enc_algo: str or None :param enc_key: If using payload transparency with an encryption algorithm, the payload encryption key. :type enc_key: str or None :param enc_serializer: If using payload transparency, the payload object serializer that was used encoding the payload. :type enc_serializer: str or None'
def __init__(self, request, args=None, kwargs=None, payload=None, progress=None, enc_algo=None, enc_key=None, enc_serializer=None):
assert (type(request) in six.integer_types) assert ((args is None) or (type(args) in [list, tuple])) assert ((kwargs is None) or (type(kwargs) == dict)) assert ((payload is None) or (type(payload) == six.binary_type)) assert ((payload is None) or ((payload is not None) and (args is None) and (kwargs is None))) assert ((progress is None) or (type(progress) == bool)) assert ((enc_algo is None) or is_valid_enc_algo(enc_algo)) assert (((enc_algo is None) and (enc_key is None) and (enc_serializer is None)) or ((payload is not None) and (enc_algo is not None))) assert ((enc_key is None) or (type(enc_key) == six.text_type)) assert ((enc_serializer is None) or is_valid_enc_serializer(enc_serializer)) Message.__init__(self) self.request = request self.args = args self.kwargs = kwargs self.payload = payload self.progress = progress self.enc_algo = enc_algo self.enc_key = enc_key self.enc_serializer = enc_serializer
'Verifies and parses an unserialized raw message into an actual WAMP message instance. :param wmsg: The unserialized raw message. :type wmsg: list :returns: An instance of this class.'
@staticmethod def parse(wmsg):
assert ((len(wmsg) > 0) and (wmsg[0] == Yield.MESSAGE_TYPE)) if (len(wmsg) not in (3, 4, 5)): raise ProtocolError('invalid message length {0} for YIELD'.format(len(wmsg))) request = check_or_raise_id(wmsg[1], u"'request' in YIELD") options = check_or_raise_extra(wmsg[2], u"'options' in YIELD") args = None kwargs = None payload = None enc_algo = None enc_key = None enc_serializer = None if ((len(wmsg) == 4) and (type(wmsg[3]) == six.binary_type)): payload = wmsg[3] enc_algo = options.get(u'enc_algo', None) if (enc_algo and (not is_valid_enc_algo(enc_algo))): raise ProtocolError("invalid value {0} for 'enc_algo' detail in YIELD".format(enc_algo)) enc_key = options.get(u'enc_key', None) if (enc_key and (type(enc_key) != six.text_type)): raise ProtocolError("invalid type {0} for 'enc_key' detail in YIELD".format(type(enc_key))) enc_serializer = options.get(u'enc_serializer', None) if (enc_serializer and (not is_valid_enc_serializer(enc_serializer))): raise ProtocolError("invalid value {0} for 'enc_serializer' detail in YIELD".format(enc_serializer)) else: if (len(wmsg) > 3): args = wmsg[3] if ((args is not None) and (type(args) != list)): raise ProtocolError("invalid type {0} for 'args' in YIELD".format(type(args))) if (len(wmsg) > 4): kwargs = wmsg[4] if (type(kwargs) != dict): raise ProtocolError("invalid type {0} for 'kwargs' in YIELD".format(type(kwargs))) progress = None if (u'progress' in options): option_progress = options[u'progress'] if (type(option_progress) != bool): raise ProtocolError("invalid type {0} for 'progress' option in YIELD".format(type(option_progress))) progress = option_progress obj = Yield(request, args=args, kwargs=kwargs, payload=payload, progress=progress, enc_algo=enc_algo, enc_key=enc_key, enc_serializer=enc_serializer) return obj
'Marshal this object into a raw message for subsequent serialization to bytes. :returns: The serialized raw message. :rtype: list'
def marshal(self):
options = {} if (self.progress is not None): options[u'progress'] = self.progress if self.payload: if (self.enc_algo is not None): options[u'enc_algo'] = self.enc_algo if (self.enc_key is not None): options[u'enc_key'] = self.enc_key if (self.enc_serializer is not None): options[u'enc_serializer'] = self.enc_serializer return [Yield.MESSAGE_TYPE, self.request, options, self.payload] elif self.kwargs: return [Yield.MESSAGE_TYPE, self.request, options, self.args, self.kwargs] elif self.args: return [Yield.MESSAGE_TYPE, self.request, options, self.args] else: return [Yield.MESSAGE_TYPE, self.request, options]
'Returns string representation of this message.'
def __str__(self):
return u'Yield(request={0}, args={1}, kwargs={2}, progress={3}, enc_algo={4}, enc_key={5}, enc_serializer={6}, payload={7})'.format(self.request, self.args, self.kwargs, self.progress, self.enc_algo, self.enc_key, self.enc_serializer, b2a(self.payload))
':param uri: The URI or URI pattern, e.g. ``"com.myapp.product.<product:int>.update"``. :type uri: str :param target: The target for this pattern: a procedure endpoint (a callable), an event handler (a callable) or an exception (a class). :type target: callable or obj :param options: An optional options object :type options: None or RegisterOptions or SubscribeOptions'
def __init__(self, uri, target, options=None):
assert (type(uri) == six.text_type) assert (len(uri) > 0) assert (target in [Pattern.URI_TARGET_ENDPOINT, Pattern.URI_TARGET_HANDLER, Pattern.URI_TARGET_EXCEPTION]) if (target == Pattern.URI_TARGET_ENDPOINT): assert ((options is None) or (type(options) == RegisterOptions)) elif (target == Pattern.URI_TARGET_HANDLER): assert ((options is None) or (type(options) == SubscribeOptions)) else: options = None components = uri.split('.') pl = [] nc = {} group_count = 0 for i in range(len(components)): component = components[i] match = Pattern._URI_NAMED_CONVERTED_COMPONENT.match(component) if match: ctype = match.groups()[1] if (ctype not in ['string', 'int', 'suffix']): raise Exception('invalid URI') if ((ctype == 'suffix') and (i != (len(components) - 1))): raise Exception('invalid URI') name = match.groups()[0] if (name in nc): raise Exception('invalid URI') if (ctype in ['string', 'suffix']): nc[name] = str elif (ctype == 'int'): nc[name] = int else: raise Exception('logic error') pl.append('(?P<{0}>[a-z0-9_]+)'.format(name)) group_count += 1 continue match = Pattern._URI_NAMED_COMPONENT.match(component) if match: name = match.groups()[0] if (name in nc): raise Exception('invalid URI') nc[name] = str pl.append('(?P<{0}>[a-z0-9_]+)'.format(name)) group_count += 1 continue match = Pattern._URI_COMPONENT.match(component) if match: pl.append(component) continue if (component == ''): group_count += 1 pl.append('([a-z0-9][a-z0-9_\\-]*)') nc[group_count] = str continue raise Exception('invalid URI') if nc: self._type = Pattern.URI_TYPE_WILDCARD p = (('^' + '\\.'.join(pl)) + '$') self._pattern = re.compile(p) self._names = nc else: self._type = Pattern.URI_TYPE_EXACT self._pattern = None self._names = None self._uri = uri self._target = target self._options = options
'Returns the Options instance (if present) for this pattern. :return: None or the Options instance :rtype: None or RegisterOptions or SubscribeOptions'
@public @property def options(self):
return self._options
'Returns the URI type of this pattern :return: :rtype: Pattern.URI_TYPE_EXACT, Pattern.URI_TYPE_PREFIX or Pattern.URI_TYPE_WILDCARD'
@public @property def uri_type(self):
return self._type
'Returns the original URI (pattern) for this pattern. :returns: The URI (pattern), e.g. ``"com.myapp.product.<product:int>.update"``. :rtype: str'
@public def uri(self):
return self._uri
'Match the given (fully qualified) URI according to this pattern and return extracted args and kwargs. :param uri: The URI to match, e.g. ``"com.myapp.product.123456.update"``. :type uri: str :returns: A tuple ``(args, kwargs)`` :rtype: tuple'
def match(self, uri):
args = [] kwargs = {} if (self._type == Pattern.URI_TYPE_EXACT): return (args, kwargs) elif (self._type == Pattern.URI_TYPE_WILDCARD): match = self._pattern.match(uri) if match: for key in self._names: val = match.group(key) val = self._names[key](val) kwargs[key] = val return (args, kwargs) else: raise Exception('no match')
'Check if this pattern is for a procedure endpoint. :returns: ``True``, iff this pattern is for a procedure endpoint. :rtype: bool'
@public def is_endpoint(self):
return (self._target == Pattern.URI_TARGET_ENDPOINT)
'Check if this pattern is for an event handler. :returns: ``True``, iff this pattern is for an event handler. :rtype: bool'
@public def is_handler(self):
return (self._target == Pattern.URI_TARGET_HANDLER)
'Check if this pattern is for an exception. :returns: ``True``, iff this pattern is for an exception. :rtype: bool'
@public def is_exception(self):
return (self._target == Pattern.URI_TARGET_EXCEPTION)
':param realm: The realm the session would like to join or ``None`` to let the router auto-decide the realm (if the router is configured and allowing to do so). :type realm: str :param extra: Optional user-supplied object with extra configuration. This can be any object you like, and is accessible in your `ApplicationSession` subclass via `self.config.extra`. `dict` is a good default choice. Important: if the component is to be hosted by Crossbar.io, the supplied value must be JSON serializable. :type extra: arbitrary :param keyring: A mapper from WAMP URIs to "from"/"to" Ed25519 keys. When using WAMP end-to-end encryption, application payload is encrypted using a symmetric message key, which in turn is encrypted using the "to" URI (topic being published to or procedure being called) public key and the "from" URI private key. In both cases, the key for the longest matching URI is used. :type keyring: obj implementing IKeyRing or None :param controller: A WAMP ApplicationSession instance that holds a session to a controlling entity. This optional feature needs to be supported by a WAMP component hosting run-time. :type controller: instance of ApplicationSession or None :param shared: A dict object to exchange user information or hold user objects shared between components run under the same controlling entity. This optional feature needs to be supported by a WAMP component hosting run-time. Use with caution, as using this feature can introduce coupling between components. A valid use case would be to hold a shared database connection pool. :type shared: dict or None'
def __init__(self, realm=None, extra=None, keyring=None, controller=None, shared=None):
assert ((realm is None) or (type(realm) == six.text_type)) self.realm = realm self.extra = extra self.keyring = keyring self.controller = controller self.shared = shared
':param realm: The realm the client is joined to. :type realm: str :param authid: The authentication ID the client is assigned, e.g. ``"joe"`` or ``"[email protected]"``. :type authid: str :param authrole: The authentication role the client is assigned, e.g. ``"anonymous"``, ``"user"`` or ``"com.myapp.user"``. :type authrole: str :param authmethod: The authentication method that was used to authenticate the client, e.g. ``"cookie"`` or ``"wampcra"``. :type authmethod: str :param authprovider: The authentication provider that was used to authenticate the client, e.g. ``"mozilla-persona"``. :type authprovider: str :param authextra: Application-specific authextra to be forwarded to the client in `WELCOME.details.authextra`. :type authextra: dict'
def __init__(self, realm=None, authid=None, authrole=None, authmethod=None, authprovider=None, authextra=None):
assert ((realm is None) or (type(realm) == six.text_type)) assert ((authid is None) or (type(authid) == six.text_type)) assert ((authrole is None) or (type(authrole) == six.text_type)) assert ((authmethod is None) or (type(authmethod) == six.text_type)) assert ((authprovider is None) or (type(authprovider) == six.text_type)) assert ((authextra is None) or (type(authextra) == dict)) self.realm = realm self.authid = authid self.authrole = authrole self.authmethod = authmethod self.authprovider = authprovider self.authextra = authextra
':param reason: The reason of denying the authentication (an URI, e.g. ``u\'wamp.error.not_authorized\'``) :type reason: str :param message: A human readable message (for logging purposes). :type message: str'
def __init__(self, reason=u'wamp.error.not_authorized', message=None):
assert (type(reason) == six.text_type) assert ((message is None) or (type(message) == six.text_type)) self.reason = reason self.message = message
':param method: The authentication method for the challenge (e.g. ``"wampcra"``). :type method: str :param extra: Any extra information for the authentication challenge. This is specific to the authentication method. :type extra: dict'
def __init__(self, method, extra=None):
assert (type(method) == six.text_type) assert ((extra is None) or (type(extra) == dict)) self.method = method self.extra = (extra or {})
':param realm: The realm the client wants to join. :type realm: str or None :param authmethods: The authentication methods the client is willing to perform. :type authmethods: list of str or None :param authid: The authid the client wants to authenticate as. :type authid: str or None :param authrole: The authrole the client wants to authenticate as. :type authrole: str or None :param authextra: Any extra information the specific authentication method requires the client to send. :type authextra: arbitrary or None :param session_roles: The WAMP session roles and features by the connecting client. :type session_roles: dict or None :param pending_session: The session ID the session will get once successfully attached. :type pending_session: int or None :param resumable: :type resumable: bool or None :param resume_session: The session the client would like to resume. :type resume_session: int or None :param resume_token: The secure authorisation token to resume the session. :type resume_token: str or None'
def __init__(self, realm=None, authmethods=None, authid=None, authrole=None, authextra=None, session_roles=None, pending_session=None, resumable=None, resume_session=None, resume_token=None):
assert ((realm is None) or (type(realm) == six.text_type)) assert ((authmethods is None) or ((type(authmethods) == list) and all(((type(x) == six.text_type) for x in authmethods)))) assert ((authid is None) or (type(authid) == six.text_type)) assert ((authrole is None) or (type(authrole) == six.text_type)) assert ((authextra is None) or (type(authextra) == dict)) assert ((pending_session is None) or (type(pending_session) in six.integer_types)) assert ((resumable is None) or (type(resumable) == bool)) assert ((resume_session is None) or (type(resume_session) == int)) assert ((resume_token is None) or (type(resume_token) == six.text_type)) self.realm = realm self.authmethods = authmethods self.authid = authid self.authrole = authrole self.authextra = authextra self.session_roles = session_roles self.pending_session = pending_session self.resumable = resumable self.resume_session = resume_session self.resume_token = resume_token
':param realm: The realm this WAMP session is attached to. :type realm: str :param session: WAMP session ID of this session. :type session: int :param resumed: Whether the session is a resumed one. :type resumed: bool or None :param resumable: Whether this session can be resumed later. :type resumable: bool or None :param resume_token: The secure authorisation token to resume the session. :type resume_token: str or None'
def __init__(self, realm, session, authid=None, authrole=None, authmethod=None, authprovider=None, authextra=None, resumed=None, resumable=None, resume_token=None):
assert (type(realm) == six.text_type) assert (type(session) in six.integer_types) assert ((authid is None) or (type(authid) == six.text_type)) assert ((authrole is None) or (type(authrole) == six.text_type)) assert ((authmethod is None) or (type(authmethod) == six.text_type)) assert ((authprovider is None) or (type(authprovider) == six.text_type)) assert ((authextra is None) or (type(authextra) == dict)) assert ((resumed is None) or (type(resumed) == bool)) assert ((resumable is None) or (type(resumable) == bool)) assert ((resume_token is None) or (type(resume_token) == six.text_type)) self.realm = realm self.session = session self.authid = authid self.authrole = authrole self.authmethod = authmethod self.authprovider = authprovider self.authextra = authextra self.resumed = resumed self.resumable = resumable self.resume_token = resume_token
':param reason: The close reason (an URI, e.g. ``wamp.close.normal``) :type reason: str :param message: Closing log message. :type message: str'
def __init__(self, reason=None, message=None):
assert ((reason is None) or (type(reason) == six.text_type)) assert ((message is None) or (type(message) == six.text_type)) self.reason = reason self.message = message
':param match: The topic matching method to be used for the subscription. :type match: str :param details: When invoking the handler, provide event details in a keyword parameter ``details``. :type details: bool :param details_arg: DEPCREATED (use "details" flag). When invoking the handler provide event details in this keyword argument to the callable. :type details_arg: str :param get_retained: Whether the client wants the retained message we may have along with the subscription. :type get_retained: bool or None'
def __init__(self, match=None, details=None, details_arg=None, get_retained=None):
assert ((match is None) or ((type(match) == six.text_type) and (match in [u'exact', u'prefix', u'wildcard']))) assert ((details is None) or ((type(details) == bool) and (details_arg is None))) assert ((details_arg is None) or (type(details_arg) == str)) assert ((get_retained is None) or (type(get_retained) is bool)) self.match = match self.details = details if details: self.details_arg = 'details' else: self.details_arg = details_arg self.get_retained = get_retained
'Returns options dict as sent within WAMP messages.'
def message_attr(self):
options = {} if (self.match is not None): options[u'match'] = self.match if (self.get_retained is not None): options[u'get_retained'] = self.get_retained return options
':param subscription: The (client side) subscription object on which this event is delivered. :type subscription: instance of :class:`autobahn.wamp.request.Subscription` :param publication: The publication ID of the event (always present). :type publication: int :param publisher: The WAMP session ID of the original publisher of this event. Only filled when publisher is disclosed. :type publisher: None or int :param publisher_authid: The WAMP authid of the original publisher of this event. Only filled when publisher is disclosed. :type publisher_authid: str or None :param publisher_authrole: The WAMP authrole of the original publisher of this event. Only filled when publisher is disclosed. :type publisher_authrole: str or None :param topic: For pattern-based subscriptions, the actual topic URI being published to. Only filled for pattern-based subscriptions. :type topic: str or None :param retained: Whether the message was retained by the broker on the topic, rather than just published. :type retained: bool or None :param enc_algo: Payload encryption algorithm that was in use (currently, either ``None`` or ``u\'cryptobox\'``). :type enc_algo: str or None'
def __init__(self, subscription, publication, publisher=None, publisher_authid=None, publisher_authrole=None, topic=None, retained=None, enc_algo=None):
assert isinstance(subscription, Subscription) assert (type(publication) in six.integer_types) assert ((publisher is None) or (type(publisher) in six.integer_types)) assert ((publisher_authid is None) or (type(publisher_authid) == six.text_type)) assert ((publisher_authrole is None) or (type(publisher_authrole) == six.text_type)) assert ((topic is None) or (type(topic) == six.text_type)) assert ((retained is None) or (type(retained) is bool)) assert ((enc_algo is None) or (type(enc_algo) == six.text_type)) self.subscription = subscription self.publication = publication self.publisher = publisher self.publisher_authid = publisher_authid self.publisher_authrole = publisher_authrole self.topic = topic self.retained = retained self.enc_algo = enc_algo
':param acknowledge: If ``True``, acknowledge the publication with a success or error response. :type acknowledge: bool :param exclude_me: If ``True``, exclude the publisher from receiving the event, even if he is subscribed (and eligible). :type exclude_me: bool or None :param exclude: A single WAMP session ID or a list thereof to exclude from receiving this event. :type exclude: int or list of int or None :param exclude_authid: A single WAMP authid or a list thereof to exclude from receiving this event. :type exclude_authid: str or list of str or None :param exclude_authrole: A single WAMP authrole or a list thereof to exclude from receiving this event. :type exclude_authrole: list of str or None :param eligible: A single WAMP session ID or a list thereof eligible to receive this event. :type eligible: int or list of int or None :param eligible_authid: A single WAMP authid or a list thereof eligible to receive this event. :type eligible_authid: str or list of str or None :param eligible_authrole: A single WAMP authrole or a list thereof eligible to receive this event. :type eligible_authrole: str or list of str or None :param retain: If ``True``, request the broker retain this event. :type retain: bool or None'
def __init__(self, acknowledge=None, exclude_me=None, exclude=None, exclude_authid=None, exclude_authrole=None, eligible=None, eligible_authid=None, eligible_authrole=None, retain=None):
assert ((acknowledge is None) or (type(acknowledge) == bool)) assert ((exclude_me is None) or (type(exclude_me) == bool)) assert ((exclude is None) or (type(exclude) in six.integer_types) or ((type(exclude) == list) and all(((type(x) in six.integer_types) for x in exclude)))) assert ((exclude_authid is None) or (type(exclude_authid) == six.text_type) or ((type(exclude_authid) == list) and all(((type(x) == six.text_type) for x in exclude_authid)))) assert ((exclude_authrole is None) or (type(exclude_authrole) == six.text_type) or ((type(exclude_authrole) == list) and all(((type(x) == six.text_type) for x in exclude_authrole)))) assert ((eligible is None) or (type(eligible) in six.integer_types) or ((type(eligible) == list) and all(((type(x) in six.integer_types) for x in eligible)))) assert ((eligible_authid is None) or (type(eligible_authid) == six.text_type) or ((type(eligible_authid) == list) and all(((type(x) == six.text_type) for x in eligible_authid)))) assert ((eligible_authrole is None) or (type(eligible_authrole) == six.text_type) or ((type(eligible_authrole) == list) and all(((type(x) == six.text_type) for x in eligible_authrole)))) assert ((retain is None) or (type(retain) == bool)) self.acknowledge = acknowledge self.exclude_me = exclude_me self.exclude = exclude self.exclude_authid = exclude_authid self.exclude_authrole = exclude_authrole self.eligible = eligible self.eligible_authid = eligible_authid self.eligible_authrole = eligible_authrole self.retain = retain