Json-rpc client

This module provides a client for json-rpc webservices.

class wacryptolib.jsonrpc_client.JsonRpcProxy(url, *args, response_error_handler=<function status_slugs_response_error_handler>, **kwargs)

Bases: Server

A connection to a HTTP JSON-RPC server, backed by the requests library.

Parameters can be passed by position, or as keyword arguments (but not both).

See https://pypi.org/project/jsonrpc-requests/ for usage examples.

The differences between our JsonRpcProxy and upstream's Server class are:

  • we dump/load data using Pymongo's Extended Json format, able to transparently deal with bytes, uuids, dates etc.

  • we do not auto-unpack single dict arguments on call, e.g proxy.foo({'fizz': 1, 'fuzz': 2}) will be treated as calling remote foo() with a single dict argument, not as passing it keyword arguments fizz and fuzz.

  • a response_error_handler callback can be provided to swallow or convert an error received in an RPC response.

wacryptolib.jsonrpc_client.status_slugs_response_error_handler(exc)

Generic error handler which recognizes status slugs of builtin exceptions in json-rpc error responses, and reraises them client-side.