|
| 1 | +import "@typespec/openapi"; |
| 2 | +import "../common/model.tsp"; |
| 3 | +import "../statuses/model.tsp"; |
| 4 | +import "./example_resource.tsp"; |
| 5 | +import "./example_post.tsp"; |
| 6 | +import "./example_patch.tsp"; |
| 7 | + |
| 8 | +using OpenAPI; |
| 9 | + |
| 10 | +/** |
| 11 | + * Status computed from adapter condition reports. |
| 12 | + * |
| 13 | + * For adapter-managed resources (Cluster, NodePool), conditions are populated |
| 14 | + * by the status aggregation pipeline. For non-adapter resources (Channel, Version), |
| 15 | + * conditions array is empty. |
| 16 | + */ |
| 17 | +model ResourceStatus { |
| 18 | + conditions: ResourceCondition[]; |
| 19 | +} |
| 20 | + |
| 21 | +@example(exampleResource) |
| 22 | +model Resource { |
| 23 | + /** Resource identifier (UUID v7) */ |
| 24 | + id: Identifier; |
| 25 | + |
| 26 | + /** Entity type discriminator (e.g., "Cluster", "Channel", "Version") */ |
| 27 | + kind: string; |
| 28 | + |
| 29 | + /** Resource name (unique per kind, or per kind+owner for child entities) */ |
| 30 | + @minLength(1) |
| 31 | + @maxLength(253) |
| 32 | + name: string; |
| 33 | + |
| 34 | + /** Resource URI (computed at creation time) */ |
| 35 | + href?: string; |
| 36 | + |
| 37 | + /** Entity-specific payload, validated at runtime against the entity's spec schema */ |
| 38 | + spec: Record<unknown>; |
| 39 | + |
| 40 | + /** Key-value pairs for filtering and grouping */ |
| 41 | + labels?: Record<string>; |
| 42 | + |
| 43 | + status: ResourceStatus; |
| 44 | + |
| 45 | + /** Incremented on spec or label changes */ |
| 46 | + @minValue(1) |
| 47 | + generation: int32; |
| 48 | + |
| 49 | + /** Parent resource reference (present only on child entities) */ |
| 50 | + owner_references?: ObjectReference; |
| 51 | + |
| 52 | + /** Non-ownership associations to other resources, keyed by reference type */ |
| 53 | + references?: Record<ObjectReference[]>; |
| 54 | + |
| 55 | + ...APIMetadata; |
| 56 | +} |
| 57 | + |
| 58 | +@example(exampleResourceCreateRequest) |
| 59 | +model ResourceCreateRequest { |
| 60 | + /** Entity type discriminator */ |
| 61 | + kind: string; |
| 62 | + |
| 63 | + /** Resource name */ |
| 64 | + @minLength(1) |
| 65 | + @maxLength(253) |
| 66 | + name: string; |
| 67 | + |
| 68 | + /** Entity-specific payload */ |
| 69 | + spec: Record<unknown>; |
| 70 | + |
| 71 | + /** Key-value pairs for filtering and grouping */ |
| 72 | + labels?: Record<string>; |
| 73 | + |
| 74 | + /** Non-ownership associations to other resources */ |
| 75 | + references?: Record<ObjectReference[]>; |
| 76 | +} |
| 77 | + |
| 78 | +@extension("minProperties", 1) |
| 79 | +@extension("additionalProperties", false) |
| 80 | +@example(exampleResourcePatchRequest) |
| 81 | +model ResourcePatchRequest { |
| 82 | + spec?: Record<unknown>; |
| 83 | + labels?: Record<string>; |
| 84 | + references?: Record<ObjectReference[]>; |
| 85 | +} |
| 86 | + |
| 87 | +model ResourceList { |
| 88 | + kind: string; |
| 89 | + page: int32; |
| 90 | + size: int32; |
| 91 | + total: int64; |
| 92 | + items: Resource[]; |
| 93 | +} |
0 commit comments