Skip to content

Commit 395b5aa

Browse files
authored
Merge pull request #857 from Pangjiping/feat/patch-metadata
feat(specs): metadata patch update
2 parents 24238a7 + 486b1d1 commit 395b5aa

1 file changed

Lines changed: 109 additions & 0 deletions

File tree

specs/sandbox-lifecycle.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,85 @@ paths:
373373
$ref: '#/components/responses/NotFound'
374374
'500':
375375
$ref: '#/components/responses/InternalServerError'
376+
patch:
377+
tags: [Sandboxes]
378+
summary: Patch sandbox metadata
379+
description: |
380+
Update sandbox metadata using JSON Merge Patch semantics (RFC 7396).
381+
382+
The request body is a partial Sandbox representation. Only `metadata` is
383+
mutable; other top-level fields are rejected with 400.
384+
385+
**Merge Patch rules for `metadata`:**
386+
| Request body key/value | Behavior |
387+
|---|---|
388+
| `"key": "value"` | Add or replace the key |
389+
| `"key": null` | Delete the key (silently ignored if key does not exist) |
390+
| key absent | Keep current value (no change) |
391+
| Empty `{}` or `{"metadata": {}}` | No-op, returns current metadata |
392+
393+
Metadata keys and values must comply with Kubernetes label rules:
394+
- Keys must be valid DNS label names or prefixed DNS subdomains
395+
- Keys with the `opensandbox.io/` prefix are reserved and rejected
396+
- Values must be 63 characters or less, matching `[A-Za-z0-9]([-A-Za-z0-9_.]*[A-Za-z0-9])?`
397+
398+
This operation does not restart or recreate the sandbox container/pod.
399+
requestBody:
400+
required: true
401+
content:
402+
application/json:
403+
schema:
404+
$ref: '#/components/schemas/PatchSandboxRequest'
405+
examples:
406+
add-and-replace:
407+
summary: Add new keys and replace existing values
408+
value:
409+
metadata:
410+
team: "platform"
411+
version: "2.0"
412+
delete-key:
413+
summary: Delete a metadata key
414+
value:
415+
metadata:
416+
deprecated-key: null
417+
mixed-operations:
418+
summary: Add, replace, and delete in a single request
419+
value:
420+
metadata:
421+
project: "new-project"
422+
team: null
423+
environment: "production"
424+
empty-body:
425+
summary: No-op (returns current metadata)
426+
value: {}
427+
empty-metadata:
428+
summary: No-op via empty metadata
429+
value:
430+
metadata: {}
431+
responses:
432+
'200':
433+
description: |
434+
Metadata patched successfully. Returns the complete sandbox resource
435+
with updated metadata.
436+
content:
437+
application/json:
438+
schema:
439+
$ref: '#/components/schemas/Sandbox'
440+
headers:
441+
X-Request-ID:
442+
$ref: '#/components/headers/XRequestId'
443+
'400':
444+
$ref: '#/components/responses/BadRequest'
445+
'401':
446+
$ref: '#/components/responses/Unauthorized'
447+
'403':
448+
$ref: '#/components/responses/Forbidden'
449+
'404':
450+
$ref: '#/components/responses/NotFound'
451+
'409':
452+
$ref: '#/components/responses/Conflict'
453+
'500':
454+
$ref: '#/components/responses/InternalServerError'
376455
delete:
377456
tags: [Sandboxes]
378457
summary: Delete a sandbox
@@ -1056,6 +1135,36 @@ components:
10561135
description: Target CPU architecture (for example `amd64` or `arm64`).
10571136
example: arm64
10581137
additionalProperties: false
1138+
PatchSandboxRequest:
1139+
type: object
1140+
description: |
1141+
JSON Merge Patch (RFC 7396) request body for partially updating a sandbox.
1142+
1143+
Only the `metadata` field is mutable. The top-level object follows merge-patch
1144+
semantics: `metadata` present replaces the metadata sub-object (merge-patched),
1145+
`metadata` absent leaves it unchanged. Other top-level fields are rejected.
1146+
1147+
Within `metadata`, the same merge-patch rules apply:
1148+
- Present keys with non-null values add or replace
1149+
- Keys with `null` values are deleted
1150+
- Absent keys are left unchanged
1151+
properties:
1152+
metadata:
1153+
type: object
1154+
additionalProperties:
1155+
type:
1156+
- string
1157+
- 'null'
1158+
description: |
1159+
Metadata key-value pairs to merge into the sandbox's current metadata.
1160+
Set a key's value to `null` to delete it.
1161+
Keys with the `opensandbox.io/` prefix are reserved and rejected.
1162+
example:
1163+
project: "new-project"
1164+
team: null
1165+
environment: "production"
1166+
additionalProperties: false
1167+
10591168
CreateSandboxRequest:
10601169
type: object
10611170
required: [resourceLimits]

0 commit comments

Comments
 (0)