Skip to content

Commit d1ae537

Browse files
author
Joshua Sachs
committed
[MORPH-8427] document systems component update semantics
1 parent 0befbc9 commit d1ae537

9 files changed

Lines changed: 85 additions & 12 deletions

components/examples/systemRequest.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
"layout": { "id": 1 },
77
"enabled": true,
88
"externalId": "ext-1234",
9-
"config": {}
9+
"config": {},
10+
"components": [
11+
{
12+
"typeCode": "primary-node",
13+
"name": "Primary Node",
14+
"config": {
15+
"hostname": "node1.example.com"
16+
}
17+
}
18+
]
1019
}
1120
}
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
{
22
"system": {
3-
"name": "my-system-renamed",
43
"description": "Updated description",
5-
"enabled": true
4+
"components": [
5+
{
6+
"id": 10,
7+
"name": "Primary Node Renamed",
8+
"externalId": "ext-comp-10"
9+
},
10+
{
11+
"typeCode": "storage-controller",
12+
"name": "Storage Controller",
13+
"config": {
14+
"hostname": "storage1.example.com"
15+
}
16+
}
17+
]
618
}
719
}

components/schemas/systemComponentRequest.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
type: object
22
description: |
3-
A component payload for use in uninitialized create and initialize requests.
4-
Components are matched to layout component type definitions by `typeCode`.
5-
Unmatched `typeCode` values are silently ignored.
3+
A component payload for Systems create, update, and initialize requests.
4+
Components can be matched by `id` or `typeCode`, depending on the endpoint behavior.
5+
For create or new-component creation flows, `typeCode` identifies the component type to create.
66
properties:
7+
id:
8+
type: integer
9+
format: int64
10+
description: Existing system component id. When supplied, endpoints that support component updates match by id first.
11+
example: 10
712
typeCode:
813
type: string
9-
description: The code of the layout component type this entry applies to.
14+
description: The code of the component type this entry applies to.
1015
example: primary-node
1116
name:
1217
type: string
@@ -20,5 +25,3 @@ properties:
2025
type: object
2126
description: Arbitrary configuration data for the component.
2227
additionalProperties: true
23-
required:
24-
- typeCode

components/schemas/systemCreate.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
type: object
2+
description: |
3+
Request body for creating a provider-backed system.
4+
Standard create supports optional `components[]`. When supplied, component entries are
5+
processed after the parent system is created and provider lifecycle begins.
26
properties:
37
name:
48
type: string
@@ -38,6 +42,14 @@ properties:
3842
type: object
3943
description: Arbitrary configuration data for the system.
4044
additionalProperties: true
45+
components:
46+
type: array
47+
description: |
48+
Optional component payloads for create. Existing components are matched by `id` first,
49+
then by `typeCode` when exactly one existing component matches. New components can be
50+
created by supplying a valid `typeCode`.
51+
items:
52+
$ref: systemComponentRequest.yaml
4153
required:
4254
- name
4355
- type

components/schemas/systemInitialize.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ properties:
3737
components:
3838
type: array
3939
description: |
40-
Optional component overrides. Components are matched by `id` first, then by `typeCode`.
41-
Updates name, externalId, and config on matched skeleton components.
40+
Optional component overrides. Components are matched by `id` first, then by `typeCode`
41+
when exactly one existing component matches. Updates name, externalId, and config on
42+
matched components, and can create a new component when a valid `typeCode` is supplied
43+
with no existing match.
4244
items:
4345
$ref: systemComponentRequest.yaml

components/schemas/systemUpdate.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ type: object
22
description: |
33
Request body for updating an existing system. All fields are optional — only supplied
44
fields are applied. The system's existing `type` cannot be changed via this endpoint.
5+
If `components` is omitted, the existing component set is left unchanged.
6+
If `components` is present, it is authoritative: the submitted array is treated as the
7+
desired final component set, and existing components omitted from the array are removed.
58
properties:
69
name:
710
type: string
@@ -39,3 +42,12 @@ properties:
3942
format: int64
4043
description: ID of the new system type layout.
4144
example: 2
45+
components:
46+
type: array
47+
description: |
48+
Optional authoritative component payloads. Components are matched by `id` first, then
49+
by `typeCode` when exactly one existing component matches. New components can be created
50+
by supplying a valid `typeCode`. When this field is present, omitted existing components
51+
are removed from the system.
52+
items:
53+
$ref: systemComponentRequest.yaml

paths/api@infrastructure@systems.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ get:
2727

2828
post:
2929
summary: Create a System
30-
description: This endpoint creates a new system.
30+
description: |
31+
Creates a new provider-backed system.
32+
33+
Standard create supports optional `system.components[]` payloads. When supplied,
34+
component entries are applied as part of the create lifecycle after the parent system
35+
record is created.
3136
operationId: addSystem
3237
tags:
3338
- Systems

paths/api@infrastructure@systems@id.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,22 @@ put:
3030
description: |
3131
Updates an existing system. All request body fields are optional — only supplied
3232
fields are applied. The system's `type` cannot be changed via this endpoint.
33+
34+
If `system.components` is omitted, the system's existing components are left unchanged.
35+
If `system.components` is present, it is authoritative: the submitted array is treated
36+
as the desired final component set, and existing components omitted from the array are removed.
37+
38+
**Component matching behavior** for `components[]` entries:
39+
40+
1. Match by `id` — if a payload supplies an `id`, the component with that id is updated.
41+
2. Fallback to `typeCode` — if no `id` is supplied (or the id is not found), the system's
42+
existing components are searched by `typeCode`. The fallback only applies when **exactly
43+
one** existing component matches; if multiple components share the same `typeCode` the
44+
entry is skipped (ambiguous — supply `id` to disambiguate).
45+
3. New component creation — if no existing component matches and the `typeCode` is a valid
46+
component type code, a new component is created.
47+
4. Unknown `typeCode` — if no existing component matches and the `typeCode` does not
48+
correspond to a known component type, the entry is silently skipped.
3349
operationId: updateSystem
3450
tags:
3551
- Systems

paths/api@infrastructure@systems@id@initialize.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ put:
55
or `failed` status. This is the counterpart to `POST /api/infrastructure/systems/uninitialized`.
66
77
Any fields supplied in the request body are applied to the system before provider invocation.
8+
Unlike normal `PUT /api/infrastructure/systems/{id}` updates, initialize does not use
9+
authoritative omission-based component removal semantics.
810
911
**Component matching behavior** for `components[]` entries:
1012

0 commit comments

Comments
 (0)