UNPKG

@anthropic-ai/sdk

Version:
210 lines • 8.68 kB
import { APIResource } from "../../core/resource.mjs"; import * as ActionURLsAPI from "./action-urls.mjs"; import { ActionURLs, } from "./action-urls.mjs"; import { BadRequestError, PermissionDeniedError } from "../../core/error.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"; /** * The request depends on a user profile that does not exist in the organization or * is no longer active. The request either names this user profile by ID, or names * a resource, such as an External Key, that is bound to it. */ export var UserProfileNotFoundError = /* @__PURE__ */ (() => { /** * The request depends on a user profile that does not exist in the organization or * is no longer active. The request either names this user profile by ID, or names * a resource, such as an External Key, that is bound to it. */ class UserProfileNotFoundError extends BadRequestError { } /** @internal */ UserProfileNotFoundError._errorName = 'UserProfileNotFoundError'; return UserProfileNotFoundError; })(); /** * The request sets `billing_policy.bill_to` to `"user_profile"` but names no user * profile. Name the profile to bill in the `anthropic-user-profile-id` header. */ export var UserProfileRequiredError = /* @__PURE__ */ (() => { /** * The request sets `billing_policy.bill_to` to `"user_profile"` but names no user * profile. Name the profile to bill in the `anthropic-user-profile-id` header. */ class UserProfileRequiredError extends BadRequestError { } /** @internal */ UserProfileRequiredError._errorName = 'UserProfileRequiredError'; return UserProfileRequiredError; })(); /** * The customer that the request's user profile represents has not authorized the * caller to bill them, or the authorization that the request's credential uses has * ended. The response does not say which applies. */ export var UserProfileBillingNotAuthorizedError = /* @__PURE__ */ (() => { /** * The customer that the request's user profile represents has not authorized the * caller to bill them, or the authorization that the request's credential uses has * ended. The response does not say which applies. */ class UserProfileBillingNotAuthorizedError extends PermissionDeniedError { } /** @internal */ UserProfileBillingNotAuthorizedError._errorName = 'UserProfileBillingNotAuthorizedError'; return UserProfileBillingNotAuthorizedError; })(); /** * The request's user profile cannot be billed. The response gives no more specific * error code and does not say what the reason is. */ export var UserProfileNotBillableError = /* @__PURE__ */ (() => { /** * The request's user profile cannot be billed. The response gives no more specific * error code and does not say what the reason is. */ class UserProfileNotBillableError extends PermissionDeniedError { } /** @internal */ UserProfileNotBillableError._errorName = 'UserProfileNotBillableError'; return UserProfileNotBillableError; })(); export var UserProfiles = /* @__PURE__ */ (() => { class UserProfiles extends APIResource { constructor() { super(...arguments); this.actionURLs = new ActionURLsAPI.ActionURLs(this._client); } /** * Create User Profile * * @example * ```ts * const userProfile = await client.userProfiles.create({}); * ``` */ create(params, options) { const { workspace_id, ...body } = params; return this._client.post('/v1/user_profiles', { body, ...options, headers: buildHeaders([ { ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined) }, options?.headers, ]), __span: startApiCallSpan(this._client, 'anthropic.user_profiles.create', options, { route: '/v1/user_profiles', createdIDAttribute: 'anthropic.user_profile.id', }), }); } /** * Get User Profile * * @example * ```ts * const userProfile = await client.userProfiles.retrieve( * 'uprof_011CZkZCu8hGbp5mYRQgUmz9', * ); * ``` */ retrieve(userProfileID, params = {}, options) { const { workspace_id } = params ?? {}; return this._client.get(path `/v1/user_profiles/${userProfileID}`, { ...options, headers: buildHeaders([ { ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined) }, options?.headers, ]), __span: startApiCallSpan(this._client, 'anthropic.user_profiles.retrieve', options, { route: '/v1/user_profiles/{user_profile_id}', attributes: { 'anthropic.user_profile.id': userProfileID }, }), }); } /** * Update User Profile * * @example * ```ts * const userProfile = await client.userProfiles.update( * 'uprof_011CZkZCu8hGbp5mYRQgUmz9', * {}, * ); * ``` */ update(userProfileID, params, options) { const { workspace_id, ...body } = params; return this._client.post(path `/v1/user_profiles/${userProfileID}`, { body, ...options, headers: buildHeaders([ { ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined) }, options?.headers, ]), __span: startApiCallSpan(this._client, 'anthropic.user_profiles.update', options, { route: '/v1/user_profiles/{user_profile_id}', attributes: { 'anthropic.user_profile.id': userProfileID }, }), }); } /** * List User Profiles * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const userProfile of client.userProfiles.list()) { * // ... * } * ``` */ list(params = {}, options) { const { workspace_id, ...query } = params ?? {}; return this._client.getAPIList('/v1/user_profiles', (PageCursor), { query, ...options, headers: buildHeaders([ { ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined) }, options?.headers, ]), __span: startApiCallSpan(this._client, 'anthropic.user_profiles.list', options, { route: '/v1/user_profiles', queryParams: ['enforcement_status', 'limit', 'order', 'order_by', 'page'], }), }); } /** * Delete User Profile * * @example * ```ts * const deletedUserProfile = await client.userProfiles.delete( * 'uprof_011CZkZCu8hGbp5mYRQgUmz9', * ); * ``` */ delete(userProfileID, params = {}, options) { const { workspace_id } = params ?? {}; return this._client.delete(path `/v1/user_profiles/${userProfileID}`, { ...options, headers: buildHeaders([ { ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined) }, options?.headers, ]), __span: startApiCallSpan(this._client, 'anthropic.user_profiles.delete', options, { route: '/v1/user_profiles/{user_profile_id}', attributes: { 'anthropic.user_profile.id': userProfileID }, }), }); } } UserProfiles.UserProfileNotFoundError = UserProfileNotFoundError; UserProfiles.UserProfileRequiredError = UserProfileRequiredError; UserProfiles.UserProfileBillingNotAuthorizedError = UserProfileBillingNotAuthorizedError; UserProfiles.UserProfileNotBillableError = UserProfileNotBillableError; UserProfiles.ActionURLs = ActionURLs; return UserProfiles; })(); //# sourceMappingURL=user-profiles.mjs.map