mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 21:41:27 +00:00
fix: add endpoint debug
This commit is contained in:
parent
c056540578
commit
239c47964c
|
@ -20,10 +20,11 @@ class KanidmUserRepository(AbstractUserRepository):
|
|||
@staticmethod
|
||||
def _send_query(endpoint: str, method: str = "GET", data=None):
|
||||
request_method = getattr(requests, method.lower(), None)
|
||||
full_endpoint = f"{KANIDM_URL}/v1/{endpoint}"
|
||||
|
||||
try:
|
||||
response = request_method(
|
||||
f"{KANIDM_URL}/v1/{endpoint}",
|
||||
full_endpoint,
|
||||
json=data,
|
||||
headers={
|
||||
"Authorization": f"Bearer {TEST_TOKEN}",
|
||||
|
@ -33,9 +34,8 @@ class KanidmUserRepository(AbstractUserRepository):
|
|||
)
|
||||
|
||||
if response.status_code != 200:
|
||||
error_text = getattr(response, "text", "No response error was found...")
|
||||
raise KanidmQueryError(
|
||||
f"Kanidm returned {response.status_code} unexpected HTTP status code. Error: {error_text}."
|
||||
f"Kanidm returned {response.status_code} unexpected HTTP status code. Endpoint: {full_endpoint}. Error: {response.text}."
|
||||
)
|
||||
json = response.json()
|
||||
return json["data"]
|
||||
|
|
|
@ -70,9 +70,8 @@ class MonitoringQueries:
|
|||
timeout=0.8,
|
||||
)
|
||||
if response.status_code != 200:
|
||||
error_text = getattr(response, "text", "No response error was found...")
|
||||
return MonitoringQueryError(
|
||||
error=f"Prometheus returned unexpected HTTP status code. Error: {error_text}. The query was {query}"
|
||||
error=f"Prometheus returned unexpected HTTP status code. Error: {response.text}. The query was {query}"
|
||||
)
|
||||
json = response.json()
|
||||
if result_type and json["data"]["resultType"] != result_type:
|
||||
|
|
Loading…
Reference in a new issue