Commit 524c951e authored by Robin Knapp's avatar Robin Knapp

WIP: ld integration

parent 1029094c
{
"battery": {
"nav": "type==type&value=value",
"type": "Property"
},
"category": {
"nav": "type==type&value=value",
"type": "Property"
},
"depth": {
"nav": "type==type&value=value",
"type": "Property"
},
"duration": {
"nav": "type==type&value=value",
"type": "Property"
},
"endDate": {
"nav": "type==type&value=value",
"type": "Property"
},
"endTick": {
"nav": "type==type&value=value",
"type": "Property"
},
"height": {
"nav": "type==type&value=value",
"type": "Property"
},
"idTruck": {
"nav": "type==type&value=value",
"type": "Property"
},
"initDate": {
"nav": "type==type&value=value",
"type": "Property"
},
"location": {
"nav": "type==type&value=value",
"type": "GeoProperty"
},
"nextWateringAmountRecommendation": {
"nav": "type==type&value=value",
"type": "Property"
},
"nextWateringDeadline": {
"nav": "type==type&value=value",
"type": "Property"
},
"soilMoisture": {
"nav": "type==type&value=value",
"type": "Property"
},
"sunExposure": {
"nav": "type==type&value=value",
"type": "Property"
},
"truckLocation": {
"nav": "type==type&value=value",
"type": "Property"
},
"version": {
"nav": "type==type&value=value",
"type": "Property"
},
"width": {
"nav": "type==type&value=value",
"type": "Property"
},
"refDevice" : {
"nav": "type==type&value=object",
"ldType": "Relationship"
......@@ -11,14 +75,10 @@
"nav": "type==type&value=value",
"type": "Property"
},
"category": {
"consumption": {
"nav": "type==type&value=value",
"type": "Property"
},
"width" : {
"nav": "type==type&value=value",
"type": "Property"
},
"dateLastWatering": {
"nav": "type==type&value=value",
"type": "Property"
......
......@@ -12,9 +12,7 @@ from src.api import config
from src.api.routes_validation_v2 import validation_v2_entities, historic_validation_v2_entities
from src.api.server_utils import ValidationErrorResponse, random_id, load_url_resources, parse_model
from src.logger import FORMATTER
# from src.api.validation_ld import validation_ld_entities
from src.api.routes_validation_ld import validation_ld_entities, historic_validation_ld_entities
def create_app():
......@@ -27,7 +25,8 @@ def create_app():
app = Flask(__name__, instance_relative_config=True)
app.register_blueprint(validation_v2_entities)
app.register_blueprint(historic_validation_v2_entities)
# app.register_blueprint(validation_ld_entities)
app.register_blueprint(validation_ld_entities)
app.register_blueprint(historic_validation_ld_entities)
if develop:
from src.api import develop_config
......
......@@ -9,7 +9,7 @@ from src.api.server_utils import ValidationErrorResponse, extract_modelname_from
from src.logic import ValidationException, Creator, Updater
validation_ld_entities = Blueprint('val_ld_ent', __name__, url_prefix='/validation/ld/entities')
historic_validation_ld_entities = Blueprint('val_ld_ent', __name__, url_prefix='historic/validation/ld/entities')
historic_validation_ld_entities = Blueprint('hist_ld_ent', __name__, url_prefix='/historic/validation/ld/entities')
def validate_post_ld(model: dict, cache: flask_caching.Cache):
......@@ -99,7 +99,7 @@ def validate_patch_ld(model: dict, model_type: str, cache: flask_caching.Cache):
def get_validation_v2_entities(url):
if request.data:
raise ValidationErrorResponse(msg=f'GET-Request must not contain data', log=False)
if request.blueprint == 'val_v2_ent':
if request.blueprint == 'val_ld_ent':
forward_url = f'{current_app.config["PLATFORM_ENDPOINT"]}{request.full_path}'
else:
forward_url = f'{current_app.config["PLATFORM_ENDPOINT_HISTORIC"]}{request.full_path}'
......@@ -109,7 +109,7 @@ def get_validation_v2_entities(url):
@historic_validation_ld_entities.route('/<path:url>', methods=["DELETE"])
@validation_ld_entities.route('/<path:url>', methods=["DELETE"])
def delete_validation_v2_entities(url):
if request.blueprint == 'val_v2_ent':
if request.blueprint == 'val_ld_ent':
forward_url = f'{current_app.config["PLATFORM_ENDPOINT"]}{request.full_path}'
else:
forward_url = f'{current_app.config["PLATFORM_ENDPOINT_HISTORIC"]}{request.full_path}'
......@@ -131,7 +131,7 @@ def options_validation_v2_entities(url):
def put_validation_v2_entities(url):
model = json.loads(request.data.decode('UTF-8')) # type = dict
if request.blueprint == 'val_v2_ent':
if request.blueprint == 'val_ld_ent':
forward_url = f'{current_app.config["PLATFORM_ENDPOINT"]}{request.full_path}'
else:
forward_url = f'{current_app.config["PLATFORM_ENDPOINT_HISTORIC"]}{request.full_path}'
......@@ -164,7 +164,7 @@ def put_validation_v2_entities(url):
def patch_validation_v2_entities(url):
model = ast.literal_eval(request.data.decode('UTF-8')) # dict or list
if request.blueprint == 'val_v2_ent':
if request.blueprint == 'val_ld_ent':
forward_url = f'{current_app.config["PLATFORM_ENDPOINT"]}{request.full_path}'
else:
forward_url = f'{current_app.config["PLATFORM_ENDPOINT_HISTORIC"]}{request.full_path}'
......@@ -187,7 +187,7 @@ def patch_validation_v2_entities(url):
def post_validation_v2_entities(url):
model = ast.literal_eval(request.data.decode('UTF-8')) # dict or list
if request.blueprint == 'val_v2_ent':
if request.blueprint == 'val_ld_ent': # `current` api
if isinstance(model, list):
raise ValidationErrorResponse(msg=f'None-historic api does not support json-array currently.',
module=__name__)
......
......@@ -136,7 +136,7 @@ class Connector(object):
target_file = f'Specs_{model_type}.json'
target_path = f'{target_dir}{target_file}'
current_app.logger.debug(f'load from disk. Target: {target_path}')
current_app.logger.debug(f'<<{__name__}.Connector.load_specs_from_disk>> load from disk. Target: {target_path}')
try:
return self.load_json_from_disk(abs_path=target_path)
......
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