Skip to content

Commit f793d93

Browse files
Merge pull request #20 from rh-amarin/nodepool-generation
Refactor NodePool models to include generation field
2 parents c1f7ca9 + 9e1dcca commit f793d93

13 files changed

Lines changed: 228 additions & 37 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.0", contact: #{ name: "HyperFleet Team" }, license: #{ name: "Apache 2.0" ,url: "https://www.apache.org/licenses/LICENSE-2.0"} })
23+
@info(#{ version: "1.0.1", 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-core/nodepool/example_nodepool.tsp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const exampleNodePool: NodePool = #{
88
name: "worker-pool-1",
99
labels: #{ environment: "production", pooltype: "worker" },
1010
spec: #{},
11+
generation: 1,
1112
created_time: "2021-01-01T00:00:00Z",
1213
updated_time: "2021-01-01T00:00:00Z",
1314
created_by: "user-123@example.com",

models-gcp/nodepool/example_nodepool.tsp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const exampleNodePool: NodePool = #{
77
href: "https://api.hyperfleet.com/v1/nodepools/nodepool-123",
88
name: "worker-pool-1",
99
labels: #{ environment: "production", pooltype: "worker" },
10+
generation: 1,
1011
spec: #{
1112
platform: #{
1213
type: "gcp",

models/clusters/model.tsp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ model ClusterBase extends APIResource {
88
/**
99
* Cluster name (unique)
1010
*/
11-
@minLength(1)
11+
@minLength(3)
1212
@maxLength(63)
13-
@pattern("^[a-z0-9-]+$")
13+
@pattern("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$")
1414
name: string;
1515

1616
/** Cluster specification
@@ -61,16 +61,16 @@ model ClusterStatus {
6161
}
6262

6363
@example(exampleCluster)
64-
model Cluster extends ClusterBase {
65-
...APICreatedResource;
64+
model Cluster extends ClusterBase {
65+
...APICreatedResource;
66+
6667
/**
6768
* Generation field is updated on customer updates, reflecting the version of the "intent" of the customer
6869
*/
6970
@minValue(1)
7071
generation: int32;
7172

7273
status: ClusterStatus;
73-
7474
}
7575

7676
@example(exampleClusterCreateRequest)

models/common/model.tsp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ enum OrderDirection {
9696
}
9797

9898
model SearchParams {
99+
/** Filter results using TSL (Tree Search Language) query syntax.
100+
* Examples: `status.phase='NotReady'`, `name in ('c1','c2')`, `labels.region='us-east'` */
99101
@query
100102
search?: string;
101103
}

models/nodepools/model.tsp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ import "../../aliases.tsp";
44

55
model NodePoolBase {
66
...APIResource;
7+
78
/**
89
* NodePool name (unique in a cluster)
910
*/
11+
@minLength(3)
12+
@maxLength(63)
13+
@pattern("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$")
1014
name: string;
1115

12-
/** Cluster specification
16+
/** NodePool specification
1317
* CLM doesn't know how to unmarshall the spec, it only stores and forwards to adapters to do their job
1418
* But CLM will validate the schema before accepting the request
1519
*/
@@ -54,21 +58,26 @@ model NodePoolStatus {
5458
}
5559

5660
@example(exampleNodePool)
57-
model NodePool extends NodePoolBase{
61+
model NodePool extends NodePoolBase {
62+
...APICreatedResource;
5863

59-
...APICreatedResource;
60-
owner_references: ObjectReference;
64+
/**
65+
* Generation field is updated on customer updates, reflecting the version of the "intent" of the customer
66+
*/
67+
@minValue(1)
68+
generation: int32;
6169

62-
status: NodePoolStatus;
70+
owner_references: ObjectReference;
71+
status: NodePoolStatus;
6372
}
6473

6574
@example(exampleNodePoolCreateRequest)
6675
model NodePoolCreateRequest {
67-
...NodePoolBase;
76+
...NodePoolBase;
6877
}
6978

7079
model NodePoolCreateResponse {
71-
...NodePool
80+
...NodePool;
7281
}
7382

7483
model NodePoolList extends List {

schemas/core/openapi.yaml

Lines changed: 53 additions & 6 deletions
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.0
4+
version: 1.0.1
55
contact:
66
name: HyperFleet Team
77
license:
@@ -40,6 +40,8 @@ paths:
4040
application/json:
4141
schema:
4242
$ref: '#/components/schemas/Error'
43+
security:
44+
- BearerAuth: []
4345
post:
4446
operationId: postCluster
4547
summary: Create cluster
@@ -71,6 +73,8 @@ paths:
7173
application/json:
7274
schema:
7375
$ref: '#/components/schemas/ClusterCreateRequest'
76+
security:
77+
- BearerAuth: []
7478
/api/hyperfleet/v1/clusters/{cluster_id}:
7579
get:
7680
operationId: getClusterById
@@ -97,6 +101,8 @@ paths:
97101
application/json:
98102
schema:
99103
$ref: '#/components/schemas/Error'
104+
security:
105+
- BearerAuth: []
100106
/api/hyperfleet/v1/clusters/{cluster_id}/nodepools:
101107
get:
102108
operationId: getNodePoolsByClusterId
@@ -129,6 +135,8 @@ paths:
129135
application/json:
130136
schema:
131137
$ref: '#/components/schemas/Error'
138+
security:
139+
- BearerAuth: []
132140
post:
133141
operationId: createNodePool
134142
summary: Create nodepool
@@ -161,6 +169,8 @@ paths:
161169
application/json:
162170
schema:
163171
$ref: '#/components/schemas/NodePoolCreateRequest'
172+
security:
173+
- BearerAuth: []
164174
/api/hyperfleet/v1/clusters/{cluster_id}/nodepools/{nodepool_id}:
165175
get:
166176
operationId: getNodePoolById
@@ -194,6 +204,8 @@ paths:
194204
application/json:
195205
schema:
196206
$ref: '#/components/schemas/Error'
207+
security:
208+
- BearerAuth: []
197209
/api/hyperfleet/v1/clusters/{cluster_id}/nodepools/{nodepool_id}/statuses:
198210
post:
199211
operationId: postNodePoolStatuses
@@ -307,6 +319,8 @@ paths:
307319
application/json:
308320
schema:
309321
$ref: '#/components/schemas/AdapterStatusCreateRequest'
322+
security:
323+
- BearerAuth: []
310324
get:
311325
operationId: getClusterStatuses
312326
summary: List all adapter statuses for cluster
@@ -334,6 +348,8 @@ paths:
334348
description: The server could not understand the request due to invalid syntax.
335349
'404':
336350
description: The server cannot find the requested resource.
351+
security:
352+
- BearerAuth: []
337353
/api/hyperfleet/v1/nodepools:
338354
get:
339355
operationId: getNodePools
@@ -360,6 +376,8 @@ paths:
360376
application/json:
361377
schema:
362378
$ref: '#/components/schemas/Error'
379+
security:
380+
- BearerAuth: []
363381
components:
364382
parameters:
365383
QueryParams.order:
@@ -399,6 +417,9 @@ components:
399417
name: search
400418
in: query
401419
required: false
420+
description: |-
421+
Filter results using TSL (Tree Search Language) query syntax.
422+
Examples: `status.phase='NotReady'`, `name in ('c1','c2')`, `labels.region='us-east'`
402423
schema:
403424
type: string
404425
explode: false
@@ -704,9 +725,9 @@ components:
704725
default: Cluster
705726
name:
706727
type: string
707-
minLength: 1
728+
minLength: 3
708729
maxLength: 63
709-
pattern: ^[a-z0-9-]+$
730+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
710731
description: Cluster name (unique)
711732
spec:
712733
allOf:
@@ -904,6 +925,7 @@ components:
904925
- updated_time
905926
- created_by
906927
- updated_by
928+
- generation
907929
- owner_references
908930
- status
909931
properties:
@@ -919,6 +941,11 @@ components:
919941
updated_by:
920942
type: string
921943
format: email
944+
generation:
945+
type: integer
946+
format: int32
947+
minimum: 1
948+
description: Generation field is updated on customer updates, reflecting the version of the "intent" of the customer
922949
owner_references:
923950
$ref: '#/components/schemas/ObjectReference'
924951
status:
@@ -934,6 +961,7 @@ components:
934961
environment: production
935962
pooltype: worker
936963
spec: {}
964+
generation: 1
937965
created_time: '2021-01-01T00:00:00Z'
938966
updated_time: '2021-01-01T00:00:00Z'
939967
created_by: user-123@example.com
@@ -986,12 +1014,15 @@ components:
9861014
description: Resource URI
9871015
name:
9881016
type: string
1017+
minLength: 3
1018+
maxLength: 63
1019+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
9891020
description: NodePool name (unique in a cluster)
9901021
spec:
9911022
allOf:
9921023
- $ref: '#/components/schemas/NodePoolSpec'
9931024
description: |-
994-
Cluster specification
1025+
NodePool specification
9951026
CLM doesn't know how to unmarshall the spec, it only stores and forwards to adapters to do their job
9961027
But CLM will validate the schema before accepting the request
9971028
NodePoolCreateRequest:
@@ -1016,12 +1047,15 @@ components:
10161047
description: Resource URI
10171048
name:
10181049
type: string
1050+
minLength: 3
1051+
maxLength: 63
1052+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
10191053
description: NodePool name (unique in a cluster)
10201054
spec:
10211055
allOf:
10221056
- $ref: '#/components/schemas/NodePoolSpec'
10231057
description: |-
1024-
Cluster specification
1058+
NodePool specification
10251059
CLM doesn't know how to unmarshall the spec, it only stores and forwards to adapters to do their job
10261060
But CLM will validate the schema before accepting the request
10271061
example:
@@ -1037,6 +1071,7 @@ components:
10371071
- updated_time
10381072
- created_by
10391073
- updated_by
1074+
- generation
10401075
- owner_references
10411076
- status
10421077
- name
@@ -1054,6 +1089,11 @@ components:
10541089
updated_by:
10551090
type: string
10561091
format: email
1092+
generation:
1093+
type: integer
1094+
format: int32
1095+
minimum: 1
1096+
description: Generation field is updated on customer updates, reflecting the version of the "intent" of the customer
10571097
owner_references:
10581098
$ref: '#/components/schemas/ObjectReference'
10591099
status:
@@ -1074,12 +1114,15 @@ components:
10741114
description: Resource URI
10751115
name:
10761116
type: string
1117+
minLength: 3
1118+
maxLength: 63
1119+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
10771120
description: NodePool name (unique in a cluster)
10781121
spec:
10791122
allOf:
10801123
- $ref: '#/components/schemas/NodePoolSpec'
10811124
description: |-
1082-
Cluster specification
1125+
NodePool specification
10831126
CLM doesn't know how to unmarshall the spec, it only stores and forwards to adapters to do their job
10841127
But CLM will validate the schema before accepting the request
10851128
NodePoolList:
@@ -1196,6 +1239,10 @@ components:
11961239
- Ready
11971240
- Failed
11981241
description: Phase of a resource (Cluster or NodePool)
1242+
securitySchemes:
1243+
BearerAuth:
1244+
type: http
1245+
scheme: bearer
11991246
servers:
12001247
- url: https://hyperfleet.redhat.com
12011248
description: Production

0 commit comments

Comments
 (0)