X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=o2ims%2Fviews%2Fapi_ns.py;h=5f3cf2359455b5aaef4df43a30abfbc11425fd42;hb=HEAD;hp=b06cb2abd50eb77dfd17047f026629da69b13da1;hpb=8f7352951c11d939bae11422c00c87dc1f1d2a85;p=pti%2Fo2.git diff --git a/o2ims/views/api_ns.py b/o2ims/views/api_ns.py index b06cb2a..5f3cf23 100644 --- a/o2ims/views/api_ns.py +++ b/o2ims/views/api_ns.py @@ -12,17 +12,106 @@ # See the License for the specific language governing permissions and # limitations under the License. +from flask import request +from flask_restx import Resource, fields + from o2common.views.route import O2Namespace -api_ims_inventory_v1 = O2Namespace( - "O2IMS_Inventory", - description='IMS Inventory related operations.') +api_ims_inventory = O2Namespace( + "O2IMS-InfrastructureInventory", + description='O2 IMS Inventory related operations.') api_provision_v1 = O2Namespace( "PROVISION", description='Provision related operations.') -api_monitoring_v1 = O2Namespace( - "O2IMS_InfrastructureMonitoring", +api_ims_monitoring = O2Namespace( + "O2IMS-InfrastructureMonitoring", description='O2 IMS Monitoring related operations.') + + +@api_ims_inventory.route('/api_versions') +class InventoryVersion(Resource): + api_version = api_ims_inventory.model( + 'InventoryApiVersionStructure', + { + 'version': fields.String( + required=True, + example='1.0.0', + description='Identifies a supported version.' + ) + }, + mask='{version,}' + ) + model = api_ims_inventory.model( + "InventoryAPIVersion", + { + 'uriPrefix': fields.String( + required=True, + example='https://128.224.115.36:30205/' + + 'o2ims-infrastructureInventory', + description='Specifies the URI prefix for the API'), + 'apiVersions': fields.List( + fields.Nested(api_version), + example=[{'version': '1.0.0'}], + description='Version(s) supported for the API ' + + 'signaled by the uriPrefix attribute.'), + }, + mask='{uriPrefix,apiVersions}' + ) + + @api_ims_inventory.doc('Get Inventory Version') + @api_ims_inventory.marshal_with(model) + def get(self): + return { + 'uriPrefix': request.base_url.rsplit('/', 1)[0], + 'apiVersions': [{ + 'version': '1.0.0', + # 'isDeprecated': 'False', + # 'retirementDate': '' + }] + } + + +@api_ims_monitoring.route('/api_versions') +class MonitoringVersion(Resource): + api_version = api_ims_inventory.model( + 'MonitoringApiVersionStructure', + { + 'version': fields.String( + required=True, + example='1.0.0', + description='Identifies a supported version.' + ) + }, + mask='{version,}' + ) + model = api_ims_inventory.model( + "MonitoringAPIVersion", + { + 'uriPrefix': fields.String( + required=True, + example='https://128.224.115.36:30205/' + + 'o2ims-infrastructureMonitoring', + description='Specifies the URI prefix for the API'), + 'apiVersions': fields.List( + fields.Nested(api_version), + example=[{'version': '1.0.0'}], + description='Version(s) supported for the API ' + + 'signaled by the uriPrefix attribute.'), + }, + mask='{uriPrefix,apiVersions}' + ) + + @api_ims_monitoring.doc('Get Monitoring Version') + @api_ims_monitoring.marshal_with(model) + def get(self): + return { + 'uriPrefix': request.base_url.rsplit('/', 1)[0], + 'apiVersions': [{ + 'version': '1.0.0', + # 'isDeprecated': 'False', + # 'retirementDate': '' + }] + }