diff --git a/main.tsp b/main.tsp index 54d420d..5712de6 100644 --- a/main.tsp +++ b/main.tsp @@ -20,7 +20,7 @@ using OpenAPI; * */ @service(#{ title: "HyperFleet API" }) -@info(#{ version: "1.0.0", contact: #{ name: "HyperFleet Team" }, license: #{ name: "Apache 2.0" ,url: "https://www.apache.org/licenses/LICENSE-2.0"} }) +@info(#{ version: "1.0.1", contact: #{ name: "HyperFleet Team" }, license: #{ name: "Apache 2.0" ,url: "https://www.apache.org/licenses/LICENSE-2.0"} }) @server("https://hyperfleet.redhat.com", "Production") @route("/api/hyperfleet/v1") namespace HyperFleet; diff --git a/models-core/nodepool/example_nodepool.tsp b/models-core/nodepool/example_nodepool.tsp index 2d08576..f7f175f 100644 --- a/models-core/nodepool/example_nodepool.tsp +++ b/models-core/nodepool/example_nodepool.tsp @@ -8,6 +8,7 @@ const exampleNodePool: NodePool = #{ name: "worker-pool-1", labels: #{ environment: "production", pooltype: "worker" }, spec: #{}, + generation: 1, created_time: "2021-01-01T00:00:00Z", updated_time: "2021-01-01T00:00:00Z", created_by: "user-123@example.com", diff --git a/models-gcp/nodepool/example_nodepool.tsp b/models-gcp/nodepool/example_nodepool.tsp index 3ca171e..05b633e 100644 --- a/models-gcp/nodepool/example_nodepool.tsp +++ b/models-gcp/nodepool/example_nodepool.tsp @@ -7,6 +7,7 @@ const exampleNodePool: NodePool = #{ href: "https://api.hyperfleet.com/v1/nodepools/nodepool-123", name: "worker-pool-1", labels: #{ environment: "production", pooltype: "worker" }, + generation: 1, spec: #{ platform: #{ type: "gcp", diff --git a/models/clusters/model.tsp b/models/clusters/model.tsp index b1edfdd..aaeaaa9 100644 --- a/models/clusters/model.tsp +++ b/models/clusters/model.tsp @@ -8,9 +8,9 @@ model ClusterBase extends APIResource { /** * Cluster name (unique) */ - @minLength(1) + @minLength(3) @maxLength(63) - @pattern("^[a-z0-9-]+$") + @pattern("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$") name: string; /** Cluster specification @@ -61,8 +61,9 @@ model ClusterStatus { } @example(exampleCluster) -model Cluster extends ClusterBase { -...APICreatedResource; +model Cluster extends ClusterBase { + ...APICreatedResource; + /** * Generation field is updated on customer updates, reflecting the version of the "intent" of the customer */ @@ -70,7 +71,6 @@ model Cluster extends ClusterBase { generation: int32; status: ClusterStatus; - } @example(exampleClusterCreateRequest) diff --git a/models/common/model.tsp b/models/common/model.tsp index c98fd1e..4772e60 100644 --- a/models/common/model.tsp +++ b/models/common/model.tsp @@ -96,6 +96,8 @@ enum OrderDirection { } model SearchParams { + /** Filter results using TSL (Tree Search Language) query syntax. + * Examples: `status.phase='NotReady'`, `name in ('c1','c2')`, `labels.region='us-east'` */ @query search?: string; } diff --git a/models/nodepools/model.tsp b/models/nodepools/model.tsp index 23fd494..de07d0e 100644 --- a/models/nodepools/model.tsp +++ b/models/nodepools/model.tsp @@ -4,12 +4,16 @@ import "../../aliases.tsp"; model NodePoolBase { ...APIResource; + /** * NodePool name (unique in a cluster) */ + @minLength(3) + @maxLength(63) + @pattern("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$") name: string; - /** Cluster specification + /** NodePool specification * CLM doesn't know how to unmarshall the spec, it only stores and forwards to adapters to do their job * But CLM will validate the schema before accepting the request */ @@ -54,21 +58,26 @@ model NodePoolStatus { } @example(exampleNodePool) -model NodePool extends NodePoolBase{ +model NodePool extends NodePoolBase { + ...APICreatedResource; - ...APICreatedResource; - owner_references: ObjectReference; + /** + * Generation field is updated on customer updates, reflecting the version of the "intent" of the customer + */ + @minValue(1) + generation: int32; - status: NodePoolStatus; + owner_references: ObjectReference; + status: NodePoolStatus; } @example(exampleNodePoolCreateRequest) model NodePoolCreateRequest { - ...NodePoolBase; + ...NodePoolBase; } model NodePoolCreateResponse { - ...NodePool + ...NodePool; } model NodePoolList extends List { diff --git a/schemas/core/openapi.yaml b/schemas/core/openapi.yaml index 9ce2b57..7b20a9f 100644 --- a/schemas/core/openapi.yaml +++ b/schemas/core/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: HyperFleet API - version: 1.0.0 + version: 1.0.1 contact: name: HyperFleet Team license: @@ -40,6 +40,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' + security: + - BearerAuth: [] post: operationId: postCluster summary: Create cluster @@ -71,6 +73,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ClusterCreateRequest' + security: + - BearerAuth: [] /api/hyperfleet/v1/clusters/{cluster_id}: get: operationId: getClusterById @@ -97,6 +101,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' + security: + - BearerAuth: [] /api/hyperfleet/v1/clusters/{cluster_id}/nodepools: get: operationId: getNodePoolsByClusterId @@ -129,6 +135,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' + security: + - BearerAuth: [] post: operationId: createNodePool summary: Create nodepool @@ -161,6 +169,8 @@ paths: application/json: schema: $ref: '#/components/schemas/NodePoolCreateRequest' + security: + - BearerAuth: [] /api/hyperfleet/v1/clusters/{cluster_id}/nodepools/{nodepool_id}: get: operationId: getNodePoolById @@ -194,6 +204,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' + security: + - BearerAuth: [] /api/hyperfleet/v1/clusters/{cluster_id}/nodepools/{nodepool_id}/statuses: post: operationId: postNodePoolStatuses @@ -307,6 +319,8 @@ paths: application/json: schema: $ref: '#/components/schemas/AdapterStatusCreateRequest' + security: + - BearerAuth: [] get: operationId: getClusterStatuses summary: List all adapter statuses for cluster @@ -334,6 +348,8 @@ paths: description: The server could not understand the request due to invalid syntax. '404': description: The server cannot find the requested resource. + security: + - BearerAuth: [] /api/hyperfleet/v1/nodepools: get: operationId: getNodePools @@ -360,6 +376,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' + security: + - BearerAuth: [] components: parameters: QueryParams.order: @@ -399,6 +417,9 @@ components: name: search in: query required: false + description: |- + Filter results using TSL (Tree Search Language) query syntax. + Examples: `status.phase='NotReady'`, `name in ('c1','c2')`, `labels.region='us-east'` schema: type: string explode: false @@ -704,9 +725,9 @@ components: default: Cluster name: type: string - minLength: 1 + minLength: 3 maxLength: 63 - pattern: ^[a-z0-9-]+$ + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ description: Cluster name (unique) spec: allOf: @@ -904,6 +925,7 @@ components: - updated_time - created_by - updated_by + - generation - owner_references - status properties: @@ -919,6 +941,11 @@ components: updated_by: type: string format: email + generation: + type: integer + format: int32 + minimum: 1 + description: Generation field is updated on customer updates, reflecting the version of the "intent" of the customer owner_references: $ref: '#/components/schemas/ObjectReference' status: @@ -934,6 +961,7 @@ components: environment: production pooltype: worker spec: {} + generation: 1 created_time: '2021-01-01T00:00:00Z' updated_time: '2021-01-01T00:00:00Z' created_by: user-123@example.com @@ -986,12 +1014,15 @@ components: description: Resource URI name: type: string + minLength: 3 + maxLength: 63 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ description: NodePool name (unique in a cluster) spec: allOf: - $ref: '#/components/schemas/NodePoolSpec' description: |- - Cluster specification + NodePool specification CLM doesn't know how to unmarshall the spec, it only stores and forwards to adapters to do their job But CLM will validate the schema before accepting the request NodePoolCreateRequest: @@ -1016,12 +1047,15 @@ components: description: Resource URI name: type: string + minLength: 3 + maxLength: 63 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ description: NodePool name (unique in a cluster) spec: allOf: - $ref: '#/components/schemas/NodePoolSpec' description: |- - Cluster specification + NodePool specification CLM doesn't know how to unmarshall the spec, it only stores and forwards to adapters to do their job But CLM will validate the schema before accepting the request example: @@ -1037,6 +1071,7 @@ components: - updated_time - created_by - updated_by + - generation - owner_references - status - name @@ -1054,6 +1089,11 @@ components: updated_by: type: string format: email + generation: + type: integer + format: int32 + minimum: 1 + description: Generation field is updated on customer updates, reflecting the version of the "intent" of the customer owner_references: $ref: '#/components/schemas/ObjectReference' status: @@ -1074,12 +1114,15 @@ components: description: Resource URI name: type: string + minLength: 3 + maxLength: 63 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ description: NodePool name (unique in a cluster) spec: allOf: - $ref: '#/components/schemas/NodePoolSpec' description: |- - Cluster specification + NodePool specification CLM doesn't know how to unmarshall the spec, it only stores and forwards to adapters to do their job But CLM will validate the schema before accepting the request NodePoolList: @@ -1196,6 +1239,10 @@ components: - Ready - Failed description: Phase of a resource (Cluster or NodePool) + securitySchemes: + BearerAuth: + type: http + scheme: bearer servers: - url: https://hyperfleet.redhat.com description: Production diff --git a/schemas/gcp/openapi.yaml b/schemas/gcp/openapi.yaml index 1dbda88..24dfb34 100644 --- a/schemas/gcp/openapi.yaml +++ b/schemas/gcp/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: HyperFleet API - version: 1.0.0 + version: 1.0.1 contact: name: HyperFleet Team license: @@ -40,6 +40,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' + security: + - BearerAuth: [] post: operationId: postCluster summary: Create cluster @@ -71,6 +73,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ClusterCreateRequest' + security: + - BearerAuth: [] /api/hyperfleet/v1/clusters/{cluster_id}: get: operationId: getClusterById @@ -97,6 +101,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' + security: + - BearerAuth: [] /api/hyperfleet/v1/clusters/{cluster_id}/nodepools: get: operationId: getNodePoolsByClusterId @@ -129,6 +135,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' + security: + - BearerAuth: [] post: operationId: createNodePool summary: Create nodepool @@ -161,6 +169,8 @@ paths: application/json: schema: $ref: '#/components/schemas/NodePoolCreateRequest' + security: + - BearerAuth: [] /api/hyperfleet/v1/clusters/{cluster_id}/nodepools/{nodepool_id}: get: operationId: getNodePoolById @@ -194,6 +204,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' + security: + - BearerAuth: [] /api/hyperfleet/v1/clusters/{cluster_id}/nodepools/{nodepool_id}/statuses: get: operationId: getNodePoolsStatuses @@ -259,6 +271,8 @@ paths: description: The server could not understand the request due to invalid syntax. '404': description: The server cannot find the requested resource. + security: + - BearerAuth: [] /api/hyperfleet/v1/nodepools: get: operationId: getNodePools @@ -285,6 +299,8 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' + security: + - BearerAuth: [] components: parameters: QueryParams.order: @@ -324,6 +340,9 @@ components: name: search in: query required: false + description: |- + Filter results using TSL (Tree Search Language) query syntax. + Examples: `status.phase='NotReady'`, `name in ('c1','c2')`, `labels.region='us-east'` schema: type: string explode: false @@ -682,9 +701,9 @@ components: default: Cluster name: type: string - minLength: 1 + minLength: 3 maxLength: 63 - pattern: ^[a-z0-9-]+$ + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ description: Cluster name (unique) spec: allOf: @@ -958,6 +977,7 @@ components: - updated_time - created_by - updated_by + - generation - owner_references - status properties: @@ -973,6 +993,11 @@ components: updated_by: type: string format: email + generation: + type: integer + format: int32 + minimum: 1 + description: Generation field is updated on customer updates, reflecting the version of the "intent" of the customer owner_references: $ref: '#/components/schemas/ObjectReference' status: @@ -987,6 +1012,7 @@ components: labels: environment: production pooltype: worker + generation: 1 spec: platform: type: gcp @@ -1059,12 +1085,15 @@ components: description: Resource URI name: type: string + minLength: 3 + maxLength: 63 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ description: NodePool name (unique in a cluster) spec: allOf: - $ref: '#/components/schemas/NodePoolSpec' description: |- - Cluster specification + NodePool specification CLM doesn't know how to unmarshall the spec, it only stores and forwards to adapters to do their job But CLM will validate the schema before accepting the request NodePoolCreateRequest: @@ -1089,12 +1118,15 @@ components: description: Resource URI name: type: string + minLength: 3 + maxLength: 63 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ description: NodePool name (unique in a cluster) spec: allOf: - $ref: '#/components/schemas/NodePoolSpec' description: |- - Cluster specification + NodePool specification CLM doesn't know how to unmarshall the spec, it only stores and forwards to adapters to do their job But CLM will validate the schema before accepting the request example: @@ -1129,6 +1161,7 @@ components: - updated_time - created_by - updated_by + - generation - owner_references - status - name @@ -1146,6 +1179,11 @@ components: updated_by: type: string format: email + generation: + type: integer + format: int32 + minimum: 1 + description: Generation field is updated on customer updates, reflecting the version of the "intent" of the customer owner_references: $ref: '#/components/schemas/ObjectReference' status: @@ -1166,12 +1204,15 @@ components: description: Resource URI name: type: string + minLength: 3 + maxLength: 63 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ description: NodePool name (unique in a cluster) spec: allOf: - $ref: '#/components/schemas/NodePoolSpec' description: |- - Cluster specification + NodePool specification CLM doesn't know how to unmarshall the spec, it only stores and forwards to adapters to do their job But CLM will validate the schema before accepting the request NodePoolList: @@ -1361,6 +1402,10 @@ components: - NoSchedule - PreferNoSchedule - NoExecute + securitySchemes: + BearerAuth: + type: http + scheme: bearer servers: - url: https://hyperfleet.redhat.com description: Production diff --git a/schemas/gcp/swagger.yaml b/schemas/gcp/swagger.yaml index c0cd7c3..57b7cc2 100644 --- a/schemas/gcp/swagger.yaml +++ b/schemas/gcp/swagger.yaml @@ -16,7 +16,7 @@ info: name: Apache 2.0 url: 'https://www.apache.org/licenses/LICENSE-2.0' title: HyperFleet API - version: 1.0.0 + version: 1.0.1 host: hyperfleet.redhat.com basePath: / schemes: @@ -51,7 +51,12 @@ paths: name: order required: false type: string - - in: query + - description: >- + Filter results using TSL (Tree Search Language) query syntax. + + Examples: `status.phase='NotReady'`, `name in ('c1','c2')`, + `labels.region='us-east'` + in: query name: search required: false type: string @@ -66,6 +71,8 @@ paths: description: An unexpected error response. schema: $ref: '#/definitions/Error' + security: + - BearerAuth: [] operationId: getClusters summary: List clusters post: @@ -92,6 +99,8 @@ paths: description: An unexpected error response. schema: $ref: '#/definitions/Error' + security: + - BearerAuth: [] description: >- Create a new cluster resource. @@ -110,7 +119,12 @@ paths: produces: - application/json parameters: - - in: query + - description: >- + Filter results using TSL (Tree Search Language) query syntax. + + Examples: `status.phase='NotReady'`, `name in ('c1','c2')`, + `labels.region='us-east'` + in: query name: search required: false type: string @@ -129,6 +143,8 @@ paths: description: An unexpected error response. schema: $ref: '#/definitions/Error' + security: + - BearerAuth: [] operationId: getClusterById summary: Get cluster by ID '/api/hyperfleet/v1/clusters/{cluster_id}/nodepools': @@ -165,7 +181,12 @@ paths: name: order required: false type: string - - in: query + - description: >- + Filter results using TSL (Tree Search Language) query syntax. + + Examples: `status.phase='NotReady'`, `name in ('c1','c2')`, + `labels.region='us-east'` + in: query name: search required: false type: string @@ -180,6 +201,8 @@ paths: description: An unexpected error response. schema: $ref: '#/definitions/Error' + security: + - BearerAuth: [] description: Returns the list of all nodepools for a cluster operationId: getNodePoolsByClusterId summary: List all nodepools for cluster @@ -212,6 +235,8 @@ paths: description: An unexpected error response. schema: $ref: '#/definitions/Error' + security: + - BearerAuth: [] description: Create a NodePool for a cluster operationId: createNodePool summary: Create nodepool @@ -241,6 +266,8 @@ paths: description: An unexpected error response. schema: $ref: '#/definitions/Error' + security: + - BearerAuth: [] description: Returns specific nodepool operationId: getNodePoolById summary: Get nodepool by ID @@ -282,7 +309,12 @@ paths: name: order required: false type: string - - in: query + - description: >- + Filter results using TSL (Tree Search Language) query syntax. + + Examples: `status.phase='NotReady'`, `name in ('c1','c2')`, + `labels.region='us-east'` + in: query name: search required: false type: string @@ -334,7 +366,12 @@ paths: name: order required: false type: string - - in: query + - description: >- + Filter results using TSL (Tree Search Language) query syntax. + + Examples: `status.phase='NotReady'`, `name in ('c1','c2')`, + `labels.region='us-east'` + in: query name: search required: false type: string @@ -347,6 +384,8 @@ paths: description: The server could not understand the request due to invalid syntax. '404': description: The server cannot find the requested resource. + security: + - BearerAuth: [] description: Returns adapter status reports for this cluster operationId: getClusterStatuses summary: List all adapter statuses for cluster @@ -379,7 +418,12 @@ paths: name: order required: false type: string - - in: query + - description: >- + Filter results using TSL (Tree Search Language) query syntax. + + Examples: `status.phase='NotReady'`, `name in ('c1','c2')`, + `labels.region='us-east'` + in: query name: search required: false type: string @@ -394,6 +438,8 @@ paths: description: An unexpected error response. schema: $ref: '#/definitions/Error' + security: + - BearerAuth: [] description: Returns the list of all nodepools operationId: getNodePools summary: List all nodepools for cluster @@ -760,8 +806,8 @@ definitions: name: description: Cluster name (unique) maxLength: 63 - minLength: 1 - pattern: '^[a-z0-9-]+$' + minLength: 3 + pattern: '^[a-z0-9]([-a-z0-9]*[a-z0-9])?$' type: string spec: allOf: @@ -1057,6 +1103,7 @@ definitions: example: created_by: user-123@example.com created_time: '2021-01-01T00:00:00Z' + generation: 1 href: 'https://api.hyperfleet.com/v1/nodepools/nodepool-123' id: nodepool-123 kind: NodePool @@ -1119,6 +1166,13 @@ definitions: created_time: format: date-time type: string + generation: + description: >- + Generation field is updated on customer updates, reflecting the + version of the "intent" of the customer + format: int32 + minimum: 1 + type: integer owner_references: $ref: '#/definitions/ObjectReference' status: @@ -1134,6 +1188,7 @@ definitions: - updated_time - created_by - updated_by + - generation - owner_references - status type: object @@ -1155,12 +1210,15 @@ definitions: type: object name: description: NodePool name (unique in a cluster) + maxLength: 63 + minLength: 3 + pattern: '^[a-z0-9]([-a-z0-9]*[a-z0-9])?$' type: string spec: allOf: - $ref: '#/definitions/NodePoolSpec' description: >- - Cluster specification + NodePool specification CLM doesn't know how to unmarshall the spec, it only stores and forwards to adapters to do their job @@ -1213,12 +1271,15 @@ definitions: type: object name: description: NodePool name (unique in a cluster) + maxLength: 63 + minLength: 3 + pattern: '^[a-z0-9]([-a-z0-9]*[a-z0-9])?$' type: string spec: allOf: - $ref: '#/definitions/NodePoolSpec' description: >- - Cluster specification + NodePool specification CLM doesn't know how to unmarshall the spec, it only stores and forwards to adapters to do their job @@ -1236,6 +1297,13 @@ definitions: created_time: format: date-time type: string + generation: + description: >- + Generation field is updated on customer updates, reflecting the + version of the "intent" of the customer + format: int32 + minimum: 1 + type: integer href: description: Resource URI type: string @@ -1252,6 +1320,9 @@ definitions: type: object name: description: NodePool name (unique in a cluster) + maxLength: 63 + minLength: 3 + pattern: '^[a-z0-9]([-a-z0-9]*[a-z0-9])?$' type: string owner_references: $ref: '#/definitions/ObjectReference' @@ -1259,7 +1330,7 @@ definitions: allOf: - $ref: '#/definitions/NodePoolSpec' description: >- - Cluster specification + NodePool specification CLM doesn't know how to unmarshall the spec, it only stores and forwards to adapters to do their job @@ -1278,6 +1349,7 @@ definitions: - updated_time - created_by - updated_by + - generation - owner_references - status - name @@ -1486,6 +1558,11 @@ definitions: - key - effect type: object +securityDefinitions: + BearerAuth: + in: header + name: Authorization + type: apiKey tags: [] x-components: parameters: @@ -1518,6 +1595,11 @@ x-components: required: false type: integer SearchParams: + description: >- + Filter results using TSL (Tree Search Language) query syntax. + + Examples: `status.phase='NotReady'`, `name in ('c1','c2')`, + `labels.region='us-east'` in: query name: search required: false diff --git a/services/clusters.tsp b/services/clusters.tsp index feec581..0890b9e 100644 --- a/services/clusters.tsp +++ b/services/clusters.tsp @@ -12,6 +12,7 @@ using OpenAPI; namespace HyperFleet; //@tag("Clusters") @route("/clusters") +@useAuth(HyperFleet.BearerAuth) interface Clusters { @get @route("") diff --git a/services/nodepools.tsp b/services/nodepools.tsp index 89666c0..7a07312 100644 --- a/services/nodepools.tsp +++ b/services/nodepools.tsp @@ -11,6 +11,7 @@ using OpenAPI; namespace HyperFleet; //@tag("NodePools") +@useAuth(HyperFleet.BearerAuth) interface NodePools { /** * Returns the list of all nodepools diff --git a/services/statuses-internal.tsp b/services/statuses-internal.tsp index 1c35f6a..8a19862 100644 --- a/services/statuses-internal.tsp +++ b/services/statuses-internal.tsp @@ -11,6 +11,7 @@ using OpenAPI; namespace HyperFleet; @route("/clusters/{cluster_id}/statuses") +@useAuth(HyperFleet.BearerAuth) //@tag("Cluster statuses") interface ClusterStatusesInternal{ diff --git a/services/statuses.tsp b/services/statuses.tsp index 04f0fa3..1a5c597 100644 --- a/services/statuses.tsp +++ b/services/statuses.tsp @@ -11,6 +11,7 @@ using OpenAPI; namespace HyperFleet; @route("/clusters/{cluster_id}/statuses") +@useAuth(HyperFleet.BearerAuth) //@tag("Cluster statuses") interface ClusterStatuses{ /**