import type { Tenant } from "../_internal/types.gen"; import type { RequestOptions } from "../base-client"; import { RequestBuilder } from "../request-builder"; /** Attributes accepted when creating a tenant. */ export type CreateTenantAttributes = { name: string; slug?: string; owner_id?: string; parent_id?: string; application_id?: string; kind?: string; logo_url?: string; badge_url?: string; training_price_credits?: number; plan_tier?: string; is_personal?: boolean; vanity_slug?: string; portal_overrides?: Record; }; /** Attributes accepted when creating an organization tenant. */ export type CreateOrgTenantAttributes = { name: string; slug?: string; application_id?: string; }; /** Attributes accepted when creating an ISV tenant. */ export type CreateIsvTenantAttributes = { name: string; slug?: string; owner_id?: string; logo_url?: string; badge_url?: string; kind?: string; initial_credits?: number; }; /** Attributes accepted when converting a personal tenant to an organization. */ export type ConvertToOrgAttributes = { name: string; slug?: string; application_id?: string; }; /** Attributes accepted when creating a personal tenant. */ export type CreatePersonalTenantAttributes = Record; /** Attributes accepted when updating a tenant (PATCH semantics). */ export type UpdateTenantAttributes = { name?: string; slug?: string; kind?: string; parent_id?: string; logo_url?: string; badge_url?: string; description?: string; contact_email?: string; contact_phone?: string; training_price_credits?: number; vanity_slug?: string; plan_tier?: string; storage_spending_cap_bytes?: number; portal_overrides?: Record; metadata?: Record; /** * Tenant-level MFA enforcement policy (D1). * * - `"required"`: every request scoped to this tenant must present a session * JWT with `mfa_satisfied: true`. Triggers the per-request `RequireTenantMfa` * plug — clients receive `401 tenant_mfa_required` and call * `client.identity.mfa.upgrade({ code })` to refresh. * - `"user_choice"`: defer to per-user opt-in (default). */ mfa_policy?: "required" | "user_choice"; }; /** Attributes for updating branding. */ export type UpdateBrandingAttributes = { logo_url?: string; badge_url?: string; }; /** Attributes for auto top-up configuration. */ export type UpdateAutoTopUpAttributes = { enabled: boolean; threshold: number; amount: number; package_id?: string; }; export interface TenantLifecycleResult { data: { id: string; status: string; }; } export declare function createTenantsNamespace(rb: RequestBuilder): { /** * List all tenants visible to the current actor. * * @param options - Optional request options (pagination, filters, sorting). * @returns A list of `Tenant` records. * * @example * ```ts * const tenants = await admin.tenants.list(); * ``` */ list: (options?: RequestOptions) => Promise; /** * Get a tenant by ID. * * @param id - The UUID of the tenant. * @param options - Optional request options. * @returns The `Tenant` record. * * @example * ```ts * const tenant = await admin.tenants.get("tenant-uuid"); * ``` */ get: (id: string, options?: RequestOptions) => Promise; /** * Create a new tenant. * * @param attributes - Tenant attributes (name is required). * @param options - Optional request options. * @returns The created `Tenant`. * * @example * ```ts * const tenant = await admin.tenants.create({ name: "Acme Corp" }); * ``` */ create: (attributes: CreateTenantAttributes, options?: RequestOptions) => Promise; /** * Update a tenant. * * @param id - The UUID of the tenant. * @param attributes - Fields to update. * @param options - Optional request options. * @returns The updated `Tenant`. * * @example * ```ts * const tenant = await admin.tenants.update("tenant-uuid", { name: "New Name" }); * ``` */ update: (id: string, attributes: UpdateTenantAttributes, options?: RequestOptions) => Promise; /** * Delete a tenant. * * @param id - The UUID of the tenant. * @param options - Optional request options. * * @example * ```ts * await admin.tenants.delete("tenant-uuid"); * ``` * * @returns Resolves when the tenant has been deleted. */ delete: (id: string, options?: RequestOptions) => Promise; /** * Allocate credits to a tenant. * * @param id - The UUID of the tenant. * @param amount - Number of credits to allocate. * @param options - Optional request options. * @returns The updated `Tenant`. * * @example * ```ts * const tenant = await admin.tenants.credit("tenant-uuid", 1000); * ``` */ credit: (id: string, amount: number, options?: RequestOptions) => Promise; /** * Schedule a tenant for data purge. * * @param id - The UUID of the tenant. * @param options - Optional request options. * @returns The updated `Tenant`. * * @example * ```ts * const tenant = await admin.tenants.schedulePurge("tenant-uuid"); * ``` */ schedulePurge: (id: string, options?: RequestOptions) => Promise; /** * Probe the tenant's storage backend. HEADs each of the tenant's three * buckets (`public`, `private`, `processing`) in GCS/MinIO and returns * a per-bucket status report. * * Platform-admin only. Returns `status: "ok"` when every bucket DB row * exists AND every HEAD succeeds; `status: "partial"` otherwise. * * @param id - The UUID of the tenant. * @param options - Optional request options. * @returns The verification report. * * @example * ```ts * const report = await admin.tenants.verifyStorage("tenant-uuid"); * // { tenant_id, status: "ok", buckets: [{ name, type, db_ok, gcs_ok }] } * ``` */ verifyStorage: (id: string, _options?: RequestOptions) => Promise<{ tenant_id: string; status: "ok" | "partial"; buckets: Array<{ name: string; type: "public" | "private" | "processing"; db_ok: boolean; gcs_ok: boolean; }>; }>; /** * Transfer ownership of a tenant to another admin member. * * @param id - The UUID of the tenant. * @param newOwnerId - The UUID of the new owner (must be an admin member). * @param options - Optional request options. * @returns The updated `Tenant`. * * @example * ```ts * const tenant = await admin.tenants.transferOwnership("tenant-uuid", "user-uuid"); * ``` */ transferOwnership: (id: string, newOwnerId: string, options?: RequestOptions) => Promise; /** * Update tenant branding (logo and badge). * * @param id - The UUID of the tenant. * @param attributes - Branding attributes to update. * @param options - Optional request options. * @returns The updated `Tenant`. * * @example * ```ts * const tenant = await admin.tenants.updateBranding("tenant-uuid", { * logo_url: "https://example.com/logo.png", * }); * ``` */ updateBranding: (id: string, attributes: UpdateBrandingAttributes, options?: RequestOptions) => Promise; /** * Update auto top-up configuration for a tenant. * * @param id - The UUID of the tenant. * @param attributes - Auto top-up settings. * @param options - Optional request options. * @returns The updated `Tenant`. * * @example * ```ts * const tenant = await admin.tenants.updateAutoTopUp("tenant-uuid", { * enabled: true, * threshold: 100, * amount: 500, * }); * ``` */ updateAutoTopUp: (id: string, attributes: UpdateAutoTopUpAttributes, options?: RequestOptions) => Promise; /** * Convert a personal tenant to an organization. * * @param id - The UUID of the personal tenant. * @param attributes - Organization attributes for the converted tenant. * @param options - Optional request options. * @returns The updated `Tenant`. * * @example * ```ts * const tenant = await admin.tenants.convertToOrg("tenant-uuid", { * name: "My Company", * slug: "my-company", * }); * ``` */ convertToOrg: (id: string, attributes: ConvertToOrgAttributes, options?: RequestOptions) => Promise; /** * Create an organization tenant. * * @param attributes - Tenant attributes (name is required). * @param options - Optional request options. * @returns The created `Tenant`. * * @example * ```ts * const tenant = await admin.tenants.createOrg({ name: "New Org" }); * ``` */ createOrg: (attributes: CreateOrgTenantAttributes, options?: RequestOptions) => Promise; /** * Create a personal tenant. * * @param attributes - Empty attributes object; personal tenant fields are derived from the actor. * @param options - Optional request options. * @returns The created `Tenant`. * * @example * ```ts * const tenant = await admin.tenants.createPersonal({}); * ``` */ createPersonal: (_attributes?: CreatePersonalTenantAttributes, options?: RequestOptions) => Promise; /** * Create an ISV tenant. * * @param attributes - Tenant attributes (name is required). * @param options - Optional request options. * @returns The created `Tenant`. * * @example * ```ts * const tenant = await admin.tenants.createIsv({ name: "ISV Tenant" }); * ``` */ createIsv: (attributes: CreateIsvTenantAttributes, options?: RequestOptions) => Promise; /** * Suspend a tenant, preventing billing charges and access. * * @param id - The UUID of the tenant. * @param reason - Human-readable reason for suspension. * @param options - Optional request options. * @returns The updated `Tenant`. * * @example * ```ts * const tenant = await admin.tenants.suspend("tenant-uuid", "Non-payment"); * ``` */ suspend: (id: string, reason: string, options?: RequestOptions) => Promise; /** * Restore a suspended tenant to active status. * * @param id - The UUID of the tenant. * @param options - Optional request options. * @returns The updated `Tenant`. * * @example * ```ts * const tenant = await admin.tenants.unsuspend("tenant-uuid"); * ``` */ unsuspend: (id: string, options?: RequestOptions) => Promise; /** * Permanently cancel a tenant. * * @param id - The UUID of the tenant. * @param options - Optional request options. * @returns The updated `Tenant`. * * @example * ```ts * const tenant = await admin.tenants.cancel("tenant-uuid"); * ``` */ cancel: (id: string, options?: RequestOptions) => Promise; /** * Archive an inactive or orphan tenant. * * Archives the tenant by setting status to :archived. Data is preserved; * this differs from `cancel` (permanent termination triggering data purge) * and the admin `destroy` cascade. Restricted to platform admin tier. * * @param id - The UUID of the tenant to archive. * @param options - Optional request options. * @returns The archived `Tenant` with status: "archived". * * @example * ```ts * const admin = new GptAdmin({ apiKey: 'sk_sys_...' }); * const tenant = await admin.tenants.archive("tenant-uuid"); * ``` */ archive: (id: string, options?: RequestOptions) => Promise; /** * Deactivate a tenant, hiding it from normal tenant selection. * * @param id - The UUID of the tenant. * @param options - Optional request options. * @returns The updated `Tenant`. * * @example * ```ts * const tenant = await admin.tenants.deactivate("tenant-uuid"); * ``` */ deactivate: (id: string, options?: RequestOptions) => Promise; /** * Reactivate a deactivated tenant. * * @param id - The UUID of the tenant. * @param options - Optional request options. * @returns The updated `Tenant`. * * @example * ```ts * const tenant = await admin.tenants.reactivate("tenant-uuid"); * ``` */ reactivate: (id: string, options?: RequestOptions) => Promise; /** * Get document statistics for a tenant. * * @param tenantId - The UUID of the tenant. * @param options - Optional request options. * @returns Document statistics. * * @example * ```ts * const stats = await admin.tenants.getDocumentStats("tenant-uuid"); * ``` */ getDocumentStats: (tenantId: string, options?: RequestOptions) => Promise; /** * Get general statistics for a tenant. * * @param tenantId - The UUID of the tenant. * @param options - Optional request options. * @returns Tenant statistics. * * @example * ```ts * const stats = await admin.tenants.getStats("tenant-uuid"); * ``` */ getStats: (tenantId: string, options?: RequestOptions) => Promise; /** * Get per-workspace document statistics for a tenant. * * @param tenantId - The UUID of the tenant. * @param options - Optional request options. * @returns Workspace-level document statistics. * * @example * ```ts * const stats = await admin.tenants.getWorkspaceStats("tenant-uuid"); * ``` */ getWorkspaceStats: (tenantId: string, options?: RequestOptions) => Promise; }; //# sourceMappingURL=tenants.d.ts.map