1 # Copyright (c) 2023 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 """A module implementing the processing of a trigger.
17 from json import loads, JSONDecodeError
23 def __init__(self, trigger) -> None:
26 self._id = trigger[0]["prop_id"].split(".")
27 self._param = self._id[1]
29 self._id = loads(self._id[0])
30 except (JSONDecodeError, TypeError):
32 self._id = {"type": self._id[0], "index": None}
33 self._val = trigger[0]["value"]
35 def __str__(self) -> str:
39 f" Type: {self._id['type']}\n"
40 f" Index: {self._id['index']}\n"
41 f" Parameter: {self._param}\n"
42 f" Value: {self._val}\n"
50 def type(self) -> str:
51 return self._id["type"]
55 return self._id["index"]
58 def parameter(self) -> str:
62 def value(self) -> any: