// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; import { APIPromise } from '../core/api-promise'; import { Cursor, type CursorParams, PagePromise } from '../core/pagination'; import { buildHeaders } from '../internal/headers'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; export class OAuthConnections extends APIResource { /** * Get OAuth connection by name */ retrieve(name: string, options?: RequestOptions): APIPromise { return this._client.get(path`/oauth-connections/${name}`, options); } /** * List OAuth connections */ list( query: OAuthConnectionListParams | null | undefined = {}, options?: RequestOptions, ): PagePromise { return this._client.getAPIList('/oauth-connections', Cursor, { query, ...options, }); } /** * Delete an OAuth connection */ delete(name: string, options?: RequestOptions): APIPromise { return this._client.delete(path`/oauth-connections/${name}`, { ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), }); } /** * Get a fresh access token for a connection */ getToken(name: string, options?: RequestOptions): APIPromise { return this._client.get(path`/oauth-connections/${name}/token`, options); } } export type OAuthConnectionListResponsesCursor = Cursor; export interface OAuthConnectionRetrieveResponse { /** * Connection ID */ id: string; /** * Account identifier (e.g. email) */ accountIdentifier: string | null; /** * Creation timestamp */ createdAt: string; /** * Whether this is the default connection for its provider */ isDefault: boolean; /** * Optional display label */ label: string | null; /** * Last used timestamp */ lastUsedAt: string | null; /** * Provider ID */ providerId: string; /** * Provider display name */ providerName: string; /** * Provider slug */ providerSlug: string; /** * Granted scopes */ scopes: string | null; /** * Connection name (slug) */ slug: string | null; /** * Connection status */ status: string; /** * Token type (e.g. Bearer) */ tokenType: string; } export interface OAuthConnectionListResponse { /** * Connection ID */ id: string; /** * Account identifier (e.g. email) */ accountIdentifier: string | null; /** * Creation timestamp */ createdAt: string; /** * Whether this is the default connection for its provider */ isDefault: boolean; /** * Optional display label */ label: string | null; /** * Last used timestamp */ lastUsedAt: string | null; /** * Provider ID */ providerId: string; /** * Provider display name */ providerName: string; /** * Provider slug */ providerSlug: string; /** * Granted scopes */ scopes: string | null; /** * Connection name (slug) */ slug: string | null; /** * Connection status */ status: string; /** * Token type (e.g. Bearer) */ tokenType: string; } export interface OAuthConnectionGetTokenResponse { /** * Fresh access token */ access_token: string; /** * The connection this token belongs to */ connection: OAuthConnectionGetTokenResponse.Connection; /** * Token expiration timestamp (ISO 8601) */ expires_at: string | null; /** * Token type (e.g. Bearer) */ token_type: string; } export namespace OAuthConnectionGetTokenResponse { /** * The connection this token belongs to */ export interface Connection { /** * Connection ID */ id: string; /** * Account identifier (e.g. email) */ accountIdentifier: string | null; /** * Creation timestamp */ createdAt: string; /** * Whether this is the default connection for its provider */ isDefault: boolean; /** * Optional display label */ label: string | null; /** * Last used timestamp */ lastUsedAt: string | null; /** * Provider ID */ providerId: string; /** * Provider display name */ providerName: string; /** * Provider slug */ providerSlug: string; /** * Granted scopes */ scopes: string | null; /** * Connection name (slug) */ slug: string | null; /** * Connection status */ status: string; /** * Token type (e.g. Bearer) */ tokenType: string; } } export interface OAuthConnectionListParams extends CursorParams { /** * Filter by provider slug */ provider?: string; } export declare namespace OAuthConnections { export { type OAuthConnectionRetrieveResponse as OAuthConnectionRetrieveResponse, type OAuthConnectionListResponse as OAuthConnectionListResponse, type OAuthConnectionGetTokenResponse as OAuthConnectionGetTokenResponse, type OAuthConnectionListResponsesCursor as OAuthConnectionListResponsesCursor, type OAuthConnectionListParams as OAuthConnectionListParams, }; }