From a214a4cac9a8fb605f04cc84a9b14fcd158ff08e Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Wed, 13 Dec 2023 14:40:45 -0800 Subject: [PATCH 1/2] Update omicron version and generated files --- OMICRON_VERSION | 2 +- libs/api/__generated__/Api.ts | 99 ++++++++++++++++++++++++++ libs/api/__generated__/OMICRON_VERSION | 2 +- libs/api/__generated__/msw-handlers.ts | 35 +++++++++ libs/api/__generated__/validate.ts | 71 ++++++++++++++++++ 5 files changed, 207 insertions(+), 2 deletions(-) diff --git a/OMICRON_VERSION b/OMICRON_VERSION index fdfa5c83bd..e9d15590bf 100644 --- a/OMICRON_VERSION +++ b/OMICRON_VERSION @@ -1 +1 @@ -8fa550c2c95b5fd3443af7e2e5837c2178fdb8c8 +7c3cd6abe9d957a51465209497064fb133854932 diff --git a/libs/api/__generated__/Api.ts b/libs/api/__generated__/Api.ts index 751f3cda5c..5499329d69 100644 --- a/libs/api/__generated__/Api.ts +++ b/libs/api/__generated__/Api.ts @@ -1831,6 +1831,18 @@ The default is that no Fleet roles are conferred by any Silo roles unless there' timeModified: Date } +/** + * The amount of provisionable resources for a Silo + */ +export type SiloQuotasCreate = { + /** The amount of virtual CPUs available for running instances in the Silo */ + cpus: number + /** The amount of RAM (in bytes) available for running instances in the Silo */ + memory: ByteCount + /** The amount of storage (in bytes) available for disks or snapshots */ + storage: ByteCount +} + /** * Create-time parameters for a `Silo` */ @@ -1847,10 +1859,41 @@ Note that if configuring a SAML based identity provider, group_attribute_name mu The default is that no Fleet roles are conferred by any Silo roles unless there's a corresponding entry in this map. */ mappedFleetRoles?: Record name: Name + /** Limits the amount of provisionable CPU, memory, and storage in the Silo. CPU and memory are only consumed by running instances, while storage is consumed by any disk or snapshot. A value of 0 means that resource is *not* provisionable. */ + quotas: SiloQuotasCreate /** Initial TLS certificates to be used for the new Silo's console and API endpoints. These should be valid for the Silo's DNS name(s). */ tlsCertificates: CertificateCreate[] } +export type SiloQuotas = { + cpus: number + memory: ByteCount + siloId: string + storage: ByteCount +} + +/** + * A single page of results + */ +export type SiloQuotasResultsPage = { + /** list of items on this page of results */ + items: SiloQuotas[] + /** token used to fetch the next page of results (if any) */ + nextPage?: string +} + +/** + * Updateable properties of a Silo's resource limits. If a value is omitted it will not be updated. + */ +export type SiloQuotasUpdate = { + /** The amount of virtual CPUs available for running instances in the Silo */ + cpus?: number + /** The amount of RAM (in bytes) available for running instances in the Silo */ + memory?: ByteCount + /** The amount of storage (in bytes) available for disks or snapshots */ + storage?: ByteCount +} + /** * A single page of results */ @@ -3345,6 +3388,12 @@ export interface RoleViewPathParams { roleName: string } +export interface SystemQuotasListQueryParams { + limit?: number + pageToken?: string + sortBy?: IdSortMode +} + export interface SiloListQueryParams { limit?: number pageToken?: string @@ -3367,6 +3416,14 @@ export interface SiloPolicyUpdatePathParams { silo: NameOrId } +export interface SiloQuotasViewPathParams { + silo: NameOrId +} + +export interface SiloQuotasUpdatePathParams { + silo: NameOrId +} + export interface SiloUserListQueryParams { limit?: number pageToken?: string @@ -3531,6 +3588,7 @@ export type ApiListMethods = Pick< | 'networkingLoopbackAddressList' | 'networkingSwitchPortSettingsList' | 'roleList' + | 'systemQuotasList' | 'siloList' | 'siloUserList' | 'userBuiltinList' @@ -5448,6 +5506,20 @@ export class Api extends HttpClient { ...params, }) }, + /** + * Lists resource quotas for all silos + */ + systemQuotasList: ( + { query = {} }: { query?: SystemQuotasListQueryParams }, + params: FetchParams = {} + ) => { + return this.request({ + path: `/v1/system/silo-quotas`, + method: 'GET', + query, + ...params, + }) + }, /** * List silos */ @@ -5520,6 +5592,33 @@ export class Api extends HttpClient { ...params, }) }, + /** + * View the resource quotas of a given silo + */ + siloQuotasView: ( + { path }: { path: SiloQuotasViewPathParams }, + params: FetchParams = {} + ) => { + return this.request({ + path: `/v1/system/silos/${path.silo}/quotas`, + method: 'GET', + ...params, + }) + }, + /** + * Update the resource quotas of a given silo + */ + siloQuotasUpdate: ( + { path, body }: { path: SiloQuotasUpdatePathParams; body: SiloQuotasUpdate }, + params: FetchParams = {} + ) => { + return this.request({ + path: `/v1/system/silos/${path.silo}/quotas`, + method: 'PUT', + body, + ...params, + }) + }, /** * List built-in (system) users in a silo */ diff --git a/libs/api/__generated__/OMICRON_VERSION b/libs/api/__generated__/OMICRON_VERSION index 117cb33b83..8add66e315 100644 --- a/libs/api/__generated__/OMICRON_VERSION +++ b/libs/api/__generated__/OMICRON_VERSION @@ -1,2 +1,2 @@ # generated file. do not update manually. see docs/update-pinned-api.md -8fa550c2c95b5fd3443af7e2e5837c2178fdb8c8 +7c3cd6abe9d957a51465209497064fb133854932 diff --git a/libs/api/__generated__/msw-handlers.ts b/libs/api/__generated__/msw-handlers.ts index 74206a56c3..b9df76c406 100644 --- a/libs/api/__generated__/msw-handlers.ts +++ b/libs/api/__generated__/msw-handlers.ts @@ -880,6 +880,12 @@ export interface MSWHandlers { req: Request cookies: Record }) => Promisable> + /** `GET /v1/system/silo-quotas` */ + systemQuotasList: (params: { + query: Api.SystemQuotasListQueryParams + req: Request + cookies: Record + }) => Promisable> /** `GET /v1/system/silos` */ siloList: (params: { query: Api.SiloListQueryParams @@ -917,6 +923,19 @@ export interface MSWHandlers { req: Request cookies: Record }) => Promisable> + /** `GET /v1/system/silos/:silo/quotas` */ + siloQuotasView: (params: { + path: Api.SiloQuotasViewPathParams + req: Request + cookies: Record + }) => Promisable> + /** `PUT /v1/system/silos/:silo/quotas` */ + siloQuotasUpdate: (params: { + path: Api.SiloQuotasUpdatePathParams + body: Json + req: Request + cookies: Record + }) => Promisable> /** `GET /v1/system/users` */ siloUserList: (params: { query: Api.SiloUserListQueryParams @@ -1793,6 +1812,10 @@ export function makeHandlers(handlers: MSWHandlers): HttpHandler[] { '/v1/system/roles/:roleName', handler(handlers['roleView'], schema.RoleViewParams, null) ), + http.get( + '/v1/system/silo-quotas', + handler(handlers['systemQuotasList'], schema.SystemQuotasListParams, null) + ), http.get( '/v1/system/silos', handler(handlers['siloList'], schema.SiloListParams, null) @@ -1818,6 +1841,18 @@ export function makeHandlers(handlers: MSWHandlers): HttpHandler[] { schema.SiloRolePolicy ) ), + http.get( + '/v1/system/silos/:silo/quotas', + handler(handlers['siloQuotasView'], schema.SiloQuotasViewParams, null) + ), + http.put( + '/v1/system/silos/:silo/quotas', + handler( + handlers['siloQuotasUpdate'], + schema.SiloQuotasUpdateParams, + schema.SiloQuotasUpdate + ) + ), http.get( '/v1/system/users', handler(handlers['siloUserList'], schema.SiloUserListParams, null) diff --git a/libs/api/__generated__/validate.ts b/libs/api/__generated__/validate.ts index e5e5ee6921..568d2a634c 100644 --- a/libs/api/__generated__/validate.ts +++ b/libs/api/__generated__/validate.ts @@ -1893,6 +1893,14 @@ export const Silo = z.preprocess( }) ) +/** + * The amount of provisionable resources for a Silo + */ +export const SiloQuotasCreate = z.preprocess( + processResponseBody, + z.object({ cpus: z.number(), memory: ByteCount, storage: ByteCount }) +) + /** * Create-time parameters for a `Silo` */ @@ -1907,10 +1915,41 @@ export const SiloCreate = z.preprocess( .record(z.string().min(1), FleetRole.array().refine(...uniqueItems)) .optional(), name: Name, + quotas: SiloQuotasCreate, tlsCertificates: CertificateCreate.array(), }) ) +export const SiloQuotas = z.preprocess( + processResponseBody, + z.object({ + cpus: z.number(), + memory: ByteCount, + siloId: z.string().uuid(), + storage: ByteCount, + }) +) + +/** + * A single page of results + */ +export const SiloQuotasResultsPage = z.preprocess( + processResponseBody, + z.object({ items: SiloQuotas.array(), nextPage: z.string().optional() }) +) + +/** + * Updateable properties of a Silo's resource limits. If a value is omitted it will not be updated. + */ +export const SiloQuotasUpdate = z.preprocess( + processResponseBody, + z.object({ + cpus: z.number().optional(), + memory: ByteCount.optional(), + storage: ByteCount.optional(), + }) +) + /** * A single page of results */ @@ -4097,6 +4136,18 @@ export const RoleViewParams = z.preprocess( }) ) +export const SystemQuotasListParams = z.preprocess( + processResponseBody, + z.object({ + path: z.object({}), + query: z.object({ + limit: z.number().min(1).max(4294967295).optional(), + pageToken: z.string().optional(), + sortBy: IdSortMode.optional(), + }), + }) +) + export const SiloListParams = z.preprocess( processResponseBody, z.object({ @@ -4157,6 +4208,26 @@ export const SiloPolicyUpdateParams = z.preprocess( }) ) +export const SiloQuotasViewParams = z.preprocess( + processResponseBody, + z.object({ + path: z.object({ + silo: NameOrId, + }), + query: z.object({}), + }) +) + +export const SiloQuotasUpdateParams = z.preprocess( + processResponseBody, + z.object({ + path: z.object({ + silo: NameOrId, + }), + query: z.object({}), + }) +) + export const SiloUserListParams = z.preprocess( processResponseBody, z.object({ From e4ff0a2f3b315ea10069c7d9a3fed1123939db33 Mon Sep 17 00:00:00 2001 From: Charlie Park Date: Wed, 13 Dec 2023 15:41:10 -0800 Subject: [PATCH 2/2] Add a few temporary mock endpoints; update form --- app/forms/silo-create.tsx | 5 +++++ libs/api-mocks/msw/handlers.ts | 3 +++ 2 files changed, 8 insertions(+) diff --git a/app/forms/silo-create.tsx b/app/forms/silo-create.tsx index 29dccc64d5..1613e61805 100644 --- a/app/forms/silo-create.tsx +++ b/app/forms/silo-create.tsx @@ -36,6 +36,11 @@ const defaultValues: SiloCreateFormValues = { tlsCertificates: [], siloAdminGetsFleetAdmin: false, siloViewerGetsFleetViewer: false, + quotas: { + cpus: 0, + memory: 0, + storage: 0, + }, } export function CreateSiloSideModalForm() { diff --git a/libs/api-mocks/msw/handlers.ts b/libs/api-mocks/msw/handlers.ts index 1313d364e4..29b05417de 100644 --- a/libs/api-mocks/msw/handlers.ts +++ b/libs/api-mocks/msw/handlers.ts @@ -1002,12 +1002,15 @@ export const handlers = makeHandlers({ roleView: NotImplemented, siloPolicyUpdate: NotImplemented, siloPolicyView: NotImplemented, + siloQuotasUpdate: NotImplemented, + siloQuotasView: NotImplemented, siloUserList: NotImplemented, siloUserView: NotImplemented, sledSetProvisionState: NotImplemented, switchList: NotImplemented, switchView: NotImplemented, systemPolicyUpdate: NotImplemented, + systemQuotasList: NotImplemented, uninitializedSledList: NotImplemented, userBuiltinList: NotImplemented, userBuiltinView: NotImplemented,