Skip to content

Commit

Permalink
new: get /_admin/support-info (#311)
Browse files Browse the repository at this point in the history
* new: `Database.support_info()`

* remove `host` assertion

* fix lint
  • Loading branch information
aMahanna committed Jan 26, 2024
1 parent 1265881 commit 805425d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
33 changes: 33 additions & 0 deletions arango/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
DatabaseDeleteError,
DatabaseListError,
DatabasePropertiesError,
DatabaseSupportInfoError,
GraphCreateError,
GraphDeleteError,
GraphListError,
Expand Down Expand Up @@ -2859,6 +2860,38 @@ def response_handler(resp: Response) -> bool:

return self._execute(request, response_handler)

###########
# Support #
###########

def support_info(self) -> Result[Json]:
"""Return information about the deployment.
Retrieves deployment information for support purposes.
The endpoint returns data about the ArangoDB version used,
the host (operating system, server ID, CPU and storage capacity,
current utilization, a few metrics) and the other servers in the
deployment (in case of Active Failover or cluster deployments).
NOTE: This method can only be accessed from inside the **_system** database.
The is a policy control startup option `--server.support-info-api` that controls
if and to whom the API is made available.
:return: Deployment information.
:rtype: dict
:raise arango.exceptions.DatabaseSupportInfoError: If retrieval fails.
"""
request = Request(method="get", endpoint="/_admin/support-info")

def response_handler(resp: Response) -> Json:
if resp.is_success:
result: Json = resp.body
return result

raise DatabaseSupportInfoError(resp, request)

return self._execute(request, response_handler)


class StandardDatabase(Database):
"""Standard database API wrapper."""
Expand Down
4 changes: 4 additions & 0 deletions arango/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ class DatabaseDeleteError(ArangoServerError):
"""Failed to delete database."""


class DatabaseSupportInfoError(ArangoServerError):
"""Failed to retrieve support info for deployment."""


class DatabaseCompactError(ArangoServerError):
"""Failed to compact databases."""

Expand Down
9 changes: 9 additions & 0 deletions tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
DatabaseDeleteError,
DatabaseListError,
DatabasePropertiesError,
DatabaseSupportInfoError,
ServerDetailsError,
ServerEchoError,
ServerEngineError,
Expand Down Expand Up @@ -305,6 +306,14 @@ def test_database_misc_methods(client, sys_db, db, bad_db, cluster, secret):
bad_db.engine()
assert err.value.error_code in {11, 1228}

with assert_raises(DatabaseSupportInfoError) as err:
db.support_info()

info = sys_db.support_info()
assert isinstance(info, dict)
assert "deployment" in info
assert "date" in info

# Test execute JavaScript code
assert db.execute(1) is None
assert db.execute(None) == {"error": False, "code": 200}
Expand Down

0 comments on commit 805425d

Please sign in to comment.