mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-14 17:02:56 +00:00
Add /installed_extensions endpoint to collect
statistics about extension usage.
It returns a list of installed extensions in the format:
```json
{
"extensions": [
{
"extname": "extension_name",
"versions": ["1.0", "1.1"],
"n_databases": 5,
}
]
}
```
---------
Co-authored-by: Heikki Linnakangas <heikki@neon.tech>
31 lines
818 B
Python
31 lines
818 B
Python
from __future__ import annotations
|
|
|
|
import requests
|
|
from requests.adapters import HTTPAdapter
|
|
|
|
|
|
class EndpointHttpClient(requests.Session):
|
|
def __init__(
|
|
self,
|
|
port: int,
|
|
):
|
|
super().__init__()
|
|
self.port = port
|
|
|
|
self.mount("http://", HTTPAdapter())
|
|
|
|
def dbs_and_roles(self):
|
|
res = self.get(f"http://localhost:{self.port}/dbs_and_roles")
|
|
res.raise_for_status()
|
|
return res.json()
|
|
|
|
def database_schema(self, database: str):
|
|
res = self.get(f"http://localhost:{self.port}/database_schema?database={database}")
|
|
res.raise_for_status()
|
|
return res.text
|
|
|
|
def installed_extensions(self):
|
|
res = self.get(f"http://localhost:{self.port}/installed_extensions")
|
|
res.raise_for_status()
|
|
return res.json()
|