From 86f2ff19a9c0eeb13a85a49cbfcc5f45aa4da505 Mon Sep 17 00:00:00 2001 From: Martin Skorupski Date: Tue, 10 Oct 2023 16:26:47 +0200 Subject: [PATCH] Create TOP Class - Top.py added to app model Issue-ID: OAM-357 Change-Id: Ie90dbedefd284f157e4e604252ef0d286318e902 Signed-off-by: Martin Skorupski --- code/network-generator/model/python/Top.py | 167 +++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 code/network-generator/model/python/Top.py diff --git a/code/network-generator/model/python/Top.py b/code/network-generator/model/python/Top.py new file mode 100644 index 0000000..365ee5c --- /dev/null +++ b/code/network-generator/model/python/Top.py @@ -0,0 +1,167 @@ +# Copyright 2023 highstreet technologies GmbH +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#!/usr/bin/python + +""" +An abstract Class for all classes +""" +import uuid +from abc import ABC, abstractmethod +from typing import Optional, Dict, Union +from model.python.TypeDefinitions import ( + AddressType, + AdministrativeState, + OperationalState, + UsageState, + Utilization, + LifeCycleState, + AlarmState, +) +from model.python.GeoLocation import GeoLocation + + +# Define the ITop interface +class ITop: + def __init__( + self, + id: str = None, + name: str = None, + administrativeState: AdministrativeState = None, + operationalState: OperationalState = None, + lifeCycleState: LifeCycleState = None, + alarmState: AlarmState = None, + usageState: UsageState = None, + utilization: Utilization = None, + ): + self.id = id + self.name = name + self.administrativeState = administrativeState + self.operationalState = operationalState + self.lifeCycleState = lifeCycleState + self.alarmState = alarmState + self.usageState = usageState + self.utilization = utilization + + +# Define the Top class +class Top(ITop): + def __init__(self, data=None): + self._id = data.id if data and data.id else str(uuid.uuid4()) + self._name = ( + data.name if data and data.name else " ".join(["Name", "of", self._id]) + ) + self._administrativeState = ( + data.administrativeState + if data and data.administrativeState + else AdministrativeState.LOCKED + ) + self._operationalState = ( + data.operationalState + if data and data.operationalState + else OperationalState.DISABLED + ) + self._lifeCycleState = ( + data.lifeCycleState + if data and data.lifeCycleState + else LifeCycleState.PLANNED + ) + self._alarmState = ( + data.alarmState if data and data.alarmState else 0 + ) + self._usageState = ( + data.usageState if data and data.usageState else UsageState.UNUSED + ) + self._utilization = ( + data.utilization if data and data.utilization else 0 + ) + + @property + def id(self): + return self._id + + @id.setter + def id(self, value): + self._id = value + + @property + def name(self): + return self._name + + @name.setter + def name(self, value): + self._name = value + + @property + def administrativeState(self): + return self._administrativeState + + @administrativeState.setter + def administrativeState(self, value): + self._administrativeState = value + + @property + def operationalState(self): + return self._operationalState + + @operationalState.setter + def operationalState(self, value): + self._operationalState = value + + @property + def lifeCycleState(self): + return self._lifeCycleState + + @lifeCycleState.setter + def lifeCycleState(self, value): + self._lifeCycleState = value + + @property + def alarmState(self): + return self._alarmState + + @alarmState.setter + def alarmState(self, value): + self._alarmState = value + + @property + def usageState(self): + return self._usageState + + @usageState.setter + def usageState(self, value): + self._usageState = value + + @property + def utilization(self): + return self._utilization + + @utilization.setter + def utilization(self, value): + self._utilization = value + + def json(self): + return { + "id": self.id, + "name": self.name, + "administrativeState": self.administrativeState.value, + "operationalState": self.operationalState.value, + "lifeCycleState": self.lifeCycleState.value, + "alarmState": self.alarmState, + "usageState": self.usageState.value, + "utilization": self.utilization, + } + + def __str__(self): + return str(self.json()) -- 2.16.6