We now have a global OctoPrintClient, which is the class from which
all clients are derived, and a global OctoPrint, which is a single
instance already setup and ready to use in case we only need one.
It would be cleaner to have clients create that singular instance
themselves, but we need to maintain backward compatibility for now
with how we established the client to work with the 1.3.0 release.
New clients can be create with
client = new OctoPrintClient({ /* options */ });
Alternatively the options can be left out and set at a later point:
client = new OctoPrintClient();
/* ... */
client.options = { /* options */ };
Individual client components register themselves with OctoPrintClient
via OctoPrintClient.registerComponent(name, component) from the
component JS files. Just like before their instances are then
available in the individual client instances under "<client>.<name>",
e.g. "OctoPrint.files".
Plugin components register themselves with OctoPrintClient via
OctoPrintClient.registerPluginComponent(name, component) from the
component JS files. Just like before their instances are then
available in the individual client instances under "<client>.plugins
.<name>", e.g. "OctoPrint.plugins.softwareupdate".
This should make it possible to create dashboard pages utilizing the
JS client that monitor the status of multiple OctoPrint instances,
without workarounds such as having to swap out the options globally
before each request.
See #1681 for the corresponding discussion.
106 lines
3.7 KiB
ReStructuredText
106 lines
3.7 KiB
ReStructuredText
.. _sec-jsclientlib-users:
|
|
|
|
:mod:`OctoPrintClient.users`
|
|
----------------------------
|
|
|
|
.. note::
|
|
|
|
Most methods here require that the used API token or a the existing browser session
|
|
has admin rights *or* corresponds to the user to be modified. Some methods
|
|
definitely require admin rights.
|
|
|
|
.. js:function:: OctoPrintClient.users.list(opts)
|
|
|
|
Get a list of all registered users.
|
|
|
|
Requires admin rights.
|
|
|
|
:param object opts: Additional options for the request
|
|
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
|
|
|
.. js:function:: OctoPrintClient.users.get(name, opts)
|
|
|
|
Get information about a specific user.
|
|
|
|
:param string name: The user's name
|
|
:param object opts: Additional options for the request
|
|
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
|
|
|
.. js:function:: OctoPrintClient.users.add(user, opts)
|
|
|
|
Add a new user.
|
|
|
|
Requires admin rights.
|
|
|
|
:param object user: The new user
|
|
:param object opts: Additional options for the request
|
|
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
|
|
|
.. js:function:: OctoPrintClient.users.update(name, active, admin, opts)
|
|
|
|
Update an existing user.
|
|
|
|
Requires admin rights.
|
|
|
|
:param string name: The user's name
|
|
:param bool active: The new ``active`` state of the user
|
|
:param bool admin: The new ``admin`` state of the user
|
|
:param object opts: Additional options for the request
|
|
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
|
|
|
.. js:function:: OctoPrintClient.users.delete(name, opts)
|
|
|
|
Delete an existing user.
|
|
|
|
Requires admin rights.
|
|
|
|
:param string name: The user's name
|
|
:param object opts: Additional options for the request
|
|
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
|
|
|
.. js:function:: OctoPrintClient.users.changePassword(name, password, opts)
|
|
|
|
Change the password for a user.
|
|
|
|
:param string name: The user's name
|
|
:param string password: The new password
|
|
:param object opts: Additional options for the request
|
|
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
|
|
|
.. js:function:: OctoPrintClient.users.generateApiKey(name, opts)
|
|
|
|
Generate a new API key for a user.
|
|
|
|
:param string name: The user's name
|
|
:param object opts: Additional options for the request
|
|
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
|
|
|
.. js:function:: OctoPrintClient.users.resetApiKey(name, opts)
|
|
|
|
Reset the API key for a user to being unset.
|
|
|
|
:param string name: The user's name
|
|
:param object opts: Additional options for the request
|
|
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
|
|
|
.. js:function:: OctoPrintClient.users.getSettings(name, opts)
|
|
|
|
Get the settings for a user.
|
|
|
|
:param string name: The user's name
|
|
:param object opts: Additional options for the request
|
|
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
|
|
|
.. js:function:: OctoPrintClient.users.saveSettings(name, settings, opts)
|
|
|
|
Save the settings for a user.
|
|
|
|
:param string name: The user's name
|
|
:param object settings: The new settings, may be a partial set of settings which will be merged unto the current ones
|
|
:param object opts: Additional options for the request
|
|
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
|
|
|
.. seealso::
|
|
|
|
:ref:`User API <sec-api-user>`
|
|
The documentation of the underlying user API.
|