Skip to content

Commit 21cd118

Browse files
Merge pull request #21 from rh-amarin/avoid-extends
HYPERFLEET-437 - refactor: changes to adopt oapi-codegen
2 parents f793d93 + 46284c2 commit 21cd118

8 files changed

Lines changed: 676 additions & 799 deletions

File tree

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.1", contact: #{ name: "HyperFleet Team" }, license: #{ name: "Apache 2.0" ,url: "https://www.apache.org/licenses/LICENSE-2.0"} })
23+
@info(#{ version: "1.0.2", 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;

models/clusters/model.tsp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import "../common/model.tsp";
22
import "../statuses/model.tsp";
33
import "../../aliases.tsp";
44

5-
model ClusterBase extends APIResource {
6-
kind: string = "Cluster";
5+
model ClusterBase {
6+
...APIResource;
77

88
/**
99
* Cluster name (unique)
@@ -13,10 +13,6 @@ model ClusterBase extends APIResource {
1313
@pattern("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$")
1414
name: string;
1515

16-
/** Cluster specification
17-
* CLM doesn't know how to unmarshall the spec, it only stores and forwards to adapters to do their job
18-
* But CLM will validate the schema before accepting the request
19-
*/
2016
spec: ClusterSpec;
2117
}
2218

@@ -29,11 +25,6 @@ model ClusterBase extends APIResource {
2925
* Provides quick overview of all reported conditions and aggregated phase.
3026
*/
3127
model ClusterStatus {
32-
/**
33-
* Current cluster phase (native database column).
34-
* Updated when conditions are reported.
35-
* Note: status.phase provides aggregated view from all conditions.
36-
*/
3728
phase: ResourcePhase;
3829

3930
/**
@@ -61,7 +52,8 @@ model ClusterStatus {
6152
}
6253

6354
@example(exampleCluster)
64-
model Cluster extends ClusterBase {
55+
model Cluster {
56+
...ClusterBase;
6557
...APICreatedResource;
6658

6759
/**
@@ -74,8 +66,10 @@ model Cluster extends ClusterBase {
7466
}
7567

7668
@example(exampleClusterCreateRequest)
77-
model ClusterCreateRequest extends ClusterBase {}
69+
model ClusterCreateRequest {
70+
...ClusterBase;
71+
}
7872

79-
model ClusterList extends List {
80-
items: Cluster[];
73+
model ClusterList {
74+
...List<Cluster>;
8175
}

models/common/model.tsp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ model ErrorResponse<Kind, ErrorCode> {
7272
@body error: Error;
7373
}
7474

75-
model APIResource extends ObjectReference {
75+
model APIResource {
76+
...ObjectReference;
7677
/** labels for the API resource as pairs of name:value strings */
7778
labels?: Record<string>;
7879
}
@@ -102,7 +103,8 @@ model SearchParams {
102103
search?: string;
103104
}
104105

105-
model QueryParams extends SearchParams {
106+
model QueryParams {
107+
...SearchParams;
106108
@query
107109
page?: int32 = 1;
108110

@@ -116,10 +118,10 @@ model QueryParams extends SearchParams {
116118
order?: OrderDirection;
117119
}
118120

119-
model List {
121+
model List<T> {
120122
kind: string;
121123
page: int32;
122124
size: int32;
123125
total: int32;
124-
items: unknown[];
126+
items: T[];
125127
}

models/nodepools/model.tsp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ model NodePoolBase {
1313
@pattern("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$")
1414
name: string;
1515

16-
/** NodePool specification
17-
* CLM doesn't know how to unmarshall the spec, it only stores and forwards to adapters to do their job
18-
* But CLM will validate the schema before accepting the request
19-
*/
2016
spec: NodePoolSpec;
2117
}
2218

@@ -26,11 +22,6 @@ model NodePoolBase {
2622
* This object is computed by the service and CANNOT be modified directly.
2723
*/
2824
model NodePoolStatus {
29-
/**
30-
* Current NodePool phase (native database column).
31-
* Updated when conditions are reported.
32-
* Note: status.phase provides aggregated view from all conditions.
33-
*/
3425
phase: ResourcePhase;
3526

3627
/**
@@ -58,7 +49,8 @@ model NodePoolStatus {
5849
}
5950

6051
@example(exampleNodePool)
61-
model NodePool extends NodePoolBase {
52+
model NodePool {
53+
...NodePoolBase;
6254
...APICreatedResource;
6355

6456
/**
@@ -80,6 +72,6 @@ model NodePoolCreateResponse {
8072
...NodePool;
8173
}
8274

83-
model NodePoolList extends List {
84-
items: NodePool[];
75+
model NodePoolList {
76+
...List<NodePool>;
8577
}

models/statuses/model.tsp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ model ConditionBase {
1919
*/
2020
type: string;
2121

22-
/**
23-
* Condition status
24-
*/
2522
status: ConditionStatus;
2623

2724
/**
@@ -47,7 +44,8 @@ model ConditionBase {
4744
* Note: observed_generation is at AdapterStatus level, not per-condition,
4845
* since all conditions in one AdapterStatus share the same observed generation
4946
*/
50-
model AdapterCondition extends ConditionBase {
47+
model AdapterCondition {
48+
...ConditionBase;
5149
// No additional fields - inherits all fields from ConditionBase
5250
}
5351

@@ -56,7 +54,8 @@ model AdapterCondition extends ConditionBase {
5654
* Used for semantic condition types: "ValidationSuccessful", "DNSSuccessful", "NodePoolSuccessful", etc.
5755
* Includes observed_generation and last_updated_time to track adapter-specific state
5856
*/
59-
model ResourceCondition extends ConditionBase {
57+
model ResourceCondition {
58+
...ConditionBase;
6059
/**
6160
* Generation of the spec that this condition reflects
6261
*/
@@ -123,7 +122,8 @@ model AdapterStatusBase {
123122
* Contains multiple conditions, job metadata, and adapter-specific data
124123
*/
125124
@example(exampleAdapterStatus)
126-
model AdapterStatus extends AdapterStatusBase {
125+
model AdapterStatus {
126+
...AdapterStatusBase;
127127
/**
128128
* Kubernetes-style conditions tracking adapter state
129129
* Typically includes: Available, Applied, Health
@@ -147,7 +147,8 @@ model AdapterStatus extends AdapterStatusBase {
147147
* Request payload for creating/updating adapter status
148148
*/
149149
@example(exampleAdapterStatusCreateRequest)
150-
model AdapterStatusCreateRequest extends AdapterStatusBase {
150+
model AdapterStatusCreateRequest {
151+
...AdapterStatusBase;
151152
/**
152153
* When the adapter observed this resource state
153154
* API will use this to set AdapterStatus.last_report_time
@@ -161,6 +162,6 @@ model AdapterStatusCreateRequest extends AdapterStatusBase {
161162
* List of adapter statuses with pagination metadata
162163
*/
163164
@example(exampleAdapterStatusList)
164-
model AdapterStatusList extends List {
165-
items: AdapterStatus[];
165+
model AdapterStatusList {
166+
...List<AdapterStatus>;
166167
}

0 commit comments

Comments
 (0)