Add a new microversion for data model API

microversion 1.3 for list data model API

Change-Id: Ibf8774a48c3d13ca9762bd5319f5e1ce2ed82b2f
Closes-Bug: #1854121
This commit is contained in:
licanwei
2019-11-29 11:52:42 +08:00
parent 42fea1c568
commit 6f43f2b003
7 changed files with 59 additions and 11 deletions

View File

@@ -30,3 +30,7 @@ audits.
---
Added ``force`` into create audit request. If ``force`` is true,
audit will be executed despite of ongoing actionplan.
1.3
---
Added list data model API.

View File

@@ -40,6 +40,7 @@ from watcher.api.controllers.v1 import goal
from watcher.api.controllers.v1 import scoring_engine
from watcher.api.controllers.v1 import service
from watcher.api.controllers.v1 import strategy
from watcher.api.controllers.v1 import utils
from watcher.api.controllers.v1 import versions
@@ -163,13 +164,14 @@ class V1(APIBase):
'audits', '',
bookmark=True)
]
v1.data_model = [link.Link.make_link('self', base_url,
'data_model', ''),
link.Link.make_link('bookmark',
base_url,
'data_model', '',
bookmark=True)
]
if utils.allow_list_datamodel():
v1.data_model = [link.Link.make_link('self', base_url,
'data_model', ''),
link.Link.make_link('bookmark',
base_url,
'data_model', '',
bookmark=True)
]
v1.actions = [link.Link.make_link('self', base_url,
'actions', ''),
link.Link.make_link('bookmark',

View File

@@ -24,6 +24,7 @@ from wsme import types as wtypes
import wsmeext.pecan as wsme_pecan
from watcher.api.controllers.v1 import types
from watcher.api.controllers.v1 import utils
from watcher.common import exception
from watcher.common import policy
from watcher.decision_engine import rpcapi
@@ -49,6 +50,8 @@ class DataModelController(rest.RestController):
:param audit_uuid: The UUID of the audit, used to filter data model
by the scope in audit.
"""
if not utils.allow_list_datamodel():
raise exception.NotAcceptable
if self.from_data_model:
raise exception.OperationNotPermitted
allowed_data_model_type = [

View File

@@ -176,3 +176,12 @@ def allow_force():
"""
return pecan.request.version.minor >= (
versions.VERSIONS.MINOR_2_FORCE.value)
def allow_list_datamodel():
"""Check if we should support list data model API.
Version 1.3 of the API added support to list data model.
"""
return pecan.request.version.minor >= (
versions.VERSIONS.MINOR_3_DATAMODEL.value)

View File

@@ -21,7 +21,8 @@ class VERSIONS(enum.Enum):
MINOR_0_ROCKY = 0 # v1.0: corresponds to Rocky API
MINOR_1_START_END_TIMING = 1 # v1.1: Add start/end timei for audit
MINOR_2_FORCE = 2 # v1.2: Add force field to audit
MINOR_MAX_VERSION = 2
MINOR_3_DATAMODEL = 3 # v1.3: Add list datamodel API
MINOR_MAX_VERSION = 3
# This is the version 1 API
BASE_VERSION = 1