imbajin commented on code in PR #657: URL: https://github.com/apache/incubator-hugegraph-toolchain/pull/657#discussion_r2083521489
########## 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 Review Comment: keep both of them for now? delete(without msg) & drop(with msg), call the same function from server (just like a syntax sugar) -- 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: issues-unsubscr...@hugegraph.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@hugegraph.apache.org For additional commands, e-mail: issues-h...@hugegraph.apache.org