From 1b1d31d69b7298e83b344ac229f7caaa245680c6 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Fri, 29 Dec 2023 19:28:25 -0500 Subject: [PATCH 1/3] new: `Database.support_info()` --- arango/database.py | 33 +++++++++++++++++++++++++++++++++ arango/exceptions.py | 4 ++++ tests/test_database.py | 10 ++++++++++ 3 files changed, 47 insertions(+) diff --git a/arango/database.py b/arango/database.py index e33bd5ae..95fa9f17 100644 --- a/arango/database.py +++ b/arango/database.py @@ -31,6 +31,7 @@ DatabaseDeleteError, DatabaseListError, DatabasePropertiesError, + DatabaseSupportInfoError, GraphCreateError, GraphDeleteError, GraphListError, @@ -2675,6 +2676,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.""" diff --git a/arango/exceptions.py b/arango/exceptions.py index fb11f8d5..0822136f 100644 --- a/arango/exceptions.py +++ b/arango/exceptions.py @@ -360,6 +360,10 @@ class DatabaseDeleteError(ArangoServerError): """Failed to delete database.""" +class DatabaseSupportInfoError(ArangoServerError): + """Failed to retrieve support info for deployment.""" + + ####################### # Document Exceptions # ####################### diff --git a/tests/test_database.py b/tests/test_database.py index da6307a4..8dacf086 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -17,6 +17,7 @@ DatabaseDeleteError, DatabaseListError, DatabasePropertiesError, + DatabaseSupportInfoError, ServerDetailsError, ServerEchoError, ServerEngineError, @@ -263,6 +264,15 @@ def test_database_misc_methods(sys_db, db, bad_db, cluster): 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 "host" in info + assert "date" in info + def test_database_management(db, sys_db, bad_db): # Test list databases From 56d92b01f0f2ca12ecd424641247ebdecd27e326 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Fri, 29 Dec 2023 20:27:52 -0500 Subject: [PATCH 2/3] remove `host` assertion --- tests/test_database.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_database.py b/tests/test_database.py index 8dacf086..c3a13602 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -270,7 +270,6 @@ def test_database_misc_methods(sys_db, db, bad_db, cluster): info = sys_db.support_info() assert isinstance(info, dict) assert "deployment" in info - assert "host" in info assert "date" in info From 03e982c590c14758ee3f9d862fab62089f88367c Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Fri, 26 Jan 2024 12:55:51 -0500 Subject: [PATCH 3/3] fix lint --- arango/exceptions.py | 1 - tests/test_database.py | 1 - 2 files changed, 2 deletions(-) diff --git a/arango/exceptions.py b/arango/exceptions.py index 1ac39794..000a0f8f 100644 --- a/arango/exceptions.py +++ b/arango/exceptions.py @@ -368,7 +368,6 @@ class DatabaseCompactError(ArangoServerError): """Failed to compact databases.""" - ####################### # Document Exceptions # ####################### diff --git a/tests/test_database.py b/tests/test_database.py index 663481d7..23f2c7f4 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -333,7 +333,6 @@ def test_database_misc_methods(client, sys_db, db, bad_db, cluster, secret): assert result == {} - def test_database_management(db, sys_db, bad_db): # Test list databases result = sys_db.databases()