# Workspaces

> Create and manage workspaces

A workspace holds datasets, and each training run and pipeline run belongs to
one. The SDK's resource is `client.workspaces`; `client.projects` is its old
name and the same object. The API still calls a workspace a project, so ids
and fields are named `project_id`.

## Create a Workspace

```python
from qualia import Qualia

client = Qualia()

project = client.workspaces.create(
    name="My Project",
    description="Optional description",
)
```

**Response**

```json title="ProjectCreateResult"
{
"created": true,
"project_id": "123e4567-e89b-12d3-a456-426614174000"
}
```

## List Projects

List your projects, a page at a time. Each says whether it is the
organization's default, its icon, and your role there.

```python
page = client.workspaces.list(limit=20)
for project in page.items:
    print(project.name, project.is_default, project.my_role)
next_page = client.workspaces.list(cursor=page.page_info.end_cursor)
```

**Response**

```json title="PaginatedPage[ProjectSummary]"
{
"items": [
  {
    "project_id": "123e4567-e89b-12d3-a456-426614174000",
    "name": "My Project",
    "description": "Optional description",
    "created_at": "2024-01-15T10:00:00Z",
    "updated_at": "2024-01-16T08:00:00Z",
    "is_default": true,
    "icon": null,
    "my_role": "contributor"
  }
],
"page_info": { "has_next": false, "end_cursor": null, "total_count": 1 }
}
```

`my_role` is `viewer`, `contributor`, `admin` or `owner`. For an API key it is
its creator's; the key's scopes cap what it may do.

## Get a Project

```python
project = client.workspaces.get(project.project_id)
```

Returns one `ProjectSummary`, the shape of a list item.

## Update a Project

Rename a project, or change its description or icon. Only what you pass
changes; `description=None` (or `""`) empties it and `icon=None` removes the
icon.

```python
project = client.workspaces.update(
    project.project_id,
    name="Arms",
    description="Upper-body teleop",
)
```

It takes what the dashboard's workspace settings take: a contributor, admin or
owner of the organization. A key needs `projects:write` and must not be
restricted to workspaces. Returns the project as it is now.

## Delete a Project

Remove a project. This will fail if the project has active jobs.

```python
client.workspaces.delete(project.project_id)
```

**Response**

```json title="ProjectDeleteResult"
{
"deleted": true,
"project_id": "123e4567-e89b-12d3-a456-426614174000"
}
```
