Skip to content

Commit 20c44cf

Browse files
committed
HYPERFLEET-1103 - feat: make statuses core only
1 parent 78199f6 commit 20c44cf

8 files changed

Lines changed: 184 additions & 220 deletions

File tree

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This repository supports the development of the Hyperfleet OpenAPI contract, but is not the source-of-truth for the OpenAPI contract.
44

5-
This project hosts the TypeSpec files to generate the HyperFleet core OpenAPI specification. TypeSpec is an implementation detail providing better ergonomics than writing contracts in plain YAML. The repository generates the core provider contract; the GCP-specific contract lives in [hyperfleet-api-spec-gcp](https://github.com/openshift-hyperfleet/hyperfleet-api-spec-gcp).
5+
This project hosts the TypeSpec files to generate the HyperFleet core OpenAPI specification. TypeSpec is an implementation detail providing better ergonomics than writing contracts in plain YAML. The repository generates the core provider contract; the provider-specific contract lives in [hyperfleet-api-spec-template](https://github.com/openshift-hyperfleet/hyperfleet-api-spec-template).
66

77
Access to the OpenAPI contract source of truth in hyperfleet-api repository:
88

@@ -68,7 +68,7 @@ The repository is organized with root-level configuration files and two main dir
6868

6969
### `/shared`
7070

71-
Contains models and services shared across providers (also published as an npm package for consumption by provider-specific repos like `hyperfleet-api-spec-gcp`):
71+
Contains models and services shared across providers (also published as an npm package for consumption by provider-specific repos like `hyperfleet-api-spec-template`):
7272

7373
- **`shared/models/clusters/`** - Cluster resource definitions (interfaces and base models)
7474
- **`shared/models/statuses/`** - Status resource definitions for clusters and nodepools
@@ -89,10 +89,10 @@ Contains core-specific models and internal services:
8989

9090
The status endpoints are split into two files to support different API consumers:
9191

92-
| File | Operations | Audience | Included in Build |
93-
|------|------------|----------|-------------------|
94-
| `shared/services/statuses.tsp` | GET (read) | External clients | ✅ Yes (default) |
95-
| `core/services/statuses-internal.tsp` | PUT (write) | Internal adapters | ❌ No (opt-in) |
92+
| File | Operations | Audience | Included in Build |
93+
| ------------------------------------- | ----------- | ----------------- | ----------------- |
94+
| `shared/services/statuses.tsp` | GET (read) | External clients | ✅ Yes (default) |
95+
| `core/services/statuses-internal.tsp` | PUT (write) | Internal adapters | ❌ No (opt-in) |
9696

9797
**Why the split?**
9898

@@ -149,7 +149,7 @@ The HyperFleet API provides simple CRUD operations for managing cluster resource
149149

150150
## Adding a New Provider
151151

152-
Provider-specific contracts live in their own repository and consume this repo as an npm package (the `hyperfleet` package). See [hyperfleet-api-spec-gcp](https://github.com/openshift-hyperfleet/hyperfleet-api-spec-gcp) for a reference implementation.
152+
Provider-specific contracts live in their own repository and consume this repo as an npm package (the `hyperfleet` package). See [hyperfleet-api-spec-template](https://github.com/openshift-hyperfleet/hyperfleet-api-spec-template) for a reference implementation.
153153

154154
## Adding a New Service
155155

@@ -162,7 +162,7 @@ To add a new service (e.g., with additional endpoints):
162162
import "@typespec/openapi";
163163
import "../models/common/model.tsp";
164164
// ... other imports as needed
165-
165+
166166
namespace HyperFleet;
167167
@route("/new-resource")
168168
interface NewService {
Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import "@typespec/http";
22
import "@typespec/openapi";
33
import "@typespec/openapi3";
44

5-
import "../models/resource/model.tsp";
6-
import "../models/common/model.tsp";
7-
import "../models/statuses/model.tsp";
5+
import "../../shared/models/resource/model.tsp";
6+
import "../../shared/models/common/model.tsp";
7+
import "../../shared/models/statuses/model.tsp";
88

99
using Http;
1010
using OpenAPI;
@@ -90,4 +90,55 @@ interface Resources {
9090
| Error
9191
| BadRequestResponse;
9292

93+
/**
94+
* Permanently removes the resource record from the database for a resource stuck in Finalizing state.
95+
* This is a database-only operation. Requires a reason for audit purposes.
96+
*/
97+
@route("/{resource_id}/force-delete")
98+
@post
99+
@summary("Force-delete a resource")
100+
@operationId("forceDeleteResource")
101+
forceDeleteResource(
102+
@path resource_id: string,
103+
@body body: ForceDeleteRequest,
104+
): {
105+
@statusCode statusCode: 204;
106+
} | Error
107+
| NotFoundResponse
108+
| BadRequestResponse
109+
| ConflictResponse;
110+
}
111+
112+
@tag("Resource statuses")
113+
@route("/resources/{resource_id}/statuses")
114+
@useAuth(HyperFleet.BearerAuth)
115+
interface ResourceStatuses {
116+
/**
117+
* Returns adapter statuses for a resource.
118+
*/
119+
@route("")
120+
@get
121+
@summary("List resource statuses")
122+
@operationId("getResourceStatuses")
123+
getResourceStatuses(
124+
@path resource_id: string,
125+
...QueryParams,
126+
): Body<AdapterStatusList>
127+
| Error
128+
| NotFoundResponse
129+
| BadRequestResponse;
130+
131+
@route("")
132+
@put
133+
@summary("Adapter creates or updates resource status")
134+
@operationId("putResourceStatuses")
135+
@doc("Adapters call this endpoint to report status for a resource after each evaluation. The adapter's status entry is created if it doesn't exist, or updated if it does (upserted by adapter name).")
136+
putResourceStatuses(
137+
@path resource_id: string,
138+
@body body: AdapterStatusCreateRequest,
139+
):
140+
| (CreatedResponse & AdapterStatus)
141+
| BadRequestResponse
142+
| NotFoundResponse
143+
| ConflictResponse;
93144
}

core/services/statuses-internal.tsp

Lines changed: 37 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,24 @@ namespace HyperFleet;
1414
@route("/clusters/{cluster_id}/statuses")
1515
@useAuth(HyperFleet.BearerAuth)
1616
@tag("Cluster statuses")
17-
interface ClusterStatusesInternal {
17+
interface ClusterStatuses {
18+
/**
19+
* Returns adapter status reports for this cluster
20+
*/
21+
@route("")
22+
@get
23+
@summary("List all adapter statuses for cluster")
24+
@operationId("getClusterStatuses")
25+
getClusterStatuses(
26+
/**
27+
* Cluster ID
28+
*/
29+
@path cluster_id: string,
30+
...QueryParams
31+
): Body<AdapterStatusList>
32+
| NotFoundResponse
33+
| BadRequestResponse;
34+
1835
@route("")
1936
@put
2037
@summary("Adapter creates or updates cluster status")
@@ -37,7 +54,25 @@ interface ClusterStatusesInternal {
3754
@tag("NodePool statuses")
3855
@route("/clusters/{cluster_id}/nodepools/{nodepool_id}/statuses")
3956
@useAuth(HyperFleet.BearerAuth)
40-
interface NodePoolStatusesInternal {
57+
interface NodePoolStatuses {
58+
/**
59+
* Returns adapter status reports for this nodepool
60+
*/
61+
@route("")
62+
@get
63+
@summary("List all adapter statuses for nodepools")
64+
@operationId("getNodePoolsStatuses")
65+
getNodePoolsStatuses(
66+
/**
67+
* Cluster ID
68+
*/
69+
@path cluster_id: string,
70+
@path nodepool_id: string,
71+
...QueryParams
72+
): Body<AdapterStatusList>
73+
| Error
74+
| BadRequestResponse;
75+
4176
@route("")
4277
@put
4378
@summary("Adapter creates or updates nodepool status")
@@ -61,45 +96,3 @@ interface NodePoolStatusesInternal {
6196
| NotFoundResponse
6297
| ConflictResponse;
6398
}
64-
65-
@tag("Resource statuses")
66-
@route("/resources/{resource_id}/statuses")
67-
@useAuth(HyperFleet.BearerAuth)
68-
interface ResourceStatusesInternal {
69-
@route("")
70-
@put
71-
@summary("Adapter creates or updates resource status")
72-
@operationId("putResourceStatuses")
73-
@doc("Adapters call this endpoint to report status for a resource after each evaluation. The adapter's status entry is created if it doesn't exist, or updated if it does (upserted by adapter name).")
74-
putResourceStatuses(
75-
@path resource_id: string,
76-
@body body: AdapterStatusCreateRequest,
77-
):
78-
| (CreatedResponse & AdapterStatus)
79-
| BadRequestResponse
80-
| NotFoundResponse
81-
| ConflictResponse;
82-
}
83-
84-
@tag("Resources")
85-
@route("/resources")
86-
@useAuth(HyperFleet.BearerAuth)
87-
interface ResourcesForceDelete {
88-
/**
89-
* Permanently removes the resource record from the database for a resource stuck in Finalizing state.
90-
* This is a database-only operation. Requires a reason for audit purposes.
91-
*/
92-
@route("/{resource_id}/force-delete")
93-
@post
94-
@summary("Force-delete a resource")
95-
@operationId("forceDeleteResource")
96-
forceDeleteResource(
97-
@path resource_id: string,
98-
@body body: ForceDeleteRequest,
99-
): {
100-
@statusCode statusCode: 204;
101-
} | Error
102-
| NotFoundResponse
103-
| BadRequestResponse
104-
| ConflictResponse;
105-
}

main.tsp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ import "./core/models/nodepool/example_nodepool.tsp";
1111
import "./core/models/nodepool/example_post.tsp";
1212
import "./core/models/nodepool/example_patch.tsp";
1313
import "./core/services/statuses-internal.tsp";
14+
import "./core/services/resources-internal.tsp";
1415

1516
import "./shared/services/clusters.tsp";
16-
import "./shared/services/statuses.tsp";
1717
import "./shared/services/nodepools.tsp";
18-
import "./shared/services/resources.tsp";
1918
import "./core/services/force-delete-internal.tsp";
2019

2120
using Http;
@@ -31,7 +30,7 @@ using OpenAPI;
3130
*/
3231
@service(#{ title: "HyperFleet API" })
3332
@info(#{
34-
version: "1.0.18",
33+
version: "1.0.21",
3534
contact: #{
3635
name: "HyperFleet Team",
3736
url: "https://github.com/openshift-hyperfleet",

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hyperfleet",
3-
"version": "1.0.18",
3+
"version": "1.0.21",
44
"type": "module",
55
"exports": {
66
"./*": "./*"

0 commit comments

Comments
 (0)