Copilot commented on code in PR #657:
URL:
https://github.com/apache/incubator-hugegraph-toolchain/pull/657#discussion_r2083520692
##########
hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java:
##########
@@ -83,17 +96,102 @@ public List<String> list() {
return result.readList(this.type(), String.class);
}
+ public List<Map<String, Object>> listProfile(String prefix) {
+ String profilePath = joinPath(this.path(), "profile");
+ Map<String, Object> params = new LinkedHashMap<>();
+ params.put("prefix", prefix);
+ RestResult result = this.client.get(profilePath, params);
+ List<Map> results = result.readList(Map.class);
+ List<Map<String, Object>> profiles = new ArrayList<>();
+ for (Object entry: results) {
+ profiles.add(JsonUtil.fromJson(JsonUtil.toJson(entry), Map.class));
+ }
+ return profiles;
+ }
+
+ public Map<String, String> setDefault(String name) {
+ String defaultPath = joinPath(this.path(), name, "default");
+ RestResult result = this.client.get(defaultPath);
+ return result.readObject(Map.class);
+ }
+
+ public Map<String, String> unSetDefault(String name) {
+ String unDefaultPath = joinPath(this.path(), name, "undefault");
+ RestResult result = this.client.get(unDefaultPath);
+ return result.readObject(Map.class);
+ }
+
+ public Map<String, String> getDefault () {
+ String defaultPath = joinPath(this.path(), "default");
+ RestResult result = this.client.get(defaultPath);
+ return result.readObject(Map.class);
+ }
+
+ // TODO(@Thespcia): in inner version, called by clear(String name) or
+ // clear(String name, boolean clearSchema)
public void clear(String graph, String message) {
this.client.delete(joinPath(this.path(), graph, CLEAR),
ImmutableMap.of(CONFIRM_MESSAGE, message));
}
+ public Map<String, String> update(String name, String nickname) {
+ Map<String, String> actionMap = new HashMap<>();
+ actionMap.put("name", name);
+ actionMap.put("nickname", nickname);
+ RestResult result = this.client.put(this.path(),
+ name,
+ ImmutableMap.of("action", "update",
+ "update",
+ actionMap));
+ Map<String, String> response = result.readObject(Map.class);
+
+ E.checkState(response.size() == 1 && response.containsKey(name),
+ "Response must be formatted to {\"%s\" : status}, " +
+ "but got %s", name, response);
+ String status = response.get(name);
+ E.checkState(UPDATED.equals(status),
+ "Server status must be %s, but got '%s'", status);
+ return response;
+ }
+
+ // TODO(@Thespcia): in inner version, this method called delete, and
doesn't need confirm
+ // message.
+ // community version server don't support now(3/11/2025), so we still need
to keep this format.
public void drop(String graph, String message) {
this.client.checkApiVersion("0.67", "dynamic graph delete");
this.client.delete(joinPath(this.path(), graph),
ImmutableMap.of(CONFIRM_MESSAGE, message));
}
+ public Map<String, String> reload(String name) {
Review Comment:
Similarly, in the reload method, the error message formatting in the
E.checkState call is missing a parameter for one of the placeholders. Please
update the error message to supply all expected parameters such as the graph
name, the expected status (RELOADED) and the actual status.
##########
hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java:
##########
@@ -83,17 +96,102 @@ public List<String> list() {
return result.readList(this.type(), String.class);
}
+ public List<Map<String, Object>> listProfile(String prefix) {
+ String profilePath = joinPath(this.path(), "profile");
+ Map<String, Object> params = new LinkedHashMap<>();
+ params.put("prefix", prefix);
+ RestResult result = this.client.get(profilePath, params);
+ List<Map> results = result.readList(Map.class);
+ List<Map<String, Object>> profiles = new ArrayList<>();
+ for (Object entry: results) {
+ profiles.add(JsonUtil.fromJson(JsonUtil.toJson(entry), Map.class));
+ }
+ return profiles;
+ }
+
+ public Map<String, String> setDefault(String name) {
+ String defaultPath = joinPath(this.path(), name, "default");
+ RestResult result = this.client.get(defaultPath);
+ return result.readObject(Map.class);
+ }
+
+ public Map<String, String> unSetDefault(String name) {
+ String unDefaultPath = joinPath(this.path(), name, "undefault");
+ RestResult result = this.client.get(unDefaultPath);
+ return result.readObject(Map.class);
+ }
+
+ public Map<String, String> getDefault () {
+ String defaultPath = joinPath(this.path(), "default");
+ RestResult result = this.client.get(defaultPath);
+ return result.readObject(Map.class);
+ }
+
+ // TODO(@Thespcia): in inner version, called by clear(String name) or
+ // clear(String name, boolean clearSchema)
public void clear(String graph, String message) {
this.client.delete(joinPath(this.path(), graph, CLEAR),
ImmutableMap.of(CONFIRM_MESSAGE, message));
}
+ public Map<String, String> update(String name, String nickname) {
Review Comment:
In the update method, the error message formatting in the E.checkState calls
is incorrect; the placeholders in the string expect more arguments than
provided. Please adjust the format arguments so that the constants (e.g.
UPDATED) and the obtained status are passed in the expected order.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]