Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new: get /_admin/support-info #311

Merged
merged 5 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading