Menu
Introduction
Getting Started
Developer guide
Release
Architecture
CLI
Technical documentations
Version
Publication date

Mar 9, 2022

Confidentiality
Public
Reactions
1
Share

SpaceService

Attributes
AUTH_API_KEY_HEADER_PREFIX: strAUTH_HEADER_KEY: strUSER_ID_HEADER_KEY: str
Functions
__init__

Constructor of the SpaceService

access_token : str | None
if access token is provided, it is used to authenticate. Otherwise the current user is used for authentication
add_or_replace_tags_on_object

Add or replace tags on a folder object in space. The tags are created if they don't exist. If a tag with the same key exists, it is replaced by the new tag.

entity_id : str
id of the object (folder, scenario, document, note, resource...)
tags : list
list of tags to add or replace
Return type : list
add_tags_to_object

Add tags to a folder object in space. The tags are created if they don't exist. It does not replace tags with the same key (use add_or_replace_tags_on_object for that).

entity_id : str
id of the object (folder, scenario, document, note, resource...)
tags : list
list of tags to add
Return type : list
check_2_fa

Check the credential of an email/password by calling space and return true if ok

credentials : UserCredentials2Fa
Return type : UserSpace
check_api_key
api_key : str
Return type : bool
check_credentials

Check the credential of an email/password by calling space, with 2Fa if needed

credentials : UserCredentialsDTO
for_login : bool - True
Return type : ExternalCheckCredentialResponse
create_child_folder

Create a child folder in the lab space.

parent_id : str
id of the parent folder
folder : ExternalSpaceCreateFolder
folder information
Return type : ExternalSpaceFolder
create_root_folder

Create a root folder in the lab space. The root folder will be shared to the current user and mark as created by the current user.

folder : ExternalSpaceCreateFolder
folder information
Return type : ExternalSpaceFolder
delete_document

Delete a document by moving it to trash

document_id : str
id of the document to delete
Return type : SpaceHierarchyObjectDTO
delete_folder

Move a folder to trash

folder_id : str
id of the folder to delete
delete_note
folder_id : str
note_id : str
delete_scenario
folder_id : str
scenario_id : str
delete_tags_on_object

Delete tags on a folder object in space.

entity_id : str
id of the object (folder, scenario, document, note, resource...)
tags : list
list of tags to delete
download_document_bytes

Download a document from space and return the bytes directly

document_id : str
id of the document to download
filename : str
filename for URL readability (not used in logic)
Return type : bytes
get_all_current_user_root_folders

Get all the root folders accessible by the current user

Return type : list
get_all_lab_root_folders

Get all the folder trees (from root) accessible by the lab

Return type : ExternalSpaceFolders
get_all_lab_users

Get all the users of the lab

Return type : list
get_current_lab_all_groups

Get all groups for the current lab

Return type : list
get_folder_users

Get all users who have access to a folder

folder_id : str
id of the folder
Return type : list
get_lab_root_folder

Get the root folder tree information. The folder must be accessible by the lab.

id_ : str
id of the root folder
Return type : ExternalSpaceFolder
get_modifications
old_content : RichTextDTO
new_content : RichTextDTO
old_modifications : gws_core.impl.rich_text.rich_text_modification.RichTextModificationsDTO | None
Return type : RichTextModificationsDTO
get_reflex_access_token

Get the reflex access token

Return type : str
get_synced_notes

Get the list of notes synced with space

Return type : list
get_synced_scenarios

Get the list of scenarios synced with space

Return type : list
get_undo_content
content : RichTextDTO
modifications : RichTextModificationsDTO
modification_id : str
Return type : RichTextDTO
get_user_info

Get the information of a user. The user must be in the same space as the lab.

user_id : str
id of the user
Return type : UserFullDTO
handle_error

Centralized error handler for all space service operations. Converts connection errors to user-friendly messages.

error : Exception
The exception that was raised
operation_description : str
Description of the operation that failed (e.g., "create folder", "save scenario")
Return type : NoReturn
register_lab_start

Call the space api to mark the lab as started

lab_config : LabConfigModelDTO
Return type : bool
rename_document

Rename a document in space

document_id : str
id of the document to rename
name : str
new name for the document
save_note
folder_id : str
note : SaveNoteToSpaceDTO
form_data : FormData
Return type : SpaceHierarchyObjectDTO
save_scenario
folder_id : str
save_scenario_dto : SaveScenarioToSpaceDTO
Return type : SpaceHierarchyObjectDTO
search_project_children_objects_paginated

Get paginated children of a folder with search capabilities

folder_id : str
id of the folder to get children from
search_params : SpaceHierarchyObjectSearchParams
search and filter parameters
page : int
page number (0-indexed)
size : int
page size (number of items per page)
Return type : PageDTO[SpaceHierarchyObjectDTO]
send_mail

Send a mail to a list of users. To send a custom mail, use the template 'generic' and provide mail content in the data.

send_mail_dto : SpaceSendMailToUsersDTO
mail information
Return type : Response
send_mail_to_mails

Send a mail to a list of mails. To send a custom mail, use the template 'generic' and provide mail content in the data.

send_mail_to_mails_dto : SpaceSendMailToMailsDTO
mail information
Return type : Response
send_notification

Send a notification to a list of users in a space

send_notification_dto : SpaceSendNotificationDTO
notification information
Return type : Response
share_resource

Share a resource in a folder in space. Only the resource link is shared, not the resource itself. After this, the resource is available in the space folder if this lab is up and running.

folder_id : str
resource_dto : ShareResourceWithSpaceDTO
_description_
Return type : SpaceHierarchyObjectDTO
share_root_folder

Share a root folder with a group or a user

root_folder_id : str
id of the root folder
group_or_user_id : str
id of the group or user
role : SpaceRootFolderUserRole - SpaceRootFolderUserRole.USER
role to assign to the group or user
Return type : list
share_root_folder_with_current_lab

Share a root folder with the current lab

root_folder_id : str
id of the root folder
Return type : ExternalSpaceFolder
unshare_root_folder

Unshare a folder from a user

root_folder_id : str
user_id : str
id of the user
update_folder

Update a folder in the lab space.

folder_id : str
id of the folder
folder : ExternalSpaceCreateFolder
folder information
Return type : ExternalSpaceFolder
update_folder_user_role

Update the role of a user for a folder. This is an alias for update_share_folder.

folder_id : str
id of the folder
user_id : str
id of the user
role : SpaceRootFolderUserRole
new role for the user
update_note_folder
current_folder_id : str
note_id : str
new_folder_id : str
update_scenario_folder
current_folder_id : str
scenario_id : str
new_folder_id : str
update_share_folder

Update the role of a user for a shared folder

folder_id : str
id of the folder
user_id : str
id of the user
role : SpaceRootFolderUserRole
new role for the user
upload_document

Upload a document to a folder in space

parent_folder_id : str
id of the parent folder
file_path : str
path to the file to upload
override_mode : DocumentUploadOverrideMode
how to handle existing files with the same name (IGNORE, ERROR, REPLACE, RENAME)
filename : str
custom filename
Return type : SpaceHierarchyObjectDTO
create_with_access_token @classmethod

Return a new instance of the SpaceService that use the access token for authentication

Return type : SpaceServiceBaseType
get_instance @classmethod

Return a new instance of the SpaceService that use the current user for authentication

Return type : SpaceServiceBaseType
build_page_dto_from_space_json @staticmethod

Build a PageDTO from Space API JSON response format (ClPageI).

The Space API returns paginated data in the ClPageI format: { "objects": T[], "first": boolean, "last": boolean, "totalElements": number, "currentPage": number, "pageSize": number, "totalIsApproximate"?: boolean }

This method converts it to the internal PageDTO format.

json_data : dict
The JSON response from the Space API
object_converter : Callable
Function to convert each object in the list from JSON to the target DTO type
Return type : PageDTO[~T]
Shine Logo
Technical bricks to reuse or customize

Have you developed a brick?

Share it to accelerate projects for the entire community.