Fixed some documentation and implementation details on the slicing API

This commit is contained in:
Gina Häußge 2015-03-19 21:03:28 +01:00
parent f2eeb50381
commit 05f6425a53
3 changed files with 9 additions and 13 deletions

View file

@ -110,7 +110,7 @@ List Slicing Profiles of a Specific Slicer
:param slicer: The identifying key of the slicer for which to list the available profiles.
:statuscode 200: No error
:statuscode 404: If the ``slicer`` was unknown to the system.
:statuscode 404: If the ``slicer`` was unknown to the system or not yet configured.
.. _sec-api-slicing-listspecific:
@ -155,7 +155,7 @@ Retrieve Specific Profile
:param slicer: The identifying key of the slicer for which to list the available profiles.
:param name: The identifying key of the profile to retrieve
:statuscode 200: No error
:statuscode 404: If the ``slicer`` or the profile was unknown to the system.
:statuscode 404: If the ``slicer`` or the profile ``key`` was unknown to the system.
.. _sec-api-slicing-add:
@ -215,7 +215,8 @@ Delete Slicing Profile
.. http:delete:: /api/slicing/(string:slicer)/profiles/(string:key)
Delete the slicing profile identified by ``key`` for the slicer ``slicer``.
Delete the slicing profile identified by ``key`` for the slicer ``slicer``. If the profile doesn't exist, the
request will succeed anyway.
:param slicer: The identifying key of the slicer for which to delete the profile
:param key: The identifying key of the profile to delete

View file

@ -89,11 +89,10 @@ def slicingAddSlicerProfile(slicer, name):
description = json_data["description"]
try:
profile = slicingManager.save_profile(slicer, name, data, display_name=display_name, description=description)
profile = slicingManager.save_profile(slicer, name, data,
allow_overwrite=True, display_name=display_name, description=description)
except UnknownSlicer:
return make_response("Unknown slicer {slicer}".format(**locals()), 404)
except ProfileAlreadyExists:
return make_response("A profile named {name} already exists for slicer {slicer}".format(**locals()), 409)
result = _getSlicingProfileData(slicer, name, profile)
r = make_response(jsonify(result), 201)
@ -137,10 +136,8 @@ def slicingPatchSlicerProfile(slicer, name):
s().set(["slicing", "defaultProfiles"], default_profiles)
s().save(force=True)
try:
saved_profile = slicingManager.save_profile(slicer, name, profile, overrides=data, display_name=display_name, description=description)
except ProfileAlreadyExists:
return make_response("Profile named {name} for slicer {slicer} does already exist".format(**locals()), 409)
saved_profile = slicingManager.save_profile(slicer, name, profile,
allow_overwrite=True, overrides=data, display_name=display_name, description=description)
return jsonify(_getSlicingProfileData(slicer, name, saved_profile))
@api.route("/slicing/<string:slicer>/profiles/<string:name>", methods=["DELETE"])
@ -150,8 +147,6 @@ def slicingDelSlicerProfile(slicer, name):
slicingManager.delete_profile(slicer, name)
except UnknownSlicer:
return make_response("Unknown slicer {slicer}".format(**locals()), 404)
except UnknownProfile:
return make_response("Unknown profile {name} for slicer {slicer}".format(**locals()), 404)
return NO_CONTENT

View file

@ -434,7 +434,7 @@ class SlicingManager(object):
raise ValueError("name must be set")
try:
path = self.get_profile_path(slicer, name)
path = self.get_profile_path(slicer, name, must_exist=True)
except UnknownProfile:
return
os.remove(path)