Skip to content

Commit d78f661

Browse files
committed
fix(keys): fix delete schema response
- Add a new interface for response schemas after deletion, as the api only returns the id of the api key instead of the whole object
1 parent 1eee81d commit d78f661

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

src/main/java/org/typesense/api/Key.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.typesense.api;
22

3+
import org.typesense.interfaces.ApiKeyDeleteResponse;
34
import org.typesense.model.ApiKey;
45

56
public class Key {
@@ -16,8 +17,8 @@ public ApiKey retrieve() throws Exception {
1617
return this.apiCall.get(this.getEndpoint(), null, ApiKey.class);
1718
}
1819

19-
public ApiKey delete() throws Exception {
20-
return this.apiCall.delete(this.getEndpoint(), null, ApiKey.class);
20+
public ApiKeyDeleteResponse delete() throws Exception {
21+
return this.apiCall.delete(this.getEndpoint(), null, ApiKeyDeleteResponse.class);
2122
}
2223

2324
private String getEndpoint(){
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package org.typesense.interfaces;
2+
3+
import java.util.Objects;
4+
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
7+
import io.swagger.v3.oas.annotations.media.Schema;
8+
9+
public class ApiKeyDeleteResponse {
10+
@JsonProperty("id")
11+
private Long id = null;
12+
13+
public ApiKeyDeleteResponse id(Long id) {
14+
this.id = id;
15+
return this;
16+
}
17+
18+
/**
19+
* The unique identifier of the deleted key
20+
* @return id
21+
**/
22+
@Schema(required = true, description = "The unique identifier of the deleted key")
23+
public Long getId() {
24+
return id;
25+
}
26+
27+
public void setId(Long id) {
28+
this.id = id;
29+
}
30+
31+
@Override
32+
public boolean equals(Object o) {
33+
if (this == o) return true;
34+
if (o == null || getClass() != o.getClass()) return false;
35+
ApiKeyDeleteResponse that = (ApiKeyDeleteResponse) o;
36+
return Objects.equals(this.id, that.id);
37+
}
38+
39+
@Override
40+
public int hashCode() {
41+
return Objects.hash(id);
42+
}
43+
44+
@Override
45+
public String toString() {
46+
StringBuilder sb = new StringBuilder();
47+
sb.append("class ApiKeyDeleteResponse {\n");
48+
sb.append(" id: ").append(toIndentedString(id)).append("\n");
49+
sb.append("}");
50+
return sb.toString();
51+
}
52+
53+
private String toIndentedString(Object o) {
54+
if (o == null) return "null";
55+
return o.toString().replace("\n", "\n ");
56+
}
57+
}

0 commit comments

Comments
 (0)