Initial commit
[ta/config-manager.git] / cmframework / src / cmframework / apis / cmvalidator.py
1 # Copyright 2019 Nokia
2
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
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
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
15
16
17 class CMValidator(object):
18     def __init__(self):
19         self.plugin_client = None
20
21     # pylint: disable=no-self-use
22     def get_subscription_info(self):
23         """get the subscription filter
24
25            This API is used to get the re for matching the properties which the
26            validation plugin is concerned about.
27
28            Return:
29
30            A string representing the regular expression used to match the
31            properties which the validation plugin is concerned about.
32
33            Raise:
34
35            CMError can be raised in-case of a failure.
36         """
37         raise cmerror.CMError('Not implemented')
38
39     # pylint: disable=no-self-use, unused-argument
40     def validate_set(self, props):
41         """validate a configuration data addition/update
42
43            Arguments:
44
45            props: A dictionary of name-value pairs representing the changed
46            properties.
47
48            Raise:
49
50            CMError can be raised if the change is not accepted by this plugin.
51         """
52         raise cmerror.CMError('Not implemented')
53
54     # pylint: disable=no-self-use, unused-argument
55     def validate_delete(self, props):
56         """validate a configuration data delete
57
58            Arguments:
59
60            props: A list containing the names of deleted properties
61
62            Raise:
63
64            CMError can raised if the delete is not accepted by this plugin.
65         """
66         raise cmerror.CMError('Not implemented')
67
68     def get_plugin_client(self):
69         """get the plugin client object
70
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.
75
76            Return:
77
78            The plugin client object
79         """
80         return self.plugin_client