Confirmed users
133
edits
(→API) |
(→API) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 9: | Line 9: | ||
==Notes== | ==Notes== | ||
The PluginService basically provides an environment in which plugins can run. | * The PluginService basically provides an environment in which plugins can run. | ||
* The plugins run within this service, and it handles the threading and the external (REST) API. | |||
The plugins run within this service, and it handles the threading and the external (REST) API. | * The PluginService runs inline/in process | ||
* The PluginServiceRestAPI provides a wrapper around it so that is can run in a separate process, or even on another machine | |||
* The PluginServiceClient (not yet implemented;) should present the same API as PluginService, but use the REST API to communicate with a remote PluginService | |||
* Clients should be able to switch between PluginService and PluginServiceClient without any code changes (constructors will differ) | |||
==API== | ==API== | ||
This is at a very early stage, so is still fairly fluid. | This is at a very early stage, so is still fairly fluid. | ||
{| border="1" cellpadding="1" | {| border="1" cellpadding="1" | ||
|- | |- | ||
! Op !! URL !! Method !! Notes | ! Op !! URL !! Method !! Notes || Example response | ||
|- | |||
| GET || /info || get_info || Get info about the PluginService (name/host and version) || {'version': 1, 'name': '127.0.0.1'} | |||
|- | |- | ||
| GET || / | | GET || /plugins || get_plugins || List all of the Get info about the PluginService (name/host and version) || {'plugins': [{'version': 1, 'type': 'WebApp', 'plugin': 'TemplatePlugin'}]} | ||
|- | |- | ||
| GET || / | | GET || /plugin/<plugin_name>/template || get_plugin_template(plugin_name) || Get the plugin template (which defines what params it needs/supports) || {'template': {'target': {'type': 'url', 'required': True, 'is_list': True}}, 'safechecks': {'type': 'bool', 'value': True}} | ||
|- | |- | ||
| | | GET || /sessions || get_sessions() || Returns a list of all of the current sessions || {'sessions': {'8db4b299106ea496c862ab3dff710155': {'status': {'status': 'PENDING', 'message': 'Plugin is pending execution.', 'success': True}, 'plugin_name': 'TemplatePlugin'}}} | ||
|- | |- | ||
| | | PUT || /session/create/<plugin_name> || create_session(plugin_name) || Create a session with the specified plugin || {'message': "Created new session for plugin 'TemplatePlugin'", 'session': '8db4b299106ea496c862ab3dff710155'} | ||
|- | |- | ||
| | | PUT || /session/<session>/value?key=<key>&value=<value> || set_session_value(session, key, value) || Sets a session value || None | ||
|- | |- | ||
| | | DELETE || /session/<session> || terminate_session(session) || Terminates the specified session || {'message': 'Session terminated', 'session': '9ba4c151b3f20690390e39bc3c3b98ae'} | ||
|- | |- | ||
| | | GET || /session/<session>/status || get_session_status(session) || Get the status of the specified session || {'status': 'PENDING', 'message': 'Plugin is pending execution.', 'success': True} | ||
|- | |- | ||
| GET || /session/<session>/ | | GET || /session/<session>/states || get_session_states(session) || Returns the valid states the specified session can be set to || ['START'] | ||
|- | |||
| POST ||"/session/<session>/state/<state> || set_session_states(session, state) || Sets the session state - used for starting, stopping etc || {'status': 'RUNNING', 'message': 'Plugin started: Execution is in progress.', 'success': True} | |||
|- | |||
| GET || /session/<session>/results || get_session_results(session) || Returns the session results (which can be incomplete) || {'issues': [ <issues - defn TBA> ]} | |||
|} | |} | ||
A typical basic sequence of calls might be: | |||
# get_info - to find out the services name and its version (the API will probably change between versions;) | |||
# get_plugins() - to see what plugins are available | |||
# get_plugin_template(plugin_name) - to find out what parameters are needed | |||
# create_session(plugin_name) - to create a new session with the specified plugin (returns the session id) | |||
# set_plugin_value(session, key, value) - called potentially multiple times to set the configuration values | |||
# set_session_states(session, MinionPlugin.STATE_START) - start the plugin | |||
# get_session_status(session) - to monitor how its progressing | |||
# get_session_results(session) - to get the results (partial results may be available before the plugin completes, depending on the plugin) | |||
==Main Classes== | ==Main Classes== |