Skip to content

Commit

Permalink
feat(ocm): add openApi schema and OpenApiRouter (#2050)
Browse files Browse the repository at this point in the history
* feat(ocm): Introduce openapi.yaml

* feat(ocm): Add openapi dependencies

* feat(ocm): Add openapi-doc.sh for docs generation

* feat(ocm): Add scripts

* feat(ocm): Add api-docs

* feat(ocm): Add generated openapirouter

* feat(ocm): Incorporate openapi router

* feat(ocm): fix new line

* feat(ocm): add security to openapi schema

* feat(ocm): add servers

* feat(ocm): add ocm api catalog entity

* feat(ocm): add backend-openapi-utils to dist-dynamic package.json
  • Loading branch information
dzemanov authored Aug 28, 2024
1 parent f374e2c commit 384434d
Show file tree
Hide file tree
Showing 23 changed files with 837 additions and 29 deletions.
23 changes: 23 additions & 0 deletions plugins/ocm-backend/api-docs/.openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
11 changes: 11 additions & 0 deletions plugins/ocm-backend/api-docs/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Apis/DefaultApi.md
Models/Cluster.md
Models/ClusterBase.md
Models/ClusterDetails.md
Models/ClusterDetails_allocatableResources.md
Models/ClusterDetails_availableResources.md
Models/ClusterNodesStatus.md
Models/ClusterOverview.md
Models/ClusterStatus.md
Models/ClusterUpdate.md
README.md
1 change: 1 addition & 0 deletions plugins/ocm-backend/api-docs/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.7.0
65 changes: 65 additions & 0 deletions plugins/ocm-backend/api-docs/Apis/DefaultApi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# DefaultApi

All URIs are relative to _http://localhost:7007/api/ocm_

| Method | HTTP request | Description |
| ---------------------------------------------------------------------------------- | ------------------------------------------ | ------------------------------------ |
| [**statusGet**](DefaultApi.md#statusGet) | **GET** /status | Get the status of all clusters |
| [**statusProviderIdClusterNameGet**](DefaultApi.md#statusProviderIdClusterNameGet) | **GET** /status/{providerId}/{clusterName} | Get the status of a specific cluster |

<a name="statusGet"></a>

# **statusGet**

> List statusGet()
Get the status of all clusters

Retrieve the status of all clusters across all hubs.

### Parameters

This endpoint does not need any parameter.

### Return type

[**List**](../Models/ClusterOverview.md)

### Authorization

[JWT](../README.md#JWT)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

<a name="statusProviderIdClusterNameGet"></a>

# **statusProviderIdClusterNameGet**

> Cluster statusProviderIdClusterNameGet(providerId, clusterName)
Get the status of a specific cluster

Retrieve the status of a specific cluster on a given hub.

### Parameters

| Name | Type | Description | Notes |
| --------------- | ---------- | -------------------------- | ----------------- |
| **providerId** | **String** | The ID of the OCM provider | [default to null] |
| **clusterName** | **String** | The name of the cluster | [default to null] |

### Return type

[**Cluster**](../Models/Cluster.md)

### Authorization

[JWT](../README.md#JWT)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json
20 changes: 20 additions & 0 deletions plugins/ocm-backend/api-docs/Models/Cluster.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Cluster

## Properties

| Name | Type | Description | Notes |
| ------------------------ | --------------------------------------------------------------------------------- | ------------------------------------------- | ---------------------------- |
| **name** | **String** | The name of the cluster | [optional] [default to null] |
| **consoleUrl** | **String** | URL for the cluster console | [optional] [default to null] |
| **kubernetesVersion** | **String** | Version of Kubernetes | [optional] [default to null] |
| **oauthUrl** | **String** | OAuth URL for the cluster | [optional] [default to null] |
| **openshiftId** | **String** | ID of the OpenShift cluster | [optional] [default to null] |
| **openshiftVersion** | **String** | Version of OpenShift running in the cluster | [optional] [default to null] |
| **platform** | **String** | Platform of the cluster | [optional] [default to null] |
| **region** | **String** | Region where the cluster is located | [optional] [default to null] |
| **allocatableResources** | [**ClusterDetails_allocatableResources**](ClusterDetails_allocatableResources.md) | | [optional] [default to null] |
| **availableResources** | [**ClusterDetails_availableResources**](ClusterDetails_availableResources.md) | | [optional] [default to null] |
| **update** | [**ClusterUpdate**](ClusterUpdate.md) | | [optional] [default to null] |
| **status** | [**ClusterStatus**](ClusterStatus.md) | | [optional] [default to null] |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
9 changes: 9 additions & 0 deletions plugins/ocm-backend/api-docs/Models/ClusterBase.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ClusterBase

## Properties

| Name | Type | Description | Notes |
| -------- | ---------- | ----------------------- | ---------------------------- |
| **name** | **String** | The name of the cluster | [optional] [default to null] |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
19 changes: 19 additions & 0 deletions plugins/ocm-backend/api-docs/Models/ClusterDetails.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ClusterDetails

## Properties

| Name | Type | Description | Notes |
| ------------------------ | --------------------------------------------------------------------------------- | ------------------------------------------- | ---------------------------- |
| **consoleUrl** | **String** | URL for the cluster console | [optional] [default to null] |
| **kubernetesVersion** | **String** | Version of Kubernetes | [optional] [default to null] |
| **oauthUrl** | **String** | OAuth URL for the cluster | [optional] [default to null] |
| **openshiftId** | **String** | ID of the OpenShift cluster | [optional] [default to null] |
| **openshiftVersion** | **String** | Version of OpenShift running in the cluster | [optional] [default to null] |
| **platform** | **String** | Platform of the cluster | [optional] [default to null] |
| **region** | **String** | Region where the cluster is located | [optional] [default to null] |
| **allocatableResources** | [**ClusterDetails_allocatableResources**](ClusterDetails_allocatableResources.md) | | [optional] [default to null] |
| **availableResources** | [**ClusterDetails_availableResources**](ClusterDetails_availableResources.md) | | [optional] [default to null] |
| **update** | [**ClusterUpdate**](ClusterUpdate.md) | | [optional] [default to null] |
| **status** | [**ClusterStatus**](ClusterStatus.md) | | [optional] [default to null] |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ClusterDetails_allocatableResources

## Properties

| Name | Type | Description | Notes |
| ---------------- | -------------- | ------------------------------- | ---------------------------- |
| **cpuCores** | **BigDecimal** | Number of CPU cores allocatable | [optional] [default to null] |
| **memorySize** | **String** | Size of allocatable memory | [optional] [default to null] |
| **numberOfPods** | **BigDecimal** | Number of allocatable pods | [optional] [default to null] |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ClusterDetails_availableResources

## Properties

| Name | Type | Description | Notes |
| ---------------- | -------------- | ----------------------------- | ---------------------------- |
| **cpuCores** | **BigDecimal** | Number of CPU cores available | [optional] [default to null] |
| **memorySize** | **String** | Size of available memory | [optional] [default to null] |
| **numberOfPods** | **BigDecimal** | Number of available pods | [optional] [default to null] |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
10 changes: 10 additions & 0 deletions plugins/ocm-backend/api-docs/Models/ClusterNodesStatus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ClusterNodesStatus

## Properties

| Name | Type | Description | Notes |
| ---------- | ---------- | ------------------ | ---------------------------- |
| **status** | **String** | Status of the node | [optional] [default to null] |
| **type** | **String** | Type of the node | [optional] [default to null] |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
14 changes: 14 additions & 0 deletions plugins/ocm-backend/api-docs/Models/ClusterOverview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# ClusterOverview

## Properties

| Name | Type | Description | Notes |
| -------------------- | ------------------------------------- | ------------------------------------------- | ---------------------------- |
| **name** | **String** | The name of the cluster | [optional] [default to null] |
| **status** | [**ClusterStatus**](ClusterStatus.md) | | [optional] [default to null] |
| **update** | [**ClusterUpdate**](ClusterUpdate.md) | | [optional] [default to null] |
| **platform** | **String** | Platform of the cluster | [optional] [default to null] |
| **openshiftVersion** | **String** | Version of OpenShift running in the cluster | [optional] [default to null] |
| **nodes** | [**List**](ClusterNodesStatus.md) | | [optional] [default to null] |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
10 changes: 10 additions & 0 deletions plugins/ocm-backend/api-docs/Models/ClusterStatus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ClusterStatus

## Properties

| Name | Type | Description | Notes |
| ------------- | ----------- | --------------------------------------------------------------- | ---------------------------- |
| **available** | **Boolean** | Indicates if the cluster is available | [default to null] |
| **reason** | **String** | Optional reason why the cluster is not available or as problems | [optional] [default to null] |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
11 changes: 11 additions & 0 deletions plugins/ocm-backend/api-docs/Models/ClusterUpdate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ClusterUpdate

## Properties

| Name | Type | Description | Notes |
| ------------- | ----------- | ----------------------------------- | ---------------------------- |
| **available** | **Boolean** | Indicates if an update is available | [optional] [default to null] |
| **version** | **String** | Version of the available update | [optional] [default to null] |
| **url** | **String** | URL for the update | [optional] [default to null] |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
36 changes: 36 additions & 0 deletions plugins/ocm-backend/api-docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Documentation for OCM Plugin API

<a name="documentation-for-api-endpoints"></a>

## Documentation for API Endpoints

All URIs are relative to _http://localhost:7007/api/ocm_

| Class | Method | HTTP request | Description |
| ------------ | --------------------------------------------------------------------------------------- | ------------------------------------------ | ------------------------------------ |
| _DefaultApi_ | [**statusGet**](Apis/DefaultApi.md#statusget) | **GET** /status | Get the status of all clusters |
| _DefaultApi_ | [**statusProviderIdClusterNameGet**](Apis/DefaultApi.md#statusprovideridclusternameget) | **GET** /status/{providerId}/{clusterName} | Get the status of a specific cluster |

<a name="documentation-for-models"></a>

## Documentation for Models

- [Cluster](./Models/Cluster.md)
- [ClusterBase](./Models/ClusterBase.md)
- [ClusterDetails](./Models/ClusterDetails.md)
- [ClusterDetails_allocatableResources](./Models/ClusterDetails_allocatableResources.md)
- [ClusterDetails_availableResources](./Models/ClusterDetails_availableResources.md)
- [ClusterNodesStatus](./Models/ClusterNodesStatus.md)
- [ClusterOverview](./Models/ClusterOverview.md)
- [ClusterStatus](./Models/ClusterStatus.md)
- [ClusterUpdate](./Models/ClusterUpdate.md)

<a name="documentation-for-authorization"></a>

## Documentation for Authorization

<a name="JWT"></a>

### JWT

- **Type**: HTTP Bearer Token authentication (JWT)
33 changes: 33 additions & 0 deletions plugins/ocm-backend/catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,36 @@ spec:
owner: rhdh-team
system: rhdh
subcomponentOf: janus-idp-ocm
providesApis:
- janus-idp-ocm-backend-api
---
# https://backstage.io/docs/features/software-catalog/descriptor-format#kind-api
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: janus-idp-ocm-backend-api
title: '@janus-idp/backstage-plugin-ocm-backend'
description: Open Cluster Management backend plugin OpenAPI specs for Backstage
annotations:
backstage.io/source-location: url:https://github.com/janus-idp/backstage-plugins/tree/main/plugins/ocm-backend
backstage.io/view-url: https://github.com/janus-idp/backstage-plugins/blob/main/plugins/ocm-backend/catalog-info.yaml
backstage.io/edit-url: https://github.com/janus-idp/backstage-plugins/edit/main/plugins/ocm-backend/catalog-info.yaml
github.com/project-slug: janus-idp/backstage-plugins
#github.com/team-slug: janus-idp/maintainers
sonarqube.org/project-key: janus-idp_backstage-plugins
tags:
- kubernetes
- openshift
links:
- url: https://github.com/janus-idp/backstage-plugins/tree/main/plugins/ocm-backend
title: GitHub Source
icon: source
type: source
spec:
type: openapi
lifecycle: production
owner: rhdh-team
system: rhdh
subcomponentOf: janus-idp-ocm
definition:
$text: https://github.com/janus-idp/backstage-plugins/blob/main/plugins/ocm-backend/src/schema/openapi.yaml
1 change: 1 addition & 0 deletions plugins/ocm-backend/dist-dynamic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"peerDependencies": {
"@backstage/backend-common": "^0.23.3",
"@backstage/backend-plugin-api": "^0.7.0",
"@backstage/backend-openapi-utils": "^0.1.15",
"@backstage/backend-tasks": "^0.5.27",
"@backstage/catalog-client": "^1.6.5",
"@backstage/catalog-model": "^1.5.0",
Expand Down
Loading

0 comments on commit 384434d

Please sign in to comment.