diff --git a/package-lock.json b/package-lock.json index a512e2d..cbf6231 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "porter-sandbox", - "version": "0.1.26", + "version": "0.1.32", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "porter-sandbox", - "version": "0.1.26", + "version": "0.1.32", "license": "Apache-2.0", "devDependencies": { "@types/node": "^20.11.0", diff --git a/package.json b/package.json index c4d0133..91d6383 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "porter-sandbox", - "version": "0.1.26", + "version": "0.1.32", "description": "TypeScript SDK for the Porter Sandbox API", "license": "Apache-2.0", "author": "Porter ", diff --git a/src/_models.ts b/src/_models.ts index 789ba50..67653ac 100644 --- a/src/_models.ts +++ b/src/_models.ts @@ -1,7 +1,7 @@ // Generated by oagen. DO NOT EDIT. -import type { FilterValuesResponsePhases, LogLineLevel, StatusResponsePhase, VolumePhase } from './enums.js'; +import type { FilterValuesResponsePhases, LogLineLevel, SandboxDomainSpecVisibility, StatusResponsePhase, VolumePhase } from './enums.js'; export interface CountPoint { /** Start of the bucket. */ @@ -115,6 +115,38 @@ export interface ReadinessResponse { active_sandboxes: number; } +export interface SandboxDomainSpec { + /** + * Fully qualified hostname for the sandbox, one label under the + * target ingress's domain. Unlike name it need not be unique, so + * successive sandboxes can reuse one hostname (only one may be live + * at a time). Defaults to ., then + * ., when omitted. + */ + domain?: string; + /** + * Which sandbox ingress serves the domain when the cluster has both a + * public and a private one. Omit to default to whichever is + * configured, public winning. Rejected when the sandbox exposes a + * port but the requested ingress is not configured on the cluster. + */ + visibility?: SandboxDomainSpecVisibility; +} + +export interface SandboxNetworkingSpec { + /** + * Port the workload listens on; the per-sandbox Service targets it on + * the pod. Privileged ports (1-1023) are not allowed. + */ + port: number; + /** + * Domains the port is served on through a sandbox ingress. Omit to + * serve the port at the default hostname through the default ingress. + * Currently only one entry is supported. + */ + domains?: SandboxDomainSpec[]; +} + export interface SandboxSpec { /** Container image to run */ image: string; @@ -137,6 +169,11 @@ export interface SandboxSpec { * sandbox; values are volume IDs. */ volume_mounts?: Record; + /** + * Network exposure for the sandbox. Omit to expose nothing. Currently + * only one entry is supported. + */ + networking?: SandboxNetworkingSpec[]; } export interface StatusResponse { @@ -156,6 +193,11 @@ export interface StatusResponse { created_at: string; /** When the sandbox pod started running */ started_at?: string | null; + /** + * Public hostname the sandbox is reachable at. Empty when the sandbox + * exposes no port or the cluster has no sandbox ingress configured. + */ + host: string; /** Volumes the sandbox mounts, keyed by mount path */ volume_mounts?: Record; /** Where a client addresses an interactive exec into the running sandbox. Absent until the sandbox has a pod. */ diff --git a/src/enums.ts b/src/enums.ts index 315d5bc..8cfb2bf 100644 --- a/src/enums.ts +++ b/src/enums.ts @@ -18,6 +18,12 @@ export const LogLineLevel = { } as const; export type LogLineLevel = typeof LogLineLevel[keyof typeof LogLineLevel]; +export const SandboxDomainSpecVisibility = { + Public: "public", + Private: "private", +} as const; +export type SandboxDomainSpecVisibility = typeof SandboxDomainSpecVisibility[keyof typeof SandboxDomainSpecVisibility]; + export const SandboxesPhase = { Queued: "queued", Creating: "creating", diff --git a/tests/models.test.ts b/tests/models.test.ts index ec41f2f..12bda2c 100644 --- a/tests/models.test.ts +++ b/tests/models.test.ts @@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'; -import type { CountPoint, CountResponse, CreateResponse, Error, ExecRequest, ExecResponse, ExecTarget, FilterValuesResponse, HealthResponse, LogsResponse, LookupResult, Pagination, ReadinessResponse, SandboxSpec, VolumeListResponse, VolumeSpec } from '../src/_models.js'; +import type { CountPoint, CountResponse, CreateResponse, Error, ExecRequest, ExecResponse, ExecTarget, FilterValuesResponse, HealthResponse, LogsResponse, LookupResult, Pagination, ReadinessResponse, SandboxDomainSpec, SandboxNetworkingSpec, SandboxSpec, VolumeListResponse, VolumeSpec } from '../src/_models.js'; describe('model round trip', () => { it('accepts a structurally valid CountPoint', () => { @@ -122,6 +122,20 @@ describe('model round trip', () => { expect(roundTripped).toEqual(value); }); + it('accepts a structurally valid SandboxDomainSpec', () => { + const value: SandboxDomainSpec = {}; + const roundTripped = JSON.parse(JSON.stringify(value)) as SandboxDomainSpec; + expect(roundTripped).toEqual(value); + }); + + it('accepts a structurally valid SandboxNetworkingSpec', () => { + const value: SandboxNetworkingSpec = { + port: 1, + }; + const roundTripped = JSON.parse(JSON.stringify(value)) as SandboxNetworkingSpec; + expect(roundTripped).toEqual(value); + }); + it('accepts a structurally valid SandboxSpec', () => { const value: SandboxSpec = { image: 'x',