Skip to content

Commit 5c53052

Browse files
feat(api): api update
1 parent 8594097 commit 5c53052

3 files changed

Lines changed: 22 additions & 27 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 15
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/the-san-francisco-compute-company/sfc-nodes-679b42a61deffd275fd9e01d6e2c0024540cd0059f4cc01bb52cc2876aaff3af.yml
3-
openapi_spec_hash: 8c3eea1499910eb3683d774fe1a21f79
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/the-san-francisco-compute-company/sfc-nodes-ac16f44d89080c75848b7db501921b159820ec69b23cac750448c429df12abdb.yml
3+
openapi_spec_hash: e58f2d7597976dca2450667819526e74
44
config_hash: 8457a42ab599fb499cdacdb3ff40cfe9

shared/constant/constants.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ func ValueOf[T Constant[T]]() T {
1818
return t.Default()
1919
}
2020

21+
type Image string // Always "image"
22+
type List string // Always "list"
23+
24+
func (c Image) Default() Image { return "image" }
25+
func (c List) Default() List { return "list" }
26+
27+
func (c Image) MarshalJSON() ([]byte, error) { return marshalString(c) }
28+
func (c List) MarshalJSON() ([]byte, error) { return marshalString(c) }
29+
2130
type constant[T any] interface {
2231
Constant[T]
2332
*T

vmimage.go

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/sfcompute/nodes-go/option"
1717
"github.com/sfcompute/nodes-go/packages/param"
1818
"github.com/sfcompute/nodes-go/packages/respjson"
19+
"github.com/sfcompute/nodes-go/shared/constant"
1920
)
2021

2122
// Custom machine images for instances.
@@ -69,9 +70,8 @@ func (r *VMImageService) Get(ctx context.Context, id string, opts ...option.Requ
6970
type VMImageListResponse struct {
7071
Data []VMImageListResponseData `json:"data" api:"required"`
7172
HasMore bool `json:"has_more" api:"required"`
72-
// Any of "list".
73-
Object VMImageListResponseObject `json:"object" api:"required"`
74-
Cursor string `json:"cursor" api:"nullable"`
73+
Object constant.List `json:"object" default:"list"`
74+
Cursor string `json:"cursor" api:"nullable"`
7575
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
7676
JSON struct {
7777
Data respjson.Field
@@ -92,11 +92,10 @@ func (r *VMImageListResponse) UnmarshalJSON(data []byte) error {
9292
type VMImageListResponseData struct {
9393
ID string `json:"id" api:"required"`
9494
// Unix timestamp.
95-
CreatedAt int64 `json:"created_at" api:"required"`
96-
Name string `json:"name" api:"required"`
97-
// Any of "image".
98-
Object string `json:"object" api:"required"`
99-
Owner string `json:"owner" api:"required"`
95+
CreatedAt int64 `json:"created_at" api:"required"`
96+
Name string `json:"name" api:"required"`
97+
Object constant.Image `json:"object" default:"image"`
98+
Owner string `json:"owner" api:"required"`
10099
// A resource path for a image resource. Format:
101100
// sfc:image:<account>:<workspace>:<name>.
102101
ResourcePath string `json:"resource_path" api:"required"`
@@ -128,20 +127,13 @@ func (r *VMImageListResponseData) UnmarshalJSON(data []byte) error {
128127
return apijson.UnmarshalRoot(data, r)
129128
}
130129

131-
type VMImageListResponseObject string
132-
133-
const (
134-
VMImageListResponseObjectList VMImageListResponseObject = "list"
135-
)
136-
137130
type VMImageGetResponse struct {
138131
ID string `json:"id" api:"required"`
139132
// Unix timestamp.
140-
CreatedAt int64 `json:"created_at" api:"required"`
141-
Name string `json:"name" api:"required"`
142-
// Any of "image".
143-
Object VMImageGetResponseObject `json:"object" api:"required"`
144-
Owner string `json:"owner" api:"required"`
133+
CreatedAt int64 `json:"created_at" api:"required"`
134+
Name string `json:"name" api:"required"`
135+
Object constant.Image `json:"object" default:"image"`
136+
Owner string `json:"owner" api:"required"`
145137
// A resource path for a image resource. Format:
146138
// sfc:image:<account>:<workspace>:<name>.
147139
ResourcePath string `json:"resource_path" api:"required"`
@@ -173,12 +165,6 @@ func (r *VMImageGetResponse) UnmarshalJSON(data []byte) error {
173165
return apijson.UnmarshalRoot(data, r)
174166
}
175167

176-
type VMImageGetResponseObject string
177-
178-
const (
179-
VMImageGetResponseObjectImage VMImageGetResponseObject = "image"
180-
)
181-
182168
type VMImageGetResponseUploadStatus string
183169

184170
const (

0 commit comments

Comments
 (0)