Skip to content
Snippets Groups Projects
OpticalConfig.py 1.4 KiB
Newer Older

from common.method_wrappers.ServiceExceptions import InvalidArgumentsException
from ._Builder import get_uuid_from_string, get_uuid_random
from common.proto.context_pb2 import DeviceId
def channel_get_uuid(
    channel_name :str , allow_random : bool = False
) -> str:
    

    if len(channel_name) > 0:
        return get_uuid_from_string(channel_name)
    if allow_random: return get_uuid_random()

    raise InvalidArgumentsException([
        ('channel uuid', channel_name),
       
    ], extra_details=['Channel name is required to produce a channel UUID'])
Mohammad Ismaeel's avatar
Mohammad Ismaeel committed
def transponder_get_uuid(
    opticalconfig_id :str , allow_random : bool = False
) -> str:
    

    if opticalconfig_id is not None:
        return get_uuid_from_string(f"{opticalconfig_id}-transponder")
    if allow_random: return get_uuid_random()

    raise InvalidArgumentsException([
        ('transponder uuid', opticalconfig_id),
       
    ], extra_details=['Channel name is required to produce a channel UUID'])
    

def opticalconfig_get_uuid ( device_id: DeviceId, allow_random : bool = False) -> str : 
    device_uuid = device_id.device_uuid.uuid
    if (len(device_uuid)>0):
        return get_uuid_from_string(f"{device_uuid}_opticalconfig")
    if allow_random: return get_uuid_random()
    raise InvalidArgumentsException([
        ('DeviceId ', device_id),
       
    ], extra_details=['device_id is required to produce a OpticalConfig UUID'])