Skip to content

Commit 15c4918

Browse files
feat: Add standby compression start delay
1 parent deb21b9 commit 15c4918

4 files changed

Lines changed: 49 additions & 16 deletions

File tree

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 52
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fhypeman-52bc64e89c8406b774158cdb7fdb239dd4c39e6bace06b32e5224b82462f9ffe.yml
3-
openapi_spec_hash: 647ddb91aa6aca7034f2015071c30ce6
4-
config_hash: d81afc6f4fabf65fc9291db9ddd79f87
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fhypeman-c6da5deb317c83b7a10434593eb22ec7cb27009aba0b92efaefbbe21884054ad.yml
3+
openapi_spec_hash: ff73a0e1f7a8bd5a5d1ae38d994bb9cd
4+
config_hash: ed668fae8826ff533f38df16c9664f44

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Params Types:
3737
- <a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#SetSnapshotScheduleRequestParam">SetSnapshotScheduleRequestParam</a>
3838
- <a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#SnapshotPolicyParam">SnapshotPolicyParam</a>
3939
- <a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#SnapshotScheduleRetentionParam">SnapshotScheduleRetentionParam</a>
40+
- <a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#StandbyInstanceRequestParam">StandbyInstanceRequestParam</a>
4041
- <a href="https://pkg.go.dev/github.com/kernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/kernel/hypeman-go#VolumeMountParam">VolumeMountParam</a>
4142

4243
Response Types:

instance.go

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
"github.com/kernel/hypeman-go/internal/apijson"
1616
"github.com/kernel/hypeman-go/internal/apiquery"
17+
shimjson "github.com/kernel/hypeman-go/internal/encoding/json"
1718
"github.com/kernel/hypeman-go/internal/requestconfig"
1819
"github.com/kernel/hypeman-go/option"
1920
"github.com/kernel/hypeman-go/packages/param"
@@ -675,11 +676,16 @@ func (r *SetSnapshotScheduleRequestParam) UnmarshalJSON(data []byte) error {
675676

676677
type SnapshotPolicy struct {
677678
Compression shared.SnapshotCompressionConfig `json:"compression"`
679+
// Delay before standby snapshot compression begins, expressed as a Go duration
680+
// like "30s" or "5m". Applies only to standby compression and defaults to
681+
// immediate start when omitted.
682+
StandbyCompressionDelay string `json:"standby_compression_delay"`
678683
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
679684
JSON struct {
680-
Compression respjson.Field
681-
ExtraFields map[string]respjson.Field
682-
raw string
685+
Compression respjson.Field
686+
StandbyCompressionDelay respjson.Field
687+
ExtraFields map[string]respjson.Field
688+
raw string
683689
} `json:"-"`
684690
}
685691

@@ -699,7 +705,11 @@ func (r SnapshotPolicy) ToParam() SnapshotPolicyParam {
699705
}
700706

701707
type SnapshotPolicyParam struct {
702-
Compression shared.SnapshotCompressionConfigParam `json:"compression,omitzero"`
708+
// Delay before standby snapshot compression begins, expressed as a Go duration
709+
// like "30s" or "5m". Applies only to standby compression and defaults to
710+
// immediate start when omitted.
711+
StandbyCompressionDelay param.Opt[string] `json:"standby_compression_delay,omitzero"`
712+
Compression shared.SnapshotCompressionConfigParam `json:"compression,omitzero"`
703713
paramObj
704714
}
705715

@@ -808,6 +818,24 @@ func (r *SnapshotScheduleRetentionParam) UnmarshalJSON(data []byte) error {
808818
return apijson.UnmarshalRoot(data, r)
809819
}
810820

821+
type StandbyInstanceRequestParam struct {
822+
// Delay before standby snapshot compression begins, expressed as a Go duration
823+
// like "30s" or "5m". Overrides the instance default for this standby operation
824+
// only.
825+
CompressionDelay param.Opt[string] `json:"compression_delay,omitzero"`
826+
// Compression settings for standby snapshot memory. Overrides instance defaults.
827+
Compression shared.SnapshotCompressionConfigParam `json:"compression,omitzero"`
828+
paramObj
829+
}
830+
831+
func (r StandbyInstanceRequestParam) MarshalJSON() (data []byte, err error) {
832+
type shadow StandbyInstanceRequestParam
833+
return param.MarshalObject(r, (*shadow)(&r))
834+
}
835+
func (r *StandbyInstanceRequestParam) UnmarshalJSON(data []byte) error {
836+
return apijson.UnmarshalRoot(data, r)
837+
}
838+
811839
type VolumeMount struct {
812840
// Path where volume is mounted in the guest
813841
MountPath string `json:"mount_path" api:"required"`
@@ -964,8 +992,9 @@ type InstanceNewParams struct {
964992
Hypervisor InstanceNewParamsHypervisor `json:"hypervisor,omitzero"`
965993
// Network configuration for the instance
966994
Network InstanceNewParamsNetwork `json:"network,omitzero"`
967-
// Snapshot compression policy for this instance. Controls compression settings
968-
// applied when creating snapshots or entering standby.
995+
// Snapshot policy for this instance. Controls compression settings applied when
996+
// creating snapshots or entering standby, plus any default standby-only
997+
// compression delay.
969998
SnapshotPolicy SnapshotPolicyParam `json:"snapshot_policy,omitzero"`
970999
// User-defined key-value tags.
9711000
Tags map[string]string `json:"tags,omitzero"`
@@ -1275,13 +1304,12 @@ const (
12751304
)
12761305

12771306
type InstanceStandbyParams struct {
1278-
Compression shared.SnapshotCompressionConfigParam `json:"compression,omitzero"`
1307+
StandbyInstanceRequest StandbyInstanceRequestParam
12791308
paramObj
12801309
}
12811310

12821311
func (r InstanceStandbyParams) MarshalJSON() (data []byte, err error) {
1283-
type shadow InstanceStandbyParams
1284-
return param.MarshalObject(r, (*shadow)(&r))
1312+
return shimjson.Marshal(r.StandbyInstanceRequest)
12851313
}
12861314
func (r *InstanceStandbyParams) UnmarshalJSON(data []byte) error {
12871315
return apijson.UnmarshalRoot(data, r)

instance_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func TestInstanceNewWithOptionalParams(t *testing.T) {
8484
Algorithm: shared.SnapshotCompressionConfigAlgorithmZstd,
8585
Level: hypeman.Int(1),
8686
},
87+
StandbyCompressionDelay: hypeman.String("2m"),
8788
},
8889
Tags: map[string]string{
8990
"team": "backend",
@@ -290,10 +291,13 @@ func TestInstanceStandbyWithOptionalParams(t *testing.T) {
290291
context.TODO(),
291292
"id",
292293
hypeman.InstanceStandbyParams{
293-
Compression: shared.SnapshotCompressionConfigParam{
294-
Enabled: true,
295-
Algorithm: shared.SnapshotCompressionConfigAlgorithmZstd,
296-
Level: hypeman.Int(1),
294+
StandbyInstanceRequest: hypeman.StandbyInstanceRequestParam{
295+
Compression: shared.SnapshotCompressionConfigParam{
296+
Enabled: true,
297+
Algorithm: shared.SnapshotCompressionConfigAlgorithmZstd,
298+
Level: hypeman.Int(1),
299+
},
300+
CompressionDelay: hypeman.String("45s"),
297301
},
298302
},
299303
)

0 commit comments

Comments
 (0)