Skip to content

Commit 062daed

Browse files
committed
implemented support for GET /_admin/server/id
1 parent 602df9b commit 062daed

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/main/java/com/arangodb/ArangoDB.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,16 @@ public synchronized ArangoDB build() {
762762
*/
763763
ServerRole getRole() throws ArangoDBException;
764764

765+
/**
766+
* Returns the id of a server in a cluster.
767+
*
768+
* @return the server id
769+
* @throws ArangoDBException
770+
* @see <a href="https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#return-id-of-a-server-in-a-cluster">API
771+
* Documentation</a>
772+
*/
773+
String getServerId() throws ArangoDBException;
774+
765775
/**
766776
* Create a new user. This user will not have access to any database. You need permission to the _system database in
767777
* order to execute this call.

src/main/java/com/arangodb/internal/ArangoDBImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ public ServerRole getRole() throws ArangoDBException {
174174
return executor.execute(getRoleRequest(), getRoleResponseDeserializer());
175175
}
176176

177+
@Override
178+
public String getServerId() throws ArangoDBException {
179+
return executor.execute(getServerIdRequest(), getServerIdResponseDeserializer());
180+
}
181+
177182
@Override
178183
public UserEntity createUser(final String user, final String passwd) throws ArangoDBException {
179184
return executor.execute(createUserRequest(db().name(), user, passwd, new UserCreateOptions()),

src/main/java/com/arangodb/internal/InternalArangoDB.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public abstract class InternalArangoDB<E extends ArangoExecutor> extends ArangoE
4747
private static final String PATH_API_ADMIN_LOG_ENTRIES = "/_admin/log/entries";
4848
private static final String PATH_API_ADMIN_LOG_LEVEL = "/_admin/log/level";
4949
private static final String PATH_API_ROLE = "/_admin/server/role";
50+
private static final String PATH_API_SERVER_ID = "/_admin/server/id";
5051
private static final String PATH_ENDPOINTS = "/_api/cluster/endpoints";
5152
private static final String PATH_API_USER = "/_api/user";
5253

@@ -58,10 +59,18 @@ protected Request getRoleRequest() {
5859
return request(ArangoRequestParam.SYSTEM, RequestType.GET, PATH_API_ROLE);
5960
}
6061

62+
protected Request getServerIdRequest() {
63+
return request(ArangoRequestParam.SYSTEM, RequestType.GET, PATH_API_SERVER_ID);
64+
}
65+
6166
protected ResponseDeserializer<ServerRole> getRoleResponseDeserializer() {
6267
return response -> util().deserialize(response.getBody().get("role"), ServerRole.class);
6368
}
6469

70+
protected ResponseDeserializer<String> getServerIdResponseDeserializer() {
71+
return response -> util().deserialize(response.getBody().get("id"), String.class);
72+
}
73+
6574
protected Request createDatabaseRequest(final DBCreateOptions options) {
6675
final Request request = request(ArangoRequestParam.SYSTEM, RequestType.POST,
6776
InternalArangoDatabase.PATH_API_DATABASE);

0 commit comments

Comments
 (0)