+ """
+ indata looks as follows:
+ - In the new case (conformant)
+ {'nsdOperationalState': 'DISABLED', 'userDefinedData': {'id': 'string23',
+ '_id': 'c6ddc544-cede-4b94-9ebe-be07b298a3c1', 'name': 'simon46'}}
+ - In the old case (backwards-compatible)
+ {'id': 'string23', '_id': 'c6ddc544-cede-4b94-9ebe-be07b298a3c1', 'name': 'simon46'}
+ """
+ if "_admin" not in indata:
+ indata["_admin"] = {}
+
+ if "nsdOperationalState" in indata:
+ if indata["nsdOperationalState"] in ("ENABLED", "DISABLED"):
+ indata["_admin"]["operationalState"] = indata.pop("nsdOperationalState")
+ else:
+ raise EngineException("State '{}' is not a valid operational state"
+ .format(indata["nsdOperationalState"]),
+ http_code=HTTPStatus.BAD_REQUEST)
+
+ # In the case of user defined data, we need to put the data in the root of the object
+ # to preserve current expected behaviour
+ if "userDefinedData" in indata:
+ data = indata.pop("userDefinedData")
+ if type(data) == dict:
+ indata["_admin"]["userDefinedData"] = data
+ else:
+ raise EngineException("userDefinedData should be an object, but is '{}' instead"
+ .format(type(data)),
+ http_code=HTTPStatus.BAD_REQUEST)
+ if ("operationalState" in indata["_admin"] and
+ content["_admin"]["operationalState"] == indata["_admin"]["operationalState"]):
+ raise EngineException("nsdOperationalState already {}".format(content["_admin"]["operationalState"]),
+ http_code=HTTPStatus.CONFLICT)