diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aaf9328..aa2972c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Setup go uses: actions/setup-go@v5 @@ -35,7 +35,7 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/hypeman-go' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Setup go uses: actions/setup-go@v5 diff --git a/.stats.yml b/.stats.yml index 35bd8a2..d6e9571 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 30 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fhypeman-6e0a4efd150867a61bb7e6d1a9afe5ed0e51cc35ffd79839b9126a4e95e111a5.yml -openapi_spec_hash: 29efc937461cf32fb3ffcf9bff9d70dd -config_hash: f65a6a2bcef49a9f623212f9de6d6f6f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fhypeman-e052ac01c788e7e3e46c96bf3c42be7ae57f9dd046129add8012d0eeb388e884.yml +openapi_spec_hash: fd805921c0162d63405f5feb7e8c7082 +config_hash: 170041ea532e81620e0f6a73f6b31d44 diff --git a/instance.go b/instance.go index 4d27eb0..7872d14 100644 --- a/instance.go +++ b/instance.go @@ -195,6 +195,8 @@ type Instance struct { DiskIoBps string `json:"disk_io_bps"` // Environment variables Env map[string]string `json:"env"` + // GPU information attached to the instance + GPU InstanceGPU `json:"gpu"` // Whether a snapshot exists for this instance HasSnapshot bool `json:"has_snapshot"` // Hotplug memory size (human-readable) @@ -228,6 +230,7 @@ type Instance struct { State respjson.Field DiskIoBps respjson.Field Env respjson.Field + GPU respjson.Field HasSnapshot respjson.Field HotplugSize respjson.Field Hypervisor respjson.Field @@ -271,6 +274,27 @@ const ( InstanceStateUnknown InstanceState = "Unknown" ) +// GPU information attached to the instance +type InstanceGPU struct { + // mdev device UUID + MdevUuid string `json:"mdev_uuid"` + // vGPU profile name + Profile string `json:"profile"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + MdevUuid respjson.Field + Profile respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r InstanceGPU) RawJSON() string { return r.JSON.raw } +func (r *InstanceGPU) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + // Hypervisor running this instance type InstanceHypervisor string @@ -435,6 +459,8 @@ type InstanceNewParams struct { Devices []string `json:"devices,omitzero"` // Environment variables Env map[string]string `json:"env,omitzero"` + // GPU configuration for the instance + GPU InstanceNewParamsGPU `json:"gpu,omitzero"` // Hypervisor to use for this instance. Defaults to server configuration. // // Any of "cloud-hypervisor", "qemu". @@ -454,6 +480,21 @@ func (r *InstanceNewParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +// GPU configuration for the instance +type InstanceNewParamsGPU struct { + // vGPU profile name (e.g., "L40S-1Q"). Only used in vGPU mode. + Profile param.Opt[string] `json:"profile,omitzero"` + paramObj +} + +func (r InstanceNewParamsGPU) MarshalJSON() (data []byte, err error) { + type shadow InstanceNewParamsGPU + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *InstanceNewParamsGPU) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + // Hypervisor to use for this instance. Defaults to server configuration. type InstanceNewParamsHypervisor string diff --git a/instance_test.go b/instance_test.go index 724509f..e5a73b9 100644 --- a/instance_test.go +++ b/instance_test.go @@ -35,6 +35,9 @@ func TestInstanceNewWithOptionalParams(t *testing.T) { "PORT": "3000", "NODE_ENV": "production", }, + GPU: hypeman.InstanceNewParamsGPU{ + Profile: hypeman.String("L40S-1Q"), + }, HotplugSize: hypeman.String("2GB"), Hypervisor: hypeman.InstanceNewParamsHypervisorCloudHypervisor, Network: hypeman.InstanceNewParamsNetwork{