export type ProjectId = number; export type CreateApiNessiePipelinePauseArgs = {body: {name: string, project_id?: ProjectId | undefined}}; export type CreateApiNessiePipelinePauseOptions = {baseUrl?: string | undefined, ServiceAccount?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Pause Pipeline * * POST /nessie/pipeline/pause * * Also accepts auth: ProjectSecret */ export const createApiNessiePipelinePause = async (args: CreateApiNessiePipelinePauseArgs, options?: CreateApiNessiePipelinePauseOptions) => { const {baseUrl = "https://mixpanel.com/api/query", fetch: fetchFn = fetch, ServiceAccount} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/x-www-form-urlencoded") if (ServiceAccount !== undefined) headers.set('authorization', `Basic ${btoa(`${ServiceAccount.username}:${ServiceAccount.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/nessie/pipeline/pause${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: new URLSearchParams(Object.entries(args.body).flatMap(([key, value]) => (value == null ? [] : [[key, String(value)]])))}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };