Skip to content

Commit 805425d

Browse files
authored
new: get /_admin/support-info (#311)
* new: `Database.support_info()` * remove `host` assertion * fix lint
1 parent 1265881 commit 805425d

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

arango/database.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
DatabaseDeleteError,
3333
DatabaseListError,
3434
DatabasePropertiesError,
35+
DatabaseSupportInfoError,
3536
GraphCreateError,
3637
GraphDeleteError,
3738
GraphListError,
@@ -2859,6 +2860,38 @@ def response_handler(resp: Response) -> bool:
28592860

28602861
return self._execute(request, response_handler)
28612862

2863+
###########
2864+
# Support #
2865+
###########
2866+
2867+
def support_info(self) -> Result[Json]:
2868+
"""Return information about the deployment.
2869+
2870+
Retrieves deployment information for support purposes.
2871+
The endpoint returns data about the ArangoDB version used,
2872+
the host (operating system, server ID, CPU and storage capacity,
2873+
current utilization, a few metrics) and the other servers in the
2874+
deployment (in case of Active Failover or cluster deployments).
2875+
2876+
NOTE: This method can only be accessed from inside the **_system** database.
2877+
The is a policy control startup option `--server.support-info-api` that controls
2878+
if and to whom the API is made available.
2879+
2880+
:return: Deployment information.
2881+
:rtype: dict
2882+
:raise arango.exceptions.DatabaseSupportInfoError: If retrieval fails.
2883+
"""
2884+
request = Request(method="get", endpoint="/_admin/support-info")
2885+
2886+
def response_handler(resp: Response) -> Json:
2887+
if resp.is_success:
2888+
result: Json = resp.body
2889+
return result
2890+
2891+
raise DatabaseSupportInfoError(resp, request)
2892+
2893+
return self._execute(request, response_handler)
2894+
28622895

28632896
class StandardDatabase(Database):
28642897
"""Standard database API wrapper."""

arango/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,10 @@ class DatabaseDeleteError(ArangoServerError):
360360
"""Failed to delete database."""
361361

362362

363+
class DatabaseSupportInfoError(ArangoServerError):
364+
"""Failed to retrieve support info for deployment."""
365+
366+
363367
class DatabaseCompactError(ArangoServerError):
364368
"""Failed to compact databases."""
365369

tests/test_database.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
DatabaseDeleteError,
1919
DatabaseListError,
2020
DatabasePropertiesError,
21+
DatabaseSupportInfoError,
2122
ServerDetailsError,
2223
ServerEchoError,
2324
ServerEngineError,
@@ -305,6 +306,14 @@ def test_database_misc_methods(client, sys_db, db, bad_db, cluster, secret):
305306
bad_db.engine()
306307
assert err.value.error_code in {11, 1228}
307308

309+
with assert_raises(DatabaseSupportInfoError) as err:
310+
db.support_info()
311+
312+
info = sys_db.support_info()
313+
assert isinstance(info, dict)
314+
assert "deployment" in info
315+
assert "date" in info
316+
308317
# Test execute JavaScript code
309318
assert db.execute(1) is None
310319
assert db.execute(None) == {"error": False, "code": 200}

0 commit comments

Comments
 (0)