X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=o2app%2Fentrypoints%2Fflask_application.py;h=fb4b6a220602e43e7d1edefa3b0d41cbdb84a1de;hb=d7c14ad6506b2f1a85246c9e1d08d0d64e9df7f2;hp=f9d5f85b3b76b39f8d7144b6e1b1c845c5d04d54;hpb=5ad82f634e2f10aaeccf1d2420fafc63e2d0056e;p=pti%2Fo2.git diff --git a/o2app/entrypoints/flask_application.py b/o2app/entrypoints/flask_application.py index f9d5f85..fb4b6a2 100644 --- a/o2app/entrypoints/flask_application.py +++ b/o2app/entrypoints/flask_application.py @@ -1,34 +1,53 @@ -# Copyright (C) 2021 Wind River Systems, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from flask import Flask -from flask_restx import Api - -from o2app import bootstrap -from o2ims.views import ocloud_route as ims_route -from o2dms.api import configure_namespace as dms_route_configure_namespace - - -# apibase = config.get_o2ims_api_base() -app = Flask(__name__) -app.config.SWAGGER_UI_DOC_EXPANSION = 'list' -api = Api(app, version='1.0.0', - title='O-Cloud O2 Services', - description='Swagger OpenAPI document for \ - O-Cloud O2 Services', - ) -bus = bootstrap.bootstrap() - -ims_route.configure_namespace(api, bus) -dms_route_configure_namespace(api) +# Copyright (C) 2021-2022 Wind River Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from flask import Flask +from flask_restx import Api + + +from o2app import bootstrap +from o2ims.views import configure_namespace as ims_route_configure_namespace +from o2common.views.route_exception import configure_exception + +from o2common.authmw import authmiddleware +from o2common.authmw import authprov +from o2common.helper import o2logging + +AUTH_ENABLED = True +FLASK_API_VERSION = '1.0.0' + +# apibase = config.get_o2ims_api_base() +app = Flask(__name__) +logger = o2logging.get_logger(__name__) + +if AUTH_ENABLED: + # perform service account identity&privilege check. + ad = authprov.auth_definer('ad') + ad.sanity_check() + app.wsgi_app = authmiddleware.authmiddleware(app.wsgi_app) + +app.config.SWAGGER_UI_DOC_EXPANSION = 'list' +# app.config['RESTX_MASK_HEADER'] = 'fields' +app.config['RESTX_MASK_SWAGGER'] = False +app.config['ERROR_INCLUDE_MESSAGE'] = False +api = Api( + app, version=FLASK_API_VERSION, + catch_all_404s=True, + title='INF O2 Services API', + description='Swagger OpenAPI document for the INF O2 Services', + ) +bus = bootstrap.bootstrap() + +configure_exception(api) +ims_route_configure_namespace(api)