Skip to content

Commit 2807639

Browse files
Merge pull request #36 from ma-hill/HYPERFLEET-978
HYPERFLEET-978 - feat: (1/2) Add PUT command for internal status endpoints …
2 parents 31fbfe1 + 383b955 commit 2807639

7 files changed

Lines changed: 207 additions & 24 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Contains service definitions that generate the OpenAPI specifications:
110110

111111
- **`services/clusters.tsp`** - Cluster resource endpoints
112112
- **`services/statuses.tsp`** - Status resource endpoints (GET only - public API)
113-
- **`services/statuses-internal.tsp`** - Status write endpoints (POST - internal API, see below)
113+
- **`services/statuses-internal.tsp`** - Status write endpoints (POST/PUT - internal API, see below)
114114
- **`services/nodepools.tsp`** - NodePool resource endpoints
115115

116116
#### Public vs Internal API Split
@@ -121,6 +121,7 @@ The status endpoints are split into two files to support different API consumers
121121
|------|------------|----------|-------------------|
122122
| `statuses.tsp` | GET (read) | External clients | ✅ Yes (default) |
123123
| `statuses-internal.tsp` | POST (write) | Internal adapters | ❌ No (opt-in) |
124+
| `statuses-internal.tsp` | PUT (write) | Internal adapters | ❌ No (opt-in) |
124125

125126
**Why the split?**
126127

