Commit 5be368da authored by Cyril Monmouton's avatar Cyril Monmouton
Browse files

Clean up router by using same depends functions

parent f94bd0e1
......@@ -145,7 +145,10 @@ async def shutdown_event():
DDMS_V2_PATH = '/ddms/v2'
DDMS_V3_PATH = '/ddms/v3'
ALPHA_APIS_PREFIX = '/alpha'
basic_dependencies = [
Depends(require_data_partition_id, use_cache=False),
Depends(require_opendes_authorized_user, use_cache=False)
]
wdms_app.include_router(probes.router)
wdms_app.include_router(about.router, prefix=DDMS_V2_PATH)
......@@ -161,14 +164,11 @@ ddms_v2_routes_groups = [
(dipset_ddms_v2, "Dipset"),
(dip_ddms_v2, "Dips"),
]
for ddms_v2_routes_group in ddms_v2_routes_groups:
wdms_app.include_router(ddms_v2_routes_group[0].router,
for v2_api, tag in ddms_v2_routes_groups:
wdms_app.include_router(v2_api.router,
prefix=DDMS_V2_PATH,
tags=[ddms_v2_routes_group[1]],
dependencies=[
Depends(require_opendes_authorized_user, use_cache=False),
Depends(require_data_partition_id, use_cache=False)
])
tags=[tag],
dependencies=basic_dependencies)
ddms_v3_routes_groups = [
(wellbore_ddms_v3, "Wellbore"),
......@@ -176,38 +176,24 @@ ddms_v3_routes_groups = [
(welllog_ddms_v3, "WellLog"),
(wellbore_trajectory_ddms_v3, "Trajectory v3"),
(markerset_ddms_v3, "Marker"),
]
for ddms_v3_routes_group in ddms_v3_routes_groups:
wdms_app.include_router(ddms_v3_routes_group[0].router,
for v3_api, tag in ddms_v3_routes_groups:
wdms_app.include_router(v3_api.router,
prefix=DDMS_V3_PATH,
tags=[ddms_v3_routes_group[1]],
dependencies=[
Depends(require_opendes_authorized_user, use_cache=False),
Depends(require_data_partition_id, use_cache=False)
])
tags=[tag],
dependencies=basic_dependencies)
wdms_app.include_router(search.router, prefix='/ddms', tags=['search'], dependencies=[
Depends(require_data_partition_id, use_cache=False),
Depends(require_opendes_authorized_user, use_cache=False)
])
wdms_app.include_router(fast_search.router, prefix='/ddms', tags=['fast-search'], dependencies=[
Depends(require_data_partition_id, use_cache=False),
Depends(require_opendes_authorized_user, use_cache=False)])
wdms_app.include_router(search.router, prefix='/ddms', tags=['search'], dependencies=basic_dependencies)
wdms_app.include_router(fast_search.router, prefix='/ddms', tags=['fast-search'], dependencies=basic_dependencies)
wdms_app.include_router(search_v3.router, prefix='/ddms/v3', tags=['search'], dependencies=[
Depends(require_data_partition_id, use_cache=False),
Depends(require_opendes_authorized_user, use_cache=False)
])
wdms_app.include_router(fast_search_v3.router, prefix='/ddms/v3', tags=['fast-search'], dependencies=[
Depends(require_data_partition_id, use_cache=False),
Depends(require_opendes_authorized_user, use_cache=False)
])
wdms_app.include_router(log_recognition.router, prefix='/log-recognition', tags=['log-recognition'], dependencies=[
Depends(require_data_partition_id, use_cache=False),
Depends(require_opendes_authorized_user, use_cache=False)])
wdms_app.include_router(search_v3.router, prefix='/ddms/v3', tags=['search v3'], dependencies=basic_dependencies)
wdms_app.include_router(fast_search_v3.router, prefix='/ddms/v3', tags=['fast-search v3'],
dependencies=basic_dependencies)
wdms_app.include_router(log_recognition.router, prefix='/log-recognition',
tags=['log-recognition'],
dependencies=basic_dependencies)
alpha_tags = ['ALPHA feature: bulk data chunking']
......@@ -248,18 +234,21 @@ for bulk_prefix, bulk_tags, is_visible in [(ALPHA_APIS_PREFIX + DDMS_V3_PATH, al
wdms_app.include_router(
sessions.router,
prefix=ALPHA_APIS_PREFIX + DDMS_V2_PATH + log_ddms_v2.LOGS_API_BASE_PATH,
tags=tags, dependencies=dependencies)
tags=alpha_tags,
dependencies=basic_dependencies)
wdms_app.include_router(
bulk_utils.router_bulk,
prefix=ALPHA_APIS_PREFIX + DDMS_V2_PATH + log_ddms_v2.LOGS_API_BASE_PATH,
tags=tags, dependencies=dependencies)
tags=alpha_tags,
dependencies=basic_dependencies)
# ------------- add alpha feature: ONLY MOUNTED IN DEV AND DA ENVs
def enable_alpha_feature():
""" must be called to enable and activate alpha feature"""
logger.get_logger().warning("Enabling alpha feature: chunking")
# logger.get_logger().warning("Enabling alpha feature")
# include alpha routers down below #
pass
# order is last executed first
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment