jetraw.spaces module

Space management for Jetraw.

Spaces are top-level entities in the Jetraw platform that serve as containers for files and folders. They are associated with one or multiple storages and support permission management at the space level.

class jetraw.spaces.Space(space, client)

Bases: object

Represents a Jetraw space.

Spaces are top-level containers for files and folders. They are associated with one or multiple storages and support permission management. Files and folders can be uploaded to spaces, and access can be controlled at the space level.

Example

>>> # Create a new space
>>> storages = [get_storage("storage-id")]
>>> space = create_space("my-space", "My Project Space", storages)
>>>
>>> # Grant permissions to users
>>> user = get_user("user-id")
>>> space.grant_permission(user)
>>>
>>> # List space permissions
>>> for perm in space.list_permissions():
...     print(f"{perm.user.name}: {perm.added_at}")
property created_at

Get the timestamp when the space was created.

property display_name

Get the space display name.

grant_permission(user)

Grant access permission to user(s) for this space.

Parameters:

user (Union[User, list[User]]) – User object(s) to grant permission to

Example

>>> # Grant permission to a single user
>>> user = get_user("user-id")
>>> space.grant_permission(user)
>>>
>>> # Grant permission to multiple users
>>> users = [get_user("user1"), get_user("user2")]
>>> space.grant_permission(users)
property id

Get the unique identifier of the space.

list_permissions()

List all users who have permission to access this space.

Yields:

SpacePermission – Permission objects containing user and timestamp

Return type:

Generator[SpacePermission, None, None]

Example

>>> # List all space permissions
>>> for perm in space.list_permissions():
...     print(f"{perm.user.name}: granted at {perm.added_at}")
property name

Get the space name.

remove()

Delete this space.

Returns:

True if deletion was successful, False otherwise

Return type:

bool

Example

>>> success = space.remove()
>>> if success:
...     print("Space deleted successfully")
revoke_permission(user)

Revoke access permission from user(s) for this space.

Parameters:

user (Union[User, list[User]]) – User object(s) to revoke permission from

Example

>>> # Revoke permission from a single user
>>> user = get_user("user-id")
>>> space.revoke_permission(user)
>>>
>>> # Revoke permission from multiple users
>>> users = [get_user("user1"), get_user("user2")]
>>> space.revoke_permission(users)
property storages: list[Storage]

Get the list of storages associated with this space.

property updated_at

Get the timestamp when the space was last updated.

class jetraw.spaces.SpacePermission(user, added_at)

Bases: object

Represents a user’s permission to access a space.

user

The user who has permission

added_at

When the permission was granted

added_at: datetime
user: User
jetraw.spaces.create_space(name, display_name, storages, *, client=None)

Create a new space.

Parameters:
  • name (str) – Unique name for the space

  • display_name (str) – Human-readable display name

  • storages (list[Storage]) – List of Storage objects to associate with the space

  • client (Client) – Jetraw client instance (uses default if None)

Returns:

The created space

Return type:

Space

Raises:

ValueError – If parameters are invalid

Example

>>> # Create a space with associated storages
>>> storages = [get_storage("storage-id-1"), get_storage("storage-id-2")]
>>> space = create_space("project-alpha", "Alpha Project", storages)
>>> print(f"Created space: {space.name}")
jetraw.spaces.get_space(name, *, client=None)

Get a space by name.

Parameters:
  • name (str) – Name of the space to retrieve

  • client (Client) – Jetraw client instance (uses default if None)

Returns:

The space object

Return type:

Space

Raises:

KeyError – If the space is not found

Example

>>> space = get_space("my-project")
>>> print(f"Space: {space.display_name}")
jetraw.spaces.list_spaces(*, client=None)

List all spaces accessible to the current user.

Parameters:

client (Client) – Jetraw client instance (uses default if None)

Returns:

List of all accessible spaces

Return type:

list[Space]

Example

>>> # List all spaces
>>> spaces = list_spaces()
>>> for space in spaces:
...     print(f"{space.name}: {space.display_name}")