-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from forza-mor-rotterdam/develop
develop -> main
- Loading branch information
Showing
3 changed files
with
12 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,17 @@ | ||
import requests | ||
from django.conf import settings | ||
from apps.meldingen.utils import get_meldingen_token | ||
from health_check.backends import BaseHealthCheckBackend | ||
from health_check.exceptions import HealthCheckException | ||
|
||
|
||
class MeldingenAPIHealthCheck(BaseHealthCheckBackend): | ||
class MeldingenTokenCheck(BaseHealthCheckBackend): | ||
critical_service = False | ||
|
||
def check_status(self): | ||
health_check_response = requests.get(settings.MELDINGEN_API_HEALTH_CHECK_URL) | ||
|
||
if health_check_response.status_code != 200: | ||
raise HealthCheckException( | ||
f"Meldingen API not ready: status code: {health_check_response.status_code}" | ||
) | ||
if health_check_response.status_code == 404: | ||
raise HealthCheckException( | ||
f"Meldingen API: health url not implemented: status code: {health_check_response.status_code}" | ||
) | ||
try: | ||
get_meldingen_token() | ||
return "OK" | ||
except Exception as e: | ||
raise HealthCheckException(e) | ||
|
||
def identifier(self): | ||
return self.__class__.__name__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters