// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../../core/resource'; import * as ActiveAPI from './active'; import { Active, ActiveCancelParams, ActiveCancelResponse } from './active'; import { APIPromise } from '../../../../core/api-promise'; import { buildHeaders } from '../../../../internal/headers'; import { RequestOptions } from '../../../../internal/request-options'; import { path } from '../../../../internal/utils/path'; export class Requests extends APIResource { active: ActiveAPI.Active = new ActiveAPI.Active(this._client); /** * Queue a personal data export after step-up OTP verification. Does not return a * download URL. */ create(params: RequestCreateParams, options?: RequestOptions): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.post('/users/personal-data-export/requests', { body, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Get export request status scoped to the caller. * * Args: request_id (str): Export request ID. current_user (CurrentUser): * Authenticated user with send-message permission. service * (PersonalDataExportRequestService): Export request business logic. * * Returns: PersonalDataExportRequestStatusResponse: Status fields without storage * keys or presigned URLs. * * Raises: HTTPException: 404 when the request is not owned by the caller in the * active organization. */ retrieve( requestID: string, params: RequestRetrieveParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat } = params ?? {}; return this._client.get(path`/users/personal-data-export/requests/${requestID}`, { ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } } /** * Export request lifecycle status. */ export type PersonalDataExportStatus = 'queued' | 'processing' | 'completed' | 'failed' | 'expired'; /** * Accepted export request (202). */ export interface RequestCreateResponse { /** * User-facing confirmation message. */ message: string; /** * Export request identifier. */ request_id: string; /** * Initial lifecycle status. */ status: PersonalDataExportStatus; } /** * Export request status for the authenticated owner. */ export interface RequestRetrieveResponse { request_id: string; requested_at: string; sections: Array; /** * Export request lifecycle status. */ status: PersonalDataExportStatus; completed_at?: string | null; expires_at?: string | null; failure_reason?: string | null; } export interface RequestCreateParams { /** * Body param: Client-generated UUID for idempotent retries. */ idempotency_key: string; /** * Body param: One-time token from OTP verification. */ otp_verification_token: string; /** * Body param: Export sections; omit or empty for all sections. */ sections?: Array< | 'personal_data' | 'chat_history' | 'uploaded_files' | 'memories' | 'personalization' | 'account_activity_log' > | null; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export interface RequestRetrieveParams { 'Accept-Language'?: string; /** * Set to `structured` to receive errors in the structured envelope. Omit it to * keep the legacy error body. */ 'X-Error-Format'?: string; } Requests.Active = Active; export declare namespace Requests { export { type PersonalDataExportStatus as PersonalDataExportStatus, type RequestCreateResponse as RequestCreateResponse, type RequestRetrieveResponse as RequestRetrieveResponse, type RequestCreateParams as RequestCreateParams, type RequestRetrieveParams as RequestRetrieveParams, }; export { Active as Active, type ActiveCancelResponse as ActiveCancelResponse, type ActiveCancelParams as ActiveCancelParams, }; }