@anthropic-ai/sdk
Version:
The official TypeScript library for the Anthropic API
128 lines • 6.08 kB
TypeScript
import { APIResource } from "../../../core/resource.js";
import * as ServiceAccountsAPI from "./service-accounts.js";
import { ServiceAccountWorkspaceMembersPageCursor } from "./service-accounts.js";
import * as OrganizationWorkspacesAPI from "../workspaces/workspaces.js";
import { APIPromise } from "../../../core/api-promise.js";
import { type PageCursorParams, PagePromise } from "../../../core/pagination.js";
import { RequestOptions } from "../../../internal/request-options.js";
export declare class Workspaces extends APIResource {
/**
* **Requires an OAuth access token with the `org:admin` scope**, from
* `ant auth login --scope org:admin` or a workload identity federation rule; Admin
* API keys are not accepted. See
* [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
*
* List the workspaces a service account is a member of.
*
* Each entry includes the service account's `workspace_role` in that workspace.
* Use `limit` and the `next_page` cursor to paginate. When the service account has
* no explicit default-workspace membership, the implicit (`implicit: true`)
* membership is returned as the first entry on the first page; with `limit=1` the
* first page may return up to 2 entries (the implicit entry plus one explicit
* membership) so a pagination cursor can be derived. Memberships are returned only
* while the service account is active. Without a `page` cursor, an archived
* service account returns an empty list. A `page` cursor that does not match an
* active membership returns a 400 invalid-request error. A cursor stops matching
* when the membership is removed, the workspace is deleted, or the service account
* is archived. Restart pagination from the first page to recover.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const serviceAccountWorkspaceMember of client.organization.serviceAccounts.workspaces.list(
* 'service_account_id',
* )) {
* // ...
* }
* ```
*/
list(serviceAccountID: string, query?: WorkspaceListParams | null | undefined, options?: RequestOptions): PagePromise<ServiceAccountWorkspaceMembersPageCursor, ServiceAccountsAPI.ServiceAccountWorkspaceMember>;
/**
* **Requires an OAuth access token with the `org:admin` scope**, from
* `ant auth login --scope org:admin` or a workload identity federation rule; Admin
* API keys are not accepted. See
* [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
*
* Add a service account to a workspace with the given `workspace_role`.
*
* Mirror of `POST /workspaces/{workspace_id}/service_accounts`, addressed from the
* service-account side; both create the same membership. If the service account is
* already an explicit member of the workspace, its `workspace_role` is replaced
* with the value supplied here. Archived workspaces return 400. Archived service
* accounts cannot be added and are rejected.
*
* @example
* ```ts
* const serviceAccountWorkspaceMember =
* await client.organization.serviceAccounts.workspaces.add(
* 'service_account_id',
* {
* workspace_id: 'workspace_id',
* workspace_role: 'workspace_admin',
* },
* );
* ```
*/
add(serviceAccountID: string, body: WorkspaceAddParams, options?: RequestOptions): APIPromise<ServiceAccountsAPI.ServiceAccountWorkspaceMember>;
/**
* **Requires an OAuth access token with the `org:admin` scope**, from
* `ant auth login --scope org:admin` or a workload identity federation rule; Admin
* API keys are not accepted. See
* [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
*
* Remove a service account from a workspace.
*
* Mirror of
* `DELETE /workspaces/{workspace_id}/service_accounts/{service_account_id}`,
* addressed from the service-account side. Removal is idempotent (returns 200 even
* if the membership was already removed). A DELETE against the implicit
* default-workspace membership returns 200 but is a no-op and the membership
* persists; deleting an explicit default-workspace row reverts to the implicit
* `workspace_user` membership. Archived workspaces return 400.
*
* @example
* ```ts
* const workspace =
* await client.organization.serviceAccounts.workspaces.remove(
* 'workspace_id',
* { service_account_id: 'service_account_id' },
* );
* ```
*/
remove(workspaceID: string, params: WorkspaceRemoveParams, options?: RequestOptions): APIPromise<WorkspaceRemoveResponse>;
}
export interface WorkspaceRemoveResponse {
/**
* Tagged service account ID (`svac_...`) named in the delete request. Removal is
* idempotent; see the endpoint description for the implicit-membership no-op.
*/
service_account_id: string;
type: 'service_account_workspace_member_deleted';
/**
* Tagged workspace ID (`wrkspc_...`) named in the delete request.
*/
workspace_id: string;
}
export interface WorkspaceListParams extends PageCursorParams {
}
export interface WorkspaceAddParams {
/**
* Tagged workspace ID to add the service account to.
*/
workspace_id: string;
/**
* Role to assign to the service account in this workspace.
*/
workspace_role: OrganizationWorkspacesAPI.NoBillingWorkspaceRole;
}
export interface WorkspaceRemoveParams {
/**
* ID of the service account.
*/
service_account_id: string;
}
export declare namespace Workspaces {
export { type WorkspaceRemoveResponse as WorkspaceRemoveResponse, type WorkspaceListParams as WorkspaceListParams, type WorkspaceAddParams as WorkspaceAddParams, type WorkspaceRemoveParams as WorkspaceRemoveParams, };
}
export { type ServiceAccountWorkspaceMembersPageCursor };
//# sourceMappingURL=workspaces.d.ts.map