DECKHAND-80: Validations API Implementation

The Validations API has been introduced to Deckhand, allowing users
to register new validation results in Deckhand, as well as query
the API for validation results for a revision. The validation results
include a list of errors that occurred during document validation.

All functional tests related to the API are now passing.

The following endpoints have been implemented:

   * /api/v1.0/revisions/{revision_id}/validations
   * /api/v1.0/revisions/{revision_id}/validations/{validation_name}
   * /api/v1.0/revisions/{revision_id}/validations/{validation_name}/entries
   * /api/v1.0/revisions/{revision_id}/validations/{validation_name}/entries/{entry_id}

Some back-end refactoring was needed to implement this API. In
particular:

  - Added a new Validation sqlalchemy DB model
  - Introduced DataSchema handling to the engine.document_validation
    module so that registered schema validations can be used
  - Changed the way the result of the 'deckhand-schema-validation' internal
    validation is generated: it is now the amalgamation of all the
    internal and registered schema validations executed
  - Introduced rawquery generation so that raw SQL queries can be used to
    get results from DB

Fixed following bug:

  - UniqueConstraint is now used to correctly generate unique constraints
    for sqlalchemy models that are supposed to be combinations of columns

Change-Id: I53c79a6544f44ef8beab2600ddc8a3ea91ada903
This commit is contained in:
Felipe Monteiro
2017-10-17 00:14:34 +01:00
parent 46803b7e60
commit 8aec0390f8
31 changed files with 1458 additions and 241 deletions

View File

@@ -0,0 +1,63 @@
# Copyright 2017 AT&T Intellectual Property. All other rights reserved.
#
# 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.
from oslo_policy import policy
from deckhand.policies import base
validation_policies = [
policy.DocumentedRuleDefault(
base.POLICY_ROOT % 'create_validation',
base.RULE_ADMIN_API,
"Add the results of a validation for a particular revision.",
[
{
'method': 'POST',
'path': '/api/v1.0/revisions/{revision_id}/validations'
}
]),
policy.DocumentedRuleDefault(
base.POLICY_ROOT % 'list_validations',
base.RULE_ADMIN_API,
""""List all validations that have been reported for a revision. Also
lists the validation entries for a particular validation.""",
[
{
'method': 'GET',
'path': '/api/v1.0/revisions/{revision_id}/validations'
},
{
'method': 'GET',
'path': '/api/v1.0/revisions/{revision_id}/validations/'
'{validation_name}'
}
]),
policy.DocumentedRuleDefault(
base.POLICY_ROOT % 'show_validation',
base.RULE_ADMIN_API,
"""Gets the full details of a particular validation entry, including
all posted error details.""",
[
{
'method': 'GET',
'path': '/api/v1.0/revisions/{revision_id}/validations/'
'{validation_name}/entries/{entry_id}'
}
]),
]
def list_rules():
return validation_policies