:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { apiMutator } from '../../../../frontend/src/lib/api-orval-mutator'
/**
* Auto-generated from the Django backend OpenAPI schema.
* To modify these types, update the Django serializers or views, then run:
* hogli build:openapi
* Questions or issues? #team-devex on Slack
*
* PostHog API - generated
* OpenAPI spec version: 1.0.0
*/
import type {
NotebookApi,
NotebookCollabPresenceApi,
NotebookCollabSaveApi,
NotebookComputeOptionsResponseApi,
NotebookKernelCompleteRequestApi,
NotebookKernelCompleteResponseApi,
NotebookKernelConfigApi,
NotebookKernelConfigResponseApi,
NotebookKernelInspectRequestApi,
NotebookKernelInspectResponseApi,
NotebookKernelStatusResponseApi,
NotebookMarkdownSaveApi,
NotebookRunInterruptResponseApi,
NotebookRunStartRequestApi,
NotebookRunStartResponseApi,
NotebookRunStatusResponseApi,
NotebookSQLV2InterruptResponseApi,
NotebookSQLV2RunRequestApi,
NotebookSQLV2RunResponseApi,
NotebookSQLV2RunStatusResponseApi,
NotebookSQLV2StateResponseApi,
NotebooksListParams,
NotebooksWidgetFrameParams,
NotebooksWidgetSnapshotFrameParams,
NotebooksWidgetSourceParams,
NotebooksWidgetVersionsParams,
PaginatedNotebookMinimalListApi,
PatchedNotebookApi,
ReusableWidgetAttachRequestApi,
ReusableWidgetDemoDataRequestApi,
ReusableWidgetDetailApi,
ReusableWidgetForkRequestApi,
ReusableWidgetPageApi,
ReusableWidgetPublishRequestApi,
ReusableWidgetRestoreRequestApi,
ReusableWidgetReviewRequestApi,
ReusableWidgetVersionPageApi,
ReusableWidgetsDemoFrameParams,
ReusableWidgetsListParams,
ReusableWidgetsSourceParams,
ReusableWidgetsVersionsParams,
WidgetCancelRequestApi,
WidgetFrameApi,
WidgetGenerateRequestApi,
WidgetPinRequestApi,
WidgetRevertRequestApi,
WidgetSnapshotApi,
WidgetSnapshotPublishApi,
WidgetSnapshotRequestApi,
WidgetSourceApi,
WidgetStatusApi,
WidgetVersionPageApi,
} from './api.schemas'
// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497
type IfEquals<X, Y, A = X, B = never> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B
type WritableKeys<T> = {
[P in keyof T]-?: IfEquals<{ [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, P>
}[keyof T]
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never
type DistributeReadOnlyOverUnions<T> = T extends any ? NonReadonly<T> : never
type Writable<T> = Pick<T, WritableKeys<T>>
type NonReadonly<T> = [T] extends [UnionToIntersection<T>]
? {
[P in keyof Writable<T>]: T[P] extends object ? NonReadonly<NonNullable<T[P]>> : T[P]
}
: DistributeReadOnlyOverUnions<T>
export const getReusableWidgetsListUrl = (projectId: string, params?: ReusableWidgetsListParams) => {
const normalizedParams = new URLSearchParams()
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? 'null' : String(value))
}
})
const stringifiedParams = normalizedParams.toString()
return stringifiedParams.length > 0
? `/api/projects/${projectId}/notebook_widgets/?${stringifiedParams}`
: `/api/projects/${projectId}/notebook_widgets/`
}
export const reusableWidgetsList = async (
projectId: string,
params?: ReusableWidgetsListParams,
options?: RequestInit
): Promise<ReusableWidgetPageApi> => {
return apiMutator<ReusableWidgetPageApi>(getReusableWidgetsListUrl(projectId, params), {
...options,
method: 'GET',
})
}
export const getReusableWidgetsRetrieveUrl = (projectId: string, id: string) => {
return `/api/projects/${projectId}/notebook_widgets/${id}/`
}
export const reusableWidgetsRetrieve = async (
projectId: string,
id: string,
options?: RequestInit
): Promise<ReusableWidgetDetailApi> => {
return apiMutator<ReusableWidgetDetailApi>(getReusableWidgetsRetrieveUrl(projectId, id), {
...options,
method: 'GET',
})
}
export const getReusableWidgetsUpdateDemoDataUrl = (projectId: string, id: string) => {
return `/api/projects/${projectId}/notebook_widgets/${id}/demo-data/`
}
export const reusableWidgetsUpdateDemoData = async (
projectId: string,
id: string,
reusableWidgetDemoDataRequestApi: ReusableWidgetDemoDataRequestApi,
options?: RequestInit
): Promise<WidgetFrameApi> => {
return apiMutator<WidgetFrameApi>(getReusableWidgetsUpdateDemoDataUrl(projectId, id), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(reusableWidgetDemoDataRequestApi),
})
}
export const getReusableWidgetsDiscardVersionUrl = (projectId: string, id: string) => {
return `/api/projects/${projectId}/notebook_widgets/${id}/discard-version/`
}
export const reusableWidgetsDiscardVersion = async (
projectId: string,
id: string,
reusableWidgetReviewRequestApi: ReusableWidgetReviewRequestApi,
options?: RequestInit
): Promise<ReusableWidgetDetailApi> => {
return apiMutator<ReusableWidgetDetailApi>(getReusableWidgetsDiscardVersionUrl(projectId, id), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(reusableWidgetReviewRequestApi),
})
}
export const getReusableWidgetsDemoFrameUrl = (
projectId: string,
id: string,
frameName: string,
params?: ReusableWidgetsDemoFrameParams
) => {
const normalizedParams = new URLSearchParams()
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? 'null' : String(value))
}
})
const stringifiedParams = normalizedParams.toString()
return stringifiedParams.length > 0
? `/api/projects/${projectId}/notebook_widgets/${id}/frames/${frameName}/?${stringifiedParams}`
: `/api/projects/${projectId}/notebook_widgets/${id}/frames/${frameName}/`
}
export const reusableWidgetsDemoFrame = async (
projectId: string,
id: string,
frameName: string,
params?: ReusableWidgetsDemoFrameParams,
options?: RequestInit
): Promise<WidgetFrameApi> => {
return apiMutator<WidgetFrameApi>(getReusableWidgetsDemoFrameUrl(projectId, id, frameName, params), {
...options,
method: 'GET',
})
}
export const getReusableWidgetsGenerateUrl = (projectId: string, id: string) => {
return `/api/projects/${projectId}/notebook_widgets/${id}/generate/`
}
export const reusableWidgetsGenerate = async (
projectId: string,
id: string,
widgetGenerateRequestApi: WidgetGenerateRequestApi,
options?: RequestInit
): Promise<WidgetStatusApi> => {
return apiMutator<WidgetStatusApi>(getReusableWidgetsGenerateUrl(projectId, id), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(widgetGenerateRequestApi),
})
}
export const getReusableWidgetsRestoreUrl = (projectId: string, id: string) => {
return `/api/projects/${projectId}/notebook_widgets/${id}/restore/`
}
export const reusableWidgetsRestore = async (
projectId: string,
id: string,
reusableWidgetRestoreRequestApi: ReusableWidgetRestoreRequestApi,
options?: RequestInit
): Promise<ReusableWidgetDetailApi> => {
return apiMutator<ReusableWidgetDetailApi>(getReusableWidgetsRestoreUrl(projectId, id), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(reusableWidgetRestoreRequestApi),
})
}
export const getReusableWidgetsSaveVersionUrl = (projectId: string, id: string) => {
return `/api/projects/${projectId}/notebook_widgets/${id}/save-version/`
}
export const reusableWidgetsSaveVersion = async (
projectId: string,
id: string,
reusableWidgetReviewRequestApi: ReusableWidgetReviewRequestApi,
options?: RequestInit
): Promise<ReusableWidgetDetailApi> => {
return apiMutator<ReusableWidgetDetailApi>(getReusableWidgetsSaveVersionUrl(projectId, id), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(reusableWidgetReviewRequestApi),
})
}
export const getReusableWidgetsSourceUrl = (projectId: string, id: string, params?: ReusableWidgetsSourceParams) => {
const normalizedParams = new URLSearchParams()
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? 'null' : String(value))
}
})
const stringifiedParams = normalizedParams.toString()
return stringifiedParams.length > 0
? `/api/projects/${projectId}/notebook_widgets/${id}/source/?${stringifiedParams}`
: `/api/projects/${projectId}/notebook_widgets/${id}/source/`
}
export const reusableWidgetsSource = async (
projectId: string,
id: string,
params?: ReusableWidgetsSourceParams,
options?: RequestInit
): Promise<WidgetSourceApi> => {
return apiMutator<WidgetSourceApi>(getReusableWidgetsSourceUrl(projectId, id, params), {
...options,
method: 'GET',
})
}
export const getReusableWidgetsStatusUrl = (projectId: string, id: string) => {
return `/api/projects/${projectId}/notebook_widgets/${id}/status/`
}
export const reusableWidgetsStatus = async (
projectId: string,
id: string,
options?: RequestInit
): Promise<WidgetStatusApi> => {
return apiMutator<WidgetStatusApi>(getReusableWidgetsStatusUrl(projectId, id), {
...options,
method: 'GET',
})
}
export const getReusableWidgetsVersionsUrl = (
projectId: string,
id: string,
params?: ReusableWidgetsVersionsParams
) => {
const normalizedParams = new URLSearchParams()
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? 'null' : String(value))
}
})
const stringifiedParams = normalizedParams.toString()
return stringifiedParams.length > 0
? `/api/projects/${projectId}/notebook_widgets/${id}/versions/?${stringifiedParams}`
: `/api/projects/${projectId}/notebook_widgets/${id}/versions/`
}
export const reusableWidgetsVersions = async (
projectId: string,
id: string,
params?: ReusableWidgetsVersionsParams,
options?: RequestInit
): Promise<ReusableWidgetVersionPageApi> => {
return apiMutator<ReusableWidgetVersionPageApi>(getReusableWidgetsVersionsUrl(projectId, id, params), {
...options,
method: 'GET',
})
}
export const getNotebooksListUrl = (projectId: string, params?: NotebooksListParams) => {
const normalizedParams = new URLSearchParams()
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? 'null' : String(value))
}
})
const stringifiedParams = normalizedParams.toString()
return stringifiedParams.length > 0
? `/api/projects/${projectId}/notebooks/?${stringifiedParams}`
: `/api/projects/${projectId}/notebooks/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksList = async (
projectId: string,
params?: NotebooksListParams,
options?: RequestInit
): Promise<PaginatedNotebookMinimalListApi> => {
return apiMutator<PaginatedNotebookMinimalListApi>(getNotebooksListUrl(projectId, params), {
...options,
method: 'GET',
})
}
export const getNotebooksCreateUrl = (projectId: string) => {
return `/api/projects/${projectId}/notebooks/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksCreate = async (
projectId: string,
notebookApi?: NonReadonly<NotebookApi>,
options?: RequestInit
): Promise<NotebookApi> => {
return apiMutator<NotebookApi>(getNotebooksCreateUrl(projectId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(notebookApi),
})
}
export const getNotebooksRetrieveUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksRetrieve = async (
projectId: string,
shortId: string,
options?: RequestInit
): Promise<NotebookApi> => {
return apiMutator<NotebookApi>(getNotebooksRetrieveUrl(projectId, shortId), {
...options,
method: 'GET',
})
}
export const getNotebooksUpdateUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksUpdate = async (
projectId: string,
shortId: string,
notebookApi?: NonReadonly<NotebookApi>,
options?: RequestInit
): Promise<NotebookApi> => {
return apiMutator<NotebookApi>(getNotebooksUpdateUrl(projectId, shortId), {
...options,
method: 'PUT',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(notebookApi),
})
}
export const getNotebooksPartialUpdateUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksPartialUpdate = async (
projectId: string,
shortId: string,
patchedNotebookApi?: NonReadonly<PatchedNotebookApi>,
options?: RequestInit
): Promise<NotebookApi> => {
return apiMutator<NotebookApi>(getNotebooksPartialUpdateUrl(projectId, shortId), {
...options,
method: 'PATCH',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(patchedNotebookApi),
})
}
export const getNotebooksDestroyUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/`
}
/**
* Hard delete of this model is not allowed. Use a patch API call to set "deleted" to true
*/
export const notebooksDestroy = async (projectId: string, shortId: string, options?: RequestInit): Promise<unknown> => {
return apiMutator<unknown>(getNotebooksDestroyUrl(projectId, shortId), {
...options,
method: 'DELETE',
})
}
export const getNotebooksActivityRetrieveUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/activity/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksActivityRetrieve = async (
projectId: string,
shortId: string,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getNotebooksActivityRetrieveUrl(projectId, shortId), {
...options,
method: 'GET',
})
}
export const getNotebooksCollabMarkdownSaveCreateUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/collab/markdown_save/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksCollabMarkdownSaveCreate = async (
projectId: string,
shortId: string,
notebookMarkdownSaveApi: NotebookMarkdownSaveApi,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getNotebooksCollabMarkdownSaveCreateUrl(projectId, shortId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(notebookMarkdownSaveApi),
})
}
export const getNotebooksCollabPresenceCreateUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/collab/presence/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksCollabPresenceCreate = async (
projectId: string,
shortId: string,
notebookCollabPresenceApi: NotebookCollabPresenceApi,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getNotebooksCollabPresenceCreateUrl(projectId, shortId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(notebookCollabPresenceApi),
})
}
export const getNotebooksCollabSaveCreateUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/collab/save/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksCollabSaveCreate = async (
projectId: string,
shortId: string,
notebookCollabSaveApi: NotebookCollabSaveApi,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getNotebooksCollabSaveCreateUrl(projectId, shortId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(notebookCollabSaveApi),
})
}
export const getNotebooksCollabStreamRetrieveUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/collab/stream/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksCollabStreamRetrieve = async (
projectId: string,
shortId: string,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getNotebooksCollabStreamRetrieveUrl(projectId, shortId), {
...options,
method: 'GET',
})
}
export const getNotebooksKernelCompleteCreateUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/kernel/complete/`
}
/**
* Completions for the cursor position in a Python cell, from the notebook's running kernel. Returns no matches when no kernel is running or the kernel is busy, and never starts one.
*/
export const notebooksKernelCompleteCreate = async (
projectId: string,
shortId: string,
notebookKernelCompleteRequestApi: NotebookKernelCompleteRequestApi,
options?: RequestInit
): Promise<NotebookKernelCompleteResponseApi> => {
return apiMutator<NotebookKernelCompleteResponseApi>(getNotebooksKernelCompleteCreateUrl(projectId, shortId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(notebookKernelCompleteRequestApi),
})
}
export const getNotebooksKernelConfigCreateUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/kernel/config/`
}
/**
* Set the notebook's kernel compute configuration. Applies at sandbox provision time: a currently running kernel keeps its resources until restarted.
*/
export const notebooksKernelConfigCreate = async (
projectId: string,
shortId: string,
notebookKernelConfigApi?: NotebookKernelConfigApi,
options?: RequestInit
): Promise<NotebookKernelConfigResponseApi> => {
return apiMutator<NotebookKernelConfigResponseApi>(getNotebooksKernelConfigCreateUrl(projectId, shortId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(notebookKernelConfigApi),
})
}
export const getNotebooksKernelExecuteCreateUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/kernel/execute/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksKernelExecuteCreate = async (
projectId: string,
shortId: string,
notebookApi?: NonReadonly<NotebookApi>,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getNotebooksKernelExecuteCreateUrl(projectId, shortId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(notebookApi),
})
}
export const getNotebooksKernelInspectCreateUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/kernel/inspect/`
}
/**
* The signature and docstring of the name at the cursor in a Python cell, from the notebook's running kernel. Returns found=false when no kernel is running or the kernel is busy.
*/
export const notebooksKernelInspectCreate = async (
projectId: string,
shortId: string,
notebookKernelInspectRequestApi: NotebookKernelInspectRequestApi,
options?: RequestInit
): Promise<NotebookKernelInspectResponseApi> => {
return apiMutator<NotebookKernelInspectResponseApi>(getNotebooksKernelInspectCreateUrl(projectId, shortId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(notebookKernelInspectRequestApi),
})
}
export const getNotebooksKernelRestartCreateUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/kernel/restart/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksKernelRestartCreate = async (
projectId: string,
shortId: string,
notebookApi?: NonReadonly<NotebookApi>,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getNotebooksKernelRestartCreateUrl(projectId, shortId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(notebookApi),
})
}
export const getNotebooksKernelStartCreateUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/kernel/start/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksKernelStartCreate = async (
projectId: string,
shortId: string,
notebookApi?: NonReadonly<NotebookApi>,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getNotebooksKernelStartCreateUrl(projectId, shortId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(notebookApi),
})
}
export const getNotebooksKernelStatusRetrieveUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/kernel/status/`
}
/**
* Live-checked kernel runtime state for this notebook, its compute configuration, and the catalog of dataframes/tables a cell can currently reference (with column schemas).
*/
export const notebooksKernelStatusRetrieve = async (
projectId: string,
shortId: string,
options?: RequestInit
): Promise<NotebookKernelStatusResponseApi> => {
return apiMutator<NotebookKernelStatusResponseApi>(getNotebooksKernelStatusRetrieveUrl(projectId, shortId), {
...options,
method: 'GET',
})
}
export const getNotebooksKernelStopCreateUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/kernel/stop/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksKernelStopCreate = async (
projectId: string,
shortId: string,
notebookApi?: NonReadonly<NotebookApi>,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getNotebooksKernelStopCreateUrl(projectId, shortId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(notebookApi),
})
}
export const getNotebooksRunsCreateUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/runs/`
}
/**
* Run every SQL and Python cell of a markdown notebook, in document order, stopping at the first cell that does not finish. Returns as soon as the run starts; poll the run status endpoint until the status is terminal. Flag-gated (revamped-py-notebooks).
*/
export const notebooksRunsCreate = async (
projectId: string,
shortId: string,
notebookRunStartRequestApi?: NotebookRunStartRequestApi,
options?: RequestInit
): Promise<NotebookRunStartResponseApi> => {
return apiMutator<NotebookRunStartResponseApi>(getNotebooksRunsCreateUrl(projectId, shortId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(notebookRunStartRequestApi),
})
}
export const getNotebooksRunsRetrieveUrl = (projectId: string, shortId: string, runId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/runs/${runId}/`
}
/**
* Read a whole-notebook run: its state, which cell it is on, and one line per planned cell. Carries no result rows — fetch a cell's result from the cell run result endpoint. Flag-gated (revamped-py-notebooks).
*/
export const notebooksRunsRetrieve = async (
projectId: string,
shortId: string,
runId: string,
options?: RequestInit
): Promise<NotebookRunStatusResponseApi> => {
return apiMutator<NotebookRunStatusResponseApi>(getNotebooksRunsRetrieveUrl(projectId, shortId, runId), {
...options,
method: 'GET',
})
}
export const getNotebooksRunsInterruptCreateUrl = (projectId: string, shortId: string, runId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/runs/${runId}/interrupt/`
}
/**
* Stop a whole-notebook run and the cell it is on. Idempotent: stopping a run that already finished returns its outcome unchanged. Flag-gated (revamped-py-notebooks).
*/
export const notebooksRunsInterruptCreate = async (
projectId: string,
shortId: string,
runId: string,
options?: RequestInit
): Promise<NotebookRunInterruptResponseApi> => {
return apiMutator<NotebookRunInterruptResponseApi>(getNotebooksRunsInterruptCreateUrl(projectId, shortId, runId), {
...options,
method: 'POST',
})
}
export const getNotebooksSqlV2RunCreateUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/sql_v2/run/`
}
/**
* Dispatch an asynchronous run of a notebook SQL or Python cell. Returns a run_id immediately; poll the run result endpoint until the status is terminal. One run at a time per notebook. Python notebooks enable all run types. HogQL runs without a connection or kernel are always available.
*/
export const notebooksSqlV2RunCreate = async (
projectId: string,
shortId: string,
notebookSQLV2RunRequestApi: NotebookSQLV2RunRequestApi,
options?: RequestInit
): Promise<NotebookSQLV2RunResponseApi> => {
return apiMutator<NotebookSQLV2RunResponseApi>(getNotebooksSqlV2RunCreateUrl(projectId, shortId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(notebookSQLV2RunRequestApi),
})
}
export const getNotebooksSqlV2RunsRetrieveUrl = (projectId: string, shortId: string, runId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/sql_v2/runs/${runId}/`
}
/**
* Read a run's durable state: its status, and — once done or interrupted — the result envelope (columns, first rows, stdout/stderr, media, error). Poll until terminal. Requires notebook and query read access, including after a notebook feature flag is disabled.
*/
export const notebooksSqlV2RunsRetrieve = async (
projectId: string,
shortId: string,
runId: string,
options?: RequestInit
): Promise<NotebookSQLV2RunStatusResponseApi> => {
return apiMutator<NotebookSQLV2RunStatusResponseApi>(getNotebooksSqlV2RunsRetrieveUrl(projectId, shortId, runId), {
...options,
method: 'GET',
})
}
export const getNotebooksSqlV2RunsInterruptCreateUrl = (projectId: string, shortId: string, runId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/sql_v2/runs/${runId}/interrupt/`
}
/**
* Stop a running cell. Idempotent: interrupting an already-finished run returns its outcome unchanged. Flag-gated (revamped-py-notebooks).
*/
export const notebooksSqlV2RunsInterruptCreate = async (
projectId: string,
shortId: string,
runId: string,
options?: RequestInit
): Promise<NotebookSQLV2InterruptResponseApi> => {
return apiMutator<NotebookSQLV2InterruptResponseApi>(
getNotebooksSqlV2RunsInterruptCreateUrl(projectId, shortId, runId),
{
...options,
method: 'POST',
}
)
}
export const getNotebooksSqlV2StateRetrieveUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/sql_v2/state/`
}
/**
* The full notebook view for agents: title, document source (markdown, or raw content for legacy rich-text notebooks), the notebook's declared variables, every cell with its dependency edges and derived run status (including staleness), and the kernel's runtime state and compute config. Flag-gated (revamped-py-notebooks).
*/
export const notebooksSqlV2StateRetrieve = async (
projectId: string,
shortId: string,
options?: RequestInit
): Promise<NotebookSQLV2StateResponseApi> => {
return apiMutator<NotebookSQLV2StateResponseApi>(getNotebooksSqlV2StateRetrieveUrl(projectId, shortId), {
...options,
method: 'GET',
})
}
export const getNotebooksWidgetSnapshotCreateUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/widget_snapshots/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksWidgetSnapshotCreate = async (
projectId: string,
shortId: string,
widgetSnapshotRequestApi: WidgetSnapshotRequestApi,
options?: RequestInit
): Promise<WidgetSnapshotApi> => {
return apiMutator<WidgetSnapshotApi>(getNotebooksWidgetSnapshotCreateUrl(projectId, shortId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(widgetSnapshotRequestApi),
})
}
export const getNotebooksWidgetSnapshotRetrieveUrl = (projectId: string, shortId: string, snapshotId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/widget_snapshots/${snapshotId}/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksWidgetSnapshotRetrieve = async (
projectId: string,
shortId: string,
snapshotId: string,
options?: RequestInit
): Promise<WidgetSnapshotApi> => {
return apiMutator<WidgetSnapshotApi>(getNotebooksWidgetSnapshotRetrieveUrl(projectId, shortId, snapshotId), {
...options,
method: 'GET',
})
}
export const getNotebooksWidgetSnapshotFrameUrl = (
projectId: string,
shortId: string,
snapshotId: string,
frameName: string,
params?: NotebooksWidgetSnapshotFrameParams
) => {
const normalizedParams = new URLSearchParams()
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? 'null' : String(value))
}
})
const stringifiedParams = normalizedParams.toString()
return stringifiedParams.length > 0
? `/api/projects/${projectId}/notebooks/${shortId}/widget_snapshots/${snapshotId}/frames/${frameName}/?${stringifiedParams}`
: `/api/projects/${projectId}/notebooks/${shortId}/widget_snapshots/${snapshotId}/frames/${frameName}/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksWidgetSnapshotFrame = async (
projectId: string,
shortId: string,
snapshotId: string,
frameName: string,
params?: NotebooksWidgetSnapshotFrameParams,
options?: RequestInit
): Promise<WidgetFrameApi> => {
return apiMutator<WidgetFrameApi>(
getNotebooksWidgetSnapshotFrameUrl(projectId, shortId, snapshotId, frameName, params),
{
...options,
method: 'GET',
}
)
}
export const getNotebooksWidgetSnapshotPublishUrl = (projectId: string, shortId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/widget_snapshots/publish/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksWidgetSnapshotPublish = async (
projectId: string,
shortId: string,
widgetSnapshotPublishApi: WidgetSnapshotPublishApi,
options?: RequestInit
): Promise<WidgetSnapshotApi> => {
return apiMutator<WidgetSnapshotApi>(getNotebooksWidgetSnapshotPublishUrl(projectId, shortId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(widgetSnapshotPublishApi),
})
}
export const getNotebooksWidgetAttachUrl = (projectId: string, shortId: string, nodeId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/widgets/${nodeId}/attach/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksWidgetAttach = async (
projectId: string,
shortId: string,
nodeId: string,
reusableWidgetAttachRequestApi: ReusableWidgetAttachRequestApi,
options?: RequestInit
): Promise<WidgetStatusApi> => {
return apiMutator<WidgetStatusApi>(getNotebooksWidgetAttachUrl(projectId, shortId, nodeId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(reusableWidgetAttachRequestApi),
})
}
export const getNotebooksWidgetCancelUrl = (projectId: string, shortId: string, nodeId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/widgets/${nodeId}/cancel/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksWidgetCancel = async (
projectId: string,
shortId: string,
nodeId: string,
widgetCancelRequestApi: WidgetCancelRequestApi,
options?: RequestInit
): Promise<void> => {
return apiMutator<void>(getNotebooksWidgetCancelUrl(projectId, shortId, nodeId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(widgetCancelRequestApi),
})
}
export const getNotebooksWidgetForkUrl = (projectId: string, shortId: string, nodeId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/widgets/${nodeId}/fork/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksWidgetFork = async (
projectId: string,
shortId: string,
nodeId: string,
reusableWidgetForkRequestApi?: ReusableWidgetForkRequestApi,
options?: RequestInit
): Promise<WidgetStatusApi> => {
return apiMutator<WidgetStatusApi>(getNotebooksWidgetForkUrl(projectId, shortId, nodeId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(reusableWidgetForkRequestApi),
})
}
export const getNotebooksWidgetFrameUrl = (
projectId: string,
shortId: string,
nodeId: string,
frameName: string,
params?: NotebooksWidgetFrameParams
) => {
const normalizedParams = new URLSearchParams()
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? 'null' : String(value))
}
})
const stringifiedParams = normalizedParams.toString()
return stringifiedParams.length > 0
? `/api/projects/${projectId}/notebooks/${shortId}/widgets/${nodeId}/frames/${frameName}/?${stringifiedParams}`
: `/api/projects/${projectId}/notebooks/${shortId}/widgets/${nodeId}/frames/${frameName}/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksWidgetFrame = async (
projectId: string,
shortId: string,
nodeId: string,
frameName: string,
params?: NotebooksWidgetFrameParams,
options?: RequestInit
): Promise<WidgetFrameApi> => {
return apiMutator<WidgetFrameApi>(getNotebooksWidgetFrameUrl(projectId, shortId, nodeId, frameName, params), {
...options,
method: 'GET',
})
}
export const getNotebooksWidgetGenerateUrl = (projectId: string, shortId: string, nodeId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/widgets/${nodeId}/generate/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksWidgetGenerate = async (
projectId: string,
shortId: string,
nodeId: string,
widgetGenerateRequestApi: WidgetGenerateRequestApi,
options?: RequestInit
): Promise<WidgetStatusApi> => {
return apiMutator<WidgetStatusApi>(getNotebooksWidgetGenerateUrl(projectId, shortId, nodeId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(widgetGenerateRequestApi),
})
}
export const getNotebooksWidgetPinUrl = (projectId: string, shortId: string, nodeId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/widgets/${nodeId}/pin/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksWidgetPin = async (
projectId: string,
shortId: string,
nodeId: string,
widgetPinRequestApi: WidgetPinRequestApi,
options?: RequestInit
): Promise<WidgetStatusApi> => {
return apiMutator<WidgetStatusApi>(getNotebooksWidgetPinUrl(projectId, shortId, nodeId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(widgetPinRequestApi),
})
}
export const getNotebooksWidgetPublishUrl = (projectId: string, shortId: string, nodeId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/widgets/${nodeId}/publish/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksWidgetPublish = async (
projectId: string,
shortId: string,
nodeId: string,
reusableWidgetPublishRequestApi: ReusableWidgetPublishRequestApi,
options?: RequestInit
): Promise<ReusableWidgetDetailApi> => {
return apiMutator<ReusableWidgetDetailApi>(getNotebooksWidgetPublishUrl(projectId, shortId, nodeId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(reusableWidgetPublishRequestApi),
})
}
export const getNotebooksWidgetRevertUrl = (projectId: string, shortId: string, nodeId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/widgets/${nodeId}/revert/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksWidgetRevert = async (
projectId: string,
shortId: string,
nodeId: string,
widgetRevertRequestApi: WidgetRevertRequestApi,
options?: RequestInit
): Promise<WidgetStatusApi> => {
return apiMutator<WidgetStatusApi>(getNotebooksWidgetRevertUrl(projectId, shortId, nodeId), {
...options,
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(widgetRevertRequestApi),
})
}
export const getNotebooksWidgetSourceUrl = (
projectId: string,
shortId: string,
nodeId: string,
params?: NotebooksWidgetSourceParams
) => {
const normalizedParams = new URLSearchParams()
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? 'null' : String(value))
}
})
const stringifiedParams = normalizedParams.toString()
return stringifiedParams.length > 0
? `/api/projects/${projectId}/notebooks/${shortId}/widgets/${nodeId}/source/?${stringifiedParams}`
: `/api/projects/${projectId}/notebooks/${shortId}/widgets/${nodeId}/source/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksWidgetSource = async (
projectId: string,
shortId: string,
nodeId: string,
params?: NotebooksWidgetSourceParams,
options?: RequestInit
): Promise<WidgetSourceApi> => {
return apiMutator<WidgetSourceApi>(getNotebooksWidgetSourceUrl(projectId, shortId, nodeId, params), {
...options,
method: 'GET',
})
}
export const getNotebooksWidgetStatusUrl = (projectId: string, shortId: string, nodeId: string) => {
return `/api/projects/${projectId}/notebooks/${shortId}/widgets/${nodeId}/status/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksWidgetStatus = async (
projectId: string,
shortId: string,
nodeId: string,
options?: RequestInit
): Promise<WidgetStatusApi> => {
return apiMutator<WidgetStatusApi>(getNotebooksWidgetStatusUrl(projectId, shortId, nodeId), {
...options,
method: 'GET',
})
}
export const getNotebooksWidgetVersionsUrl = (
projectId: string,
shortId: string,
nodeId: string,
params?: NotebooksWidgetVersionsParams
) => {
const normalizedParams = new URLSearchParams()
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? 'null' : String(value))
}
})
const stringifiedParams = normalizedParams.toString()
return stringifiedParams.length > 0
? `/api/projects/${projectId}/notebooks/${shortId}/widgets/${nodeId}/versions/?${stringifiedParams}`
: `/api/projects/${projectId}/notebooks/${shortId}/widgets/${nodeId}/versions/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksWidgetVersions = async (
projectId: string,
shortId: string,
nodeId: string,
params?: NotebooksWidgetVersionsParams,
options?: RequestInit
): Promise<WidgetVersionPageApi> => {
return apiMutator<WidgetVersionPageApi>(getNotebooksWidgetVersionsUrl(projectId, shortId, nodeId, params), {
...options,
method: 'GET',
})
}
export const getNotebooksAllActivityRetrieveUrl = (projectId: string) => {
return `/api/projects/${projectId}/notebooks/activity/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksAllActivityRetrieve = async (projectId: string, options?: RequestInit): Promise<void> => {
return apiMutator<void>(getNotebooksAllActivityRetrieveUrl(projectId), {
...options,
method: 'GET',
})
}
export const getNotebooksKernelComputeOptionsRetrieveUrl = (projectId: string) => {
return `/api/projects/${projectId}/notebooks/kernel/compute_options/`
}
/**
* Compute rates, presets, and the sizes the kernel config endpoint accepts. Static per region, so a client can fetch it once and price any shape a user picks.
*/
export const notebooksKernelComputeOptionsRetrieve = async (
projectId: string,
options?: RequestInit
): Promise<NotebookComputeOptionsResponseApi> => {
return apiMutator<NotebookComputeOptionsResponseApi>(getNotebooksKernelComputeOptionsRetrieveUrl(projectId), {
...options,
method: 'GET',
})
}
export const getNotebooksRecordingCommentsRetrieveUrl = (projectId: string) => {
return `/api/projects/${projectId}/notebooks/recording_comments/`
}
/**
* The API for interacting with Notebooks. This feature is in early access and the API can have breaking changes without announcement.
*/
export const notebooksRecordingCommentsRetrieve = async (projectId: string, options?: RequestInit): Promise<void> => {
return apiMutator<void>(getNotebooksRecordingCommentsRetrieveUrl(projectId), {
...options,
method: 'GET',
})
}