labapi.user.User#

class labapi.user.User(
uid: str,
email: str,
notebooks: Sequence[NotebookInit],
client: Client,
)[source]#

Bases: object

Represents an authenticated LabArchives user session.

This class holds user-specific information such as the user ID and provides an interface to interact with the LabArchives API, particularly for accessing and managing notebooks and their contents.

__init__(
uid: str,
email: str,
notebooks: Sequence[NotebookInit],
client: Client,
)[source]#

Initialize a user session.

Parameters:
  • uid – The unique ID of the user.

  • email – The email address of the user.

  • notebooks – A sequence of NotebookInit objects representing the notebooks accessible to the user.

  • client – The Client instance used for API communication.

Methods

__init__(uid, email, notebooks, client)

Initialize a user session.

api_get(api_method_uri, **kwargs)

Send a GET request on behalf of this user.

api_post(api_method_uri, body, **kwargs)

Send a POST request on behalf of this user.

get_max_upload_size()

Return the maximum upload size for this user in bytes.

Attributes

client

The Client instance associated with this user session.

email

The email address of the user.

id

The unique ID of the user.

notebooks

Provides access to the user's notebooks.

property id: str#

The unique ID of the user.

Returns:

The user’s ID.

property email: str#

The email address of the user.

Returns:

The user’s email.

property client: Client#

The Client instance associated with this user session.

Returns:

The client instance.

api_get(
api_method_uri: str | Sequence[str],
**kwargs: Any,
)[source]#

Send a GET request on behalf of this user.

This method automatically appends the user’s ID to the API call.

Parameters:
  • api_method_uri – The API method URI (e.g., “get_user_settings”). Can be a string or a sequence of strings representing path segments.

  • kwargs – Additional query parameters to pass to the API method.

Returns:

The response from the API, typically an lxml Element.

Raises:

RuntimeError – If the API request fails.

api_post(
api_method_uri: str | Sequence[str],
body: Mapping[str, str] | BufferedIOBase,
**kwargs: Any,
)[source]#

Send a POST request on behalf of this user.

This method automatically appends the user’s ID to the API call.

Parameters:
  • api_method_uri – The API method URI (e.g., “create_entry”). Can be a string or a sequence of strings representing path segments.

  • body – The request body, which can be a mapping of form data or a file-like object.

  • kwargs – Additional query parameters to pass to the API method.

Returns:

The response from the API, typically an lxml Element.

Raises:

RuntimeError – If the API request fails.

get_max_upload_size() int[source]#

Return the maximum upload size for this user in bytes.

The unit of the returned value is bytes.

Returns:

The maximum upload size in bytes.

Raises:

RuntimeError – If the API request fails.

property notebooks: Notebooks#

Provides access to the user’s notebooks.

Returns:

A Notebooks object managing the user’s notebooks.