Managing Workspaces
This section covers how to manage workspaces using the Qelos SDK. Workspaces in Qelos provide multi-tenant support, allowing you to organize users and resources efficiently.
Workspace Methods
The workspaces
module in the Qelos SDK provides several methods for managing workspaces:
Getting a List of Workspaces
To retrieve a list of all workspaces the current user has access to:
const workspaces = await sdk.workspaces.getList();
This returns an array of IWorkspace
objects containing details about each workspace.
Getting a Specific Workspace
To retrieve details about a specific workspace:
const workspace = await sdk.workspaces.getWorkspace(workspaceId);
Getting Workspace Members
To retrieve the members of a specific workspace:
const members = await sdk.workspaces.getMembers(workspaceId);
This returns an array of IWorkspaceMember
objects containing details about each member.
Creating a New Workspace
To create a new workspace:
const newWorkspace = await sdk.workspaces.create({
name: "My New Workspace",
labels: ["team", "project"]
});
Updating a Workspace
To update an existing workspace:
const updatedWorkspace = await sdk.workspaces.update(workspaceId, {
name: "Updated Workspace Name",
logo: "https://example.com/logo.png"
});
Activating a Workspace
To activate a specific workspace (set it as the current active workspace):
const activatedWorkspace = await sdk.workspaces.activate(workspaceId);
Removing a Workspace
To remove a workspace:
await sdk.workspaces.remove(workspaceId);
Workspace Interfaces
IWorkspace Interface
interface IWorkspace {
name: string;
logo?: string;
isPrivilegedUser?: boolean;
members?: IWorkspaceMember[];
invites?: IInvite[];
labels: string[];
[key: string]: any;
}
IWorkspaceMember Interface
interface IWorkspaceMember {
user: string;
roles: string[];
created?: string | Date;
}
IInvite Interface
interface IInvite {
name?: string;
email: string;
created?: string | Date;
}
Admin Workspaces
For administrative operations on workspaces, you can use the admin SDK:
Calling an API Endpoint
To call a specific API endpoint for workspace-related operations:
const response = await sdkAdmin.adminWorkspaces.callApi('/endpoint', { method: 'GET' });
Getting List of All Workspaces (Admin)
To retrieve a list of all workspaces as an administrator:
const workspaces = await sdkAdmin.adminWorkspaces.getList();