diff --git a/api/patch_request.py b/api/patch_request.py index a149f1db52bbe2efeceabb804d6c4af7cba00305..a6281d0fc6830a9ef72dcd191725c5815df80f77 100644 --- a/api/patch_request.py +++ b/api/patch_request.py @@ -39,103 +39,25 @@ async def get_available_sites(token: APIToken = Depends(check_auth), conn=Depend @router.get('/insert_types') async def get_insert_types(token: APIToken = Depends(check_auth), conn=Depends(get_conn)) -> list[InsertType]: Mgr.check_token(conn, token) - ta = [ - { - 'name': 'ndcfg.module_type.list', - 'idx': 'tmp_module_type_list', - 'old': { - 'filter_params_dict': { - 'attrs_list': None, - 'show': True - } - } - }, - { - 'name': 'cntl.ot_attr_val.list', - 'idx': 'ot_attr_val_list', - 'inner_join_ref': { - 'tmp_module_type_list': None - }, - 'old': { - 'ot_attr_def_key_word': 'prq_insert_is_exchangeable', - 'value': True, - 'value_operator': 'eq', - 'filter_params_dict': { - 'attrs_list': None, - 'show': True - } - } - }, - { - 'name': 'ndcfg.module_type.list', - 'idx': 'module_type_list', - 'inner_join_ref': { - 'tmp_module_type_list': 'self', - 'ot_attr_val_list': None - }, - 'old': { - 'sorting_params_list': ['name ASC'], - } - }, - { - 'name': 'ndcfg.p_port2module_type.list', - 'idx': 'pp2mt_list', - 'inner_join_ref': { - 'module_type_list': 'default' - }, - } - ] - - result = execute_wapi_function(conn, ta, dry_mode=True, superuser=True) - - module_types: dict[str, InsertType] = {} - - for api_type in result['module_type_list']: - module_types[api_type['name']] = InsertType(name=api_type['name']) - - for api_port in result['pp2mt_list']: - if api_port['port_type'].lower().startswith('festkabel'): - continue - tmp_ports = [api_port] - - cmp_ports: list[dict] = [] - for tmp_port in tmp_ports: - if not tmp_port['port_name_suffix'].startswith('{'): - cmp_ports.append(tmp_port) - continue - suffix_list = list(tmp_port['port_name_suffix'].replace('{', '').replace('}', '')) - tmp_port['port_count'] -= (len(suffix_list) - 1) if len(suffix_list) > 0 else 0 - for i in suffix_list if len(suffix_list) > 0 else ['']: - cmp_ports.append({ - **tmp_port, - 'port_name_suffix': '::' + i - }) - tmp_ports = cmp_ports - - cmp_ports: list[dict] = [] - for tmp_port in tmp_ports: - if not tmp_port['port_name_prefix'].startswith('{'): - cmp_ports.append(tmp_port) - continue - prefix_list = list(tmp_port['port_name_prefix'].replace('{', '').replace('}', '')) - tmp_port['port_count'] -= (len(prefix_list) - 1) if len(prefix_list) > 0 else 0 - for i in prefix_list if len(prefix_list) > 0 else ['']: - cmp_ports.append({ - **tmp_port, - 'port_name_prefix': i + '::' - }) - tmp_ports = cmp_ports - - for p in tmp_ports: - module_types[p['module_type']].ports.append( - InsertPort(type=p['port_type'], - type_group=p['port_type_group'], - count=p['port_count'], - proto=p['port_proto'], - name_prefix=p['port_name_prefix'], - name_suffix=p['port_name_suffix'] - ) - ) + + module_types: dict[str, InsertType] = { + '1xETH (Gbit)': InsertType(name='1xETH (Gbit)', ports=[ + InsertPort(type='ETH', type_group='ETH', count=1, proto='Ethernet', name_prefix='', name_suffix='::1'), + ]), + '2xETH (100 Mbit)': InsertType(name='2xETH (100 Mbit)', ports=[ + InsertPort(type='ETH', type_group='ETH', count=1, proto='Ethernet', name_prefix='', name_suffix='/1'), + InsertPort(type='ETH', type_group='ETH', count=1, proto='Ethernet', name_prefix='', name_suffix='/2'), + ]), + '1xETH (100 Mbit) + 1xTEL': InsertType(name='1xETH (100 Mbit) + 1xTEL', ports=[ + InsertPort(type='ETH', type_group='ETH', count=1, proto='Ethernet', name_prefix='', name_suffix='/1'), + InsertPort(type='TEL', type_group='TEL', count=1, proto='ISDN', name_prefix='', name_suffix='/A'), + ]), + '1xETH (100 Mbit) + 2xTEL': InsertType(name='1xETH (100 Mbit) + 2xTEL', ports=[ + InsertPort(type='ETH', type_group='ETH', count=1, proto='Ethernet', name_prefix='', name_suffix='/1'), + InsertPort(type='TEL', type_group='TEL', count=1, proto='ISDN', name_prefix='', name_suffix='/A'), + InsertPort(type='TEL', type_group='TEL', count=1, proto='ISDN', name_prefix='', name_suffix='/B'), + ]) + } return list(module_types.values())