main.tsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ using OpenAPI;
2020
*
2121
*/
2222
@service(#{ title: "HyperFleet API" })
23-
@info(#{ version: "1.0.8", contact: #{ name: "HyperFleet Team" }, license: #{ name: "Apache 2.0" ,url: "https://www.apache.org/licenses/LICENSE-2.0"} })
23+
@info(#{ version: "1.0.9", contact: #{ name: "HyperFleet Team" }, license: #{ name: "Apache 2.0" ,url: "https://www.apache.org/licenses/LICENSE-2.0"} })
2424
@server("https://hyperfleet.redhat.com", "Production")
2525
@route("/api/hyperfleet/v1")
2626
namespace HyperFleet;

schemas/core/openapi.yaml

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
openapi: 3.0.0
22
info:
33
title: HyperFleet API
4-
version: 1.0.8
4+
version: 1.0.9
55
contact:
66
name: HyperFleet Team
77
license:
@@ -494,6 +494,7 @@ paths:
494494
- name: nodepool_id
495495
in: path
496496
required: true
497+
description: Nodepool ID
497498
schema:
498499
type: string
499500
responses:
@@ -515,6 +516,45 @@ paths:
515516
application/json:
516517
schema:
517518
$ref: '#/components/schemas/AdapterStatusCreateRequest'
519+
security:
520+
- BearerAuth: []
521+
put:
522+
operationId: putNodePoolStatuses
523+
summary: Adapter creates or updates resource nodepool status
524+
parameters:
525+
- name: cluster_id
526+
in: path
527+
required: true
528+
description: Cluster ID
529+
schema:
530+
type: string
531+
- name: nodepool_id
532+
in: path
533+
required: true
534+
description: Nodepool ID
535+
schema:
536+
type: string
537+
responses:
538+
'201':
539+
description: The request has succeeded and a new resource has been created as a result.
540+
content:
541+
application/json:
542+
schema:
543+
$ref: '#/components/schemas/AdapterStatus'
544+
'400':
545+
description: The server could not understand the request due to invalid syntax.
546+
'404':
547+
description: The server cannot find the requested resource.
548+
'409':
549+
description: The request conflicts with the current state of the server.
550+
requestBody:
551+
required: true
552+
content:
553+
application/json:
554+
schema:
555+
$ref: '#/components/schemas/AdapterStatusCreateRequest'
556+
security:
557+
- BearerAuth: []
518558
get:
519559
operationId: getNodePoolsStatuses
520560
summary: List all adapter statuses for nodepools
@@ -589,6 +629,37 @@ paths:
589629
$ref: '#/components/schemas/AdapterStatusCreateRequest'
590630
security:
591631
- BearerAuth: []
632+
put:
633+
operationId: putClusterStatuses
634+
summary: Adapter creates or updates resource cluster status
635+
parameters:
636+
- name: cluster_id
637+
in: path
638+
required: true
639+
description: Cluster ID
640+
schema:
641+
type: string
642+
responses:
643+
'201':
644+
description: The request has succeeded and a new resource has been created as a result.
645+
content:
646+
application/json:
647+
schema:
648+
$ref: '#/components/schemas/AdapterStatus'
649+
'400':
650+
description: The server could not understand the request due to invalid syntax.
651+
'404':
652+
description: The server cannot find the requested resource.
653+
'409':
654+
description: The request conflicts with the current state of the server.
655+
requestBody:
656+
required: true
657+
content:
658+
application/json:
659+
schema:
660+
$ref: '#/components/schemas/AdapterStatusCreateRequest'
661+
security:
662+
- BearerAuth: []
592663
get:
593664
operationId: getClusterStatuses
594665
summary: List all adapter statuses for cluster

schemas/core/swagger.yaml

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ info:
1616
name: Apache 2.0
1717
url: 'https://www.apache.org/licenses/LICENSE-2.0'
1818
title: HyperFleet API
19-
version: 1.0.8
19+
version: 1.0.9
2020
host: hyperfleet.redhat.com
2121
basePath: /
2222
schemes:
@@ -648,7 +648,8 @@ paths:
648648
name: cluster_id
649649
required: true
650650
type: string
651-
- in: path
651+
- description: Nodepool ID
652+
in: path
652653
name: nodepool_id
653654
required: true
654655
type: string
@@ -670,6 +671,8 @@ paths:
670671
description: The server cannot find the requested resource.
671672
'409':
672673
description: The request conflicts with the current state of the server.
674+
security:
675+
- BearerAuth: []
673676
description: >-
674677
Adapter creates or updates its status report for this nodepool.
675678
@@ -682,6 +685,44 @@ paths:
682685
Adapter should call this endpoint every time it evaluates the nodepool.
683686
operationId: postNodePoolStatuses
684687
summary: Create or update adapter status
688+
put:
689+
consumes:
690+
- application/json
691+
produces:
692+
- application/json
693+
parameters:
694+
- description: Cluster ID
695+
in: path
696+
name: cluster_id
697+
required: true
698+
type: string
699+
- description: Nodepool ID
700+
in: path
701+
name: nodepool_id
702+
required: true
703+
type: string
704+
- in: body
705+
name: body
706+
required: true
707+
schema:
708+
$ref: '#/definitions/AdapterStatusCreateRequest'
709+
responses:
710+
'201':
711+
description: >-
712+
The request has succeeded and a new resource has been created as a
713+
result.
714+
schema:
715+
$ref: '#/definitions/AdapterStatus'
716+
'400':
717+
description: The server could not understand the request due to invalid syntax.
718+
'404':
719+
description: The server cannot find the requested resource.
720+
'409':
721+
description: The request conflicts with the current state of the server.
722+
security:
723+
- BearerAuth: []
724+
operationId: putNodePoolStatuses
725+
summary: Adapter creates or updates resource nodepool status
685726
'/api/hyperfleet/v1/clusters/{cluster_id}/statuses':
686727
get:
687728
produces:
@@ -782,6 +823,39 @@ paths:
782823
Adapter should call this endpoint every time it evaluates the cluster.
783824
operationId: postClusterStatuses
784825
summary: Create or update adapter status
826+
put:
827+
consumes:
828+
- application/json
829+
produces:
830+
- application/json
831+
parameters:
832+
- description: Cluster ID
833+
in: path
834+
name: cluster_id
835+
required: true
836+
type: string
837+
- in: body
838+
name: body
839+
required: true
840+
schema:
841+
$ref: '#/definitions/AdapterStatusCreateRequest'
842+
responses:
843+
'201':
844+
description: >-
845+
The request has succeeded and a new resource has been created as a
846+
result.
847+
schema:
848+
$ref: '#/definitions/AdapterStatus'
849+
'400':
850+
description: The server could not understand the request due to invalid syntax.
851+
'404':
852+
description: The server cannot find the requested resource.
853+
'409':
854+
description: The request conflicts with the current state of the server.
855+
security:
856+
- BearerAuth: []
857+
operationId: putClusterStatuses
858+
summary: Adapter creates or updates resource cluster status
785859
/api/hyperfleet/v1/nodepools:
786860
get:
787861
produces:

schemas/gcp/openapi.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
openapi: 3.0.0
22
info:
33
title: HyperFleet API
4-
version: 1.0.8
4+
version: 1.0.9
55
contact:
66
name: HyperFleet Team
77
license:

schemas/gcp/swagger.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ info:
1616
name: Apache 2.0
1717
url: 'https://www.apache.org/licenses/LICENSE-2.0'
1818
title: HyperFleet API
19-
version: 1.0.8
19+
version: 1.0.9
2020
host: hyperfleet.redhat.com
2121
basePath: /
2222
schemes:

services/statuses-internal.tsp

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,17 @@ using Http;
1010
using OpenAPI;
1111

1212
namespace HyperFleet;
13+
1314
@route("/clusters/{cluster_id}/statuses")
1415
@useAuth(HyperFleet.BearerAuth)
1516
//@tag("Cluster statuses")
16-
interface ClusterStatusesInternal{
17-
17+
interface ClusterStatusesInternal {
1818
/**
1919
* Adapter creates or updates its status report for this cluster.
2020
* If adapter already has a status, it will be updated (upsert by adapter name).
2121
*
2222
* Response includes the full adapter status with all conditions.
2323
* Adapter should call this endpoint every time it evaluates the cluster.
24-
*
2524
*/
2625
@route("")
2726
@post
@@ -31,29 +30,43 @@ interface ClusterStatusesInternal{
3130
/**
3231
* Cluster ID
3332
*/
34-
@path cluster_id: string,
33+
@path cluster_id: string,
3534

3635
@body body: AdapterStatusCreateRequest,
3736
):
3837
| (CreatedResponse & AdapterStatus)
39-
| BadRequestResponse
40-
| NotFoundResponse
41-
| ConflictResponse
42-
| BadRequestResponse;
38+
| BadRequestResponse
39+
| NotFoundResponse
40+
| ConflictResponse;
41+
42+
@route("")
43+
@put
44+
@summary("Adapter creates or updates resource cluster status")
45+
@operationId("putClusterStatuses")
46+
putClusterStatuses(
47+
/**
48+
* Cluster ID
49+
*/
50+
@path cluster_id: string,
4351

52+
@body body: AdapterStatusCreateRequest,
53+
):
54+
| (CreatedResponse & AdapterStatus)
55+
| BadRequestResponse
56+
| NotFoundResponse
57+
| ConflictResponse;
4458
}
4559

4660
//@tag("NodePool statuses")
4761
@route("/clusters/{cluster_id}/nodepools/{nodepool_id}/statuses")
48-
interface NodePoolStatusesInternal{
49-
62+
@useAuth(HyperFleet.BearerAuth)
63+
interface NodePoolStatusesInternal {
5064
/**
5165
* Adapter creates or updates its status report for this nodepool.
5266
* If adapter already has a status, it will be updated (upsert by adapter name).
5367
*
5468
* Response includes the full adapter status with all conditions.
5569
* Adapter should call this endpoint every time it evaluates the nodepool.
56-
*
5770
*/
5871
@route("")
5972
@post
@@ -63,15 +76,39 @@ interface NodePoolStatusesInternal{
6376
/**
6477
* Cluster ID
6578
*/
66-
@path cluster_id: string,
67-
@path nodepool_id: string,
79+
@path cluster_id: string,
80+
81+
/**
82+
* Nodepool ID
83+
*/
84+
@path nodepool_id: string,
6885

6986
@body body: AdapterStatusCreateRequest,
7087
):
7188
| (CreatedResponse & AdapterStatus)
72-
| BadRequestResponse
73-
| NotFoundResponse
74-
| ConflictResponse
75-
| BadRequestResponse;
89+
| BadRequestResponse
90+
| NotFoundResponse
91+
| ConflictResponse;
92+
93+
@route("")
94+
@put
95+
@summary("Adapter creates or updates resource nodepool status")
96+
@operationId("putNodePoolStatuses")
97+
putNodePoolStatuses(
98+
/**
99+
* Cluster ID
100+
*/
101+
@path cluster_id: string,
102+
103+
/**
104+
* Nodepool ID
105+
*/
106+
@path nodepool_id: string,
76107

108+
@body body: AdapterStatusCreateRequest,
109+
):
110+
| (CreatedResponse & AdapterStatus)
111+
| BadRequestResponse
112+
| NotFoundResponse
113+
| ConflictResponse;
77114
}

0 commit comments

Comments
 (0)