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 typing import Any
19 from json import loads, JSONDecodeError
25 def __init__(self, trigger) -> None:
28 self._id = trigger[0]["prop_id"].split(".")
29 self._param = self._id[1]
31 self._id = loads(self._id[0])
32 except (JSONDecodeError, TypeError):
34 self._id = {"type": self._id[0], "index": None}
35 self._val = trigger[0]["value"]
37 def __str__(self) -> str:
41 f" Type: {self._id['type']}\n"
42 f" Index: {self._id['index']}\n"
43 f" Parameter: {self._param}\n"
44 f" Value: {self._val}\n"
52 def type(self) -> str:
53 return self._id["type"]
57 return self._id["index"]
60 def parameter(self) -> str:
64 def value(self) -> Any: