Skip to content

Commit

Permalink
now reading from environments.json in MAAP API
Browse files Browse the repository at this point in the history
  • Loading branch information
grallewellyn committed Dec 4, 2024
1 parent 2e0f12f commit 154e28e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
3 changes: 0 additions & 3 deletions api/endpoints/constants.py

This file was deleted.

15 changes: 5 additions & 10 deletions api/endpoints/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from api import settings
import requests
import urllib.parse
import os
import api.endpoints.constants as constants
import json

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -62,16 +61,12 @@ def get(self, ade_host):
def get_config(ade_host):
print("graceal1 in API get_config with")
print(ade_host)
print(settings.MAAP_ENVIRONMENT_FILE)
req = requests.get(settings.MAAP_ENVIRONMENT_FILE)
if req.status_code == requests.codes.ok:
data = req.json()
else:
print('Content was not found.')
with open("environments.json") as f:
data = json.loads(f)

base_url = "{0.netloc}".format(urlsplit(urllib.parse.unquote(ade_host)))
print("graceal1 req returned was")
print(req)
print("graceal1 req returned is")
print(data)
match = next((x for x in data if base_url in x['ade_server']), None)
maap_config = next((x for x in data if x['default_host'] == True), None) if match is None else match
print("graceal1 the maap_config is")
Expand Down
33 changes: 33 additions & 0 deletions api/endpoints/environments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[
{
"environment": "dit",
"ade_server": "ade.dit.maap-project.org",
"api_server": "api.dit.maap-project.org",
"auth_server": "auth.dit.maap-project.org",
"mas_server": "repo.dit.maap-project.org",
"edsc_server": "ade.dit.maap-project.org:30052",
"workspace_bucket": "maap-dit-workspace",
"kibana_url": "https://35.88.169.231/metrics/goto/4f1115df1b6563782292fb1f75676f95",
"default_host": true
},
{
"environment": "uat",
"ade_server": "ade.uat.maap-project.org",
"api_server": "api.uat.maap-project.org",
"auth_server": "auth.uat.maap-project.org",
"mas_server": "repo.uat.maap-project.org",
"edsc_server": "ade.uat.maap-project.org:30052",
"workspace_bucket": "maap-uat-workspace",
"default_host": false
},
{
"environment": "ops",
"ade_server": "ade.maap-project.org",
"api_server": "api.maap-project.org",
"auth_server": "auth.maap-project.org",
"mas_server": "mas.maap-project.org",
"edsc_server": "ade.maap-project.org:30052",
"workspace_bucket": "maap-ops-workspace",
"default_host": false
}
]

0 comments on commit 154e28e

Please sign in to comment.