feat: adding background jobs ui page and apis - requires user is_admin to be set to true

This commit is contained in:
allanice001
2025-11-04 23:52:37 +00:00
parent 91686c1ea4
commit c41af60b26
97 changed files with 11135 additions and 138 deletions

View File

@@ -13,16 +13,33 @@
*/
import * as runtime from "../runtime";
import type { DtoAnnotationResponse } from "../models/index";
import type {
DtoAnnotationResponse,
DtoCreateAnnotationRequest,
DtoUpdateAnnotationRequest,
} from "../models/index";
import {
DtoAnnotationResponseFromJSON,
DtoAnnotationResponseToJSON,
DtoCreateAnnotationRequestFromJSON,
DtoCreateAnnotationRequestToJSON,
DtoUpdateAnnotationRequestFromJSON,
DtoUpdateAnnotationRequestToJSON,
} from "../models/index";
export interface CreateAnnotationRequest {
body: DtoCreateAnnotationRequest;
xOrgID?: string;
}
export interface DeleteAnnotationRequest {
id: string;
xOrgID?: string;
}
export interface GetAnnotationRequest {
id: string;
xOrgID?: string;
include?: string;
}
export interface ListAnnotationsRequest {
@@ -32,10 +49,165 @@ export interface ListAnnotationsRequest {
q?: string;
}
export interface UpdateAnnotationRequest {
id: string;
body: DtoUpdateAnnotationRequest;
xOrgID?: string;
}
/**
*
*/
export class AnnotationsApi extends runtime.BaseAPI {
/**
* Creates an annotation.
* Create annotation (org scoped)
*/
async createAnnotationRaw(
requestParameters: CreateAnnotationRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<runtime.ApiResponse<DtoAnnotationResponse>> {
if (requestParameters["body"] == null) {
throw new runtime.RequiredError(
"body",
'Required parameter "body" was null or undefined when calling createAnnotation().',
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
headerParameters["Content-Type"] = "application/json";
if (requestParameters["xOrgID"] != null) {
headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
}
if (this.configuration && this.configuration.apiKey) {
headerParameters["X-ORG-KEY"] =
await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
}
if (this.configuration && this.configuration.apiKey) {
headerParameters["X-ORG-SECRET"] =
await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
}
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] =
await this.configuration.apiKey("Authorization"); // BearerAuth authentication
}
let urlPath = `/annotations`;
const response = await this.request(
{
path: urlPath,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: DtoCreateAnnotationRequestToJSON(requestParameters["body"]),
},
initOverrides,
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
DtoAnnotationResponseFromJSON(jsonValue),
);
}
/**
* Creates an annotation.
* Create annotation (org scoped)
*/
async createAnnotation(
requestParameters: CreateAnnotationRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<DtoAnnotationResponse> {
const response = await this.createAnnotationRaw(
requestParameters,
initOverrides,
);
return await response.value();
}
/**
* Permanently deletes the annotation.
* Delete annotation (org scoped)
*/
async deleteAnnotationRaw(
requestParameters: DeleteAnnotationRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<runtime.ApiResponse<string>> {
if (requestParameters["id"] == null) {
throw new runtime.RequiredError(
"id",
'Required parameter "id" was null or undefined when calling deleteAnnotation().',
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (requestParameters["xOrgID"] != null) {
headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
}
if (this.configuration && this.configuration.apiKey) {
headerParameters["X-ORG-KEY"] =
await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
}
if (this.configuration && this.configuration.apiKey) {
headerParameters["X-ORG-SECRET"] =
await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
}
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] =
await this.configuration.apiKey("Authorization"); // BearerAuth authentication
}
let urlPath = `/annotations/{id}`;
urlPath = urlPath.replace(
`{${"id"}}`,
encodeURIComponent(String(requestParameters["id"])),
);
const response = await this.request(
{
path: urlPath,
method: "DELETE",
headers: headerParameters,
query: queryParameters,
},
initOverrides,
);
if (this.isJsonMime(response.headers.get("content-type"))) {
return new runtime.JSONApiResponse<string>(response);
} else {
return new runtime.TextApiResponse(response) as any;
}
}
/**
* Permanently deletes the annotation.
* Delete annotation (org scoped)
*/
async deleteAnnotation(
requestParameters: DeleteAnnotationRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<string> {
const response = await this.deleteAnnotationRaw(
requestParameters,
initOverrides,
);
return await response.value();
}
/**
* Returns one annotation. Add `include=node_pools` to include node pools.
* Get annotation by ID (org scoped)
@@ -53,10 +225,6 @@ export class AnnotationsApi extends runtime.BaseAPI {
const queryParameters: any = {};
if (requestParameters["include"] != null) {
queryParameters["include"] = requestParameters["include"];
}
const headerParameters: runtime.HTTPHeaders = {};
if (requestParameters["xOrgID"] != null) {
@@ -188,4 +356,88 @@ export class AnnotationsApi extends runtime.BaseAPI {
);
return await response.value();
}
/**
* Partially update annotation fields.
* Update annotation (org scoped)
*/
async updateAnnotationRaw(
requestParameters: UpdateAnnotationRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<runtime.ApiResponse<DtoAnnotationResponse>> {
if (requestParameters["id"] == null) {
throw new runtime.RequiredError(
"id",
'Required parameter "id" was null or undefined when calling updateAnnotation().',
);
}
if (requestParameters["body"] == null) {
throw new runtime.RequiredError(
"body",
'Required parameter "body" was null or undefined when calling updateAnnotation().',
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
headerParameters["Content-Type"] = "application/json";
if (requestParameters["xOrgID"] != null) {
headerParameters["X-Org-ID"] = String(requestParameters["xOrgID"]);
}
if (this.configuration && this.configuration.apiKey) {
headerParameters["X-ORG-KEY"] =
await this.configuration.apiKey("X-ORG-KEY"); // OrgKeyAuth authentication
}
if (this.configuration && this.configuration.apiKey) {
headerParameters["X-ORG-SECRET"] =
await this.configuration.apiKey("X-ORG-SECRET"); // OrgSecretAuth authentication
}
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] =
await this.configuration.apiKey("Authorization"); // BearerAuth authentication
}
let urlPath = `/annotations/{id}`;
urlPath = urlPath.replace(
`{${"id"}}`,
encodeURIComponent(String(requestParameters["id"])),
);
const response = await this.request(
{
path: urlPath,
method: "PATCH",
headers: headerParameters,
query: queryParameters,
body: DtoUpdateAnnotationRequestToJSON(requestParameters["body"]),
},
initOverrides,
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
DtoAnnotationResponseFromJSON(jsonValue),
);
}
/**
* Partially update annotation fields.
* Update annotation (org scoped)
*/
async updateAnnotation(
requestParameters: UpdateAnnotationRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<DtoAnnotationResponse> {
const response = await this.updateAnnotationRaw(
requestParameters,
initOverrides,
);
return await response.value();
}
}

View File

@@ -0,0 +1,356 @@
/* tslint:disable */
/* eslint-disable */
/**
* AutoGlue API
* API for managing K3s clusters across cloud providers
*
* The version of the OpenAPI document: 1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import * as runtime from "../runtime";
import type { DtoJob, DtoPageJob, DtoQueueInfo } from "../models/index";
import {
DtoJobFromJSON,
DtoJobToJSON,
DtoPageJobFromJSON,
DtoPageJobToJSON,
DtoQueueInfoFromJSON,
DtoQueueInfoToJSON,
} from "../models/index";
export interface AdminCancelArcherJobRequest {
id: string;
}
export interface AdminEnqueueArcherJobRequest {
body: object;
}
export interface AdminListArcherJobsRequest {
status?: AdminListArcherJobsStatusEnum;
queue?: string;
q?: string;
page?: number;
pageSize?: number;
}
export interface AdminRetryArcherJobRequest {
id: string;
}
/**
*
*/
export class ArcherAdminApi extends runtime.BaseAPI {
/**
* Set job status to canceled if cancellable. For running jobs, this only affects future picks; wire to Archer if you need active kill.
* Cancel an Archer job (admin)
*/
async adminCancelArcherJobRaw(
requestParameters: AdminCancelArcherJobRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<runtime.ApiResponse<DtoJob>> {
if (requestParameters["id"] == null) {
throw new runtime.RequiredError(
"id",
'Required parameter "id" was null or undefined when calling adminCancelArcherJob().',
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] =
await this.configuration.apiKey("Authorization"); // BearerAuth authentication
}
let urlPath = `/admin/archer/jobs/{id}/cancel`;
urlPath = urlPath.replace(
`{${"id"}}`,
encodeURIComponent(String(requestParameters["id"])),
);
const response = await this.request(
{
path: urlPath,
method: "POST",
headers: headerParameters,
query: queryParameters,
},
initOverrides,
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
DtoJobFromJSON(jsonValue),
);
}
/**
* Set job status to canceled if cancellable. For running jobs, this only affects future picks; wire to Archer if you need active kill.
* Cancel an Archer job (admin)
*/
async adminCancelArcherJob(
requestParameters: AdminCancelArcherJobRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<DtoJob> {
const response = await this.adminCancelArcherJobRaw(
requestParameters,
initOverrides,
);
return await response.value();
}
/**
* Create a job immediately or schedule it for the future via `run_at`.
* Enqueue a new Archer job (admin)
*/
async adminEnqueueArcherJobRaw(
requestParameters: AdminEnqueueArcherJobRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<runtime.ApiResponse<DtoJob>> {
if (requestParameters["body"] == null) {
throw new runtime.RequiredError(
"body",
'Required parameter "body" was null or undefined when calling adminEnqueueArcherJob().',
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
headerParameters["Content-Type"] = "application/json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] =
await this.configuration.apiKey("Authorization"); // BearerAuth authentication
}
let urlPath = `/admin/archer/jobs`;
const response = await this.request(
{
path: urlPath,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: requestParameters["body"] as any,
},
initOverrides,
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
DtoJobFromJSON(jsonValue),
);
}
/**
* Create a job immediately or schedule it for the future via `run_at`.
* Enqueue a new Archer job (admin)
*/
async adminEnqueueArcherJob(
requestParameters: AdminEnqueueArcherJobRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<DtoJob> {
const response = await this.adminEnqueueArcherJobRaw(
requestParameters,
initOverrides,
);
return await response.value();
}
/**
* Paginated background jobs with optional filters. Search `q` may match id, type, error, payload (implementation-dependent).
* List Archer jobs (admin)
*/
async adminListArcherJobsRaw(
requestParameters: AdminListArcherJobsRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<runtime.ApiResponse<DtoPageJob>> {
const queryParameters: any = {};
if (requestParameters["status"] != null) {
queryParameters["status"] = requestParameters["status"];
}
if (requestParameters["queue"] != null) {
queryParameters["queue"] = requestParameters["queue"];
}
if (requestParameters["q"] != null) {
queryParameters["q"] = requestParameters["q"];
}
if (requestParameters["page"] != null) {
queryParameters["page"] = requestParameters["page"];
}
if (requestParameters["pageSize"] != null) {
queryParameters["page_size"] = requestParameters["pageSize"];
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] =
await this.configuration.apiKey("Authorization"); // BearerAuth authentication
}
let urlPath = `/admin/archer/jobs`;
const response = await this.request(
{
path: urlPath,
method: "GET",
headers: headerParameters,
query: queryParameters,
},
initOverrides,
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
DtoPageJobFromJSON(jsonValue),
);
}
/**
* Paginated background jobs with optional filters. Search `q` may match id, type, error, payload (implementation-dependent).
* List Archer jobs (admin)
*/
async adminListArcherJobs(
requestParameters: AdminListArcherJobsRequest = {},
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<DtoPageJob> {
const response = await this.adminListArcherJobsRaw(
requestParameters,
initOverrides,
);
return await response.value();
}
/**
* Summary metrics per queue (pending, running, failed, scheduled).
* List Archer queues (admin)
*/
async adminListArcherQueuesRaw(
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<runtime.ApiResponse<Array<DtoQueueInfo>>> {
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] =
await this.configuration.apiKey("Authorization"); // BearerAuth authentication
}
let urlPath = `/admin/archer/queues`;
const response = await this.request(
{
path: urlPath,
method: "GET",
headers: headerParameters,
query: queryParameters,
},
initOverrides,
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
jsonValue.map(DtoQueueInfoFromJSON),
);
}
/**
* Summary metrics per queue (pending, running, failed, scheduled).
* List Archer queues (admin)
*/
async adminListArcherQueues(
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<Array<DtoQueueInfo>> {
const response = await this.adminListArcherQueuesRaw(initOverrides);
return await response.value();
}
/**
* Marks the job retriable (DB flip). Swap this for an Archer admin call if you expose one.
* Retry a failed/canceled Archer job (admin)
*/
async adminRetryArcherJobRaw(
requestParameters: AdminRetryArcherJobRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<runtime.ApiResponse<DtoJob>> {
if (requestParameters["id"] == null) {
throw new runtime.RequiredError(
"id",
'Required parameter "id" was null or undefined when calling adminRetryArcherJob().',
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] =
await this.configuration.apiKey("Authorization"); // BearerAuth authentication
}
let urlPath = `/admin/archer/jobs/{id}/retry`;
urlPath = urlPath.replace(
`{${"id"}}`,
encodeURIComponent(String(requestParameters["id"])),
);
const response = await this.request(
{
path: urlPath,
method: "POST",
headers: headerParameters,
query: queryParameters,
},
initOverrides,
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
DtoJobFromJSON(jsonValue),
);
}
/**
* Marks the job retriable (DB flip). Swap this for an Archer admin call if you expose one.
* Retry a failed/canceled Archer job (admin)
*/
async adminRetryArcherJob(
requestParameters: AdminRetryArcherJobRequest,
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<DtoJob> {
const response = await this.adminRetryArcherJobRaw(
requestParameters,
initOverrides,
);
return await response.value();
}
}
/**
* @export
*/
export const AdminListArcherJobsStatusEnum = {
queued: "queued",
running: "running",
succeeded: "succeeded",
failed: "failed",
canceled: "canceled",
retrying: "retrying",
scheduled: "scheduled",
} as const;
export type AdminListArcherJobsStatusEnum =
(typeof AdminListArcherJobsStatusEnum)[keyof typeof AdminListArcherJobsStatusEnum];

View File

@@ -1,6 +1,7 @@
/* tslint:disable */
/* eslint-disable */
export * from "./AnnotationsApi";
export * from "./ArcherAdminApi";
export * from "./AuthApi";
export * from "./HealthApi";
export * from "./LabelsApi";