labapi.user.User#
- class labapi.user.User(
- uid: str,
- email: str,
- notebooks: Sequence[NotebookInit],
- client: Client,
Bases:
objectRepresents 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,
Initialize a user session.
- Parameters:
uid – The unique ID of the user.
email – The email address of the user.
notebooks – A sequence of
NotebookInitobjects representing the notebooks accessible to the user.client – The
Clientinstance 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.
Return the maximum upload size for this user in bytes.
Attributes
The
Clientinstance associated with this user session.The email address of the user.
The unique ID of the user.
Provides access to the user's notebooks.
- property client: Client#
The
Clientinstance associated with this user session.- Returns:
The client instance.
- api_get( )[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.etree.Element.- Raises:
RuntimeError – If the underlying client session has been closed.
AuthenticationError – If LabArchives rejects the request due to invalid or expired credentials.
ApiError – If LabArchives returns any other non-success response.
Invalid XML propagates
lxml.etree.XMLSyntaxError.
- api_post( )[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.etree.Element.- Raises:
RuntimeError – If the underlying client session has been closed.
AuthenticationError – If LabArchives rejects the request due to invalid or expired credentials.
ApiError – If LabArchives returns any other non-success response.
Invalid XML propagates
lxml.etree.XMLSyntaxError.
- 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 underlying client session has been closed.
AuthenticationError – If LabArchives rejects the request due to invalid or expired credentials.
ApiError – If LabArchives returns any other non-success response.
labapi.exceptions.ExtractionError – If the response does not include
max-file-size.
Invalid XML propagates
lxml.etree.XMLSyntaxError.