// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import * as RealtimeAPI from './realtime'; import { Realtime, RealtimeAuthParams, RealtimeAuthResponse, RealtimeCredentialsResponse } from './realtime'; import { APIPromise } from '../../core/api-promise'; import { RequestOptions } from '../../internal/request-options'; export class Cli extends APIResource { realtime: RealtimeAPI.Realtime = new RealtimeAPI.Realtime(this._client); /** * Generates a new CLI session with a random 6-character code. This endpoint is the * first step in the CLI authentication flow, creating a session that can later be * linked to a user account. The generated code is displayed to the user in the CLI * and should be entered in the web interface to complete authentication. * Optionally accepts a scope ('project' or 'user') and a source string. */ createSession( body: CliCreateSessionParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.post('/api/v3.1/cli/create-session', { body, ...options }); } /** * Retrieves the current state of a CLI session using either the session ID (UUID) * or the 6-character code. This endpoint is used by both the CLI client to check * if the session has been linked, and by the web interface to display session * details before linking. */ getSession(query: CliGetSessionParams, options?: RequestOptions): APIPromise { return this._client.get('/api/v3.1/cli/get-session', { query, ...options }); } } export interface CliCreateSessionResponse { /** * Unique identifier for the CLI session. UUID v4 format used for tracking and * retrieval. */ id: string; /** * The 6-character hexadecimal code used for CLI login */ code: string; /** * The ISO timestamp when the session expires */ expiresAt: string; /** * The key scope for this session */ scope: 'project' | 'user'; /** * The current status of the session */ status: 'pending' | 'linked'; } export interface CliGetSessionResponse { /** * The unique identifier for the CLI session */ id: string; /** * Information about the linked account, if any. Null if the session status is * "pending". */ account: CliGetSessionResponse.Account | null; /** * The API key for the linked account */ api_key: string | null; /** * The 6-character hexadecimal code used for CLI login */ code: string; /** * The ISO timestamp when the session expires */ expiresAt: string; /** * The key scope for this session */ scope: 'project' | 'user' | null; /** * The current status of the session */ status: 'pending' | 'linked'; } export namespace CliGetSessionResponse { /** * Information about the linked account, if any. Null if the session status is * "pending". */ export interface Account { /** * The ID of the linked account */ id: string; /** * The email address of the linked account */ email: string; /** * The display name of the linked account */ name: string; } } export interface CliCreateSessionParams { /** * Key scope. 'project' (default) returns a project-level API key; 'user' returns a * user-level API key valid across projects. */ scope?: 'project' | 'user'; /** * Free-form string describing the source, e.g. 'Johns MacBook (darwin, v1.2.3)' */ source?: string; } export interface CliGetSessionParams { /** * CLI session ID (UUID format) or 6-character code to check. Both formats are * supported for flexibility in client implementations. */ id: string; } Cli.Realtime = Realtime; export declare namespace Cli { export { type CliCreateSessionResponse as CliCreateSessionResponse, type CliGetSessionResponse as CliGetSessionResponse, type CliCreateSessionParams as CliCreateSessionParams, type CliGetSessionParams as CliGetSessionParams, }; export { Realtime as Realtime, type RealtimeAuthResponse as RealtimeAuthResponse, type RealtimeCredentialsResponse as RealtimeCredentialsResponse, type RealtimeAuthParams as RealtimeAuthParams, }; }