3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 from cmframework.apis import cmerror
17 class CMValidator(object):
19 self.plugin_client = None
21 # pylint: disable=no-self-use
22 def get_subscription_info(self):
23 """get the subscription filter
25 This API is used to get the re for matching the properties which the
26 validation plugin is concerned about.
30 A string representing the regular expression used to match the
31 properties which the validation plugin is concerned about.
35 CMError can be raised in-case of a failure.
37 raise cmerror.CMError('Not implemented')
39 # pylint: disable=no-self-use, unused-argument
40 def validate_set(self, props):
41 """validate a configuration data addition/update
45 props: A dictionary of name-value pairs representing the changed
50 CMError can be raised if the change is not accepted by this plugin.
52 raise cmerror.CMError('Not implemented')
54 # pylint: disable=no-self-use, unused-argument
55 def validate_delete(self, props):
56 """validate a configuration data delete
60 props: A list containing the names of deleted properties
64 CMError can raised if the delete is not accepted by this plugin.
66 raise cmerror.CMError('Not implemented')
68 def get_plugin_client(self):
69 """get the plugin client object
71 This API can be used by the plugin to get the client object which the
72 plugin can use to access the configuration data. Notice that the data
73 accessed by this is what is stored in the backend. The changed data
74 is passed as argument to the different validate functions.
78 The plugin client object
80 return self.plugin_client