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

set default grafana_url if GRAFANA_API_URL set #4702

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions engine/apps/grafana_plugin/helpers/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import time
import typing
from urllib.parse import urljoin
from urllib.parse import urljoin, urlparse

import requests
from django.conf import settings
Expand Down Expand Up @@ -94,7 +94,10 @@ def __call__(self, *args, **kwargs) -> requests.Response:

class APIClient:
def __init__(self, api_url: str, api_token: str) -> None:
self.api_url = api_url
if settings.SELF_HOSTED_SETTINGS["GRAFANA_API_URL"] is not None:
self.api_url = settings.SELF_HOSTED_SETTINGS["GRAFANA_API_URL"]
if urlparse(self.api_url).path and not self.api_url.endswith('/'):
self.api_url += '/'
self.api_token = api_token

def api_head(self, endpoint: str, body: typing.Optional[typing.Dict] = None, **kwargs) -> APIClientResponse[_RT]:
Expand Down