@anthropic-ai/sdk
Version:
The official TypeScript library for the Anthropic API
171 lines • 6.62 kB
JavaScript
import { APIResource } from "../../core/resource.mjs";
import { BadRequestError } from "../../core/error.mjs";
import { Page } from "../../core/pagination.mjs";
import { startApiCallSpan } from "../../internal/tracing.mjs";
import { path } from "../../internal/utils/path.mjs";
/**
* The email address already belongs to a user in the organization. The message
* names the user.
*/
export var AlreadyMemberError = /* @__PURE__ */ (() => {
/**
* The email address already belongs to a user in the organization. The message
* names the user.
*/
class AlreadyMemberError extends BadRequestError {
}
/** @internal */
AlreadyMemberError._errorName = 'AlreadyMemberError';
return AlreadyMemberError;
})();
/**
* The email address's domain is not one of the verified domains of the
* organization's parent organization.
*/
export var CannotInviteEmailsWithUnverifiedDomainsError = /* @__PURE__ */ (() => {
/**
* The email address's domain is not one of the verified domains of the
* organization's parent organization.
*/
class CannotInviteEmailsWithUnverifiedDomainsError extends BadRequestError {
}
/** @internal */
CannotInviteEmailsWithUnverifiedDomainsError._errorName = 'CannotInviteEmailsWithUnverifiedDomainsError';
return CannotInviteEmailsWithUnverifiedDomainsError;
})();
/**
* The organization restricts invites to an allowed list of email domains, and the
* list is empty or does not include the email address's domain.
*/
export var EmailDomainNotAllowedError = /* @__PURE__ */ (() => {
/**
* The organization restricts invites to an allowed list of email domains, and the
* list is empty or does not include the email address's domain.
*/
class EmailDomainNotAllowedError extends BadRequestError {
}
/** @internal */
EmailDomainNotAllowedError._errorName = 'EmailDomainNotAllowedError';
return EmailDomainNotAllowedError;
})();
/**
* A pending invite already exists for the email address. The message names the
* invite.
*/
export var InviteAlreadyExistsError = /* @__PURE__ */ (() => {
/**
* A pending invite already exists for the email address. The message names the
* invite.
*/
class InviteAlreadyExistsError extends BadRequestError {
}
/** @internal */
InviteAlreadyExistsError._errorName = 'InviteAlreadyExistsError';
return InviteAlreadyExistsError;
})();
export var Invites = /* @__PURE__ */ (() => {
class Invites extends APIResource {
/**
* Invite a user to join the organization by email.
*
* On plans that draw members from a finite pool of purchased seats, the invite
* automatically consumes a seat from the lowest tier with availability; there is
* no seat-tier parameter. When no seat is free the request fails with a 400 error
* rather than purchasing a seat.
*
* @throws {AlreadyMemberError}
* @throws {CannotInviteEmailsWithUnverifiedDomainsError}
* @throws {EmailDomainNotAllowedError}
* @throws {InviteAlreadyExistsError}
* @throws {OrgMemberLimitExceededError}
* @throws {RBACGroupGrantsOwnerAccessError}
* @throws {RBACGroupOwnerAccessUnconfirmedError}
* @throws {SandboxEgressRestrictedError}
*
* @example
* ```ts
* const organizationInvite =
* await client.organization.invites.create({
* email: 'user@emaildomain.com',
* role: 'user',
* });
* ```
*/
create(body, options) {
return this._client.post('/v1/organizations/invites', {
body,
...options,
__span: startApiCallSpan(this._client, 'anthropic.organization.invites.create', options, {
route: '/v1/organizations/invites',
createdIDAttribute: 'anthropic.organization.invite.id',
}),
});
}
/**
* Retrieve an invite by ID.
*
* @example
* ```ts
* const organizationInvite =
* await client.organization.invites.retrieve('invite_id');
* ```
*/
retrieve(inviteID, options) {
return this._client.get(path `/v1/organizations/invites/${inviteID}`, {
...options,
__span: startApiCallSpan(this._client, 'anthropic.organization.invites.retrieve', options, {
route: '/v1/organizations/invites/{invite_id}',
attributes: { 'anthropic.organization.invite.id': inviteID },
}),
});
}
/**
* List the organization's invites.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const organizationInvite of client.organization.invites.list()) {
* // ...
* }
* ```
*/
list(query = {}, options) {
return this._client.getAPIList('/v1/organizations/invites', (Page), {
query,
...options,
__span: startApiCallSpan(this._client, 'anthropic.organization.invites.list', options, {
route: '/v1/organizations/invites',
queryParams: ['after_id', 'before_id', 'email', 'limit', 'roles', 'statuses'],
}),
});
}
/**
* Delete a pending invite.
*
* @throws {SandboxEgressRestrictedError}
*
* @example
* ```ts
* const invite = await client.organization.invites.delete(
* 'invite_id',
* );
* ```
*/
delete(inviteID, options) {
return this._client.delete(path `/v1/organizations/invites/${inviteID}`, {
...options,
__span: startApiCallSpan(this._client, 'anthropic.organization.invites.delete', options, {
route: '/v1/organizations/invites/{invite_id}',
attributes: { 'anthropic.organization.invite.id': inviteID },
}),
});
}
}
Invites.AlreadyMemberError = AlreadyMemberError;
Invites.CannotInviteEmailsWithUnverifiedDomainsError = CannotInviteEmailsWithUnverifiedDomainsError;
Invites.EmailDomainNotAllowedError = EmailDomainNotAllowedError;
Invites.InviteAlreadyExistsError = InviteAlreadyExistsError;
return Invites;
})();
//# sourceMappingURL=invites.mjs.map