File tree Expand file tree Collapse file tree 5 files changed +38
-0
lines changed
Expand file tree Collapse file tree 5 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 3131import javax .net .ssl .SSLContext ;
3232
3333import com .arangodb .entity .ArangoDBVersion ;
34+ import com .arangodb .entity .ArangoDBRole ;
3435import com .arangodb .entity .LogEntity ;
3536import com .arangodb .entity .LogLevelEntity ;
3637import com .arangodb .entity .UserEntity ;
@@ -453,6 +454,18 @@ public ArangoDBVersion getVersion() throws ArangoDBException {
453454 return db ().getVersion ();
454455 }
455456
457+ /**
458+ * Returns the server role.
459+ *
460+ * @see <a href="https://docs.arangodb.com/current/HTTP/MiscellaneousFunctions/index.html#return-server-version">API
461+ * Documentation</a>
462+ * @return the server role
463+ * @throws ArangoDBException
464+ */
465+ public ArangoDBRole getRole () throws ArangoDBException {
466+ return db ().getRole ();
467+ }
468+
456469 /**
457470 * Create a new user. This user will not have access to any database. You need permission to the _system database in
458471 * order to execute this call.
Original file line number Diff line number Diff line change 2727import com .arangodb .entity .AqlFunctionEntity ;
2828import com .arangodb .entity .AqlParseEntity ;
2929import com .arangodb .entity .ArangoDBVersion ;
30+ import com .arangodb .entity .ArangoDBRole ;
3031import com .arangodb .entity .CollectionEntity ;
3132import com .arangodb .entity .CursorEntity ;
3233import com .arangodb .entity .DatabaseEntity ;
@@ -87,6 +88,18 @@ public ArangoDBVersion getVersion() throws ArangoDBException {
8788 return executor .execute (getVersionRequest (), ArangoDBVersion .class );
8889 }
8990
91+ /**
92+ * Returns the server name and version number.
93+ *
94+ * @see <a href="https://docs.arangodb.com/current/HTTP/MiscellaneousFunctions/index.html#return-server-version">API
95+ * Documentation</a>
96+ * @return the server version, number
97+ * @throws ArangoDBException
98+ */
99+ public ArangoDBRole getRole () throws ArangoDBException {
100+ return executor .execute (getRoleRequest (), ArangoDBRole .class );
101+ }
102+
90103 /**
91104 * Retrieves a list of all databases the current user can access
92105 *
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ public class ArangoDBConstants {
6161 public static final String PATH_API_ADMIN_LOG_LEVEL = "/_admin/log/level" ;
6262 public static final String PATH_API_ADMIN_ROUTING_RELOAD = "/_admin/routing/reload" ;
6363 public static final String PATH_API_IMPORT = "/_api/import" ;
64+ public static final String PATH_API_ROLE = "_admin/server/role" ;
6465
6566 public static final String ENCRYPTION_PLAIN = "plain" ;
6667
Original file line number Diff line number Diff line change @@ -92,6 +92,10 @@ protected Request getVersionRequest() {
9292 return new Request (name , RequestType .GET , ArangoDBConstants .PATH_API_VERSION );
9393 }
9494
95+ protected Request getRoleRequest () {
96+ return new Request (name , RequestType .GET , ArangoDBConstants .PATH_API_ROLE );
97+ }
98+
9599 protected Request createCollectionRequest (final String name , final CollectionCreateOptions options ) {
96100 return new Request (name (), RequestType .POST , ArangoDBConstants .PATH_API_COLLECTION ).setBody (
97101 executor .serialize (OptionsBuilder .build (options != null ? options : new CollectionCreateOptions (), name )));
Original file line number Diff line number Diff line change 4949import com .arangodb .entity .AqlParseEntity ;
5050import com .arangodb .entity .AqlParseEntity .AstNode ;
5151import com .arangodb .entity .ArangoDBVersion ;
52+ import com .arangodb .entity .ArangoDBRole ;
5253import com .arangodb .entity .BaseDocument ;
5354import com .arangodb .entity .BaseEdgeDocument ;
5455import com .arangodb .entity .CollectionEntity ;
@@ -124,6 +125,9 @@ public void deleteCollection() {
124125
125126 @ Test
126127 public void deleteSystemCollection () {
128+ if (db .getRole ().getRole () == "COORDINATOR" ) {
129+ return ;
130+ }
127131 final String name = "_system_test" ;
128132 db .createCollection (name , new CollectionCreateOptions ().isSystem (true ));
129133 db .collection (name ).drop (true );
@@ -136,6 +140,9 @@ public void deleteSystemCollection() {
136140
137141 @ Test
138142 public void deleteSystemCollectionFail () {
143+ if (db .getRole ().getRole () == "COORDINATOR" ) {
144+ return ;
145+ }
139146 final String name = "_system_test" ;
140147 db .createCollection (name , new CollectionCreateOptions ().isSystem (true ));
141148 try {
You can’t perform that action at this time.
0 commit comments