Files
oopt-gnpy-api/gnpyapi/core/route/path_request_route.py
Renato Ambrosone c30308eb92 FIX: api version is now consistent with release
Change-Id: I25582e7937ec912666e2ba48d5687ec3ae694883
2025-04-18 15:09:02 +02:00

29 lines
988 B
Python

# coding: utf-8
from flask import request
from gnpyapi.core import app
from gnpyapi.core.exception.equipment_error import EquipmentError
from gnpyapi.core.exception.topology_error import TopologyError
from gnpyapi.core.service.path_request_service import PathRequestService
from gnpyapi.core import API_VERSION
PATH_REQUEST_BASE_PATH = '/path-request'
@app.route(API_VERSION + PATH_REQUEST_BASE_PATH, methods=['POST'])
@app.route(PATH_REQUEST_BASE_PATH, methods=['POST'])
def path_request(path_request_service: PathRequestService):
data = request.json
service = data['gnpy-api:service']
if 'gnpy-api:topology' in data:
topology = data['gnpy-api:topology']
else:
raise TopologyError('No topology found in request')
if 'gnpy-api:equipment' in data:
equipment = data['gnpy-api:equipment']
else:
raise EquipmentError('No equipment found in request')
return path_request_service.path_request(topology, equipment, service), 201