/**
* Generated by orval v7.17.0 🍺
* Do not edit manually.
* superglue AI API
* API for running superglue AI tools
* OpenAPI spec version: 1.0.0
*/
import type {
Error,
ListRuns200,
ListRunsParams,
ListTools200,
ListToolsParams,
Run,
RunRequest,
Tool,
} from "./models";
import { customFetch } from "../fetcher";
/**
* @summary List tools
*/
export type listToolsResponse200 = {
data: ListTools200;
status: 200;
};
export type listToolsResponseSuccess = listToolsResponse200 & {
headers: Headers;
};
export type listToolsResponse = listToolsResponseSuccess;
export const getListToolsUrl = (params?: ListToolsParams) => {
const normalizedParams = new URLSearchParams();
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? "null" : value.toString());
}
});
const stringifiedParams = normalizedParams.toString();
return stringifiedParams.length > 0
? `/tools?${stringifiedParams}`
: `/tools`;
};
export const listTools = async (
params?: ListToolsParams,
options?: RequestInit,
): Promise<listToolsResponse> => {
return customFetch<listToolsResponse>(getListToolsUrl(params), {
...options,
method: "GET",
});
};
/**
* @summary Get tool details
*/
export type getToolResponse200 = {
data: Tool;
status: 200;
};
export type getToolResponse404 = {
data: Error;
status: 404;
};
export type getToolResponseSuccess = getToolResponse200 & {
headers: Headers;
};
export type getToolResponseError = getToolResponse404 & {
headers: Headers;
};
export type getToolResponse = getToolResponseSuccess | getToolResponseError;
export const getGetToolUrl = (toolId: string) => {
return `/tools/${toolId}`;
};
export const getTool = async (
toolId: string,
options?: RequestInit,
): Promise<getToolResponse> => {
return customFetch<getToolResponse>(getGetToolUrl(toolId), {
...options,
method: "GET",
});
};
/**
* @summary Run a tool
*/
export type runToolResponse200 = {
data: Run;
status: 200;
};
export type runToolResponse202 = {
data: Run;
status: 202;
};
export type runToolResponse400 = {
data: Error;
status: 400;
};
export type runToolResponse409 = {
data: Error;
status: 409;
};
export type runToolResponse410 = {
data: Error;
status: 410;
};
export type runToolResponse429 = {
data: Error;
status: 429;
};
export type runToolResponseSuccess = (
| runToolResponse200
| runToolResponse202
) & {
headers: Headers;
};
export type runToolResponseError = (
| runToolResponse400
| runToolResponse409
| runToolResponse410
| runToolResponse429
) & {
headers: Headers;
};
export type runToolResponse = runToolResponseSuccess | runToolResponseError;
export const getRunToolUrl = (toolId: string) => {
return `/tools/${toolId}/run`;
};
export const runTool = async (
toolId: string,
runRequest: RunRequest,
options?: RequestInit,
): Promise<runToolResponse> => {
return customFetch<runToolResponse>(getRunToolUrl(toolId), {
...options,
method: "POST",
headers: { "Content-Type": "application/json", ...options?.headers },
body: JSON.stringify(runRequest),
});
};
/**
* @summary Get run status
*/
export type getRunResponse200 = {
data: Run;
status: 200;
};
export type getRunResponse404 = {
data: Error;
status: 404;
};
export type getRunResponseSuccess = getRunResponse200 & {
headers: Headers;
};
export type getRunResponseError = getRunResponse404 & {
headers: Headers;
};
export type getRunResponse = getRunResponseSuccess | getRunResponseError;
export const getGetRunUrl = (runId: string) => {
return `/runs/${runId}`;
};
export const getRun = async (
runId: string,
options?: RequestInit,
): Promise<getRunResponse> => {
return customFetch<getRunResponse>(getGetRunUrl(runId), {
...options,
method: "GET",
});
};
/**
* @summary Cancel a run
*/
export type cancelRunResponse200 = {
data: Run;
status: 200;
};
export type cancelRunResponse400 = {
data: Error;
status: 400;
};
export type cancelRunResponseSuccess = cancelRunResponse200 & {
headers: Headers;
};
export type cancelRunResponseError = cancelRunResponse400 & {
headers: Headers;
};
export type cancelRunResponse =
| cancelRunResponseSuccess
| cancelRunResponseError;
export const getCancelRunUrl = (runId: string) => {
return `/runs/${runId}/cancel`;
};
export const cancelRun = async (
runId: string,
options?: RequestInit,
): Promise<cancelRunResponse> => {
return customFetch<cancelRunResponse>(getCancelRunUrl(runId), {
...options,
method: "POST",
});
};
/**
* @summary List runs
*/
export type listRunsResponse200 = {
data: ListRuns200;
status: 200;
};
export type listRunsResponseSuccess = listRunsResponse200 & {
headers: Headers;
};
export type listRunsResponse = listRunsResponseSuccess;
export const getListRunsUrl = (params?: ListRunsParams) => {
const normalizedParams = new URLSearchParams();
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? "null" : value.toString());
}
});
const stringifiedParams = normalizedParams.toString();
return stringifiedParams.length > 0 ? `/runs?${stringifiedParams}` : `/runs`;
};
export const listRuns = async (
params?: ListRunsParams,
options?: RequestInit,
): Promise<listRunsResponse> => {
return customFetch<listRunsResponse>(getListRunsUrl(params), {
...options,
method: "GET",
});
};