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

Issue30 builderclasses #60

Merged
merged 18 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/main/java/io/aiven/klaw/controller/TopicController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.aiven.klaw.controller;

import io.aiven.klaw.error.KlawException;
import io.aiven.klaw.model.ApiResponse;
import io.aiven.klaw.model.TopicInfo;
import io.aiven.klaw.model.TopicRequestModel;
import io.aiven.klaw.service.TopicControllerService;
Expand Down Expand Up @@ -101,10 +102,18 @@ public ResponseEntity<String> deleteTopicRequests(@RequestParam("topicId") Strin
@PostMapping(
value = "/execTopicRequests",
produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<String> approveTopicRequests(@RequestParam("topicId") String topicId)
throws KlawException {
return new ResponseEntity<>(
topicControllerService.approveTopicRequests(topicId), HttpStatus.OK);
public ResponseEntity<ApiResponse> approveTopicRequests(@RequestParam("topicId") String topicId) {
try {
return new ResponseEntity<>(
topicControllerService.approveTopicRequests(topicId), HttpStatus.OK);
} catch (KlawException e) {
return new ResponseEntity<>(
ApiResponse.builder()
.message(e.getMessage())
mdedetrich marked this conversation as resolved.
Show resolved Hide resolved
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.build(),
HttpStatus.INTERNAL_SERVER_ERROR);
}
}

@PostMapping(
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/io/aiven/klaw/model/ApiResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.aiven.klaw.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.http.HttpStatus;

@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class ApiResponse {
private HttpStatus status;

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy hh:mm:ss")
private LocalDateTime timestamp;

private String message;

private String debugMessage;

private String result;
}
14 changes: 14 additions & 0 deletions src/main/java/io/aiven/klaw/model/ApiResultStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.aiven.klaw.model;

public enum ApiResultStatus {
SUCCESS("success"),
FAILURE("failure"),
NOT_AUTHORIZED("Not Authorized"),
ERROR("error");

public final String value;

ApiResultStatus(String value) {
this.value = value;
}
}
13 changes: 13 additions & 0 deletions src/main/java/io/aiven/klaw/model/ClusterStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.aiven.klaw.model;

public enum ClusterStatus {
OFFLINE("OFFLINE"),
ONLINE("ONLINE"),
NOT_KNOWN("NOT_KNOWN");

public final String value;

ClusterStatus(String value) {
this.value = value;
}
}
21 changes: 21 additions & 0 deletions src/main/java/io/aiven/klaw/model/ClusterTopicRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.aiven.klaw.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import lombok.Builder;

@Builder(toBuilder = true)
public class ClusterTopicRequest implements Serializable {

@JsonProperty private String env;

@JsonProperty private int partitions;

@JsonProperty private short replicationFactor;

@JsonProperty private String protocol;

@JsonProperty private String clusterName;

@JsonProperty private String topicName;
}
Loading