forked from AOT-Technologies/forms-flow-ai
-
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 AOT-Technologies#2397 from auslin-aot/FWF-4001-add…
…-form-access-import [Bug fix] Added form access on import & export fixes
- Loading branch information
Showing
8 changed files
with
190 additions
and
23 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
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
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
29 changes: 29 additions & 0 deletions
29
forms-flow-api/src/formsflow_api/services/external/admin.py
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""This exposes the Admin API.""" | ||
|
||
import json | ||
|
||
import requests | ||
from flask import current_app | ||
from formsflow_api_utils.exceptions import BusinessException | ||
from formsflow_api_utils.utils import HTTP_TIMEOUT | ||
|
||
from formsflow_api.constants import BusinessErrorCode | ||
|
||
|
||
class AdminService: # pylint: disable=too-few-public-methods | ||
"""This class manages external calls to admin api service.""" | ||
|
||
@classmethod | ||
def get_request(cls, url, token): | ||
"""Get HTTP request to Admin API with auth header.""" | ||
headers = {"Authorization": token, "content-type": "application/json"} | ||
try: | ||
response = requests.get(url, headers=headers, timeout=HTTP_TIMEOUT) | ||
current_app.logger.debug( | ||
"GET URL : %s, Response Code : %s", url, response.status_code | ||
) | ||
if response.ok: | ||
return json.loads(response.text) | ||
raise BusinessException(BusinessErrorCode.INVALID_ADMIN_RESPONSE) | ||
except requests.ConnectionError as e: | ||
raise BusinessException(BusinessErrorCode.ADMIN_SERVICE_UNAVAILABLE) from e |
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