Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1711 api pagination updates #1728

Merged
merged 8 commits into from
Sep 4, 2023
34 changes: 31 additions & 3 deletions coral/src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ const API_PATHS = {
getEnvsForSchemaRequests: "/getEnvsForSchemaRequests",
getEnvsBaseCluster: "/getEnvsBaseCluster",
getEnvsBaseClusterFilteredForTeam: "/getEnvsBaseClusterFilteredForTeam",
getSchemaRegEnvsPaginated: "/environments/schemaRegistry",
getKafkaEnvsPaginated: "/environments/kafka",
getKafkaConnectEnvsPaginated: "/environments/connect",
getEnvParams: "/getEnvParams",
getEnvDetails: "/getEnvDetails",
getDbAuth: "/getDbAuth",
Expand Down Expand Up @@ -196,7 +199,12 @@ const API_PATHS = {
} satisfies {
[key in keyof Omit<
ApiOperations,
"getSchemaOfTopicFromSource" | "getSwitchTeams" | "getTopicRequest"
| "getSchemaOfTopicFromSource"
| "getSwitchTeams"
| "getTopicRequest"
| "getKafkaEnv"
| "getKafkaConnectEnv"
| "getSchemaRegEnv"
>]: keyof ApiPaths;
};

Expand All @@ -208,6 +216,9 @@ type GetSchemaOfTopicFromSource = (params: {
}) => keyof ApiPaths;
type GetSwitchTeams = (params: { userId: string }) => keyof ApiPaths;
type GetTopicRequest = (params: { topicReqId: string }) => keyof ApiPaths;
type GetKafkaEnv = (params: { envId: string }) => keyof ApiPaths;
type GetConnectEnv = (params: { envId: string }) => keyof ApiPaths;
type GetSchemaRegEnv = (params: { envId: string }) => keyof ApiPaths;

const DYNAMIC_API_PATHS = {
getSchemaOfTopicFromSource: ({
Expand All @@ -221,11 +232,28 @@ const DYNAMIC_API_PATHS = {
`/user/${userId}/switchTeamsList` as keyof ApiPaths,
getTopicRequest: ({ topicReqId }: Parameters<GetTopicRequest>[0]) =>
`/topic/request/${topicReqId}` as keyof ApiPaths,
getKafkaEnv: ({ envId }: Parameters<GetKafkaEnv>[0]) =>
`/environments/kafka/${envId}` as keyof ApiPaths,
getKafkaConnectEnv: ({ envId }: Parameters<GetConnectEnv>[0]) =>
`/environments/connect/${envId}` as keyof ApiPaths,
getSchemaRegEnv: ({ envId }: Parameters<GetSchemaRegEnv>[0]) =>
`/environments/schemaRegistry/${envId}` as keyof ApiPaths,
} satisfies {
[key in keyof Pick<
ApiOperations,
"getSchemaOfTopicFromSource" | "getSwitchTeams" | "getTopicRequest"
>]: GetSchemaOfTopicFromSource | GetSwitchTeams | GetTopicRequest;
| "getSchemaOfTopicFromSource"
| "getSwitchTeams"
| "getTopicRequest"
| "getKafkaEnv"
| "getKafkaConnectEnv"
| "getSchemaRegEnv"
>]:
| GetSchemaOfTopicFromSource
| GetSwitchTeams
| GetTopicRequest
| GetKafkaEnv
| GetConnectEnv
| GetSchemaRegEnv;
};

type Params = URLSearchParams;
Expand Down
123 changes: 123 additions & 0 deletions coral/types/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,24 @@ export type paths = {
"/getAclCommands": {
get: operations["getAclCommand"];
};
"/environments/schemaRegistry": {
get: operations["getSchemaRegEnvsPaginated"];
};
"/environments/schemaRegistry/{envId}": {
get: operations["getSchemaRegEnv"];
};
"/environments/kafka": {
get: operations["getKafkaEnvsPaginated"];
};
"/environments/kafka/{envId}": {
get: operations["getKafkaEnv"];
};
"/environments/connect": {
get: operations["getKafkaConnectEnvsPaginated"];
};
"/environments/connect/{envId}": {
get: operations["getKafkaConnectEnv"];
};
};

export type webhooks = Record<string, never>;
Expand Down Expand Up @@ -4150,4 +4168,109 @@ export type operations = {
};
};
};
getSchemaRegEnvsPaginated: {
parameters: {
query: {
pageNo: string;
searchEnvParam?: string;
};
};
responses: {
/** @description OK */
200: {
content: {
"application/json": (components["schemas"]["EnvModelResponse"])[];
};
};
};
};
getSchemaRegEnv: {
parameters: {
query: {
pageNo: string;
searchEnvParam?: string;
};
path: {
envId: string;
};
};
responses: {
/** @description OK */
200: {
content: {
"application/json": (components["schemas"]["EnvModelResponse"])[];
};
};
};
};
getKafkaEnvsPaginated: {
parameters: {
query: {
pageNo: string;
searchEnvParam?: string;
};
};
responses: {
/** @description OK */
200: {
content: {
"application/json": (components["schemas"]["EnvModelResponse"])[];
};
};
};
};
getKafkaEnv: {
parameters: {
query: {
pageNo: string;
searchEnvParam?: string;
};
path: {
envId: string;
};
};
responses: {
/** @description OK */
200: {
content: {
"application/json": (components["schemas"]["EnvModelResponse"])[];
};
};
};
};
getKafkaConnectEnvsPaginated: {
parameters: {
query: {
pageNo: string;
searchEnvParam?: string;
};
};
responses: {
/** @description OK */
200: {
content: {
"application/json": (components["schemas"]["EnvModelResponse"])[];
};
};
};
};
getKafkaConnectEnv: {
parameters: {
query: {
pageNo: string;
searchEnvParam?: string;
};
path: {
envId: string;
};
};
responses: {
/** @description OK */
200: {
content: {
"application/json": (components["schemas"]["EnvModelResponse"])[];
};
};
};
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.aiven.klaw.error.KlawValidationException;
import io.aiven.klaw.model.ApiResponse;
import io.aiven.klaw.model.KwTenantModel;
import io.aiven.klaw.model.enums.KafkaClustersType;
import io.aiven.klaw.model.requests.EnvModel;
import io.aiven.klaw.model.requests.KwClustersModel;
import io.aiven.klaw.model.response.AclCommands;
Expand All @@ -24,12 +25,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/")
Expand Down Expand Up @@ -135,7 +131,8 @@ public ResponseEntity<List<EnvModelResponse>> getEnvsPaginated(
@RequestParam(value = "envId", defaultValue = "") String envId,
@RequestParam(value = "searchEnvParam", defaultValue = "") String searchEnvParam) {
return new ResponseEntity<>(
envsClustersTenantsControllerService.getEnvsPaginated(envId, pageNo, searchEnvParam),
envsClustersTenantsControllerService.getEnvsPaginated(
KafkaClustersType.KAFKA, envId, pageNo, searchEnvParam),
HttpStatus.OK);
}

Expand Down Expand Up @@ -168,6 +165,33 @@ public ResponseEntity<EnvParams> getEnvParams(
envsClustersTenantsControllerService.getEnvParams(envSelected), HttpStatus.OK);
}

@RequestMapping(
value = "/environments/kafka",
method = RequestMethod.GET,
produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<List<EnvModelResponse>> getKafkaEnvsPaginated(
@RequestParam("pageNo") String pageNo,
@RequestParam(value = "searchEnvParam", defaultValue = "") String searchEnvParam) {
return new ResponseEntity<>(
envsClustersTenantsControllerService.getEnvsPaginated(
KafkaClustersType.KAFKA, "", pageNo, searchEnvParam),
HttpStatus.OK);
}

@RequestMapping(
value = "/environments/kafka/{envId}",
method = RequestMethod.GET,
produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<List<EnvModelResponse>> getKafkaEnv(
@RequestParam("pageNo") String pageNo,
@PathVariable(value = "envId") String envId,
@RequestParam(value = "searchEnvParam", defaultValue = "") String searchEnvParam) {
return new ResponseEntity<>(
envsClustersTenantsControllerService.getEnvsPaginated(
KafkaClustersType.KAFKA, envId, pageNo, searchEnvParam),
HttpStatus.OK);
}

@RequestMapping(
value = "/getSchemaRegEnvs",
method = RequestMethod.GET,
Expand All @@ -177,6 +201,33 @@ public ResponseEntity<List<EnvModelResponse>> getSchemaRegEnvs() {
envsClustersTenantsControllerService.getSchemaRegEnvs(), HttpStatus.OK);
}

@RequestMapping(
value = "/environments/schemaRegistry",
method = RequestMethod.GET,
produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<List<EnvModelResponse>> getSchemaRegEnvsPaginated(
@RequestParam("pageNo") String pageNo,
@RequestParam(value = "searchEnvParam", defaultValue = "") String searchEnvParam) {
return new ResponseEntity<>(
envsClustersTenantsControllerService.getEnvsPaginated(
KafkaClustersType.SCHEMA_REGISTRY, "", pageNo, searchEnvParam),
HttpStatus.OK);
}

@RequestMapping(
value = "/environments/schemaRegistry/{envId}",
method = RequestMethod.GET,
produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<List<EnvModelResponse>> getSchemaRegEnv(
@RequestParam("pageNo") String pageNo,
@PathVariable(value = "envId") String envId,
@RequestParam(value = "searchEnvParam", defaultValue = "") String searchEnvParam) {
return new ResponseEntity<>(
envsClustersTenantsControllerService.getEnvsPaginated(
KafkaClustersType.SCHEMA_REGISTRY, envId, pageNo, searchEnvParam),
HttpStatus.OK);
}

@RequestMapping(
value = "/getEnvsForSchemaRequests",
method = RequestMethod.GET,
Expand All @@ -195,6 +246,33 @@ public ResponseEntity<List<EnvModelResponse>> getKafkaConnectEnvs() {
envsClustersTenantsControllerService.getKafkaConnectEnvs(), HttpStatus.OK);
}

@RequestMapping(
value = "/environments/connect",
aindriu-aiven marked this conversation as resolved.
Show resolved Hide resolved
method = RequestMethod.GET,
produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<List<EnvModelResponse>> getKafkaConnectEnvsPaginated(
@RequestParam("pageNo") String pageNo,
@RequestParam(value = "searchEnvParam", defaultValue = "") String searchEnvParam) {
return new ResponseEntity<>(
envsClustersTenantsControllerService.getEnvsPaginated(
KafkaClustersType.KAFKA_CONNECT, "", pageNo, searchEnvParam),
HttpStatus.OK);
}

@RequestMapping(
value = "/environments/connect/{envId}",
aindriu-aiven marked this conversation as resolved.
Show resolved Hide resolved
method = RequestMethod.GET,
produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<List<EnvModelResponse>> getKafkaConnectEnv(
@RequestParam("pageNo") String pageNo,
@PathVariable(value = "envId") String envId,
@RequestParam(value = "searchEnvParam", defaultValue = "") String searchEnvParam) {
return new ResponseEntity<>(
envsClustersTenantsControllerService.getEnvsPaginated(
KafkaClustersType.KAFKA_CONNECT, envId, pageNo, searchEnvParam),
HttpStatus.OK);
}

@PostMapping(
value = "/addNewEnv",
produces = {MediaType.APPLICATION_JSON_VALUE})
Expand Down
Loading