Skip to content
Merged

Next #16

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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".
Expand All @@ -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

Expand Down
3 changes: 3 additions & 0 deletions instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down