diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index b7e2bab..e7308b9 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -19,16 +19,22 @@ jobs: - uses: actions/setup-node@v4 with: node-version: "18" + - working-directory: "./oxide-api" + run: npm install + - name: Typecheck client + working-directory: "./oxide-api" + run: npm run tsc - working-directory: "./oxide-openapi-gen-ts" run: npm install + # TODO: this probably doesn't make sense anymore, it should be done already - name: Generate client run: "./tools/gen.sh" - - name: Typecheck + - name: Typecheck generator working-directory: "./oxide-openapi-gen-ts" run: npm run tsc - - name: Lint + - name: Lint generator working-directory: "./oxide-openapi-gen-ts" run: npm run lint - - name: Test + - name: Test generator working-directory: "./oxide-openapi-gen-ts" run: npm test run diff --git a/oxide-api/README.md b/oxide-api/README.md index 71b3bd6..fd55a62 100644 --- a/oxide-api/README.md +++ b/oxide-api/README.md @@ -51,11 +51,3 @@ if (result.type === "success") { ### Request bodies ### Responses: `ApiResult` - -## Other stuff in the package - -Most likely nobody but us wants this, and we should take it out of the npm package. - -### Mock Service Worker API skeleton - -### Zod validators diff --git a/oxide-api/package-lock.json b/oxide-api/package-lock.json index 7975c5a..774aeda 100644 --- a/oxide-api/package-lock.json +++ b/oxide-api/package-lock.json @@ -1,16 +1,13 @@ { "name": "@oxide/api", - "version": "0.1.0-alpha.4", + "version": "0.1.0-alpha.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@oxide/api", - "version": "0.1.0-alpha.4", + "version": "0.1.0-alpha.5", "license": "MPL-2.0", - "dependencies": { - "zod": "^3.23.6" - }, "devDependencies": { "tsup": "^8.0.2", "typescript": "^5.4.5" @@ -2053,14 +2050,6 @@ "engines": { "node": ">= 14" } - }, - "node_modules/zod": { - "version": "3.23.6", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.6.tgz", - "integrity": "sha512-RTHJlZhsRbuA8Hmp/iNL7jnfc4nZishjsanDAfEY1QpDQZCahUp3xDzl+zfweE9BklxMUcgBgS1b7Lvie/ZVwA==", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } } } } diff --git a/oxide-api/package.json b/oxide-api/package.json index b0444aa..5e354b3 100644 --- a/oxide-api/package.json +++ b/oxide-api/package.json @@ -1,6 +1,6 @@ { "name": "@oxide/api", - "version": "0.1.0-alpha.4", + "version": "0.1.0-alpha.5", "description": "TypeScript client for the Oxide API", "engines": { "node": ">=18" @@ -19,7 +19,8 @@ }, "scripts": { "build": "tsup --dts", - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "tsc": "tsc" }, "repository": { "type": "git", @@ -50,8 +51,5 @@ "cjs", "esm" ] - }, - "dependencies": { - "zod": "^3.23.6" } } diff --git a/oxide-api/src/msw-handlers.ts b/oxide-api/src/msw-handlers.ts deleted file mode 100644 index 5de6227..0000000 --- a/oxide-api/src/msw-handlers.ts +++ /dev/null @@ -1,2358 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * Copyright Oxide Computer Company - */ - -import { - http, - type HttpHandler, - HttpResponse, - type StrictResponse, - type PathParams, -} from "msw"; -import type { - SnakeCasedPropertiesDeep as Snakify, - Promisable, -} from "type-fest"; -import { type ZodSchema } from "zod"; -import type * as Api from "./Api"; -import { snakeify } from "./util"; -import * as schema from "./validate"; - -type HandlerResult = Json | StrictResponse>; -type StatusCode = number; - -// these are used for turning our nice JS-ified API types back into the original -// API JSON types (snake cased and dates as strings) for use in our mock API - -type StringifyDates = T extends Date - ? string - : { - [K in keyof T]: T[K] extends Array - ? Array> - : StringifyDates; - }; - -/** - * Snake case fields and convert dates to strings. Not intended to be a general - * purpose JSON type! - */ -export type Json = Snakify>; -export const json = HttpResponse.json; - -// Shortcut to reduce number of imports required in consumers -export { HttpResponse }; - -export interface MSWHandlers { - /** `POST /device/auth` */ - deviceAuthRequest: (params: { - req: Request; - cookies: Record; - }) => Promisable; - /** `POST /device/confirm` */ - deviceAuthConfirm: (params: { - body: Json; - req: Request; - cookies: Record; - }) => Promisable; - /** `POST /device/token` */ - deviceAccessToken: (params: { - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /experimental/v1/probes` */ - probeList: (params: { - query: Api.ProbeListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /experimental/v1/probes` */ - probeCreate: (params: { - query: Api.ProbeCreateQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /experimental/v1/probes/:probe` */ - probeView: (params: { - path: Api.ProbeViewPathParams; - query: Api.ProbeViewQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /experimental/v1/probes/:probe` */ - probeDelete: (params: { - path: Api.ProbeDeletePathParams; - query: Api.ProbeDeleteQueryParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `POST /login/:siloName/saml/:providerName` */ - loginSaml: (params: { - path: Api.LoginSamlPathParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/certificates` */ - certificateList: (params: { - query: Api.CertificateListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/certificates` */ - certificateCreate: (params: { - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/certificates/:certificate` */ - certificateView: (params: { - path: Api.CertificateViewPathParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/certificates/:certificate` */ - certificateDelete: (params: { - path: Api.CertificateDeletePathParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/disks` */ - diskList: (params: { - query: Api.DiskListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/disks` */ - diskCreate: (params: { - query: Api.DiskCreateQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/disks/:disk` */ - diskView: (params: { - path: Api.DiskViewPathParams; - query: Api.DiskViewQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/disks/:disk` */ - diskDelete: (params: { - path: Api.DiskDeletePathParams; - query: Api.DiskDeleteQueryParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `POST /v1/disks/:disk/bulk-write` */ - diskBulkWriteImport: (params: { - path: Api.DiskBulkWriteImportPathParams; - query: Api.DiskBulkWriteImportQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable; - /** `POST /v1/disks/:disk/bulk-write-start` */ - diskBulkWriteImportStart: (params: { - path: Api.DiskBulkWriteImportStartPathParams; - query: Api.DiskBulkWriteImportStartQueryParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `POST /v1/disks/:disk/bulk-write-stop` */ - diskBulkWriteImportStop: (params: { - path: Api.DiskBulkWriteImportStopPathParams; - query: Api.DiskBulkWriteImportStopQueryParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `POST /v1/disks/:disk/finalize` */ - diskFinalizeImport: (params: { - path: Api.DiskFinalizeImportPathParams; - query: Api.DiskFinalizeImportQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/disks/:disk/metrics/:metric` */ - diskMetricsList: (params: { - path: Api.DiskMetricsListPathParams; - query: Api.DiskMetricsListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/floating-ips` */ - floatingIpList: (params: { - query: Api.FloatingIpListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/floating-ips` */ - floatingIpCreate: (params: { - query: Api.FloatingIpCreateQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/floating-ips/:floatingIp` */ - floatingIpView: (params: { - path: Api.FloatingIpViewPathParams; - query: Api.FloatingIpViewQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `PUT /v1/floating-ips/:floatingIp` */ - floatingIpUpdate: (params: { - path: Api.FloatingIpUpdatePathParams; - query: Api.FloatingIpUpdateQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/floating-ips/:floatingIp` */ - floatingIpDelete: (params: { - path: Api.FloatingIpDeletePathParams; - query: Api.FloatingIpDeleteQueryParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `POST /v1/floating-ips/:floatingIp/attach` */ - floatingIpAttach: (params: { - path: Api.FloatingIpAttachPathParams; - query: Api.FloatingIpAttachQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/floating-ips/:floatingIp/detach` */ - floatingIpDetach: (params: { - path: Api.FloatingIpDetachPathParams; - query: Api.FloatingIpDetachQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/groups` */ - groupList: (params: { - query: Api.GroupListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/groups/:groupId` */ - groupView: (params: { - path: Api.GroupViewPathParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/images` */ - imageList: (params: { - query: Api.ImageListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/images` */ - imageCreate: (params: { - query: Api.ImageCreateQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/images/:image` */ - imageView: (params: { - path: Api.ImageViewPathParams; - query: Api.ImageViewQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/images/:image` */ - imageDelete: (params: { - path: Api.ImageDeletePathParams; - query: Api.ImageDeleteQueryParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `POST /v1/images/:image/demote` */ - imageDemote: (params: { - path: Api.ImageDemotePathParams; - query: Api.ImageDemoteQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/images/:image/promote` */ - imagePromote: (params: { - path: Api.ImagePromotePathParams; - query: Api.ImagePromoteQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/instances` */ - instanceList: (params: { - query: Api.InstanceListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/instances` */ - instanceCreate: (params: { - query: Api.InstanceCreateQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/instances/:instance` */ - instanceView: (params: { - path: Api.InstanceViewPathParams; - query: Api.InstanceViewQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/instances/:instance` */ - instanceDelete: (params: { - path: Api.InstanceDeletePathParams; - query: Api.InstanceDeleteQueryParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/instances/:instance/disks` */ - instanceDiskList: (params: { - path: Api.InstanceDiskListPathParams; - query: Api.InstanceDiskListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/instances/:instance/disks/attach` */ - instanceDiskAttach: (params: { - path: Api.InstanceDiskAttachPathParams; - query: Api.InstanceDiskAttachQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/instances/:instance/disks/detach` */ - instanceDiskDetach: (params: { - path: Api.InstanceDiskDetachPathParams; - query: Api.InstanceDiskDetachQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/instances/:instance/external-ips` */ - instanceExternalIpList: (params: { - path: Api.InstanceExternalIpListPathParams; - query: Api.InstanceExternalIpListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/instances/:instance/external-ips/ephemeral` */ - instanceEphemeralIpAttach: (params: { - path: Api.InstanceEphemeralIpAttachPathParams; - query: Api.InstanceEphemeralIpAttachQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/instances/:instance/external-ips/ephemeral` */ - instanceEphemeralIpDetach: (params: { - path: Api.InstanceEphemeralIpDetachPathParams; - query: Api.InstanceEphemeralIpDetachQueryParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `POST /v1/instances/:instance/migrate` */ - instanceMigrate: (params: { - path: Api.InstanceMigratePathParams; - query: Api.InstanceMigrateQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/instances/:instance/reboot` */ - instanceReboot: (params: { - path: Api.InstanceRebootPathParams; - query: Api.InstanceRebootQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/instances/:instance/serial-console` */ - instanceSerialConsole: (params: { - path: Api.InstanceSerialConsolePathParams; - query: Api.InstanceSerialConsoleQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/instances/:instance/serial-console/stream` */ - instanceSerialConsoleStream: (params: { - path: Api.InstanceSerialConsoleStreamPathParams; - query: Api.InstanceSerialConsoleStreamQueryParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/instances/:instance/ssh-public-keys` */ - instanceSshPublicKeyList: (params: { - path: Api.InstanceSshPublicKeyListPathParams; - query: Api.InstanceSshPublicKeyListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/instances/:instance/start` */ - instanceStart: (params: { - path: Api.InstanceStartPathParams; - query: Api.InstanceStartQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/instances/:instance/stop` */ - instanceStop: (params: { - path: Api.InstanceStopPathParams; - query: Api.InstanceStopQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/ip-pools` */ - projectIpPoolList: (params: { - query: Api.ProjectIpPoolListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/ip-pools/:pool` */ - projectIpPoolView: (params: { - path: Api.ProjectIpPoolViewPathParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/login/:siloName/local` */ - loginLocal: (params: { - path: Api.LoginLocalPathParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable; - /** `POST /v1/logout` */ - logout: (params: { - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/me` */ - currentUserView: (params: { - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/me/groups` */ - currentUserGroups: (params: { - query: Api.CurrentUserGroupsQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/me/ssh-keys` */ - currentUserSshKeyList: (params: { - query: Api.CurrentUserSshKeyListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/me/ssh-keys` */ - currentUserSshKeyCreate: (params: { - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/me/ssh-keys/:sshKey` */ - currentUserSshKeyView: (params: { - path: Api.CurrentUserSshKeyViewPathParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/me/ssh-keys/:sshKey` */ - currentUserSshKeyDelete: (params: { - path: Api.CurrentUserSshKeyDeletePathParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/metrics/:metricName` */ - siloMetric: (params: { - path: Api.SiloMetricPathParams; - query: Api.SiloMetricQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/network-interfaces` */ - instanceNetworkInterfaceList: (params: { - query: Api.InstanceNetworkInterfaceListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/network-interfaces` */ - instanceNetworkInterfaceCreate: (params: { - query: Api.InstanceNetworkInterfaceCreateQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/network-interfaces/:interface` */ - instanceNetworkInterfaceView: (params: { - path: Api.InstanceNetworkInterfaceViewPathParams; - query: Api.InstanceNetworkInterfaceViewQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `PUT /v1/network-interfaces/:interface` */ - instanceNetworkInterfaceUpdate: (params: { - path: Api.InstanceNetworkInterfaceUpdatePathParams; - query: Api.InstanceNetworkInterfaceUpdateQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/network-interfaces/:interface` */ - instanceNetworkInterfaceDelete: (params: { - path: Api.InstanceNetworkInterfaceDeletePathParams; - query: Api.InstanceNetworkInterfaceDeleteQueryParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/ping` */ - ping: (params: { - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/policy` */ - policyView: (params: { - req: Request; - cookies: Record; - }) => Promisable>; - /** `PUT /v1/policy` */ - policyUpdate: (params: { - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/projects` */ - projectList: (params: { - query: Api.ProjectListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/projects` */ - projectCreate: (params: { - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/projects/:project` */ - projectView: (params: { - path: Api.ProjectViewPathParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `PUT /v1/projects/:project` */ - projectUpdate: (params: { - path: Api.ProjectUpdatePathParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/projects/:project` */ - projectDelete: (params: { - path: Api.ProjectDeletePathParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/projects/:project/policy` */ - projectPolicyView: (params: { - path: Api.ProjectPolicyViewPathParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `PUT /v1/projects/:project/policy` */ - projectPolicyUpdate: (params: { - path: Api.ProjectPolicyUpdatePathParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/snapshots` */ - snapshotList: (params: { - query: Api.SnapshotListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/snapshots` */ - snapshotCreate: (params: { - query: Api.SnapshotCreateQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/snapshots/:snapshot` */ - snapshotView: (params: { - path: Api.SnapshotViewPathParams; - query: Api.SnapshotViewQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/snapshots/:snapshot` */ - snapshotDelete: (params: { - path: Api.SnapshotDeletePathParams; - query: Api.SnapshotDeleteQueryParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/system/hardware/disks` */ - physicalDiskList: (params: { - query: Api.PhysicalDiskListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/hardware/racks` */ - rackList: (params: { - query: Api.RackListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/hardware/racks/:rackId` */ - rackView: (params: { - path: Api.RackViewPathParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/hardware/sleds` */ - sledList: (params: { - query: Api.SledListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/system/hardware/sleds` */ - sledAdd: (params: { - body: Json; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/system/hardware/sleds/:sledId` */ - sledView: (params: { - path: Api.SledViewPathParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/hardware/sleds/:sledId/disks` */ - sledPhysicalDiskList: (params: { - path: Api.SledPhysicalDiskListPathParams; - query: Api.SledPhysicalDiskListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/hardware/sleds/:sledId/instances` */ - sledInstanceList: (params: { - path: Api.SledInstanceListPathParams; - query: Api.SledInstanceListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `PUT /v1/system/hardware/sleds/:sledId/provision-policy` */ - sledSetProvisionPolicy: (params: { - path: Api.SledSetProvisionPolicyPathParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/hardware/sleds-uninitialized` */ - sledListUninitialized: (params: { - query: Api.SledListUninitializedQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/hardware/switch-port` */ - networkingSwitchPortList: (params: { - query: Api.NetworkingSwitchPortListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/system/hardware/switch-port/:port/settings` */ - networkingSwitchPortApplySettings: (params: { - path: Api.NetworkingSwitchPortApplySettingsPathParams; - query: Api.NetworkingSwitchPortApplySettingsQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable; - /** `DELETE /v1/system/hardware/switch-port/:port/settings` */ - networkingSwitchPortClearSettings: (params: { - path: Api.NetworkingSwitchPortClearSettingsPathParams; - query: Api.NetworkingSwitchPortClearSettingsQueryParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/system/hardware/switches` */ - switchList: (params: { - query: Api.SwitchListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/hardware/switches/:switchId` */ - switchView: (params: { - path: Api.SwitchViewPathParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/identity-providers` */ - siloIdentityProviderList: (params: { - query: Api.SiloIdentityProviderListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/system/identity-providers/local/users` */ - localIdpUserCreate: (params: { - query: Api.LocalIdpUserCreateQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/system/identity-providers/local/users/:userId` */ - localIdpUserDelete: (params: { - path: Api.LocalIdpUserDeletePathParams; - query: Api.LocalIdpUserDeleteQueryParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `POST /v1/system/identity-providers/local/users/:userId/set-password` */ - localIdpUserSetPassword: (params: { - path: Api.LocalIdpUserSetPasswordPathParams; - query: Api.LocalIdpUserSetPasswordQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable; - /** `POST /v1/system/identity-providers/saml` */ - samlIdentityProviderCreate: (params: { - query: Api.SamlIdentityProviderCreateQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/identity-providers/saml/:provider` */ - samlIdentityProviderView: (params: { - path: Api.SamlIdentityProviderViewPathParams; - query: Api.SamlIdentityProviderViewQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/ip-pools` */ - ipPoolList: (params: { - query: Api.IpPoolListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/system/ip-pools` */ - ipPoolCreate: (params: { - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/ip-pools/:pool` */ - ipPoolView: (params: { - path: Api.IpPoolViewPathParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `PUT /v1/system/ip-pools/:pool` */ - ipPoolUpdate: (params: { - path: Api.IpPoolUpdatePathParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/system/ip-pools/:pool` */ - ipPoolDelete: (params: { - path: Api.IpPoolDeletePathParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/system/ip-pools/:pool/ranges` */ - ipPoolRangeList: (params: { - path: Api.IpPoolRangeListPathParams; - query: Api.IpPoolRangeListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/system/ip-pools/:pool/ranges/add` */ - ipPoolRangeAdd: (params: { - path: Api.IpPoolRangeAddPathParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/system/ip-pools/:pool/ranges/remove` */ - ipPoolRangeRemove: (params: { - path: Api.IpPoolRangeRemovePathParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/system/ip-pools/:pool/silos` */ - ipPoolSiloList: (params: { - path: Api.IpPoolSiloListPathParams; - query: Api.IpPoolSiloListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/system/ip-pools/:pool/silos` */ - ipPoolSiloLink: (params: { - path: Api.IpPoolSiloLinkPathParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `PUT /v1/system/ip-pools/:pool/silos/:silo` */ - ipPoolSiloUpdate: (params: { - path: Api.IpPoolSiloUpdatePathParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/system/ip-pools/:pool/silos/:silo` */ - ipPoolSiloUnlink: (params: { - path: Api.IpPoolSiloUnlinkPathParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/system/ip-pools-service` */ - ipPoolServiceView: (params: { - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/ip-pools-service/ranges` */ - ipPoolServiceRangeList: (params: { - query: Api.IpPoolServiceRangeListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/system/ip-pools-service/ranges/add` */ - ipPoolServiceRangeAdd: (params: { - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/system/ip-pools-service/ranges/remove` */ - ipPoolServiceRangeRemove: (params: { - body: Json; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/system/metrics/:metricName` */ - systemMetric: (params: { - path: Api.SystemMetricPathParams; - query: Api.SystemMetricQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/networking/address-lot` */ - networkingAddressLotList: (params: { - query: Api.NetworkingAddressLotListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/system/networking/address-lot` */ - networkingAddressLotCreate: (params: { - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/system/networking/address-lot/:addressLot` */ - networkingAddressLotDelete: (params: { - path: Api.NetworkingAddressLotDeletePathParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/system/networking/address-lot/:addressLot/blocks` */ - networkingAddressLotBlockList: (params: { - path: Api.NetworkingAddressLotBlockListPathParams; - query: Api.NetworkingAddressLotBlockListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/system/networking/bfd-disable` */ - networkingBfdDisable: (params: { - body: Json; - req: Request; - cookies: Record; - }) => Promisable; - /** `POST /v1/system/networking/bfd-enable` */ - networkingBfdEnable: (params: { - body: Json; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/system/networking/bfd-status` */ - networkingBfdStatus: (params: { - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/networking/bgp` */ - networkingBgpConfigList: (params: { - query: Api.NetworkingBgpConfigListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/system/networking/bgp` */ - networkingBgpConfigCreate: (params: { - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/system/networking/bgp` */ - networkingBgpConfigDelete: (params: { - query: Api.NetworkingBgpConfigDeleteQueryParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/system/networking/bgp-announce` */ - networkingBgpAnnounceSetList: (params: { - query: Api.NetworkingBgpAnnounceSetListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/system/networking/bgp-announce` */ - networkingBgpAnnounceSetCreate: (params: { - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/system/networking/bgp-announce` */ - networkingBgpAnnounceSetDelete: (params: { - query: Api.NetworkingBgpAnnounceSetDeleteQueryParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/system/networking/bgp-routes-ipv4` */ - networkingBgpImportedRoutesIpv4: (params: { - query: Api.NetworkingBgpImportedRoutesIpv4QueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/networking/bgp-status` */ - networkingBgpStatus: (params: { - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/networking/loopback-address` */ - networkingLoopbackAddressList: (params: { - query: Api.NetworkingLoopbackAddressListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/system/networking/loopback-address` */ - networkingLoopbackAddressCreate: (params: { - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/system/networking/loopback-address/:rackId/:switchLocation/:address/:subnetMask` */ - networkingLoopbackAddressDelete: (params: { - path: Api.NetworkingLoopbackAddressDeletePathParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/system/networking/switch-port-settings` */ - networkingSwitchPortSettingsList: (params: { - query: Api.NetworkingSwitchPortSettingsListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/system/networking/switch-port-settings` */ - networkingSwitchPortSettingsCreate: (params: { - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/system/networking/switch-port-settings` */ - networkingSwitchPortSettingsDelete: (params: { - query: Api.NetworkingSwitchPortSettingsDeleteQueryParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/system/networking/switch-port-settings/:port` */ - networkingSwitchPortSettingsView: (params: { - path: Api.NetworkingSwitchPortSettingsViewPathParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/policy` */ - systemPolicyView: (params: { - req: Request; - cookies: Record; - }) => Promisable>; - /** `PUT /v1/system/policy` */ - systemPolicyUpdate: (params: { - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/roles` */ - roleList: (params: { - query: Api.RoleListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/roles/:roleName` */ - roleView: (params: { - path: Api.RoleViewPathParams; - 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; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/system/silos` */ - siloCreate: (params: { - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/silos/:silo` */ - siloView: (params: { - path: Api.SiloViewPathParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/system/silos/:silo` */ - siloDelete: (params: { - path: Api.SiloDeletePathParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/system/silos/:silo/ip-pools` */ - siloIpPoolList: (params: { - path: Api.SiloIpPoolListPathParams; - query: Api.SiloIpPoolListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/silos/:silo/policy` */ - siloPolicyView: (params: { - path: Api.SiloPolicyViewPathParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `PUT /v1/system/silos/:silo/policy` */ - siloPolicyUpdate: (params: { - path: Api.SiloPolicyUpdatePathParams; - body: Json; - 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; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/users/:userId` */ - siloUserView: (params: { - path: Api.SiloUserViewPathParams; - query: Api.SiloUserViewQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/users-builtin` */ - userBuiltinList: (params: { - query: Api.UserBuiltinListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/users-builtin/:user` */ - userBuiltinView: (params: { - path: Api.UserBuiltinViewPathParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/utilization/silos` */ - siloUtilizationList: (params: { - query: Api.SiloUtilizationListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/system/utilization/silos/:silo` */ - siloUtilizationView: (params: { - path: Api.SiloUtilizationViewPathParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/users` */ - userList: (params: { - query: Api.UserListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/utilization` */ - utilizationView: (params: { - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/vpc-firewall-rules` */ - vpcFirewallRulesView: (params: { - query: Api.VpcFirewallRulesViewQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `PUT /v1/vpc-firewall-rules` */ - vpcFirewallRulesUpdate: (params: { - query: Api.VpcFirewallRulesUpdateQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/vpc-subnets` */ - vpcSubnetList: (params: { - query: Api.VpcSubnetListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/vpc-subnets` */ - vpcSubnetCreate: (params: { - query: Api.VpcSubnetCreateQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/vpc-subnets/:subnet` */ - vpcSubnetView: (params: { - path: Api.VpcSubnetViewPathParams; - query: Api.VpcSubnetViewQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `PUT /v1/vpc-subnets/:subnet` */ - vpcSubnetUpdate: (params: { - path: Api.VpcSubnetUpdatePathParams; - query: Api.VpcSubnetUpdateQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/vpc-subnets/:subnet` */ - vpcSubnetDelete: (params: { - path: Api.VpcSubnetDeletePathParams; - query: Api.VpcSubnetDeleteQueryParams; - req: Request; - cookies: Record; - }) => Promisable; - /** `GET /v1/vpc-subnets/:subnet/network-interfaces` */ - vpcSubnetListNetworkInterfaces: (params: { - path: Api.VpcSubnetListNetworkInterfacesPathParams; - query: Api.VpcSubnetListNetworkInterfacesQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/vpcs` */ - vpcList: (params: { - query: Api.VpcListQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `POST /v1/vpcs` */ - vpcCreate: (params: { - query: Api.VpcCreateQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `GET /v1/vpcs/:vpc` */ - vpcView: (params: { - path: Api.VpcViewPathParams; - query: Api.VpcViewQueryParams; - req: Request; - cookies: Record; - }) => Promisable>; - /** `PUT /v1/vpcs/:vpc` */ - vpcUpdate: (params: { - path: Api.VpcUpdatePathParams; - query: Api.VpcUpdateQueryParams; - body: Json; - req: Request; - cookies: Record; - }) => Promisable>; - /** `DELETE /v1/vpcs/:vpc` */ - vpcDelete: (params: { - path: Api.VpcDeletePathParams; - query: Api.VpcDeleteQueryParams; - req: Request; - cookies: Record; - }) => Promisable; -} - -function validateParams( - schema: S, - req: Request, - pathParams: PathParams, -) { - const rawParams = new URLSearchParams(new URL(req.url).search); - const params: [string, unknown][] = []; - - // Ensure numeric params like `limit` are parsed as numbers - for (const [name, value] of rawParams) { - params.push([name, isNaN(Number(value)) ? value : Number(value)]); - } - - const result = schema.safeParse({ - path: pathParams, - query: Object.fromEntries(params), - }); - - if (result.success) { - return { params: result.data }; - } - - // if any of the errors come from path params, just 404 — the resource cannot - // exist if there's no valid name - const { issues } = result.error; - const status = issues.some((e) => e.path[0] === "path") ? 404 : 400; - return { paramsErr: json(issues, { status }) }; -} - -const handler = - ( - handler: MSWHandlers[keyof MSWHandlers], - paramSchema: ZodSchema | null, - bodySchema: ZodSchema | null, - ) => - async ({ - request: req, - params: pathParams, - cookies, - }: { - request: Request; - params: PathParams; - cookies: Record; - }) => { - const { params, paramsErr } = paramSchema - ? validateParams(paramSchema, req, pathParams) - : { params: {}, paramsErr: undefined }; - if (paramsErr) return json(paramsErr, { status: 400 }); - - const { path, query } = params; - - let body = undefined; - if (bodySchema) { - const rawBody = await req.json(); - const result = bodySchema.transform(snakeify).safeParse(rawBody); - if (!result.success) return json(result.error.issues, { status: 400 }); - body = result.data; - } - - try { - // TypeScript can't narrow the handler down because there's not an explicit relationship between the schema - // being present and the shape of the handler API. The type of this function could be resolved such that the - // relevant schema is required if and only if the handler has a type that matches the inferred schema - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const result = await (handler as any).apply(null, [ - { path, query, body, req, cookies }, - ]); - if (typeof result === "number") { - return new HttpResponse(null, { status: result }); - } - if (typeof result === "function") { - return result(); - } - if (result instanceof Response) { - return result; - } - return json(result); - } catch (thrown) { - if (typeof thrown === "number") { - return new HttpResponse(null, { status: thrown }); - } - if (typeof thrown === "function") { - return thrown(); - } - if (typeof thrown === "string") { - return json({ message: thrown }, { status: 400 }); - } - if (thrown instanceof Response) { - return thrown; - } - console.error("Unexpected mock error", thrown); - return json({ message: "Unknown Server Error" }, { status: 500 }); - } - }; - -export function makeHandlers(handlers: MSWHandlers): HttpHandler[] { - return [ - http.post( - "/device/auth", - handler(handlers["deviceAuthRequest"], null, null), - ), - http.post( - "/device/confirm", - handler(handlers["deviceAuthConfirm"], null, schema.DeviceAuthVerify), - ), - http.post( - "/device/token", - handler(handlers["deviceAccessToken"], null, null), - ), - http.get( - "/experimental/v1/probes", - handler(handlers["probeList"], schema.ProbeListParams, null), - ), - http.post( - "/experimental/v1/probes", - handler( - handlers["probeCreate"], - schema.ProbeCreateParams, - schema.ProbeCreate, - ), - ), - http.get( - "/experimental/v1/probes/:probe", - handler(handlers["probeView"], schema.ProbeViewParams, null), - ), - http.delete( - "/experimental/v1/probes/:probe", - handler(handlers["probeDelete"], schema.ProbeDeleteParams, null), - ), - http.post( - "/login/:siloName/saml/:providerName", - handler(handlers["loginSaml"], schema.LoginSamlParams, null), - ), - http.get( - "/v1/certificates", - handler(handlers["certificateList"], schema.CertificateListParams, null), - ), - http.post( - "/v1/certificates", - handler(handlers["certificateCreate"], null, schema.CertificateCreate), - ), - http.get( - "/v1/certificates/:certificate", - handler(handlers["certificateView"], schema.CertificateViewParams, null), - ), - http.delete( - "/v1/certificates/:certificate", - handler( - handlers["certificateDelete"], - schema.CertificateDeleteParams, - null, - ), - ), - http.get( - "/v1/disks", - handler(handlers["diskList"], schema.DiskListParams, null), - ), - http.post( - "/v1/disks", - handler( - handlers["diskCreate"], - schema.DiskCreateParams, - schema.DiskCreate, - ), - ), - http.get( - "/v1/disks/:disk", - handler(handlers["diskView"], schema.DiskViewParams, null), - ), - http.delete( - "/v1/disks/:disk", - handler(handlers["diskDelete"], schema.DiskDeleteParams, null), - ), - http.post( - "/v1/disks/:disk/bulk-write", - handler( - handlers["diskBulkWriteImport"], - schema.DiskBulkWriteImportParams, - schema.ImportBlocksBulkWrite, - ), - ), - http.post( - "/v1/disks/:disk/bulk-write-start", - handler( - handlers["diskBulkWriteImportStart"], - schema.DiskBulkWriteImportStartParams, - null, - ), - ), - http.post( - "/v1/disks/:disk/bulk-write-stop", - handler( - handlers["diskBulkWriteImportStop"], - schema.DiskBulkWriteImportStopParams, - null, - ), - ), - http.post( - "/v1/disks/:disk/finalize", - handler( - handlers["diskFinalizeImport"], - schema.DiskFinalizeImportParams, - schema.FinalizeDisk, - ), - ), - http.get( - "/v1/disks/:disk/metrics/:metric", - handler(handlers["diskMetricsList"], schema.DiskMetricsListParams, null), - ), - http.get( - "/v1/floating-ips", - handler(handlers["floatingIpList"], schema.FloatingIpListParams, null), - ), - http.post( - "/v1/floating-ips", - handler( - handlers["floatingIpCreate"], - schema.FloatingIpCreateParams, - schema.FloatingIpCreate, - ), - ), - http.get( - "/v1/floating-ips/:floatingIp", - handler(handlers["floatingIpView"], schema.FloatingIpViewParams, null), - ), - http.put( - "/v1/floating-ips/:floatingIp", - handler( - handlers["floatingIpUpdate"], - schema.FloatingIpUpdateParams, - schema.FloatingIpUpdate, - ), - ), - http.delete( - "/v1/floating-ips/:floatingIp", - handler( - handlers["floatingIpDelete"], - schema.FloatingIpDeleteParams, - null, - ), - ), - http.post( - "/v1/floating-ips/:floatingIp/attach", - handler( - handlers["floatingIpAttach"], - schema.FloatingIpAttachParams, - schema.FloatingIpAttach, - ), - ), - http.post( - "/v1/floating-ips/:floatingIp/detach", - handler( - handlers["floatingIpDetach"], - schema.FloatingIpDetachParams, - null, - ), - ), - http.get( - "/v1/groups", - handler(handlers["groupList"], schema.GroupListParams, null), - ), - http.get( - "/v1/groups/:groupId", - handler(handlers["groupView"], schema.GroupViewParams, null), - ), - http.get( - "/v1/images", - handler(handlers["imageList"], schema.ImageListParams, null), - ), - http.post( - "/v1/images", - handler( - handlers["imageCreate"], - schema.ImageCreateParams, - schema.ImageCreate, - ), - ), - http.get( - "/v1/images/:image", - handler(handlers["imageView"], schema.ImageViewParams, null), - ), - http.delete( - "/v1/images/:image", - handler(handlers["imageDelete"], schema.ImageDeleteParams, null), - ), - http.post( - "/v1/images/:image/demote", - handler(handlers["imageDemote"], schema.ImageDemoteParams, null), - ), - http.post( - "/v1/images/:image/promote", - handler(handlers["imagePromote"], schema.ImagePromoteParams, null), - ), - http.get( - "/v1/instances", - handler(handlers["instanceList"], schema.InstanceListParams, null), - ), - http.post( - "/v1/instances", - handler( - handlers["instanceCreate"], - schema.InstanceCreateParams, - schema.InstanceCreate, - ), - ), - http.get( - "/v1/instances/:instance", - handler(handlers["instanceView"], schema.InstanceViewParams, null), - ), - http.delete( - "/v1/instances/:instance", - handler(handlers["instanceDelete"], schema.InstanceDeleteParams, null), - ), - http.get( - "/v1/instances/:instance/disks", - handler( - handlers["instanceDiskList"], - schema.InstanceDiskListParams, - null, - ), - ), - http.post( - "/v1/instances/:instance/disks/attach", - handler( - handlers["instanceDiskAttach"], - schema.InstanceDiskAttachParams, - schema.DiskPath, - ), - ), - http.post( - "/v1/instances/:instance/disks/detach", - handler( - handlers["instanceDiskDetach"], - schema.InstanceDiskDetachParams, - schema.DiskPath, - ), - ), - http.get( - "/v1/instances/:instance/external-ips", - handler( - handlers["instanceExternalIpList"], - schema.InstanceExternalIpListParams, - null, - ), - ), - http.post( - "/v1/instances/:instance/external-ips/ephemeral", - handler( - handlers["instanceEphemeralIpAttach"], - schema.InstanceEphemeralIpAttachParams, - schema.EphemeralIpCreate, - ), - ), - http.delete( - "/v1/instances/:instance/external-ips/ephemeral", - handler( - handlers["instanceEphemeralIpDetach"], - schema.InstanceEphemeralIpDetachParams, - null, - ), - ), - http.post( - "/v1/instances/:instance/migrate", - handler( - handlers["instanceMigrate"], - schema.InstanceMigrateParams, - schema.InstanceMigrate, - ), - ), - http.post( - "/v1/instances/:instance/reboot", - handler(handlers["instanceReboot"], schema.InstanceRebootParams, null), - ), - http.get( - "/v1/instances/:instance/serial-console", - handler( - handlers["instanceSerialConsole"], - schema.InstanceSerialConsoleParams, - null, - ), - ), - http.get( - "/v1/instances/:instance/serial-console/stream", - handler( - handlers["instanceSerialConsoleStream"], - schema.InstanceSerialConsoleStreamParams, - null, - ), - ), - http.get( - "/v1/instances/:instance/ssh-public-keys", - handler( - handlers["instanceSshPublicKeyList"], - schema.InstanceSshPublicKeyListParams, - null, - ), - ), - http.post( - "/v1/instances/:instance/start", - handler(handlers["instanceStart"], schema.InstanceStartParams, null), - ), - http.post( - "/v1/instances/:instance/stop", - handler(handlers["instanceStop"], schema.InstanceStopParams, null), - ), - http.get( - "/v1/ip-pools", - handler( - handlers["projectIpPoolList"], - schema.ProjectIpPoolListParams, - null, - ), - ), - http.get( - "/v1/ip-pools/:pool", - handler( - handlers["projectIpPoolView"], - schema.ProjectIpPoolViewParams, - null, - ), - ), - http.post( - "/v1/login/:siloName/local", - handler( - handlers["loginLocal"], - schema.LoginLocalParams, - schema.UsernamePasswordCredentials, - ), - ), - http.post("/v1/logout", handler(handlers["logout"], null, null)), - http.get("/v1/me", handler(handlers["currentUserView"], null, null)), - http.get( - "/v1/me/groups", - handler( - handlers["currentUserGroups"], - schema.CurrentUserGroupsParams, - null, - ), - ), - http.get( - "/v1/me/ssh-keys", - handler( - handlers["currentUserSshKeyList"], - schema.CurrentUserSshKeyListParams, - null, - ), - ), - http.post( - "/v1/me/ssh-keys", - handler(handlers["currentUserSshKeyCreate"], null, schema.SshKeyCreate), - ), - http.get( - "/v1/me/ssh-keys/:sshKey", - handler( - handlers["currentUserSshKeyView"], - schema.CurrentUserSshKeyViewParams, - null, - ), - ), - http.delete( - "/v1/me/ssh-keys/:sshKey", - handler( - handlers["currentUserSshKeyDelete"], - schema.CurrentUserSshKeyDeleteParams, - null, - ), - ), - http.get( - "/v1/metrics/:metricName", - handler(handlers["siloMetric"], schema.SiloMetricParams, null), - ), - http.get( - "/v1/network-interfaces", - handler( - handlers["instanceNetworkInterfaceList"], - schema.InstanceNetworkInterfaceListParams, - null, - ), - ), - http.post( - "/v1/network-interfaces", - handler( - handlers["instanceNetworkInterfaceCreate"], - schema.InstanceNetworkInterfaceCreateParams, - schema.InstanceNetworkInterfaceCreate, - ), - ), - http.get( - "/v1/network-interfaces/:interface", - handler( - handlers["instanceNetworkInterfaceView"], - schema.InstanceNetworkInterfaceViewParams, - null, - ), - ), - http.put( - "/v1/network-interfaces/:interface", - handler( - handlers["instanceNetworkInterfaceUpdate"], - schema.InstanceNetworkInterfaceUpdateParams, - schema.InstanceNetworkInterfaceUpdate, - ), - ), - http.delete( - "/v1/network-interfaces/:interface", - handler( - handlers["instanceNetworkInterfaceDelete"], - schema.InstanceNetworkInterfaceDeleteParams, - null, - ), - ), - http.get("/v1/ping", handler(handlers["ping"], null, null)), - http.get("/v1/policy", handler(handlers["policyView"], null, null)), - http.put( - "/v1/policy", - handler(handlers["policyUpdate"], null, schema.SiloRolePolicy), - ), - http.get( - "/v1/projects", - handler(handlers["projectList"], schema.ProjectListParams, null), - ), - http.post( - "/v1/projects", - handler(handlers["projectCreate"], null, schema.ProjectCreate), - ), - http.get( - "/v1/projects/:project", - handler(handlers["projectView"], schema.ProjectViewParams, null), - ), - http.put( - "/v1/projects/:project", - handler( - handlers["projectUpdate"], - schema.ProjectUpdateParams, - schema.ProjectUpdate, - ), - ), - http.delete( - "/v1/projects/:project", - handler(handlers["projectDelete"], schema.ProjectDeleteParams, null), - ), - http.get( - "/v1/projects/:project/policy", - handler( - handlers["projectPolicyView"], - schema.ProjectPolicyViewParams, - null, - ), - ), - http.put( - "/v1/projects/:project/policy", - handler( - handlers["projectPolicyUpdate"], - schema.ProjectPolicyUpdateParams, - schema.ProjectRolePolicy, - ), - ), - http.get( - "/v1/snapshots", - handler(handlers["snapshotList"], schema.SnapshotListParams, null), - ), - http.post( - "/v1/snapshots", - handler( - handlers["snapshotCreate"], - schema.SnapshotCreateParams, - schema.SnapshotCreate, - ), - ), - http.get( - "/v1/snapshots/:snapshot", - handler(handlers["snapshotView"], schema.SnapshotViewParams, null), - ), - http.delete( - "/v1/snapshots/:snapshot", - handler(handlers["snapshotDelete"], schema.SnapshotDeleteParams, null), - ), - http.get( - "/v1/system/hardware/disks", - handler( - handlers["physicalDiskList"], - schema.PhysicalDiskListParams, - null, - ), - ), - http.get( - "/v1/system/hardware/racks", - handler(handlers["rackList"], schema.RackListParams, null), - ), - http.get( - "/v1/system/hardware/racks/:rackId", - handler(handlers["rackView"], schema.RackViewParams, null), - ), - http.get( - "/v1/system/hardware/sleds", - handler(handlers["sledList"], schema.SledListParams, null), - ), - http.post( - "/v1/system/hardware/sleds", - handler(handlers["sledAdd"], null, schema.UninitializedSledId), - ), - http.get( - "/v1/system/hardware/sleds/:sledId", - handler(handlers["sledView"], schema.SledViewParams, null), - ), - http.get( - "/v1/system/hardware/sleds/:sledId/disks", - handler( - handlers["sledPhysicalDiskList"], - schema.SledPhysicalDiskListParams, - null, - ), - ), - http.get( - "/v1/system/hardware/sleds/:sledId/instances", - handler( - handlers["sledInstanceList"], - schema.SledInstanceListParams, - null, - ), - ), - http.put( - "/v1/system/hardware/sleds/:sledId/provision-policy", - handler( - handlers["sledSetProvisionPolicy"], - schema.SledSetProvisionPolicyParams, - schema.SledProvisionPolicyParams, - ), - ), - http.get( - "/v1/system/hardware/sleds-uninitialized", - handler( - handlers["sledListUninitialized"], - schema.SledListUninitializedParams, - null, - ), - ), - http.get( - "/v1/system/hardware/switch-port", - handler( - handlers["networkingSwitchPortList"], - schema.NetworkingSwitchPortListParams, - null, - ), - ), - http.post( - "/v1/system/hardware/switch-port/:port/settings", - handler( - handlers["networkingSwitchPortApplySettings"], - schema.NetworkingSwitchPortApplySettingsParams, - schema.SwitchPortApplySettings, - ), - ), - http.delete( - "/v1/system/hardware/switch-port/:port/settings", - handler( - handlers["networkingSwitchPortClearSettings"], - schema.NetworkingSwitchPortClearSettingsParams, - null, - ), - ), - http.get( - "/v1/system/hardware/switches", - handler(handlers["switchList"], schema.SwitchListParams, null), - ), - http.get( - "/v1/system/hardware/switches/:switchId", - handler(handlers["switchView"], schema.SwitchViewParams, null), - ), - http.get( - "/v1/system/identity-providers", - handler( - handlers["siloIdentityProviderList"], - schema.SiloIdentityProviderListParams, - null, - ), - ), - http.post( - "/v1/system/identity-providers/local/users", - handler( - handlers["localIdpUserCreate"], - schema.LocalIdpUserCreateParams, - schema.UserCreate, - ), - ), - http.delete( - "/v1/system/identity-providers/local/users/:userId", - handler( - handlers["localIdpUserDelete"], - schema.LocalIdpUserDeleteParams, - null, - ), - ), - http.post( - "/v1/system/identity-providers/local/users/:userId/set-password", - handler( - handlers["localIdpUserSetPassword"], - schema.LocalIdpUserSetPasswordParams, - schema.UserPassword, - ), - ), - http.post( - "/v1/system/identity-providers/saml", - handler( - handlers["samlIdentityProviderCreate"], - schema.SamlIdentityProviderCreateParams, - schema.SamlIdentityProviderCreate, - ), - ), - http.get( - "/v1/system/identity-providers/saml/:provider", - handler( - handlers["samlIdentityProviderView"], - schema.SamlIdentityProviderViewParams, - null, - ), - ), - http.get( - "/v1/system/ip-pools", - handler(handlers["ipPoolList"], schema.IpPoolListParams, null), - ), - http.post( - "/v1/system/ip-pools", - handler(handlers["ipPoolCreate"], null, schema.IpPoolCreate), - ), - http.get( - "/v1/system/ip-pools/:pool", - handler(handlers["ipPoolView"], schema.IpPoolViewParams, null), - ), - http.put( - "/v1/system/ip-pools/:pool", - handler( - handlers["ipPoolUpdate"], - schema.IpPoolUpdateParams, - schema.IpPoolUpdate, - ), - ), - http.delete( - "/v1/system/ip-pools/:pool", - handler(handlers["ipPoolDelete"], schema.IpPoolDeleteParams, null), - ), - http.get( - "/v1/system/ip-pools/:pool/ranges", - handler(handlers["ipPoolRangeList"], schema.IpPoolRangeListParams, null), - ), - http.post( - "/v1/system/ip-pools/:pool/ranges/add", - handler( - handlers["ipPoolRangeAdd"], - schema.IpPoolRangeAddParams, - schema.IpRange, - ), - ), - http.post( - "/v1/system/ip-pools/:pool/ranges/remove", - handler( - handlers["ipPoolRangeRemove"], - schema.IpPoolRangeRemoveParams, - schema.IpRange, - ), - ), - http.get( - "/v1/system/ip-pools/:pool/silos", - handler(handlers["ipPoolSiloList"], schema.IpPoolSiloListParams, null), - ), - http.post( - "/v1/system/ip-pools/:pool/silos", - handler( - handlers["ipPoolSiloLink"], - schema.IpPoolSiloLinkParams, - schema.IpPoolLinkSilo, - ), - ), - http.put( - "/v1/system/ip-pools/:pool/silos/:silo", - handler( - handlers["ipPoolSiloUpdate"], - schema.IpPoolSiloUpdateParams, - schema.IpPoolSiloUpdate, - ), - ), - http.delete( - "/v1/system/ip-pools/:pool/silos/:silo", - handler( - handlers["ipPoolSiloUnlink"], - schema.IpPoolSiloUnlinkParams, - null, - ), - ), - http.get( - "/v1/system/ip-pools-service", - handler(handlers["ipPoolServiceView"], null, null), - ), - http.get( - "/v1/system/ip-pools-service/ranges", - handler( - handlers["ipPoolServiceRangeList"], - schema.IpPoolServiceRangeListParams, - null, - ), - ), - http.post( - "/v1/system/ip-pools-service/ranges/add", - handler(handlers["ipPoolServiceRangeAdd"], null, schema.IpRange), - ), - http.post( - "/v1/system/ip-pools-service/ranges/remove", - handler(handlers["ipPoolServiceRangeRemove"], null, schema.IpRange), - ), - http.get( - "/v1/system/metrics/:metricName", - handler(handlers["systemMetric"], schema.SystemMetricParams, null), - ), - http.get( - "/v1/system/networking/address-lot", - handler( - handlers["networkingAddressLotList"], - schema.NetworkingAddressLotListParams, - null, - ), - ), - http.post( - "/v1/system/networking/address-lot", - handler( - handlers["networkingAddressLotCreate"], - null, - schema.AddressLotCreate, - ), - ), - http.delete( - "/v1/system/networking/address-lot/:addressLot", - handler( - handlers["networkingAddressLotDelete"], - schema.NetworkingAddressLotDeleteParams, - null, - ), - ), - http.get( - "/v1/system/networking/address-lot/:addressLot/blocks", - handler( - handlers["networkingAddressLotBlockList"], - schema.NetworkingAddressLotBlockListParams, - null, - ), - ), - http.post( - "/v1/system/networking/bfd-disable", - handler(handlers["networkingBfdDisable"], null, schema.BfdSessionDisable), - ), - http.post( - "/v1/system/networking/bfd-enable", - handler(handlers["networkingBfdEnable"], null, schema.BfdSessionEnable), - ), - http.get( - "/v1/system/networking/bfd-status", - handler(handlers["networkingBfdStatus"], null, null), - ), - http.get( - "/v1/system/networking/bgp", - handler( - handlers["networkingBgpConfigList"], - schema.NetworkingBgpConfigListParams, - null, - ), - ), - http.post( - "/v1/system/networking/bgp", - handler( - handlers["networkingBgpConfigCreate"], - null, - schema.BgpConfigCreate, - ), - ), - http.delete( - "/v1/system/networking/bgp", - handler( - handlers["networkingBgpConfigDelete"], - schema.NetworkingBgpConfigDeleteParams, - null, - ), - ), - http.get( - "/v1/system/networking/bgp-announce", - handler( - handlers["networkingBgpAnnounceSetList"], - schema.NetworkingBgpAnnounceSetListParams, - null, - ), - ), - http.post( - "/v1/system/networking/bgp-announce", - handler( - handlers["networkingBgpAnnounceSetCreate"], - null, - schema.BgpAnnounceSetCreate, - ), - ), - http.delete( - "/v1/system/networking/bgp-announce", - handler( - handlers["networkingBgpAnnounceSetDelete"], - schema.NetworkingBgpAnnounceSetDeleteParams, - null, - ), - ), - http.get( - "/v1/system/networking/bgp-routes-ipv4", - handler( - handlers["networkingBgpImportedRoutesIpv4"], - schema.NetworkingBgpImportedRoutesIpv4Params, - null, - ), - ), - http.get( - "/v1/system/networking/bgp-status", - handler(handlers["networkingBgpStatus"], null, null), - ), - http.get( - "/v1/system/networking/loopback-address", - handler( - handlers["networkingLoopbackAddressList"], - schema.NetworkingLoopbackAddressListParams, - null, - ), - ), - http.post( - "/v1/system/networking/loopback-address", - handler( - handlers["networkingLoopbackAddressCreate"], - null, - schema.LoopbackAddressCreate, - ), - ), - http.delete( - "/v1/system/networking/loopback-address/:rackId/:switchLocation/:address/:subnetMask", - handler( - handlers["networkingLoopbackAddressDelete"], - schema.NetworkingLoopbackAddressDeleteParams, - null, - ), - ), - http.get( - "/v1/system/networking/switch-port-settings", - handler( - handlers["networkingSwitchPortSettingsList"], - schema.NetworkingSwitchPortSettingsListParams, - null, - ), - ), - http.post( - "/v1/system/networking/switch-port-settings", - handler( - handlers["networkingSwitchPortSettingsCreate"], - null, - schema.SwitchPortSettingsCreate, - ), - ), - http.delete( - "/v1/system/networking/switch-port-settings", - handler( - handlers["networkingSwitchPortSettingsDelete"], - schema.NetworkingSwitchPortSettingsDeleteParams, - null, - ), - ), - http.get( - "/v1/system/networking/switch-port-settings/:port", - handler( - handlers["networkingSwitchPortSettingsView"], - schema.NetworkingSwitchPortSettingsViewParams, - null, - ), - ), - http.get( - "/v1/system/policy", - handler(handlers["systemPolicyView"], null, null), - ), - http.put( - "/v1/system/policy", - handler(handlers["systemPolicyUpdate"], null, schema.FleetRolePolicy), - ), - http.get( - "/v1/system/roles", - handler(handlers["roleList"], schema.RoleListParams, null), - ), - http.get( - "/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), - ), - http.post( - "/v1/system/silos", - handler(handlers["siloCreate"], null, schema.SiloCreate), - ), - http.get( - "/v1/system/silos/:silo", - handler(handlers["siloView"], schema.SiloViewParams, null), - ), - http.delete( - "/v1/system/silos/:silo", - handler(handlers["siloDelete"], schema.SiloDeleteParams, null), - ), - http.get( - "/v1/system/silos/:silo/ip-pools", - handler(handlers["siloIpPoolList"], schema.SiloIpPoolListParams, null), - ), - http.get( - "/v1/system/silos/:silo/policy", - handler(handlers["siloPolicyView"], schema.SiloPolicyViewParams, null), - ), - http.put( - "/v1/system/silos/:silo/policy", - handler( - handlers["siloPolicyUpdate"], - schema.SiloPolicyUpdateParams, - 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), - ), - http.get( - "/v1/system/users/:userId", - handler(handlers["siloUserView"], schema.SiloUserViewParams, null), - ), - http.get( - "/v1/system/users-builtin", - handler(handlers["userBuiltinList"], schema.UserBuiltinListParams, null), - ), - http.get( - "/v1/system/users-builtin/:user", - handler(handlers["userBuiltinView"], schema.UserBuiltinViewParams, null), - ), - http.get( - "/v1/system/utilization/silos", - handler( - handlers["siloUtilizationList"], - schema.SiloUtilizationListParams, - null, - ), - ), - http.get( - "/v1/system/utilization/silos/:silo", - handler( - handlers["siloUtilizationView"], - schema.SiloUtilizationViewParams, - null, - ), - ), - http.get( - "/v1/users", - handler(handlers["userList"], schema.UserListParams, null), - ), - http.get( - "/v1/utilization", - handler(handlers["utilizationView"], null, null), - ), - http.get( - "/v1/vpc-firewall-rules", - handler( - handlers["vpcFirewallRulesView"], - schema.VpcFirewallRulesViewParams, - null, - ), - ), - http.put( - "/v1/vpc-firewall-rules", - handler( - handlers["vpcFirewallRulesUpdate"], - schema.VpcFirewallRulesUpdateParams, - schema.VpcFirewallRuleUpdateParams, - ), - ), - http.get( - "/v1/vpc-subnets", - handler(handlers["vpcSubnetList"], schema.VpcSubnetListParams, null), - ), - http.post( - "/v1/vpc-subnets", - handler( - handlers["vpcSubnetCreate"], - schema.VpcSubnetCreateParams, - schema.VpcSubnetCreate, - ), - ), - http.get( - "/v1/vpc-subnets/:subnet", - handler(handlers["vpcSubnetView"], schema.VpcSubnetViewParams, null), - ), - http.put( - "/v1/vpc-subnets/:subnet", - handler( - handlers["vpcSubnetUpdate"], - schema.VpcSubnetUpdateParams, - schema.VpcSubnetUpdate, - ), - ), - http.delete( - "/v1/vpc-subnets/:subnet", - handler(handlers["vpcSubnetDelete"], schema.VpcSubnetDeleteParams, null), - ), - http.get( - "/v1/vpc-subnets/:subnet/network-interfaces", - handler( - handlers["vpcSubnetListNetworkInterfaces"], - schema.VpcSubnetListNetworkInterfacesParams, - null, - ), - ), - http.get( - "/v1/vpcs", - handler(handlers["vpcList"], schema.VpcListParams, null), - ), - http.post( - "/v1/vpcs", - handler(handlers["vpcCreate"], schema.VpcCreateParams, schema.VpcCreate), - ), - http.get( - "/v1/vpcs/:vpc", - handler(handlers["vpcView"], schema.VpcViewParams, null), - ), - http.put( - "/v1/vpcs/:vpc", - handler(handlers["vpcUpdate"], schema.VpcUpdateParams, schema.VpcUpdate), - ), - http.delete( - "/v1/vpcs/:vpc", - handler(handlers["vpcDelete"], schema.VpcDeleteParams, null), - ), - ]; -} diff --git a/oxide-api/src/type-test.ts b/oxide-api/src/type-test.ts deleted file mode 100644 index 298b585..0000000 --- a/oxide-api/src/type-test.ts +++ /dev/null @@ -1,499 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * Copyright Oxide Computer Company - */ - -import { type z } from "zod"; -import { assert, type Equals } from "tsafe"; -import type * as A from "./Api"; -import type * as V from "./validate"; - -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert< - Equals< - A.AddressLotBlockResultsPage, - z.infer - > ->(); -assert>>(); -assert< - Equals> ->(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert< - Equals< - A.IdentityProviderResultsPage, - z.infer - > ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert< - Equals< - A.InstanceNetworkInterfaceCreate, - z.infer - > ->(); -assert< - Equals< - A.InstanceNetworkInterfaceAttachment, - z.infer - > ->(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert< - Equals< - A.InstanceNetworkInterfaceResultsPage, - z.infer - > ->(); -assert< - Equals< - A.InstanceNetworkInterfaceUpdate, - z.infer - > ->(); -assert>>(); -assert< - Equals< - A.InstanceSerialConsoleData, - z.infer - > ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert< - Equals< - A.IpPoolSiloLinkResultsPage, - z.infer - > ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert< - Equals< - A.LoopbackAddressResultsPage, - z.infer - > ->(); -assert>>(); -assert< - Equals> ->(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals< - A.ProjectRoleRoleAssignment, - z.infer - > ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert< - Equals< - A.SamlIdentityProviderCreate, - z.infer - > ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert< - Equals< - A.SiloUtilizationResultsPage, - z.infer - > ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert< - Equals< - A.SledProvisionPolicyParams, - z.infer - > ->(); -assert< - Equals< - A.SledProvisionPolicyResponse, - z.infer - > ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert< - Equals> ->(); -assert>>(); -assert< - Equals< - A.SwitchInterfaceConfigCreate, - z.infer - > ->(); -assert>>(); -assert< - Equals> ->(); -assert< - Equals> ->(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert< - Equals> ->(); -assert< - Equals> ->(); -assert< - Equals> ->(); -assert>>(); -assert< - Equals> ->(); -assert< - Equals> ->(); -assert< - Equals< - A.SwitchPortSettingsResultsPage, - z.infer - > ->(); -assert< - Equals< - A.SwitchVlanInterfaceConfig, - z.infer - > ->(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals< - A.UninitializedSledResultsPage, - z.infer - > ->(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals< - A.UsernamePasswordCredentials, - z.infer - > ->(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert< - Equals> ->(); -assert< - Equals< - A.VpcFirewallRuleHostFilter, - z.infer - > ->(); -assert< - Equals> ->(); -assert< - Equals> ->(); -assert< - Equals> ->(); -assert< - Equals> ->(); -assert>>(); -assert< - Equals> ->(); -assert< - Equals< - A.VpcFirewallRuleUpdateParams, - z.infer - > ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert< - Equals> ->(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); -assert>>(); diff --git a/oxide-api/src/validate.ts b/oxide-api/src/validate.ts deleted file mode 100644 index bb4ad1f..0000000 --- a/oxide-api/src/validate.ts +++ /dev/null @@ -1,5200 +0,0 @@ -/* eslint-disable */ - -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * Copyright Oxide Computer Company - */ - -import { z, ZodType } from "zod"; -import { processResponseBody, uniqueItems } from "./util"; - -/** - * Zod only supports string enums at the moment. A previous issue was opened - * and closed as stale but it provided a hint on how to implement it. - * - * @see https://github.com/colinhacks/zod/issues/1118 - * TODO: PR an update for zod to support other native enum types - */ -const IntEnum = (values: T) => - z.number().refine((v) => values.includes(v)) as ZodType; - -/** Helper to ensure booleans provided as strings end up with the correct value */ -const SafeBoolean = z.preprocess( - (v) => (v === "false" ? false : v), - z.coerce.boolean(), -); - -/** - * An IPv4 subnet - * - * An IPv4 subnet, including prefix and subnet mask - */ -export const Ipv4Net = z.preprocess( - processResponseBody, - z - .string() - .regex( - /^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\/([0-9]|1[0-9]|2[0-9]|3[0-2])$/, - ), -); - -/** - * An IPv6 subnet - * - * An IPv6 subnet, including prefix and subnet mask - */ -export const Ipv6Net = z.preprocess( - processResponseBody, - z - .string() - .regex( - /^([fF][dD])[0-9a-fA-F]{2}:(([0-9a-fA-F]{1,4}:){6}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,6}:)([0-9a-fA-F]{1,4})?\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$/, - ), -); - -export const IpNet = z.preprocess( - processResponseBody, - z.union([Ipv4Net, Ipv6Net]), -); - -/** - * A name unique within the parent collection - * - * Names must begin with a lower case ASCII letter, be composed exclusively of lowercase ASCII, uppercase ASCII, numbers, and '-', and may not end with a '-'. Names cannot be a UUID though they may contain a UUID. - */ -export const Name = z.preprocess( - processResponseBody, - z - .string() - .min(1) - .max(63) - .regex( - /^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z]([a-zA-Z0-9-]*[a-zA-Z0-9]+)?$/, - ), -); - -export const NameOrId = z.preprocess( - processResponseBody, - z.union([z.string().uuid(), Name]), -); - -/** - * An address tied to an address lot. - */ -export const Address = z.preprocess( - processResponseBody, - z.object({ address: IpNet, addressLot: NameOrId }), -); - -/** - * A set of addresses associated with a port configuration. - */ -export const AddressConfig = z.preprocess( - processResponseBody, - z.object({ addresses: Address.array() }), -); - -/** - * The kind associated with an address lot. - */ -export const AddressLotKind = z.preprocess( - processResponseBody, - z.enum(["infra", "pool"]), -); - -/** - * Represents an address lot object, containing the id of the lot that can be used in other API calls. - */ -export const AddressLot = z.preprocess( - processResponseBody, - z.object({ - description: z.string(), - id: z.string().uuid(), - kind: AddressLotKind, - name: Name, - timeCreated: z.coerce.date(), - timeModified: z.coerce.date(), - }), -); - -/** - * An address lot block is a part of an address lot and contains a range of addresses. The range is inclusive. - */ -export const AddressLotBlock = z.preprocess( - processResponseBody, - z.object({ - firstAddress: z.string().ip(), - id: z.string().uuid(), - lastAddress: z.string().ip(), - }), -); - -/** - * Parameters for creating an address lot block. Fist and last addresses are inclusive. - */ -export const AddressLotBlockCreate = z.preprocess( - processResponseBody, - z.object({ firstAddress: z.string().ip(), lastAddress: z.string().ip() }), -); - -/** - * A single page of results - */ -export const AddressLotBlockResultsPage = z.preprocess( - processResponseBody, - z.object({ items: AddressLotBlock.array(), nextPage: z.string().optional() }), -); - -/** - * Parameters for creating an address lot. - */ -export const AddressLotCreate = z.preprocess( - processResponseBody, - z.object({ - blocks: AddressLotBlockCreate.array(), - description: z.string(), - kind: AddressLotKind, - name: Name, - }), -); - -/** - * An address lot and associated blocks resulting from creating an address lot. - */ -export const AddressLotCreateResponse = z.preprocess( - processResponseBody, - z.object({ blocks: AddressLotBlock.array(), lot: AddressLot }), -); - -/** - * A single page of results - */ -export const AddressLotResultsPage = z.preprocess( - processResponseBody, - z.object({ items: AddressLot.array(), nextPage: z.string().optional() }), -); - -/** - * Properties that uniquely identify an Oxide hardware component - */ -export const Baseboard = z.preprocess( - processResponseBody, - z.object({ part: z.string(), revision: z.number(), serial: z.string() }), -); - -export const BfdMode = z.preprocess( - processResponseBody, - z.enum(["single_hop", "multi_hop"]), -); - -/** - * Information needed to disable a BFD session - */ -export const BfdSessionDisable = z.preprocess( - processResponseBody, - z.object({ remote: z.string().ip(), switch: Name }), -); - -/** - * Information about a bidirectional forwarding detection (BFD) session. - */ -export const BfdSessionEnable = z.preprocess( - processResponseBody, - z.object({ - detectionThreshold: z.number().min(0).max(255), - local: z.string().ip().optional(), - mode: BfdMode, - remote: z.string().ip(), - requiredRx: z.number().min(0), - switch: Name, - }), -); - -export const BfdState = z.preprocess( - processResponseBody, - z.enum(["admin_down", "down", "init", "up"]), -); - -export const BfdStatus = z.preprocess( - processResponseBody, - z.object({ - detectionThreshold: z.number().min(0).max(255), - local: z.string().ip().optional(), - mode: BfdMode, - peer: z.string().ip(), - requiredRx: z.number().min(0), - state: BfdState, - switch: Name, - }), -); - -/** - * Represents a BGP announce set by id. The id can be used with other API calls to view and manage the announce set. - */ -export const BgpAnnounceSet = z.preprocess( - processResponseBody, - z.object({ - description: z.string(), - id: z.string().uuid(), - name: Name, - timeCreated: z.coerce.date(), - timeModified: z.coerce.date(), - }), -); - -/** - * A BGP announcement tied to a particular address lot block. - */ -export const BgpAnnouncementCreate = z.preprocess( - processResponseBody, - z.object({ addressLotBlock: NameOrId, network: IpNet }), -); - -/** - * Parameters for creating a named set of BGP announcements. - */ -export const BgpAnnounceSetCreate = z.preprocess( - processResponseBody, - z.object({ - announcement: BgpAnnouncementCreate.array(), - description: z.string(), - name: Name, - }), -); - -/** - * A BGP announcement tied to an address lot block. - */ -export const BgpAnnouncement = z.preprocess( - processResponseBody, - z.object({ - addressLotBlockId: z.string().uuid(), - announceSetId: z.string().uuid(), - network: IpNet, - }), -); - -/** - * A base BGP configuration. - */ -export const BgpConfig = z.preprocess( - processResponseBody, - z.object({ - asn: z.number().min(0).max(4294967295), - description: z.string(), - id: z.string().uuid(), - name: Name, - timeCreated: z.coerce.date(), - timeModified: z.coerce.date(), - vrf: z.string().optional(), - }), -); - -/** - * Parameters for creating a BGP configuration. This includes and autonomous system number (ASN) and a virtual routing and forwarding (VRF) identifier. - */ -export const BgpConfigCreate = z.preprocess( - processResponseBody, - z.object({ - asn: z.number().min(0).max(4294967295), - bgpAnnounceSetId: NameOrId, - description: z.string(), - name: Name, - vrf: Name.optional(), - }), -); - -/** - * A single page of results - */ -export const BgpConfigResultsPage = z.preprocess( - processResponseBody, - z.object({ items: BgpConfig.array(), nextPage: z.string().optional() }), -); - -/** - * Identifies switch physical location - */ -export const SwitchLocation = z.preprocess( - processResponseBody, - z.enum(["switch0", "switch1"]), -); - -/** - * A route imported from a BGP peer. - */ -export const BgpImportedRouteIpv4 = z.preprocess( - processResponseBody, - z.object({ - id: z.number().min(0).max(4294967295), - nexthop: z.string().ip({ version: "v4" }), - prefix: Ipv4Net, - switch: SwitchLocation, - }), -); - -/** - * A BGP peer configuration for an interface. Includes the set of announcements that will be advertised to the peer identified by `addr`. The `bgp_config` parameter is a reference to global BGP parameters. The `interface_name` indicates what interface the peer should be contacted on. - */ -export const BgpPeer = z.preprocess( - processResponseBody, - z.object({ - addr: z.string().ip(), - bgpAnnounceSet: NameOrId, - bgpConfig: NameOrId, - connectRetry: z.number().min(0).max(4294967295), - delayOpen: z.number().min(0).max(4294967295), - holdTime: z.number().min(0).max(4294967295), - idleHoldTime: z.number().min(0).max(4294967295), - interfaceName: z.string(), - keepalive: z.number().min(0).max(4294967295), - }), -); - -export const BgpPeerConfig = z.preprocess( - processResponseBody, - z.object({ peers: BgpPeer.array() }), -); - -/** - * The current state of a BGP peer. - */ -export const BgpPeerState = z.preprocess( - processResponseBody, - z.enum([ - "idle", - "connect", - "active", - "open_sent", - "open_confirm", - "session_setup", - "established", - ]), -); - -/** - * The current status of a BGP peer. - */ -export const BgpPeerStatus = z.preprocess( - processResponseBody, - z.object({ - addr: z.string().ip(), - localAsn: z.number().min(0).max(4294967295), - remoteAsn: z.number().min(0).max(4294967295), - state: BgpPeerState, - stateDurationMillis: z.number().min(0), - switch: SwitchLocation, - }), -); - -/** - * A type storing a range over `T`. - * - * This type supports ranges similar to the `RangeTo`, `Range` and `RangeFrom` types in the standard library. Those cover `(..end)`, `(start..end)`, and `(start..)` respectively. - */ -export const BinRangedouble = z.preprocess( - processResponseBody, - z.union([ - z.object({ end: z.number(), type: z.enum(["range_to"]) }), - z.object({ end: z.number(), start: z.number(), type: z.enum(["range"]) }), - z.object({ start: z.number(), type: z.enum(["range_from"]) }), - ]), -); - -/** - * A type storing a range over `T`. - * - * This type supports ranges similar to the `RangeTo`, `Range` and `RangeFrom` types in the standard library. Those cover `(..end)`, `(start..end)`, and `(start..)` respectively. - */ -export const BinRangefloat = z.preprocess( - processResponseBody, - z.union([ - z.object({ end: z.number(), type: z.enum(["range_to"]) }), - z.object({ end: z.number(), start: z.number(), type: z.enum(["range"]) }), - z.object({ start: z.number(), type: z.enum(["range_from"]) }), - ]), -); - -/** - * A type storing a range over `T`. - * - * This type supports ranges similar to the `RangeTo`, `Range` and `RangeFrom` types in the standard library. Those cover `(..end)`, `(start..end)`, and `(start..)` respectively. - */ -export const BinRangeint16 = z.preprocess( - processResponseBody, - z.union([ - z.object({ - end: z.number().min(-32767).max(32767), - type: z.enum(["range_to"]), - }), - z.object({ - end: z.number().min(-32767).max(32767), - start: z.number().min(-32767).max(32767), - type: z.enum(["range"]), - }), - z.object({ - start: z.number().min(-32767).max(32767), - type: z.enum(["range_from"]), - }), - ]), -); - -/** - * A type storing a range over `T`. - * - * This type supports ranges similar to the `RangeTo`, `Range` and `RangeFrom` types in the standard library. Those cover `(..end)`, `(start..end)`, and `(start..)` respectively. - */ -export const BinRangeint32 = z.preprocess( - processResponseBody, - z.union([ - z.object({ - end: z.number().min(-2147483647).max(2147483647), - type: z.enum(["range_to"]), - }), - z.object({ - end: z.number().min(-2147483647).max(2147483647), - start: z.number().min(-2147483647).max(2147483647), - type: z.enum(["range"]), - }), - z.object({ - start: z.number().min(-2147483647).max(2147483647), - type: z.enum(["range_from"]), - }), - ]), -); - -/** - * A type storing a range over `T`. - * - * This type supports ranges similar to the `RangeTo`, `Range` and `RangeFrom` types in the standard library. Those cover `(..end)`, `(start..end)`, and `(start..)` respectively. - */ -export const BinRangeint64 = z.preprocess( - processResponseBody, - z.union([ - z.object({ end: z.number(), type: z.enum(["range_to"]) }), - z.object({ end: z.number(), start: z.number(), type: z.enum(["range"]) }), - z.object({ start: z.number(), type: z.enum(["range_from"]) }), - ]), -); - -/** - * A type storing a range over `T`. - * - * This type supports ranges similar to the `RangeTo`, `Range` and `RangeFrom` types in the standard library. Those cover `(..end)`, `(start..end)`, and `(start..)` respectively. - */ -export const BinRangeint8 = z.preprocess( - processResponseBody, - z.union([ - z.object({ - end: z.number().min(-127).max(127), - type: z.enum(["range_to"]), - }), - z.object({ - end: z.number().min(-127).max(127), - start: z.number().min(-127).max(127), - type: z.enum(["range"]), - }), - z.object({ - start: z.number().min(-127).max(127), - type: z.enum(["range_from"]), - }), - ]), -); - -/** - * A type storing a range over `T`. - * - * This type supports ranges similar to the `RangeTo`, `Range` and `RangeFrom` types in the standard library. Those cover `(..end)`, `(start..end)`, and `(start..)` respectively. - */ -export const BinRangeuint16 = z.preprocess( - processResponseBody, - z.union([ - z.object({ end: z.number().min(0).max(65535), type: z.enum(["range_to"]) }), - z.object({ - end: z.number().min(0).max(65535), - start: z.number().min(0).max(65535), - type: z.enum(["range"]), - }), - z.object({ - start: z.number().min(0).max(65535), - type: z.enum(["range_from"]), - }), - ]), -); - -/** - * A type storing a range over `T`. - * - * This type supports ranges similar to the `RangeTo`, `Range` and `RangeFrom` types in the standard library. Those cover `(..end)`, `(start..end)`, and `(start..)` respectively. - */ -export const BinRangeuint32 = z.preprocess( - processResponseBody, - z.union([ - z.object({ - end: z.number().min(0).max(4294967295), - type: z.enum(["range_to"]), - }), - z.object({ - end: z.number().min(0).max(4294967295), - start: z.number().min(0).max(4294967295), - type: z.enum(["range"]), - }), - z.object({ - start: z.number().min(0).max(4294967295), - type: z.enum(["range_from"]), - }), - ]), -); - -/** - * A type storing a range over `T`. - * - * This type supports ranges similar to the `RangeTo`, `Range` and `RangeFrom` types in the standard library. Those cover `(..end)`, `(start..end)`, and `(start..)` respectively. - */ -export const BinRangeuint64 = z.preprocess( - processResponseBody, - z.union([ - z.object({ end: z.number().min(0), type: z.enum(["range_to"]) }), - z.object({ - end: z.number().min(0), - start: z.number().min(0), - type: z.enum(["range"]), - }), - z.object({ start: z.number().min(0), type: z.enum(["range_from"]) }), - ]), -); - -/** - * A type storing a range over `T`. - * - * This type supports ranges similar to the `RangeTo`, `Range` and `RangeFrom` types in the standard library. Those cover `(..end)`, `(start..end)`, and `(start..)` respectively. - */ -export const BinRangeuint8 = z.preprocess( - processResponseBody, - z.union([ - z.object({ end: z.number().min(0).max(255), type: z.enum(["range_to"]) }), - z.object({ - end: z.number().min(0).max(255), - start: z.number().min(0).max(255), - type: z.enum(["range"]), - }), - z.object({ - start: z.number().min(0).max(255), - type: z.enum(["range_from"]), - }), - ]), -); - -/** - * Type storing bin edges and a count of samples within it. - */ -export const Bindouble = z.preprocess( - processResponseBody, - z.object({ count: z.number().min(0), range: BinRangedouble }), -); - -/** - * Type storing bin edges and a count of samples within it. - */ -export const Binfloat = z.preprocess( - processResponseBody, - z.object({ count: z.number().min(0), range: BinRangefloat }), -); - -/** - * Type storing bin edges and a count of samples within it. - */ -export const Binint16 = z.preprocess( - processResponseBody, - z.object({ count: z.number().min(0), range: BinRangeint16 }), -); - -/** - * Type storing bin edges and a count of samples within it. - */ -export const Binint32 = z.preprocess( - processResponseBody, - z.object({ count: z.number().min(0), range: BinRangeint32 }), -); - -/** - * Type storing bin edges and a count of samples within it. - */ -export const Binint64 = z.preprocess( - processResponseBody, - z.object({ count: z.number().min(0), range: BinRangeint64 }), -); - -/** - * Type storing bin edges and a count of samples within it. - */ -export const Binint8 = z.preprocess( - processResponseBody, - z.object({ count: z.number().min(0), range: BinRangeint8 }), -); - -/** - * Type storing bin edges and a count of samples within it. - */ -export const Binuint16 = z.preprocess( - processResponseBody, - z.object({ count: z.number().min(0), range: BinRangeuint16 }), -); - -/** - * Type storing bin edges and a count of samples within it. - */ -export const Binuint32 = z.preprocess( - processResponseBody, - z.object({ count: z.number().min(0), range: BinRangeuint32 }), -); - -/** - * Type storing bin edges and a count of samples within it. - */ -export const Binuint64 = z.preprocess( - processResponseBody, - z.object({ count: z.number().min(0), range: BinRangeuint64 }), -); - -/** - * Type storing bin edges and a count of samples within it. - */ -export const Binuint8 = z.preprocess( - processResponseBody, - z.object({ count: z.number().min(0), range: BinRangeuint8 }), -); - -/** - * disk block size in bytes - */ -export const BlockSize = z.preprocess( - processResponseBody, - IntEnum([512, 2048, 4096] as const), -); - -/** - * Byte count to express memory or storage capacity. - */ -export const ByteCount = z.preprocess(processResponseBody, z.number().min(0)); - -/** - * The service intended to use this certificate. - */ -export const ServiceUsingCertificate = z.preprocess( - processResponseBody, - z.enum(["external_api"]), -); - -/** - * View of a Certificate - */ -export const Certificate = z.preprocess( - processResponseBody, - z.object({ - description: z.string(), - id: z.string().uuid(), - name: Name, - service: ServiceUsingCertificate, - timeCreated: z.coerce.date(), - timeModified: z.coerce.date(), - }), -); - -/** - * Create-time parameters for a `Certificate` - */ -export const CertificateCreate = z.preprocess( - processResponseBody, - z.object({ - cert: z.string(), - description: z.string(), - key: z.string(), - name: Name, - service: ServiceUsingCertificate, - }), -); - -/** - * A single page of results - */ -export const CertificateResultsPage = z.preprocess( - processResponseBody, - z.object({ items: Certificate.array(), nextPage: z.string().optional() }), -); - -/** - * A cumulative or counter data type. - */ -export const Cumulativedouble = z.preprocess( - processResponseBody, - z.object({ startTime: z.coerce.date(), value: z.number() }), -); - -/** - * A cumulative or counter data type. - */ -export const Cumulativefloat = z.preprocess( - processResponseBody, - z.object({ startTime: z.coerce.date(), value: z.number() }), -); - -/** - * A cumulative or counter data type. - */ -export const Cumulativeint64 = z.preprocess( - processResponseBody, - z.object({ startTime: z.coerce.date(), value: z.number() }), -); - -/** - * A cumulative or counter data type. - */ -export const Cumulativeuint64 = z.preprocess( - processResponseBody, - z.object({ startTime: z.coerce.date(), value: z.number().min(0) }), -); - -/** - * Info about the current user - */ -export const CurrentUser = z.preprocess( - processResponseBody, - z.object({ - displayName: z.string(), - id: z.string().uuid(), - siloId: z.string().uuid(), - siloName: Name, - }), -); - -/** - * Histogram metric - * - * A histogram maintains the count of any number of samples, over a set of bins. Bins are specified on construction via their _left_ edges, inclusive. There can't be any "gaps" in the bins, and an additional bin may be added to the left, right, or both so that the bins extend to the entire range of the support. - * - * Note that any gaps, unsorted bins, or non-finite values will result in an error. - */ -export const Histogramint8 = z.preprocess( - processResponseBody, - z.object({ - bins: Binint8.array(), - nSamples: z.number().min(0), - startTime: z.coerce.date(), - }), -); - -/** - * Histogram metric - * - * A histogram maintains the count of any number of samples, over a set of bins. Bins are specified on construction via their _left_ edges, inclusive. There can't be any "gaps" in the bins, and an additional bin may be added to the left, right, or both so that the bins extend to the entire range of the support. - * - * Note that any gaps, unsorted bins, or non-finite values will result in an error. - */ -export const Histogramuint8 = z.preprocess( - processResponseBody, - z.object({ - bins: Binuint8.array(), - nSamples: z.number().min(0), - startTime: z.coerce.date(), - }), -); - -/** - * Histogram metric - * - * A histogram maintains the count of any number of samples, over a set of bins. Bins are specified on construction via their _left_ edges, inclusive. There can't be any "gaps" in the bins, and an additional bin may be added to the left, right, or both so that the bins extend to the entire range of the support. - * - * Note that any gaps, unsorted bins, or non-finite values will result in an error. - */ -export const Histogramint16 = z.preprocess( - processResponseBody, - z.object({ - bins: Binint16.array(), - nSamples: z.number().min(0), - startTime: z.coerce.date(), - }), -); - -/** - * Histogram metric - * - * A histogram maintains the count of any number of samples, over a set of bins. Bins are specified on construction via their _left_ edges, inclusive. There can't be any "gaps" in the bins, and an additional bin may be added to the left, right, or both so that the bins extend to the entire range of the support. - * - * Note that any gaps, unsorted bins, or non-finite values will result in an error. - */ -export const Histogramuint16 = z.preprocess( - processResponseBody, - z.object({ - bins: Binuint16.array(), - nSamples: z.number().min(0), - startTime: z.coerce.date(), - }), -); - -/** - * Histogram metric - * - * A histogram maintains the count of any number of samples, over a set of bins. Bins are specified on construction via their _left_ edges, inclusive. There can't be any "gaps" in the bins, and an additional bin may be added to the left, right, or both so that the bins extend to the entire range of the support. - * - * Note that any gaps, unsorted bins, or non-finite values will result in an error. - */ -export const Histogramint32 = z.preprocess( - processResponseBody, - z.object({ - bins: Binint32.array(), - nSamples: z.number().min(0), - startTime: z.coerce.date(), - }), -); - -/** - * Histogram metric - * - * A histogram maintains the count of any number of samples, over a set of bins. Bins are specified on construction via their _left_ edges, inclusive. There can't be any "gaps" in the bins, and an additional bin may be added to the left, right, or both so that the bins extend to the entire range of the support. - * - * Note that any gaps, unsorted bins, or non-finite values will result in an error. - */ -export const Histogramuint32 = z.preprocess( - processResponseBody, - z.object({ - bins: Binuint32.array(), - nSamples: z.number().min(0), - startTime: z.coerce.date(), - }), -); - -/** - * Histogram metric - * - * A histogram maintains the count of any number of samples, over a set of bins. Bins are specified on construction via their _left_ edges, inclusive. There can't be any "gaps" in the bins, and an additional bin may be added to the left, right, or both so that the bins extend to the entire range of the support. - * - * Note that any gaps, unsorted bins, or non-finite values will result in an error. - */ -export const Histogramint64 = z.preprocess( - processResponseBody, - z.object({ - bins: Binint64.array(), - nSamples: z.number().min(0), - startTime: z.coerce.date(), - }), -); - -/** - * Histogram metric - * - * A histogram maintains the count of any number of samples, over a set of bins. Bins are specified on construction via their _left_ edges, inclusive. There can't be any "gaps" in the bins, and an additional bin may be added to the left, right, or both so that the bins extend to the entire range of the support. - * - * Note that any gaps, unsorted bins, or non-finite values will result in an error. - */ -export const Histogramuint64 = z.preprocess( - processResponseBody, - z.object({ - bins: Binuint64.array(), - nSamples: z.number().min(0), - startTime: z.coerce.date(), - }), -); - -/** - * Histogram metric - * - * A histogram maintains the count of any number of samples, over a set of bins. Bins are specified on construction via their _left_ edges, inclusive. There can't be any "gaps" in the bins, and an additional bin may be added to the left, right, or both so that the bins extend to the entire range of the support. - * - * Note that any gaps, unsorted bins, or non-finite values will result in an error. - */ -export const Histogramfloat = z.preprocess( - processResponseBody, - z.object({ - bins: Binfloat.array(), - nSamples: z.number().min(0), - startTime: z.coerce.date(), - }), -); - -/** - * Histogram metric - * - * A histogram maintains the count of any number of samples, over a set of bins. Bins are specified on construction via their _left_ edges, inclusive. There can't be any "gaps" in the bins, and an additional bin may be added to the left, right, or both so that the bins extend to the entire range of the support. - * - * Note that any gaps, unsorted bins, or non-finite values will result in an error. - */ -export const Histogramdouble = z.preprocess( - processResponseBody, - z.object({ - bins: Bindouble.array(), - nSamples: z.number().min(0), - startTime: z.coerce.date(), - }), -); - -/** - * The type of an individual datum of a metric. - */ -export const DatumType = z.preprocess( - processResponseBody, - z.enum([ - "bool", - "i8", - "u8", - "i16", - "u16", - "i32", - "u32", - "i64", - "u64", - "f32", - "f64", - "string", - "bytes", - "cumulative_i64", - "cumulative_u64", - "cumulative_f32", - "cumulative_f64", - "histogram_i8", - "histogram_u8", - "histogram_i16", - "histogram_u16", - "histogram_i32", - "histogram_u32", - "histogram_i64", - "histogram_u64", - "histogram_f32", - "histogram_f64", - ]), -); - -export const MissingDatum = z.preprocess( - processResponseBody, - z.object({ datumType: DatumType, startTime: z.coerce.date().optional() }), -); - -/** - * A `Datum` is a single sampled data point from a metric. - */ -export const Datum = z.preprocess( - processResponseBody, - z.union([ - z.object({ datum: SafeBoolean, type: z.enum(["bool"]) }), - z.object({ datum: z.number().min(-127).max(127), type: z.enum(["i8"]) }), - z.object({ datum: z.number().min(0).max(255), type: z.enum(["u8"]) }), - z.object({ - datum: z.number().min(-32767).max(32767), - type: z.enum(["i16"]), - }), - z.object({ datum: z.number().min(0).max(65535), type: z.enum(["u16"]) }), - z.object({ - datum: z.number().min(-2147483647).max(2147483647), - type: z.enum(["i32"]), - }), - z.object({ - datum: z.number().min(0).max(4294967295), - type: z.enum(["u32"]), - }), - z.object({ datum: z.number(), type: z.enum(["i64"]) }), - z.object({ datum: z.number().min(0), type: z.enum(["u64"]) }), - z.object({ datum: z.number(), type: z.enum(["f32"]) }), - z.object({ datum: z.number(), type: z.enum(["f64"]) }), - z.object({ datum: z.string(), type: z.enum(["string"]) }), - z.object({ - datum: z.number().min(0).max(255).array(), - type: z.enum(["bytes"]), - }), - z.object({ datum: Cumulativeint64, type: z.enum(["cumulative_i64"]) }), - z.object({ datum: Cumulativeuint64, type: z.enum(["cumulative_u64"]) }), - z.object({ datum: Cumulativefloat, type: z.enum(["cumulative_f32"]) }), - z.object({ datum: Cumulativedouble, type: z.enum(["cumulative_f64"]) }), - z.object({ datum: Histogramint8, type: z.enum(["histogram_i8"]) }), - z.object({ datum: Histogramuint8, type: z.enum(["histogram_u8"]) }), - z.object({ datum: Histogramint16, type: z.enum(["histogram_i16"]) }), - z.object({ datum: Histogramuint16, type: z.enum(["histogram_u16"]) }), - z.object({ datum: Histogramint32, type: z.enum(["histogram_i32"]) }), - z.object({ datum: Histogramuint32, type: z.enum(["histogram_u32"]) }), - z.object({ datum: Histogramint64, type: z.enum(["histogram_i64"]) }), - z.object({ datum: Histogramuint64, type: z.enum(["histogram_u64"]) }), - z.object({ datum: Histogramfloat, type: z.enum(["histogram_f32"]) }), - z.object({ datum: Histogramdouble, type: z.enum(["histogram_f64"]) }), - z.object({ datum: MissingDatum, type: z.enum(["missing"]) }), - ]), -); - -export const DerEncodedKeyPair = z.preprocess( - processResponseBody, - z.object({ privateKey: z.string(), publicCert: z.string() }), -); - -export const DeviceAccessTokenRequest = z.preprocess( - processResponseBody, - z.object({ - clientId: z.string().uuid(), - deviceCode: z.string(), - grantType: z.string(), - }), -); - -export const DeviceAuthRequest = z.preprocess( - processResponseBody, - z.object({ clientId: z.string().uuid() }), -); - -export const DeviceAuthVerify = z.preprocess( - processResponseBody, - z.object({ userCode: z.string() }), -); - -export const Digest = z.preprocess( - processResponseBody, - z.object({ type: z.enum(["sha256"]), value: z.string() }), -); - -/** - * State of a Disk - */ -export const DiskState = z.preprocess( - processResponseBody, - z.union([ - z.object({ state: z.enum(["creating"]) }), - z.object({ state: z.enum(["detached"]) }), - z.object({ state: z.enum(["import_ready"]) }), - z.object({ state: z.enum(["importing_from_url"]) }), - z.object({ state: z.enum(["importing_from_bulk_writes"]) }), - z.object({ state: z.enum(["finalizing"]) }), - z.object({ state: z.enum(["maintenance"]) }), - z.object({ instance: z.string().uuid(), state: z.enum(["attaching"]) }), - z.object({ instance: z.string().uuid(), state: z.enum(["attached"]) }), - z.object({ instance: z.string().uuid(), state: z.enum(["detaching"]) }), - z.object({ state: z.enum(["destroyed"]) }), - z.object({ state: z.enum(["faulted"]) }), - ]), -); - -/** - * View of a Disk - */ -export const Disk = z.preprocess( - processResponseBody, - z.object({ - blockSize: ByteCount, - description: z.string(), - devicePath: z.string(), - id: z.string().uuid(), - imageId: z.string().uuid().optional(), - name: Name, - projectId: z.string().uuid(), - size: ByteCount, - snapshotId: z.string().uuid().optional(), - state: DiskState, - timeCreated: z.coerce.date(), - timeModified: z.coerce.date(), - }), -); - -/** - * Different sources for a disk - */ -export const DiskSource = z.preprocess( - processResponseBody, - z.union([ - z.object({ blockSize: BlockSize, type: z.enum(["blank"]) }), - z.object({ snapshotId: z.string().uuid(), type: z.enum(["snapshot"]) }), - z.object({ imageId: z.string().uuid(), type: z.enum(["image"]) }), - z.object({ blockSize: BlockSize, type: z.enum(["importing_blocks"]) }), - ]), -); - -/** - * Create-time parameters for a `Disk` - */ -export const DiskCreate = z.preprocess( - processResponseBody, - z.object({ - description: z.string(), - diskSource: DiskSource, - name: Name, - size: ByteCount, - }), -); - -export const DiskPath = z.preprocess( - processResponseBody, - z.object({ disk: NameOrId }), -); - -/** - * A single page of results - */ -export const DiskResultsPage = z.preprocess( - processResponseBody, - z.object({ items: Disk.array(), nextPage: z.string().optional() }), -); - -/** - * Parameters for creating an ephemeral IP address for an instance. - */ -export const EphemeralIpCreate = z.preprocess( - processResponseBody, - z.object({ pool: NameOrId.optional() }), -); - -/** - * Error information from a response. - */ -export const Error = z.preprocess( - processResponseBody, - z.object({ - errorCode: z.string().optional(), - message: z.string(), - requestId: z.string(), - }), -); - -export const ExternalIp = z.preprocess( - processResponseBody, - z.union([ - z.object({ ip: z.string().ip(), kind: z.enum(["ephemeral"]) }), - z.object({ - description: z.string(), - id: z.string().uuid(), - instanceId: z.string().uuid().optional(), - ip: z.string().ip(), - kind: z.enum(["floating"]), - name: Name, - projectId: z.string().uuid(), - timeCreated: z.coerce.date(), - timeModified: z.coerce.date(), - }), - ]), -); - -/** - * Parameters for creating an external IP address for instances. - */ -export const ExternalIpCreate = z.preprocess( - processResponseBody, - z.union([ - z.object({ pool: NameOrId.optional(), type: z.enum(["ephemeral"]) }), - z.object({ floatingIp: NameOrId, type: z.enum(["floating"]) }), - ]), -); - -/** - * A single page of results - */ -export const ExternalIpResultsPage = z.preprocess( - processResponseBody, - z.object({ items: ExternalIp.array(), nextPage: z.string().optional() }), -); - -/** - * Parameters for finalizing a disk - */ -export const FinalizeDisk = z.preprocess( - processResponseBody, - z.object({ snapshotName: Name.optional() }), -); - -export const FleetRole = z.preprocess( - processResponseBody, - z.enum(["admin", "collaborator", "viewer"]), -); - -/** - * Describes what kind of identity is described by an id - */ -export const IdentityType = z.preprocess( - processResponseBody, - z.enum(["silo_user", "silo_group"]), -); - -/** - * Describes the assignment of a particular role on a particular resource to a particular identity (user, group, etc.) - * - * The resource is not part of this structure. Rather, `RoleAssignment`s are put into a `Policy` and that Policy is applied to a particular resource. - */ -export const FleetRoleRoleAssignment = z.preprocess( - processResponseBody, - z.object({ - identityId: z.string().uuid(), - identityType: IdentityType, - roleName: FleetRole, - }), -); - -/** - * Policy for a particular resource - * - * Note that the Policy only describes access granted explicitly for this resource. The policies of parent resources can also cause a user to have access to this resource. - */ -export const FleetRolePolicy = z.preprocess( - processResponseBody, - z.object({ roleAssignments: FleetRoleRoleAssignment.array() }), -); - -/** - * A Floating IP is a well-known IP address which can be attached and detached from instances. - */ -export const FloatingIp = z.preprocess( - processResponseBody, - z.object({ - description: z.string(), - id: z.string().uuid(), - instanceId: z.string().uuid().optional(), - ip: z.string().ip(), - name: Name, - projectId: z.string().uuid(), - timeCreated: z.coerce.date(), - timeModified: z.coerce.date(), - }), -); - -/** - * The type of resource that a floating IP is attached to - */ -export const FloatingIpParentKind = z.preprocess( - processResponseBody, - z.enum(["instance"]), -); - -/** - * Parameters for attaching a floating IP address to another resource - */ -export const FloatingIpAttach = z.preprocess( - processResponseBody, - z.object({ kind: FloatingIpParentKind, parent: NameOrId }), -); - -/** - * Parameters for creating a new floating IP address for instances. - */ -export const FloatingIpCreate = z.preprocess( - processResponseBody, - z.object({ - description: z.string(), - ip: z.string().ip().optional(), - name: Name, - pool: NameOrId.optional(), - }), -); - -/** - * A single page of results - */ -export const FloatingIpResultsPage = z.preprocess( - processResponseBody, - z.object({ items: FloatingIp.array(), nextPage: z.string().optional() }), -); - -/** - * Updateable identity-related parameters - */ -export const FloatingIpUpdate = z.preprocess( - processResponseBody, - z.object({ description: z.string().optional(), name: Name.optional() }), -); - -/** - * View of a Group - */ -export const Group = z.preprocess( - processResponseBody, - z.object({ - displayName: z.string(), - id: z.string().uuid(), - siloId: z.string().uuid(), - }), -); - -/** - * A single page of results - */ -export const GroupResultsPage = z.preprocess( - processResponseBody, - z.object({ items: Group.array(), nextPage: z.string().optional() }), -); - -/** - * An RFC-1035-compliant hostname - * - * A hostname identifies a host on a network, and is usually a dot-delimited sequence of labels, where each label contains only letters, digits, or the hyphen. See RFCs 1035 and 952 for more details. - */ -export const Hostname = z.preprocess( - processResponseBody, - z - .string() - .min(1) - .max(253) - .regex( - /^([a-zA-Z0-9]+[a-zA-Z0-9\-]*(?