API reference¶
This section describes the API of the pyserver and pyopenmatdb module.
API for creating plug-ins in python¶
Each plug-in’s run-function shall have session as its first argument. session is an instance of PythonPluginSever. It has an attribute db_client which holds an instance CouchClient - i.e. providing direct data base functions to the plug-ins.
PythonPluginSever¶
CouchClient¶
-
class
openmatdb.pyopenmatdb.
CouchClient
(api_url, db_name, record_id_fields)¶ Client for the RESTful API of couchDB
Parameters: - api_url (str) – Url to data base (incl. port number)
- db_name (str) – Data base name
- record_id_fields (list) – List of str - record attribute names to join to record Ids.
-
api_url
¶ Url to data base (incl. port number)
Type: str
-
db_name
¶ Data base name
Type: str
-
record_id_fields
¶ List of str - record attribute names to join to record Ids.
Type: list
-
get_collections
()¶ Get collections
-
add_collection
(collection_name)¶ Adds a new view/collection
-
add_record
(collection, record_data)¶ Adds a record to the data base
-
add_records
(collection, record_list)¶ Add records to a collection
Parameters: - collection (str) – Name of the collection
- record_list (list) – List of dictionaries with record attributes and values
Returns: List of valid records
Return type: list
-
get_records
(collection, query_dict=None)¶ Returns records as a list
-
get_record_by_ID
(collection, record_ID)¶ Get record by ID - collection
API for creating UIs in python¶
Each UI needs to communicate with the plug-in servers. The OpenmatEnvironment class provides an interface for this.
OpenmatEnvironemnt¶
-
class
openmatdb.pyopenmatdb.
OpenmatEnvironment
¶ Manager for the openmatDB environment (mainly communication with plug-in servers)
-
plugin_servers
¶ A list of server information. Dict for each server with keys: ‘server_name’, ‘url’, ‘plug-ins’, ‘plugin_language’
Type: list
-
active_record_id
¶ ID of the currently active record (to be set by UI)
Type: str
-
active_collection
¶ Name of the active collection (to be set by UI)
Type: str
Note
The active… attributes can be used to provide default values to plug-ins based on currently selected items in the UI.
-
get_plugin_server_data
(url)¶ Retrieves information from a plug-in server (i.e. server name, plug-in language, available plug-ins + config) :param url: URL to plug-in server API :type url: str
Returns: with keys: ‘server_name’, ‘url’, ‘plug-ins’, ‘plugin_language’ Return type: dict
-
add_plugin_server
(url)¶ Adds a plug-in server reference and sends an updated plug-in route table to all servers
Parameters: url (str) – URL to the plug-in servers API
-
plugin_config
¶ Returns the plug-in configs of all plug-ins in the system
-
plugin_route_table
¶ Returns a dict of plug-in module names and their corresponding server url
Type: dict
-
run_plugin
(plugin_name, *params)¶ Starts a plug-in launch request
Parameters: - plugin_name (str) – Name of the plug-in to run
- params (list) – List of parameters to pass to plug-in
-
RESTful API for building plugin-servers¶
TBD