placement/placement/errors.py
Eric Fried 328f7a3a36 Add query.duplicate_key and .bad_value in api-ref
This commit documents new error codes placement.query.duplicate_key and
placement.query.bad_value, which were were added via [1] but missed in
the summary table in the API reference [2].

Story: #2006194
Task: #35776

[1] I76cad83248920fa71da122711f1f763c4ebdb1ba
[2] https://developer.openstack.org/api-ref/placement/#errors

Change-Id: I024eaa38c6574f5847d585c83d527e3374031105
2019-07-09 10:32:45 +00:00

54 lines
2.4 KiB
Python

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Error code symbols to be used in structured JSON error responses.
These are strings to be used in the 'code' attribute, as described by
the API guideline on `errors`_.
There must be only one instance of any string value and it should have
only one associated constant SYMBOL.
In a WSGI handler (representing the sole handler for an HTTP method and
URI) each error condition should get a separate error code. Reusing an
error code in a different handler is not just acceptable, but useful.
For example 'placement.inventory.inuse' is meaningful and correct in both
``PUT /resource_providers/{uuid}/inventories`` and ``DELETE`` on the same
URI.
.. _errors: http://specs.openstack.org/openstack/api-wg/guidelines/errors.html
"""
# NOTE(cdent): This is the simplest thing that can possibly work, for now.
# If it turns out we want to automate this, or put different resources in
# different files, or otherwise change things, that's fine. The only thing
# that needs to be maintained as the same are the strings that API end
# users use. How they are created is completely fungible.
# Do not change the string values. Once set, they are set.
# Do not reuse string values. There should be only one symbol for any
# value.
# Don't forget to document new error codes in api-ref/source/errors.inc.
DEFAULT = 'placement.undefined_code'
INVENTORY_INUSE = 'placement.inventory.inuse'
CONCURRENT_UPDATE = 'placement.concurrent_update'
DUPLICATE_NAME = 'placement.duplicate_name'
PROVIDER_IN_USE = 'placement.resource_provider.inuse'
PROVIDER_CANNOT_DELETE_PARENT = (
'placement.resource_provider.cannot_delete_parent')
RESOURCE_PROVIDER_NOT_FOUND = 'placement.resource_provider.not_found'
ILLEGAL_DUPLICATE_QUERYPARAM = 'placement.query.duplicate_key'
# Failure of a post-schema value check
QUERYPARAM_BAD_VALUE = 'placement.query.bad_value'
QUERYPARAM_MISSING_VALUE = 'placement.query.missing_value'