From ada600df24a07c3853b58be3e32b83a302b6719c Mon Sep 17 00:00:00 2001 From: Mirjam Aulbach Date: Tue, 27 Feb 2024 16:12:25 +0700 Subject: [PATCH] feat: Add support for clusterType param in getClustersPaginated endpoint (#2327) * Use enum string instead of value in KwClustersModelResponse's getClustersPaginated * Update openapi file and TS types. --------- Signed-off-by: Mirjam Aulbach --- coral/src/domain/cluster/cluster-api.ts | 2 +- coral/types/api.d.ts | 2 +- .../klaw/controller/EnvsClustersTenantsController.java | 2 +- .../klaw/service/EnvsClustersTenantsControllerService.java | 6 ++++-- core/src/main/resources/static/js/envs.js | 4 ++-- openapi.yaml | 3 ++- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/coral/src/domain/cluster/cluster-api.ts b/coral/src/domain/cluster/cluster-api.ts index 65a30fa284..299c25d35d 100644 --- a/coral/src/domain/cluster/cluster-api.ts +++ b/coral/src/domain/cluster/cluster-api.ts @@ -37,7 +37,7 @@ async function getClustersPaginated({ "clusterType" >): Promise { const params: KlawApiRequestQueryParameters<"getClustersPaginated"> = { - clusterType: "all", + clusterType: "ALL", pageNo, ...(searchClusterParam && { searchClusterParam: searchClusterParam }), }; diff --git a/coral/types/api.d.ts b/coral/types/api.d.ts index feff6d4555..ed19c2f5cf 100644 --- a/coral/types/api.d.ts +++ b/coral/types/api.d.ts @@ -4013,7 +4013,7 @@ export type operations = { getClustersPaginated: { parameters: { query: { - clusterType: string; + clusterType: "ALL" | "KAFKA" | "SCHEMA_REGISTRY" | "KAFKA_CONNECT"; pageNo: string; clusterId?: string; searchClusterParam?: string; diff --git a/core/src/main/java/io/aiven/klaw/controller/EnvsClustersTenantsController.java b/core/src/main/java/io/aiven/klaw/controller/EnvsClustersTenantsController.java index c4ffd835cf..d6792caf84 100644 --- a/core/src/main/java/io/aiven/klaw/controller/EnvsClustersTenantsController.java +++ b/core/src/main/java/io/aiven/klaw/controller/EnvsClustersTenantsController.java @@ -48,7 +48,7 @@ public ResponseEntity> getClusters( method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE}) public ResponseEntity> getClustersPaginated( - @RequestParam(value = "clusterType") String clusterType, + @RequestParam(value = "clusterType") KafkaClustersType clusterType, @RequestParam("pageNo") String pageNo, @RequestParam(value = "clusterId", defaultValue = "") String clusterId, @RequestParam(value = "searchClusterParam", defaultValue = "") String searchClusterParam) { diff --git a/core/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java b/core/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java index 5cc7a9c2b6..d26c118165 100644 --- a/core/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java +++ b/core/src/main/java/io/aiven/klaw/service/EnvsClustersTenantsControllerService.java @@ -169,8 +169,10 @@ public List getClusters(String typeOfCluster) { } public List getClustersPaginated( - String typeOfCluster, String clusterId, String pageNo, String searchClusterParam) { - List kwClustersModelList = getClusters("all"); + KafkaClustersType typeOfCluster, String clusterId, String pageNo, String searchClusterParam) { + + String clusterTypeValue = typeOfCluster.value; + List kwClustersModelList = getClusters(clusterTypeValue); if (clusterId != null && !clusterId.equals("")) { kwClustersModelList = diff --git a/core/src/main/resources/static/js/envs.js b/core/src/main/resources/static/js/envs.js index 8a9b627c6c..6a1728f0d0 100644 --- a/core/src/main/resources/static/js/envs.js +++ b/core/src/main/resources/static/js/envs.js @@ -247,9 +247,9 @@ app.controller("envsCtrl", function($scope, $http, $location, $window) { method: "GET", url: "getClustersPaginated", headers : { 'Content-Type' : 'application/json' }, - params: {'clusterType' : 'all', 'clusterId' : $scope.clusterIdFromUrl, + params: {'clusterType' : 'ALL', 'clusterId' : $scope.clusterIdFromUrl, 'pageNo' : pageNo, 'searchClusterParam' : $scope.searchClusterParam}, - data: {'clusterType' : 'all'} + data: {'clusterType' : 'ALL'} }).success(function(output) { $scope.allclustersset = output; if(output && output.length > 0 && output[0] != null){ diff --git a/openapi.yaml b/openapi.yaml index 637f677384..ee0cc6bc1b 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -4827,7 +4827,8 @@ "in" : "query", "required" : true, "schema" : { - "type" : "string" + "type" : "string", + "enum" : [ "ALL", "KAFKA", "SCHEMA_REGISTRY", "KAFKA_CONNECT" ] } }, { "name" : "pageNo",