Merge "Change not found HTTP status code from 400 to 404"

This commit is contained in:
Jenkins 2015-12-03 08:24:07 +00:00 committed by Gerrit Code Review
commit 272a9cb1cb
12 changed files with 26 additions and 26 deletions

View File

@ -45,7 +45,7 @@ class MappingController(rest.RestController):
return collector_models.ServiceToCollectorMapping(
**mapping.as_dict())
except db_api.NoSuchMapping as e:
pecan.abort(400, six.text_type(e))
pecan.abort(404, six.text_type(e))
@wsme_pecan.wsexpose(collector_models.ServiceToCollectorMappingCollection,
wtypes.text)
@ -89,7 +89,7 @@ class MappingController(rest.RestController):
try:
self._db.delete_mapping(service)
except db_api.NoSuchMapping as e:
pecan.abort(400, six.text_type(e))
pecan.abort(404, six.text_type(e))
class CollectorStateController(rest.RestController):

View File

@ -99,7 +99,7 @@ class ModulesController(rest.RestController, RatingModulesMixin):
with lock:
module = self.extensions[module_id]
except KeyError:
pecan.abort(400, 'Module not found.')
pecan.abort(404, 'Module not found.')
infos = module.obj.module_info.copy()
infos['module_id'] = infos.pop('name')
return rating_models.CloudkittyModule(**infos)

View File

