Skip to content

Commit 4141287

Browse files
feat: Resource accounting
1 parent d708091 commit 4141287

File tree

4 files changed

+34
-13
lines changed

4 files changed

+34
-13
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 30
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fhypeman-cfdd18a303e2e6c87d671e6ae3ecdcd1d9642b053c2ef6bc507eee3f55cc6aa8.yml
3-
openapi_spec_hash: 0b038c955d95740ace74103a9c18d5a3
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fhypeman-6e0a4efd150867a61bb7e6d1a9afe5ed0e51cc35ffd79839b9126a4e95e111a5.yml
3+
openapi_spec_hash: 29efc937461cf32fb3ffcf9bff9d70dd
44
config_hash: f65a6a2bcef49a9f623212f9de6d6f6f

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2025 Hypeman
189+
Copyright 2026 Hypeman
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

instance.go

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ type Instance struct {
191191
// Any of "Created", "Running", "Paused", "Shutdown", "Stopped", "Standby",
192192
// "Unknown".
193193
State InstanceState `json:"state,required"`
194+
// Disk I/O rate limit (human-readable, e.g., "100MB/s")
195+
DiskIoBps string `json:"disk_io_bps"`
194196
// Environment variables
195197
Env map[string]string `json:"env"`
196198
// Whether a snapshot exists for this instance
@@ -224,6 +226,7 @@ type Instance struct {
224226
Image respjson.Field
225227
Name respjson.Field
226228
State respjson.Field
229+
DiskIoBps respjson.Field
227230
Env respjson.Field
228231
HasSnapshot respjson.Field
229232
HotplugSize respjson.Field
@@ -278,6 +281,10 @@ const (
278281

279282
// Network configuration of the instance
280283
type InstanceNetwork struct {
284+
// Download bandwidth limit (human-readable, e.g., "1Gbps", "125MB/s")
285+
BandwidthDownload string `json:"bandwidth_download"`
286+
// Upload bandwidth limit (human-readable, e.g., "1Gbps", "125MB/s")
287+
BandwidthUpload string `json:"bandwidth_upload"`
281288
// Whether instance is attached to the default network
282289
Enabled bool `json:"enabled"`
283290
// Assigned IP address (null if no network)
@@ -288,12 +295,14 @@ type InstanceNetwork struct {
288295
Name string `json:"name"`
289296
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
290297
JSON struct {
291-
Enabled respjson.Field
292-
IP respjson.Field
293-
Mac respjson.Field
294-
Name respjson.Field
295-
ExtraFields map[string]respjson.Field
296-
raw string
298+
BandwidthDownload respjson.Field
299+
BandwidthUpload respjson.Field
300+
Enabled respjson.Field
301+
IP respjson.Field
302+
Mac respjson.Field
303+
Name respjson.Field
304+
ExtraFields map[string]respjson.Field
305+
raw string
297306
} `json:"-"`
298307
}
299308

@@ -411,6 +420,9 @@ type InstanceNewParams struct {
411420
// Human-readable name (lowercase letters, digits, and dashes only; cannot start or
412421
// end with a dash)
413422
Name string `json:"name,required"`
423+
// Disk I/O rate limit (e.g., "100MB/s", "500MB/s"). Defaults to proportional share
424+
// based on CPU allocation if configured.
425+
DiskIoBps param.Opt[string] `json:"disk_io_bps,omitzero"`
414426
// Additional memory for hotplug (human-readable format like "3GB", "1G")
415427
HotplugSize param.Opt[string] `json:"hotplug_size,omitzero"`
416428
// Writable overlay disk size (human-readable format like "10GB", "50G")
@@ -452,6 +464,12 @@ const (
452464

453465
// Network configuration for the instance
454466
type InstanceNewParamsNetwork struct {
467+
// Download bandwidth limit (external→VM, e.g., "1Gbps", "125MB/s"). Defaults to
468+
// proportional share based on CPU allocation.
469+
BandwidthDownload param.Opt[string] `json:"bandwidth_download,omitzero"`
470+
// Upload bandwidth limit (VM→external, e.g., "1Gbps", "125MB/s"). Defaults to
471+
// proportional share based on CPU allocation.
472+
BandwidthUpload param.Opt[string] `json:"bandwidth_upload,omitzero"`
455473
// Whether to attach instance to the default network
456474
Enabled param.Opt[bool] `json:"enabled,omitzero"`
457475
paramObj

instance_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,20 @@ func TestInstanceNewWithOptionalParams(t *testing.T) {
2727
option.WithAPIKey("My API Key"),
2828
)
2929
_, err := client.Instances.New(context.TODO(), hypeman.InstanceNewParams{
30-
Image: "docker.io/library/alpine:latest",
31-
Name: "my-workload-1",
32-
Devices: []string{"l4-gpu"},
30+
Image: "docker.io/library/alpine:latest",
31+
Name: "my-workload-1",
32+
Devices: []string{"l4-gpu"},
33+
DiskIoBps: hypeman.String("100MB/s"),
3334
Env: map[string]string{
3435
"PORT": "3000",
3536
"NODE_ENV": "production",
3637
},
3738
HotplugSize: hypeman.String("2GB"),
3839
Hypervisor: hypeman.InstanceNewParamsHypervisorCloudHypervisor,
3940
Network: hypeman.InstanceNewParamsNetwork{
40-
Enabled: hypeman.Bool(true),
41+
BandwidthDownload: hypeman.String("1Gbps"),
42+
BandwidthUpload: hypeman.String("1Gbps"),
43+
Enabled: hypeman.Bool(true),
4144
},
4245
OverlaySize: hypeman.String("20GB"),
4346
Size: hypeman.String("2GB"),

0 commit comments

Comments
 (0)