1 # Copyright 2023 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.
18 An abstract Class for all classes
20 from abc import ABC, abstractmethod
21 from typing import Any, TypedDict, cast
23 from network_generation.model.python.type_definitions import (
33 # Define the ITop interface
34 class ITop(TypedDict):
37 administrativeState: AdministrativeState
38 operationalState: OperationalState
39 lifeCycleState: LifeCycleState
40 alarmState: AlarmState
41 usageState: UsageState
42 utilization: Utilization
45 # define default value
46 default_value: ITop = {
47 "id": "be5229af-2660-4bae-8f2c-b9d0f788fad1",
49 "administrativeState": AdministrativeState.LOCKED,
50 "operationalState": OperationalState.DISABLED,
51 "lifeCycleState": LifeCycleState.PLANNED,
53 "usageState": UsageState.UNUSED,
58 # Define the Top class
61 def default() -> dict[str, Any]:
62 return cast(dict[str, Any], default_value)
65 self, data: dict[str, Any] = cast(dict[str, Any], default_value)
68 itop: ITop = self._to_itop_data(data)
69 self._id: str = itop["id"]
70 self._name: str = itop["name"]
71 self._administrativeState: AdministrativeState = itop[
74 self._operationalState: OperationalState = itop["operationalState"]
75 self._lifeCycleState: LifeCycleState = itop["lifeCycleState"]
76 self._alarmState: AlarmState = itop["alarmState"]
77 self._usageState: UsageState = itop["usageState"]
78 self._utilization: Utilization = itop["utilization"]
80 def _to_itop_data(self, data: dict[str, Any]) -> ITop:
81 result: ITop = default_value
82 for key, key_type in ITop.__annotations__.items():
84 result[key] = data[key] # type: ignore
92 def id(self, value: str) -> None:
96 def name(self) -> str:
100 def name(self, value: str) -> None:
104 def administrativeState(self) -> AdministrativeState:
105 return self._administrativeState
107 @administrativeState.setter
108 def administrativeState(self, value: AdministrativeState) -> None:
109 self._administrativeState = value
112 def operationalState(self) -> OperationalState:
113 return self._operationalState
115 @operationalState.setter
116 def operationalState(self, value: OperationalState) -> None:
117 self._operationalState = value
120 def lifeCycleState(self) -> LifeCycleState:
121 return self._lifeCycleState
123 @lifeCycleState.setter
124 def lifeCycleState(self, value: LifeCycleState) -> None:
125 self._lifeCycleState = value
128 def alarmState(self) -> AlarmState:
129 return self._alarmState
132 def alarmState(self, value: AlarmState) -> None:
133 self._alarmState = value
136 def usageState(self) -> UsageState:
137 return self._usageState
140 def usageState(self, value: UsageState) -> None:
141 self._usageState = value
144 def utilization(self) -> Utilization:
145 return self._utilization
148 def utilization(self, value: Utilization) -> None:
149 self._utilization = value
152 def json(self) -> dict[str, Any]:
156 "administrativeState": self.administrativeState,
157 "operationalState": self.operationalState,
158 "lifeCycleState": self.lifeCycleState,
159 "alarmState": self.alarmState,
160 "usageState": self.usageState,
161 "utilization": self.utilization,
164 def __str__(self) -> str:
165 return str(self.json())