Skip to content

Commit 1fe0edd

Browse files
chore(internal): move custom custom json tags to api
1 parent adcf40b commit 1fe0edd

16 files changed

Lines changed: 188 additions & 149 deletions

build.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,30 +110,30 @@ func (r *BuildService) Get(ctx context.Context, id string, opts ...option.Reques
110110

111111
type Build struct {
112112
// Build job identifier
113-
ID string `json:"id,required"`
113+
ID string `json:"id" api:"required"`
114114
// Build creation timestamp
115-
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
115+
CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"`
116116
// Build job status
117117
//
118118
// Any of "queued", "building", "pushing", "ready", "failed", "cancelled".
119-
Status BuildStatus `json:"status,required"`
119+
Status BuildStatus `json:"status" api:"required"`
120120
// Instance ID of the builder VM (for debugging)
121-
BuilderInstanceID string `json:"builder_instance_id,nullable"`
121+
BuilderInstanceID string `json:"builder_instance_id" api:"nullable"`
122122
// Build completion timestamp
123-
CompletedAt time.Time `json:"completed_at,nullable" format:"date-time"`
123+
CompletedAt time.Time `json:"completed_at" api:"nullable" format:"date-time"`
124124
// Build duration in milliseconds
125-
DurationMs int64 `json:"duration_ms,nullable"`
125+
DurationMs int64 `json:"duration_ms" api:"nullable"`
126126
// Error message (only when status is failed)
127-
Error string `json:"error,nullable"`
127+
Error string `json:"error" api:"nullable"`
128128
// Digest of built image (only when status is ready)
129-
ImageDigest string `json:"image_digest,nullable"`
129+
ImageDigest string `json:"image_digest" api:"nullable"`
130130
// Full image reference (only when status is ready)
131-
ImageRef string `json:"image_ref,nullable"`
131+
ImageRef string `json:"image_ref" api:"nullable"`
132132
Provenance BuildProvenance `json:"provenance"`
133133
// Position in build queue (only when status is queued)
134-
QueuePosition int64 `json:"queue_position,nullable"`
134+
QueuePosition int64 `json:"queue_position" api:"nullable"`
135135
// Build start timestamp
136-
StartedAt time.Time `json:"started_at,nullable" format:"date-time"`
136+
StartedAt time.Time `json:"started_at" api:"nullable" format:"date-time"`
137137
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
138138
JSON struct {
139139
ID respjson.Field
@@ -161,11 +161,11 @@ func (r *Build) UnmarshalJSON(data []byte) error {
161161

162162
type BuildEvent struct {
163163
// Event timestamp
164-
Timestamp time.Time `json:"timestamp,required" format:"date-time"`
164+
Timestamp time.Time `json:"timestamp" api:"required" format:"date-time"`
165165
// Event type
166166
//
167167
// Any of "log", "status", "heartbeat".
168-
Type BuildEventType `json:"type,required"`
168+
Type BuildEventType `json:"type" api:"required"`
169169
// Log line content (only for type=log)
170170
Content string `json:"content"`
171171
// New build status (only for type=status)
@@ -241,7 +241,7 @@ const (
241241

242242
type BuildNewParams struct {
243243
// Source tarball (tar.gz) containing application code and optionally a Dockerfile
244-
Source io.Reader `json:"source,omitzero,required" format:"binary"`
244+
Source io.Reader `json:"source,omitzero" api:"required" format:"binary"`
245245
// Optional pinned base image digest
246246
BaseImageDigest param.Opt[string] `json:"base_image_digest,omitzero"`
247247
// Tenant-specific cache key prefix

device.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ func (r *DeviceService) ListAvailable(ctx context.Context, opts ...option.Reques
8787

8888
type AvailableDevice struct {
8989
// PCI device ID (hex)
90-
DeviceID string `json:"device_id,required"`
90+
DeviceID string `json:"device_id" api:"required"`
9191
// IOMMU group number
92-
IommuGroup int64 `json:"iommu_group,required"`
92+
IommuGroup int64 `json:"iommu_group" api:"required"`
9393
// PCI address
94-
PciAddress string `json:"pci_address,required"`
94+
PciAddress string `json:"pci_address" api:"required"`
9595
// PCI vendor ID (hex)
96-
VendorID string `json:"vendor_id,required"`
96+
VendorID string `json:"vendor_id" api:"required"`
9797
// Currently bound driver (null if none)
98-
CurrentDriver string `json:"current_driver,nullable"`
98+
CurrentDriver string `json:"current_driver" api:"nullable"`
9999
// Human-readable device name
100100
DeviceName string `json:"device_name"`
101101
// Human-readable vendor name
@@ -122,31 +122,31 @@ func (r *AvailableDevice) UnmarshalJSON(data []byte) error {
122122

123123
type Device struct {
124124
// Auto-generated unique identifier (CUID2 format)
125-
ID string `json:"id,required"`
125+
ID string `json:"id" api:"required"`
126126
// Whether the device is currently bound to the vfio-pci driver, which is required
127127
// for VM passthrough.
128128
//
129129
// - true: Device is bound to vfio-pci and ready for (or currently in use by) a VM.
130130
// The device's native driver has been unloaded.
131131
// - false: Device is using its native driver (e.g., nvidia) or no driver. Hypeman
132132
// will automatically bind to vfio-pci when attaching to an instance.
133-
BoundToVfio bool `json:"bound_to_vfio,required"`
133+
BoundToVfio bool `json:"bound_to_vfio" api:"required"`
134134
// Registration timestamp (RFC3339)
135-
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
135+
CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"`
136136
// PCI device ID (hex)
137-
DeviceID string `json:"device_id,required"`
137+
DeviceID string `json:"device_id" api:"required"`
138138
// IOMMU group number
139-
IommuGroup int64 `json:"iommu_group,required"`
139+
IommuGroup int64 `json:"iommu_group" api:"required"`
140140
// PCI address
141-
PciAddress string `json:"pci_address,required"`
141+
PciAddress string `json:"pci_address" api:"required"`
142142
// Type of PCI device
143143
//
144144
// Any of "gpu", "pci".
145-
Type DeviceType `json:"type,required"`
145+
Type DeviceType `json:"type" api:"required"`
146146
// PCI vendor ID (hex)
147-
VendorID string `json:"vendor_id,required"`
147+
VendorID string `json:"vendor_id" api:"required"`
148148
// Instance ID if attached
149-
AttachedTo string `json:"attached_to,nullable"`
149+
AttachedTo string `json:"attached_to" api:"nullable"`
150150
// Device name (user-provided or auto-generated from PCI address)
151151
Name string `json:"name"`
152152
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
@@ -182,7 +182,7 @@ const (
182182

183183
type DeviceNewParams struct {
184184
// PCI address of the device (required, e.g., "0000:a2:00.0")
185-
PciAddress string `json:"pci_address,required"`
185+
PciAddress string `json:"pci_address" api:"required"`
186186
// Optional globally unique device name. If not provided, a name is auto-generated
187187
// from the PCI address (e.g., "pci-0000-a2-00-0")
188188
Name param.Opt[string] `json:"name,omitzero"`

health.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (r *HealthService) Check(ctx context.Context, opts ...option.RequestOption)
4242

4343
type HealthCheckResponse struct {
4444
// Any of "ok".
45-
Status HealthCheckResponseStatus `json:"status,required"`
45+
Status HealthCheckResponseStatus `json:"status" api:"required"`
4646
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
4747
JSON struct {
4848
Status respjson.Field

image.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,29 +79,29 @@ func (r *ImageService) Get(ctx context.Context, name string, opts ...option.Requ
7979

8080
type Image struct {
8181
// Creation timestamp (RFC3339)
82-
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
82+
CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"`
8383
// Resolved manifest digest
84-
Digest string `json:"digest,required"`
84+
Digest string `json:"digest" api:"required"`
8585
// Normalized OCI image reference (tag or digest)
86-
Name string `json:"name,required"`
86+
Name string `json:"name" api:"required"`
8787
// Build status
8888
//
8989
// Any of "pending", "pulling", "converting", "ready", "failed".
90-
Status ImageStatus `json:"status,required"`
90+
Status ImageStatus `json:"status" api:"required"`
9191
// CMD from container metadata
92-
Cmd []string `json:"cmd,nullable"`
92+
Cmd []string `json:"cmd" api:"nullable"`
9393
// Entrypoint from container metadata
94-
Entrypoint []string `json:"entrypoint,nullable"`
94+
Entrypoint []string `json:"entrypoint" api:"nullable"`
9595
// Environment variables from container metadata
9696
Env map[string]string `json:"env"`
9797
// Error message if status is failed
98-
Error string `json:"error,nullable"`
98+
Error string `json:"error" api:"nullable"`
9999
// Position in build queue (null if not queued)
100-
QueuePosition int64 `json:"queue_position,nullable"`
100+
QueuePosition int64 `json:"queue_position" api:"nullable"`
101101
// Disk size in bytes (null until ready)
102-
SizeBytes int64 `json:"size_bytes,nullable"`
102+
SizeBytes int64 `json:"size_bytes" api:"nullable"`
103103
// Working directory from container metadata
104-
WorkingDir string `json:"working_dir,nullable"`
104+
WorkingDir string `json:"working_dir" api:"nullable"`
105105
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
106106
JSON struct {
107107
CreatedAt respjson.Field
@@ -139,7 +139,7 @@ const (
139139

140140
type ImageNewParams struct {
141141
// OCI image reference (e.g., docker.io/library/nginx:latest)
142-
Name string `json:"name,required"`
142+
Name string `json:"name" api:"required"`
143143
paramObj
144144
}
145145

ingress.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ func (r *IngressService) Get(ctx context.Context, id string, opts ...option.Requ
8080

8181
type Ingress struct {
8282
// Auto-generated unique identifier
83-
ID string `json:"id,required"`
83+
ID string `json:"id" api:"required"`
8484
// Creation timestamp (RFC3339)
85-
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
85+
CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"`
8686
// Human-readable name
87-
Name string `json:"name,required"`
87+
Name string `json:"name" api:"required"`
8888
// Routing rules for this ingress
89-
Rules []IngressRule `json:"rules,required"`
89+
Rules []IngressRule `json:"rules" api:"required"`
9090
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
9191
JSON struct {
9292
ID respjson.Field
@@ -113,7 +113,7 @@ type IngressMatch struct {
113113
// Pattern hostnames use named captures in curly braces (e.g., {instance}, {app})
114114
// that extract parts of the hostname for routing. The extracted values can be
115115
// referenced in the target.instance field.
116-
Hostname string `json:"hostname,required"`
116+
Hostname string `json:"hostname" api:"required"`
117117
// Host port to listen on for this rule (default 80)
118118
Port int64 `json:"port"`
119119
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
@@ -150,7 +150,7 @@ type IngressMatchParam struct {
150150
// Pattern hostnames use named captures in curly braces (e.g., {instance}, {app})
151151
// that extract parts of the hostname for routing. The extracted values can be
152152
// referenced in the target.instance field.
153-
Hostname string `json:"hostname,required"`
153+
Hostname string `json:"hostname" api:"required"`
154154
// Host port to listen on for this rule (default 80)
155155
Port param.Opt[int64] `json:"port,omitzero"`
156156
paramObj
@@ -165,8 +165,8 @@ func (r *IngressMatchParam) UnmarshalJSON(data []byte) error {
165165
}
166166

167167
type IngressRule struct {
168-
Match IngressMatch `json:"match,required"`
169-
Target IngressTarget `json:"target,required"`
168+
Match IngressMatch `json:"match" api:"required"`
169+
Target IngressTarget `json:"target" api:"required"`
170170
// Auto-create HTTP to HTTPS redirect for this hostname (only applies when tls is
171171
// enabled)
172172
RedirectHTTP bool `json:"redirect_http"`
@@ -200,8 +200,8 @@ func (r IngressRule) ToParam() IngressRuleParam {
200200

201201
// The properties Match, Target are required.
202202
type IngressRuleParam struct {
203-
Match IngressMatchParam `json:"match,omitzero,required"`
204-
Target IngressTargetParam `json:"target,omitzero,required"`
203+
Match IngressMatchParam `json:"match,omitzero" api:"required"`
204+
Target IngressTargetParam `json:"target,omitzero" api:"required"`
205205
// Auto-create HTTP to HTTPS redirect for this hostname (only applies when tls is
206206
// enabled)
207207
RedirectHTTP param.Opt[bool] `json:"redirect_http,omitzero"`
@@ -227,9 +227,9 @@ type IngressTarget struct {
227227
//
228228
// When using pattern hostnames, the instance is resolved dynamically at request
229229
// time.
230-
Instance string `json:"instance,required"`
230+
Instance string `json:"instance" api:"required"`
231231
// Target port on the instance
232-
Port int64 `json:"port,required"`
232+
Port int64 `json:"port" api:"required"`
233233
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
234234
JSON struct {
235235
Instance respjson.Field
@@ -264,9 +264,9 @@ type IngressTargetParam struct {
264264
//
265265
// When using pattern hostnames, the instance is resolved dynamically at request
266266
// time.
267-
Instance string `json:"instance,required"`
267+
Instance string `json:"instance" api:"required"`
268268
// Target port on the instance
269-
Port int64 `json:"port,required"`
269+
Port int64 `json:"port" api:"required"`
270270
paramObj
271271
}
272272

@@ -281,9 +281,9 @@ func (r *IngressTargetParam) UnmarshalJSON(data []byte) error {
281281
type IngressNewParams struct {
282282
// Human-readable name (lowercase letters, digits, and dashes only; cannot start or
283283
// end with a dash)
284-
Name string `json:"name,required"`
284+
Name string `json:"name" api:"required"`
285285
// Routing rules for this ingress
286-
Rules []IngressRuleParam `json:"rules,omitzero,required"`
286+
Rules []IngressRuleParam `json:"rules,omitzero" api:"required"`
287287
paramObj
288288
}
289289

0 commit comments

Comments
 (0)