Organizations and workspaces
New to the SDK? Getting started shows how to connect and use it.
Organizations
Organizations
The organizations the caller belongs to.
Organizations.get()
get(*, id: str) -> Organization
Return one organization by ID.
Arguments
| Name | Type | Description |
|---|---|---|
id | str | The organization UUID. |
Returns: Organization — The organization. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
BadRequest | The runtime rejected the request as invalid. message, code and fields say why. |
NotAuthorized | The caller lacks the access that this call needs. message says why. |
NotFound | The organization does not exist. |
Organizations.count()
count() -> int
Return how many organizations the caller belongs to.
Returns: int — The organization count, which saturates at 10,001. Async mode returns an awaitable.
Organizations.list()
list(
*,
limit: int | None = None,
offset: int = 0,
) -> Iterable[Organization] | AsyncIterable[Organization]
Yield the organizations that the caller belongs to, page by page.
It needs no scope, so it is the entry point when the caller knows no IDs yet.
Arguments
| Name | Type | Description |
|---|---|---|
limit | int | None | The most items to return. None returns every item up to item 10,100, where the runtime stops paging. |
offset | int | The number of items that the runtime skips first. |
Returns: Iterable[Organization] | AsyncIterable[Organization] — An iterable of organizations. Async mode returns an async iterable.
Raises
| Exception | When |
|---|---|
ValueError | A negative limit or offset. |
Organization
An organization: the tenant that owns workspaces, members and billing.
| Name | Type | Example | Description |
|---|---|---|---|
organization.workspaces | Workspaces | organization.workspaces.list() | The workspaces in this organization. |
Attributes
| Name | Type | Description |
|---|---|---|
id | str | Unique ID (a UUID). |
name | str | The name of the organization. |
description | str | None | Free-text description of the organization; None when none is set. |
dataplane_id | str | None | Data plane of the organization's workspaces; None until a region is set. |
created_at | datetime | When it was created. |
Organization.set_dataplane()
set_dataplane(*, dataplane_id: str) -> Organization
Set the data plane that holds the workspaces of this organization.
The organization needs a data plane before it can hold a workspace. The data plane fixes where the data of the workspaces resides. The choice is final.
Arguments
| Name | Type | Description |
|---|---|---|
dataplane_id | str | The data plane to assign. |
Returns: Organization — A fresh snapshot. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
BadRequest | The runtime rejected the request as invalid. message, code and fields say why. |
Conflict | The organization already has a data plane. |
NotAuthorized | The caller lacks the access that this call needs. message says why. |
NotFound | The organization does not exist. |
Organization.me()
me() -> OrganizationCaller
Return who the caller is in this organization, with role and workspaces.
It works for an API key and for a user token.
Returns: OrganizationCaller — The identity, role and workspace memberships of the caller in this organization. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
NotAuthorized | The caller lacks the access that this call needs. message says why. |
NotFound | The organization no longer exists. |
Membership
A workspace that the caller belongs to, with the role of the caller.
Attributes
| Name | Type | Description |
|---|---|---|
workspace | Workspace | The workspace, bound and ready to navigate from. |
role | str | The role of the user in the workspace. |
OrganizationCaller
Who the token belongs to, and what the caller can do in one organization.
Attributes
| Name | Type | Description |
|---|---|---|
email | str | The email of the current user. |
user_id | str | The ID of the current user. |
organization_membership_id | str | The ID of the organization member for this organization. |
role | str | The role of the user in this organization. |
workspace_memberships | tuple[Membership, ...] | The workspaces of the organization that the caller belongs to. |
Workspaces
Workspaces
The workspaces of an organization, scoped by the context that reaches them.
Workspaces.create()
create(
*,
name: str,
description: str | None = None,
organization_id: str | None = None,
) -> Workspace
Create a workspace in an organization.
Arguments
| Name | Type | Description |
|---|---|---|
name | str | Name of the new workspace. Names do not have to be unique. |
description | str | None | Free-text description, or None for none. |
organization_id | str | None | Overrides the organization in scope. Required when the context carries none. |
Returns: Workspace — The new workspace, scoped so that its jobs are reachable. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
BadRequest | The runtime rejected the request as invalid. message, code and fields say why. |
Conflict | The organization has no data plane yet, or a trial organization already has its workspace. code and message say why. |
NotAuthorized | The caller lacks the access that this call needs. message says why. |
NotFound | The organization does not exist. |
ScopeMissing | No organization in scope and none passed. |
Workspaces.get()
get(*, id: str) -> Workspace
Return one workspace by ID.
Arguments
| Name | Type | Description |
|---|---|---|
id | str | The workspace UUID. |
Returns: Workspace — The workspace. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
BadRequest | The runtime rejected the request as invalid. message, code and fields say why. |
NotAuthorized | The caller lacks the access that this call needs. message says why. |
NotFound | The workspace does not exist. |
Workspaces.count()
count(*, organization_id: str | None = None) -> int
Count the workspaces of one organization, without reading them.
It counts the live (unarchived) workspaces of the organization that the caller can see.
Arguments
| Name | Type | Description |
|---|---|---|
organization_id | str | None | Overrides the organization in scope. Required when the context carries none. |
Returns: int — The workspace count, which saturates at 10,001. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
BadRequest | The runtime rejected the request as invalid. message, code and fields say why. |
NotAuthorized | The caller lacks the access that this call needs. message says why. |
NotFound | The organization does not exist. |
ScopeMissing | No organization in scope and none passed. |
Workspaces.list()
list(
*,
organization_id: str | None = None,
limit: int | None = None,
offset: int = 0,
) -> Iterable[Workspace] | AsyncIterable[Workspace]
Yield the workspaces of one organization, page by page.
It yields the live (unarchived) workspaces of the organization that the caller can see. Errors from the runtime raise when the iteration starts.
Arguments
| Name | Type | Description |
|---|---|---|
organization_id | str | None | Overrides the organization in scope. Required when the context carries none. |
limit | int | None | The most workspaces to return. None returns every workspace up to item 10,100, where the runtime stops paging. |
offset | int | The number of workspaces that the runtime skips first. |
Returns: Iterable[Workspace] | AsyncIterable[Workspace] — An iterable of workspaces. Async mode returns an async iterable.
Raises
| Exception | When |
|---|---|
BadRequest | The runtime rejected the request as invalid. message, code and fields say why. |
NotAuthorized | The caller lacks the access that this call needs. message says why. |
NotFound | The organization does not exist. |
ScopeMissing | No organization in scope and none passed. |
ValueError | A negative limit or offset. |
Workspace
A workspace: the unit that holds deployed jobs.
| Name | Type | Example | Description |
|---|---|---|---|
workspace.job_runs | JobRuns | workspace.job_runs.list() | The job runs of this workspace, across all its jobs. |
workspace.deployments | Deployments | workspace.deployments.list() | The code versions uploaded to this workspace. |
workspace.configurations | Configurations | workspace.configurations.list() | The configuration versions uploaded to this workspace. |
workspace.telemetry | Telemetry | workspace.telemetry.status() | What the runtime recorded about the pipeline runs of this workspace. |
workspace.variables | Variables | workspace.variables.list() | The variables that the job runs of this workspace read. |
workspace.jobs | Jobs | workspace.jobs.list() | The jobs deployed in this workspace. |
Attributes
| Name | Type | Description |
|---|---|---|
id | str | Unique ID (a UUID). |
name | str | The name of the workspace. |
description | str | None | Free-text description of the workspace; None when none is set. |
organization_id | str | The ID of the parent organization. |
dataplane_id | str | Identifier of the data plane that holds this workspace's user data. Matches the subdomain of the plane's public entrypoint. |
is_playground | bool | Whether this is the user's auto-created personal playground workspace. A playground has a single member and cannot be updated, archived, shared, or given API keys. |
predefined_profiles | Mapping[str, str] | Deprecated and always empty. A job definition declares its data access. |
created_at | datetime | When it was created. |
archived_at | datetime | None | When the workspace was archived; None when live. An archived workspace rejects all changes except unarchiving, though owners can still manage its workspace variables. |
dashboard_url | str | The page of this workspace in the dltHub web app. |
Workspace.update()
update(*, name: str | Keep = KEEP, description: str | None | Keep = KEEP) -> Workspace
Change the name of the workspace, its description, or both.
Arguments
| Name | Type | Description |
|---|---|---|
name | str | Keep | New name. KEEP, the default, leaves it unchanged. |
description | str | None | Keep | New description. None clears it, and KEEP leaves it unchanged. |
Returns: Workspace — A fresh snapshot. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
BadRequest | The runtime rejected the request as invalid. message, code and fields say why. |
Conflict | The current state does not allow the call, for example an archived workspace. code and message say why. |
NotAuthorized | The caller lacks the access that this call needs. message says why. |
NotFound | The workspace no longer exists. |
Workspace.archive()
archive() -> Workspace
Freeze the workspace: its schedules stop and it refuses changes.
Returns: Workspace — A fresh snapshot with archived_at set. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
BadRequest | The runtime rejected the request as invalid. message, code and fields say why. |
Conflict | The workspace is already archived, or a job run in it is still active. code and message say why. |
NotAuthorized | The caller lacks the access that this call needs. message says why. |
NotFound | The workspace no longer exists. |
Workspace.unarchive()
unarchive() -> Workspace
Reopen an archived workspace and restart its schedules.
Returns: Workspace — A fresh snapshot with archived_at cleared. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
Conflict | The workspace is not archived. |
NotAuthorized | The caller lacks the access that this call needs. message says why. |
NotFound | The workspace no longer exists. |
Workspace.members()
members(
*,
limit: int | None = None,
offset: int = 0,
) -> Iterable[WorkspaceMember] | AsyncIterable[WorkspaceMember]
Yield the members of this workspace, with their roles.
Arguments
| Name | Type | Description |
|---|---|---|
limit | int | None | The most items to return. None returns every item up to item 10,100, where the runtime stops paging. |
offset | int | The number of items that the runtime skips first. |
Returns: Iterable[WorkspaceMember] | AsyncIterable[WorkspaceMember] — An iterable of members. Async mode returns an async iterable.
Raises
| Exception | When |
|---|---|
NotAuthorized | The caller lacks the access that this call needs. message says why. |
ValueError | A negative limit or offset. |
Workspace.me()
me() -> WorkspaceCaller
Return who the caller is in this workspace, and what the caller can do.
It works for an API key and for a user token. It also records this
workspace as the latest one of the caller, so Runtime.me() then
reports its organization as latest_organization.
Returns: WorkspaceCaller — The identity and roles of the caller. Async mode returns an awaitable.
Raises
| Exception | When |
|---|---|
NotAuthorized | The caller lacks the access that this call needs. message says why. |
NotFound | The workspace no longer exists. |
WorkspaceCaller
Who the token belongs to, and what the caller can do in one workspace.
Attributes
| Name | Type | Description |
|---|---|---|
email | str | The email of the current user. |
user_id | str | The ID of the current user. |
organization_membership_id | str | The ID of the organization member in the parent organization. |
organization_id | str | The ID of the parent organization. |
organization_role | str | The role of the user in the parent organization. |
workspace_role | str | The role of the user in this workspace. |
WorkspaceMember
One member of a workspace: a person or a service account (workspace API key).
Attributes
| Name | Type | Description |
|---|---|---|
email | str | The email of the user. |
user_id | str | The ID of the user. |
role | str | The role of the user in the workspace. |
name | str | None | Display name; None when the user has no name set. |
Caller
Caller
The person that the token belongs to.
A user token or a personal API key gets it. A workspace API key gets
dlthub_sdk.NotAuthorized instead (see dlthub_sdk.Runtime.me()).
Organization.me() and Workspace.me() answer for any caller.
Attributes
| Name | Type | Description |
|---|---|---|
email | str | The email of the current user. |
user_id | str | The ID of the current user. |
organization_membership_id | str | Your membership id in latest_organization. |
name | str | None | The user's display name (full name); None if the identity provider supplied none. |
primary_organization | Organization | The organization where new workspaces are created by default. |
latest_organization | Organization | The organization you used most recently. |
organization_memberships | tuple[OrganizationMembership, ...] | Every organization that the user belongs to, with the role of the user. |
OrganizationMembership
An organization that the caller belongs to, with the role of the caller.
Attributes
| Name | Type | Description |
|---|---|---|
organization | Organization | The organization, bound and ready to navigate from. |
role | str | The role of the user in the organization. |
is_active | bool | Whether the membership is active. |
Data planes
Dataplanes
The data planes that this caller can choose from.
The runtime returns them in one response, so there is nothing to page and no count.
Dataplanes.list()
list() -> tuple[Dataplane, ...]
Return every data plane available to this caller.
It needs no organization or workspace, like Organizations.list().
Returns: tuple[Dataplane, ...] — All of them, in the order of the runtime. Async mode returns an awaitable.
Dataplane
A data plane that an organization can use for its workspaces.
Attributes
| Name | Type | Description |
|---|---|---|
id | str | Data plane id, e.g. eu1; also the subdomain of its URL. |
name | str | Human-readable data plane name. |
region | str | Cloud region the data plane runs in, e.g. europe-west4. |
description | str | None | Optional note about the data plane; None when there is none. |