Add basic structure to access django-orchestra API
This commit is contained in:
parent
676e9b94a5
commit
750d5cc465
|
@ -1,3 +1,4 @@
|
||||||
SECRET_KEY='$omeR@nd0mSecr3tKeyWith4V3ryL0ng$tring!?'
|
SECRET_KEY='$omeR@nd0mSecr3tKeyWith4V3ryL0ng$tring!?'
|
||||||
DEBUG=True
|
DEBUG=True
|
||||||
ALLOWED_HOSTS=.localhost,127.0.0.1
|
ALLOWED_HOSTS=.localhost,127.0.0.1
|
||||||
|
API_BASE_URL = 'https://api.examplea.org/'
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.urls.exceptions import NoReverseMatch
|
||||||
|
|
||||||
|
DOMAINS_PATH = 'domains/'
|
||||||
|
TOKEN_PATH = '/api-token-auth/'
|
||||||
|
|
||||||
|
API_PATHS = {
|
||||||
|
# auth
|
||||||
|
'token-auth': '/api-token-auth/',
|
||||||
|
|
||||||
|
# services
|
||||||
|
'domain-list': 'domains/',
|
||||||
|
# ... TODO (@slamora) complete list of backend URLs
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def build_absolute_uri(path_name):
|
||||||
|
path = API_PATHS.get(path_name, None)
|
||||||
|
if path is None:
|
||||||
|
raise NoReverseMatch("Not found API path name '{}'".format(path_name))
|
||||||
|
|
||||||
|
return urllib.parse.urljoin(settings.API_BASE_URL, path)
|
|
@ -2,4 +2,5 @@ django==2.2
|
||||||
python-decouple==3.1
|
python-decouple==3.1
|
||||||
django-extensions
|
django-extensions
|
||||||
dj_database_url==0.5.0
|
dj_database_url==0.5.0
|
||||||
|
requests==2.22.0
|
||||||
|
|
||||||
|
|
|
@ -135,3 +135,7 @@ USE_TZ = True
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
STATIC_ROOT = config('STATIC_ROOT')
|
STATIC_ROOT = config('STATIC_ROOT')
|
||||||
|
|
||||||
|
# Backend API configuration
|
||||||
|
|
||||||
|
API_BASE_URL = config('API_BASE_URL')
|
||||||
|
|
Loading…
Reference in New Issue