From 17289a123367c8f7f8d8795be838464ca790a9a5 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Wed, 5 Jun 2024 15:29:35 +0000 Subject: [PATCH] feat: update generated APIs --- .../clients/src/api/jobs/v1alpha1/api.gen.ts | 18 ++++++++++++ .../src/api/jobs/v1alpha1/index.gen.ts | 3 ++ .../src/api/jobs/v1alpha1/marshalling.gen.ts | 29 +++++++++++++++++++ .../src/api/jobs/v1alpha1/types.gen.ts | 17 +++++++++++ 4 files changed, 67 insertions(+) diff --git a/packages/clients/src/api/jobs/v1alpha1/api.gen.ts b/packages/clients/src/api/jobs/v1alpha1/api.gen.ts index 550502fe9..99e98a7b1 100644 --- a/packages/clients/src/api/jobs/v1alpha1/api.gen.ts +++ b/packages/clients/src/api/jobs/v1alpha1/api.gen.ts @@ -15,6 +15,7 @@ import { unmarshalJobRun, unmarshalListJobDefinitionsResponse, unmarshalListJobRunsResponse, + unmarshalListJobsResourcesResponse, unmarshalStartJobDefinitionResponse, } from './marshalling.gen' import type { @@ -28,6 +29,8 @@ import type { ListJobDefinitionsResponse, ListJobRunsRequest, ListJobRunsResponse, + ListJobsResourcesRequest, + ListJobsResourcesResponse, StartJobDefinitionRequest, StartJobDefinitionResponse, StopJobRunRequest, @@ -226,4 +229,19 @@ export class API extends ParentAPI { */ listJobRuns = (request: Readonly = {}) => enrichForPagination('jobRuns', this.pageOfListJobRuns, request) + + /** + * List jobs resources for the console. + * + * @param request - The request {@link ListJobsResourcesRequest} + * @returns A Promise of ListJobsResourcesResponse + */ + listJobsResources = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/serverless-jobs/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/jobs-resources`, + }, + unmarshalListJobsResourcesResponse, + ) } diff --git a/packages/clients/src/api/jobs/v1alpha1/index.gen.ts b/packages/clients/src/api/jobs/v1alpha1/index.gen.ts index 8e85e29f8..d6fe68eb6 100644 --- a/packages/clients/src/api/jobs/v1alpha1/index.gen.ts +++ b/packages/clients/src/api/jobs/v1alpha1/index.gen.ts @@ -18,6 +18,9 @@ export type { ListJobRunsRequest, ListJobRunsRequestOrderBy, ListJobRunsResponse, + ListJobsResourcesRequest, + ListJobsResourcesResponse, + Resource, StartJobDefinitionRequest, StartJobDefinitionResponse, StopJobRunRequest, diff --git a/packages/clients/src/api/jobs/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/jobs/v1alpha1/marshalling.gen.ts index 9786c5e6e..9ef49a320 100644 --- a/packages/clients/src/api/jobs/v1alpha1/marshalling.gen.ts +++ b/packages/clients/src/api/jobs/v1alpha1/marshalling.gen.ts @@ -15,6 +15,8 @@ import type { JobRun, ListJobDefinitionsResponse, ListJobRunsResponse, + ListJobsResourcesResponse, + Resource, StartJobDefinitionRequest, StartJobDefinitionResponse, UpdateJobDefinitionRequest, @@ -122,6 +124,33 @@ export const unmarshalListJobRunsResponse = ( } as ListJobRunsResponse } +const unmarshalResource = (data: unknown): Resource => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Resource' failed as data isn't a dictionary.`, + ) + } + + return { + cpuLimit: data.cpu_limit, + memoryLimit: data.memory_limit, + } as Resource +} + +export const unmarshalListJobsResourcesResponse = ( + data: unknown, +): ListJobsResourcesResponse => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListJobsResourcesResponse' failed as data isn't a dictionary.`, + ) + } + + return { + resources: unmarshalArrayOfObject(data.resources, unmarshalResource), + } as ListJobsResourcesResponse +} + export const unmarshalStartJobDefinitionResponse = ( data: unknown, ): StartJobDefinitionResponse => { diff --git a/packages/clients/src/api/jobs/v1alpha1/types.gen.ts b/packages/clients/src/api/jobs/v1alpha1/types.gen.ts index 5e3392070..9e18cfb27 100644 --- a/packages/clients/src/api/jobs/v1alpha1/types.gen.ts +++ b/packages/clients/src/api/jobs/v1alpha1/types.gen.ts @@ -78,6 +78,11 @@ export interface JobRun { region: Region } +export interface Resource { + cpuLimit: number + memoryLimit: number +} + export interface UpdateJobDefinitionRequestCronScheduleConfig { schedule?: string timezone?: string @@ -182,6 +187,18 @@ export interface ListJobRunsResponse { totalCount: number } +export type ListJobsResourcesRequest = { + /** + * Region to target. If none is passed will use default region from the + * config. + */ + region?: Region +} + +export interface ListJobsResourcesResponse { + resources: Resource[] +} + export type StartJobDefinitionRequest = { /** * Region to target. If none is passed will use default region from the