dposlib.rest

rest module provides network loaders and usrv.req.EndPoint root class to implement GET, POST, PUT and DELETE HTTP requests.

When a specific blockchain package is loaded through rest.use definition, a dposlib.core module is available to provide necessary classes and definitions.

GET

HTTP GET request builder

POST

HTTP POST request builder

PUT

HTTP PUT request builder

DELETE

HTTP DELETE request builder

load

def load(name)

Load a given blockchain package as dposlib.core module. A valid blockchain package must provide init(peer=None) and stop() definitions. Available blockchains are referenced in dposli.net module.

Arguments:

  • name str - package name to load.

Raises:

  • Exception - if package name is not found or if package can not be initialized properly.

use

def use(network, **kwargs)

Sets the blockchain parameters in the dposlib.rest.cfg module and initializes blockchain package. Network options can be created or overriden using **kwargs argument.

Arguments:

  • network str - network to initialize.
  • **kwargs - parameters to be overriden.

Returns:

  • bool - True if network connection established, False otherwise.

Raises:

  • Exception - if blockchain not defined or if initialization failed.