1 # Copyright 2022 highstreet technologies GmbH
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.
17 Module for the TAPI Topology Context
19 from typing import Dict, List, Union
20 from lxml import etree
21 from model.python.tapi_topology import TapiTopology
22 from model.python.top import Top
25 class TapiTopologyContext(Top):
27 Class providing a TAPI Topology Context object
30 __data: Dict[str, Dict[str, List]] = {
31 "tapi-topology:topology-context": {
33 __tapi_topology: List[TapiTopology] = []
36 def __init__(self, configuration: Dict[str, Union[str, Dict[str, int]]]):
37 super().__init__(configuration)
38 topology = TapiTopology(configuration)
39 self.__tapi_topology.append(topology)
42 def configuration(self) -> dict:
44 Getter for a json object representing the TAPI Topology Context initail
46 :return TAPI Topology Context configuration as json object.
48 return self.__configuration
50 def data(self) -> dict:
52 Getter for a json object representing the TAPI Topology Context.
53 :return TAPI Topology Context as json object.
57 def name(self) -> str:
59 Getter returning the container name.
62 return "tapi-topology:topology-context"
64 def identifier(self) -> str:
66 Getter returning the container name which acts as identifier
71 def json(self) -> dict:
73 Getter for a json object representing the TAPI Topology Context.
74 :return TAPI Topology Context as json object.
76 result = self.__data.copy()
77 for topology in self.__tapi_topology:
78 result["tapi-topology:topology-context"]["topology"].append(
82 def svg(self, x, y) -> etree.Element:
84 Getter for a xml Element object representing the TAPI Topology Context.
85 :return TAPI Topology Context as svg object.
87 group = etree.Element("g")
88 title = etree.Element("title")
89 title.text = "\n context: " + self.identifier() + "\n name: " + self.name()
92 for topology in self.__tapi_topology:
93 group.append(topology.svg(x, y))