@ -62,7 +62,7 @@ class HashMapFieldsController(rating.RatingRestControllerBase):
field_db = hashmap.get_field(uuid=field_id)
return field_models.Field(**field_db.export_model())
except db_api.NoSuchField as e:
pecan.abort(400, six.text_type(e))
pecan.abort(404, six.text_type(e))
@wsme_pecan.wsexpose(field_models.Field,
body=field_models.Field,
@ -98,4 +98,4 @@ class HashMapFieldsController(rating.RatingRestControllerBase):
try:
hashmap.delete_field(uuid=field_id)
except db_api.NoSuchService as e:
pecan.abort(400, six.text_type(e))
pecan.abort(404, six.text_type(e))

View File

@ -97,7 +97,7 @@ class HashMapGroupsController(rating.RatingRestControllerBase):
group_db = hashmap.get_group(uuid=group_id)
return group_models.Group(**group_db.export_model())
except db_api.NoSuchGroup as e:
pecan.abort(400, six.text_type(e))
pecan.abort(404, six.text_type(e))
@wsme_pecan.wsexpose(group_models.Group,
body=group_models.Group,
@ -133,4 +133,4 @@ class HashMapGroupsController(rating.RatingRestControllerBase):
try:
hashmap.delete_group(uuid=group_id, recurse=recursive)
except db_api.NoSuchGroup as e:
pecan.abort(400, six.text_type(e))
pecan.abort(404, six.text_type(e))

View File

@ -93,7 +93,7 @@ class HashMapMappingsController(rating.RatingRestControllerBase):
return mapping_models.Mapping(
**mapping_db.export_model())
except db_api.NoSuchMapping as e:
pecan.abort(400, six.text_type(e))
pecan.abort(404, six.text_type(e))
@wsme_pecan.wsexpose(mapping_models.Mapping,
body=mapping_models.Mapping,
@ -144,7 +144,7 @@ class HashMapMappingsController(rating.RatingRestControllerBase):
except (db_api.NoSuchService,
db_api.NoSuchField,
db_api.NoSuchMapping) as e:
pecan.abort(400, six.text_type(e))
pecan.abort(404, six.text_type(e))
@wsme_pecan.wsexpose(None,
ck_types.UuidType(),
@ -160,4 +160,4 @@ class HashMapMappingsController(rating.RatingRestControllerBase):
except (db_api.NoSuchService,
db_api.NoSuchField,
db_api.NoSuchMapping) as e:
pecan.abort(400, six.text_type(e))
pecan.abort(404, six.text_type(e))

View File

@ -60,7 +60,7 @@ class HashMapServicesController(rating.RatingRestControllerBase):
service_db = hashmap.get_service(uuid=service_id)
return service_models.Service(**service_db.export_model())
except db_api.NoSuchService as e:
pecan.abort(400, six.text_type(e))
pecan.abort(404, six.text_type(e))
@wsme_pecan.wsexpose(service_models.Service,
body=service_models.Service,
@ -92,4 +92,4 @@ class HashMapServicesController(rating.RatingRestControllerBase):
try:
hashmap.delete_service(uuid=service_id)
except db_api.NoSuchService as e:
pecan.abort(400, six.text_type(e))
pecan.abort(404, six.text_type(e))

View File

@ -93,7 +93,7 @@ class HashMapThresholdsController(rating.RatingRestControllerBase):
return threshold_models.Threshold(
**threshold_db.export_model())
except db_api.NoSuchThreshold as e:
pecan.abort(400, six.text_type(e))
pecan.abort(404, six.text_type(e))
@wsme_pecan.wsexpose(threshold_models.Threshold,
body=threshold_models.Threshold,
@ -144,7 +144,7 @@ class HashMapThresholdsController(rating.RatingRestControllerBase):
except (db_api.NoSuchService,
db_api.NoSuchField,
db_api.NoSuchThreshold) as e:
pecan.abort(400, six.text_type(e))
pecan.abort(404, six.text_type(e))
@wsme_pecan.wsexpose(None,
ck_types.UuidType(),
@ -160,4 +160,4 @@ class HashMapThresholdsController(rating.RatingRestControllerBase):
except (db_api.NoSuchService,
db_api.NoSuchField,
db_api.NoSuchThreshold) as e:
pecan.abort(400, six.text_type(e))
pecan.abort(404, six.text_type(e))

View File

@ -73,7 +73,7 @@ class PyScriptsScriptsController(rating.RatingRestControllerBase):
script_db = pyscripts.get_script(uuid=script_id)
return script_models.Script(**script_db.export_model())
except db_api.NoSuchScript as e:
pecan.abort(400, six.text_type(e))
pecan.abort(404, six.text_type(e))
@wsme_pecan.wsexpose(script_models.Script,
body=script_models.Script,
@ -119,7 +119,7 @@ class PyScriptsScriptsController(rating.RatingRestControllerBase):
return script_models.Script(
**script_db.export_model())
except db_api.NoSuchScript as e:
pecan.abort(400, six.text_type(e))
pecan.abort(404, six.text_type(e))
@wsme_pecan.wsexpose(None, ck_types.UuidType(), status_code=204)
def delete(self, script_id):
@ -131,4 +131,4 @@ class PyScriptsScriptsController(rating.RatingRestControllerBase):
try:
pyscripts.delete_script(uuid=script_id)
except db_api.NoSuchScript as e:
pecan.abort(400, six.text_type(e))
pecan.abort(404, six.text_type(e))

View File

@ -41,7 +41,7 @@ tests:
- name: get information of a unknown module
url: /v1/billing/modules/fakb
status: 400
status: 404
response_strings:
- "Module not found."

View File

@ -55,14 +55,14 @@ tests:
- name: try to get an unknown mapping
url: /v1/collector/mappings/notfound
status: 400
status: 404
response_strings:
- "No mapping for service: notfound"
- name: try to delete an unknown mapping
url: /v1/collector/mappings/notfound
method: DELETE
status: 400
status: 404
response_strings:
- "No mapping for service: notfound"
@ -133,6 +133,6 @@ tests:
- name: check the mapping got deleted
url: /v1/collector/mappings/metric1
status: 400
status: 404
response_strings:
- "No mapping for service: metric1"

View File

@ -41,7 +41,7 @@ tests:
- name: get information of a unknown module
url: /v1/rating/modules/fakb
status: 400
status: 404
response_strings:
- "Module not found."

View File

@ -96,7 +96,7 @@ tests:
data:
name: "policy1"
data: "a = 1"
status: 400
status: 404
response_strings:
- "No such script: None (UUID: 42)"
@ -119,13 +119,13 @@ tests:
- name: get unknown script
url: /v1/rating/module_config/pyscripts/scripts/42
status: 400
status: 404
response_strings:
- "No such script: None (UUID: 42)"
- name: delete unknown script
url: /v1/rating/module_config/pyscripts/scripts/42
method: DELETE
status: 400
status: 404
response_strings:
- "No such script: None (UUID: 42)"