UNPKG

@anthropic-ai/sdk

Version:
195 lines • 9.27 kB
import { APIResource } from "../../../../../core/resource.mjs"; import { PageCursor } from "../../../../../core/pagination.mjs"; import { buildHeaders } from "../../../../../internal/headers.mjs"; import { startApiCallSpan } from "../../../../../internal/tracing.mjs"; import { path } from "../../../../../internal/utils/path.mjs"; export class RBACGroups extends APIResource { /** * Retrieve an RBAC Group's Claude Code managed settings. * * **Accepted credentials:** an organization-level Admin API key with the * `read:claude_code_managed_settings` scope. * * Every request must include the beta header * `anthropic-beta: ce-claude-code-managed-settings-2026-10-06`. A request without * it, or from an organization not enabled for this beta, returns `404`. The Claude * Code Managed Settings API is in beta and is available to Claude Enterprise * organizations only. * * @throws {BetaCMEKFeatureUnsupportedError} * @throws {CMEKKeyDisabledError} * @throws {BetaRBACGroupManagedSettingsNotFoundError} * * @example * ```ts * const betaClaudeCodeRBACGroupManagedSettings = * await client.beta.organization.claudeCode.managedSettings.rbacGroups.retrieve( * 'rbac_group_id', * ); * ``` */ retrieve(rbacGroupID, params = {}, options) { const { betas } = params ?? {}; return this._client.get(path `/v1/organizations/claude_code/managed_settings/rbac_groups/${rbacGroupID}`, { ...options, headers: buildHeaders([ { 'anthropic-beta': [...(betas ?? []), 'ce-claude-code-managed-settings-2026-10-06'].toString() }, options?.headers, ]), __qualifiers: { beta: 'true' }, __span: startApiCallSpan(this._client, 'anthropic.organization.claude_code.managed_settings.rbac_groups.retrieve', options, { route: '/v1/organizations/claude_code/managed_settings/rbac_groups/{rbac_group_id}', attributes: { 'anthropic.organization.claude_code.managed_setting.rbac_group.id': rbacGroupID }, }), }); } /** * List the RBAC Groups that have Claude Code managed settings, highest precedence * first. * * Each entry gives the group's status and timestamps, not its settings. The list * includes deleted groups that still have settings, and leaves out the default * settings. If the order changes between pages, the request returns `409`: list * again from the first page. * * **Accepted credentials:** an organization-level Admin API key with the * `read:claude_code_managed_settings` scope. * * Every request must include the beta header * `anthropic-beta: ce-claude-code-managed-settings-2026-10-06`. A request without * it, or from an organization not enabled for this beta, returns `404`. The Claude * Code Managed Settings API is in beta and is available to Claude Enterprise * organizations only. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const betaClaudeCodeRBACGroupManagedSettingsSummary of client.beta.organization.claudeCode.managedSettings.rbacGroups.list()) { * // ... * } * ``` */ list(params = {}, options) { const { betas, ...query } = params ?? {}; return this._client.getAPIList('/v1/organizations/claude_code/managed_settings/rbac_groups', (PageCursor), { query, ...options, headers: buildHeaders([ { 'anthropic-beta': [...(betas ?? []), 'ce-claude-code-managed-settings-2026-10-06'].toString() }, options?.headers, ]), __qualifiers: { beta: 'true' }, __span: startApiCallSpan(this._client, 'anthropic.organization.claude_code.managed_settings.rbac_groups.list', options, { route: '/v1/organizations/claude_code/managed_settings/rbac_groups', queryParams: ['limit', 'page'], }), }); } /** * Delete an RBAC Group's Claude Code managed settings and remove the group from * `rbac_group_order`. * * A group with no settings returns `404` with the error code * `rbac_group_managed_settings_not_found`. That code on a retry of a delete that * returned `503` means the settings are gone. * * **Accepted credentials:** an organization-level Admin API key with the * `write:claude_code_managed_settings` scope. * * Every request must include the beta header * `anthropic-beta: ce-claude-code-managed-settings-2026-10-06`. A request without * it, or from an organization not enabled for this beta, returns `404`. The Claude * Code Managed Settings API is in beta and is available to Claude Enterprise * organizations only. * * A write that returns `503` may have applied. Retrying it is safe. * * @throws {CMEKKeyDisabledError} * @throws {BetaSettingsHistoryLimitExceededError} * @throws {SandboxEgressRestrictedError} * @throws {BetaRBACGroupManagedSettingsNotFoundError} * * @example * ```ts * const betaDeletedClaudeCodeRBACGroupManagedSettings = * await client.beta.organization.claudeCode.managedSettings.rbacGroups.delete( * 'rbac_group_id', * ); * ``` */ delete(rbacGroupID, params = {}, options) { const { betas } = params ?? {}; return this._client.delete(path `/v1/organizations/claude_code/managed_settings/rbac_groups/${rbacGroupID}`, { ...options, headers: buildHeaders([ { 'anthropic-beta': [...(betas ?? []), 'ce-claude-code-managed-settings-2026-10-06'].toString() }, options?.headers, ]), __qualifiers: { beta: 'true' }, __span: startApiCallSpan(this._client, 'anthropic.organization.claude_code.managed_settings.rbac_groups.delete', options, { route: '/v1/organizations/claude_code/managed_settings/rbac_groups/{rbac_group_id}', attributes: { 'anthropic.organization.claude_code.managed_setting.rbac_group.id': rbacGroupID }, }), }); } /** * Create or replace an RBAC Group's Claude Code managed settings. * * New settings join the end of `rbac_group_order`, and existing settings keep * their place. Until the group is moved up, its members who also belong to an * earlier group keep that group's settings. In `organization` mode a write changes * no member's settings until the organization switches to `rbac_groups` mode. Once * a group has settings, that switch no longer copies the organization settings * into default settings, so members in no RBAC Group in `rbac_group_order` receive * no settings unless you set the default settings before the switch. * * Get the group's ID from the RBAC Groups API. One key can hold `read:rbac_groups` * and `write:claude_code_managed_settings`. * * **Accepted credentials:** an organization-level Admin API key with the * `write:claude_code_managed_settings` scope. * * Every request must include the beta header * `anthropic-beta: ce-claude-code-managed-settings-2026-10-06`. A request without * it, or from an organization not enabled for this beta, returns `404`. The Claude * Code Managed Settings API is in beta and is available to Claude Enterprise * organizations only. * * A write that returns `503` may have applied. Retrying it is safe. * * @throws {BetaCMEKFeatureUnsupportedError} * @throws {CMEKKeyDisabledError} * @throws {BetaRBACGroupOrderLimitExceededError} * @throws {BetaRequestBodyTimeoutError} * @throws {BetaSettingsDocumentLimitExceededError} * @throws {BetaSettingsHistoryLimitExceededError} * @throws {SandboxEgressRestrictedError} * @throws {BetaRBACGroupNotFoundError} * * @example * ```ts * const betaClaudeCodeRBACGroupManagedSettings = * await client.beta.organization.claudeCode.managedSettings.rbacGroups.set( * 'rbac_group_id', * { settings: { foo: 'bar' } }, * ); * ``` */ set(rbacGroupID, params, options) { const { betas, ...body } = params; return this._client.post(path `/v1/organizations/claude_code/managed_settings/rbac_groups/${rbacGroupID}`, { body, ...options, headers: buildHeaders([ { 'anthropic-beta': [...(betas ?? []), 'ce-claude-code-managed-settings-2026-10-06'].toString() }, options?.headers, ]), __qualifiers: { beta: 'true' }, __span: startApiCallSpan(this._client, 'anthropic.organization.claude_code.managed_settings.rbac_groups.set', options, { route: '/v1/organizations/claude_code/managed_settings/rbac_groups/{rbac_group_id}', attributes: { 'anthropic.organization.claude_code.managed_setting.rbac_group.id': rbacGroupID }, }), }); } } //# sourceMappingURL=rbac-groups.mjs.map