-def portmapping_request(node: str, mapping: str):
- url = {'rfc8040': '{}/data/transportpce-portmapping:network/nodes={}/mapping={}',
- 'draft-bierman02': '{}/config/transportpce-portmapping:network/nodes/{}/mapping/{}'}
- response = get_request(url[RESTCONF_VERSION].format('{}', node, mapping))
- res = response.json()
- return_key = {'rfc8040': 'transportpce-portmapping:mapping',
- 'draft-bierman02': 'mapping'}
- mapping = res[return_key[RESTCONF_VERSION]]
- return {'status_code': response.status_code,
- 'mapping': mapping}
-
-
-def portmapping_switching_pool_request(node: str, switching_pool: str):
- url = {'rfc8040': '{}/data/transportpce-portmapping:network/nodes={}/switching-pool-lcp={}',
- 'draft-bierman02': '{}/config/transportpce-portmapping:network/nodes/{}/switching-pool-lcp/{}'}
- response = get_request(url[RESTCONF_VERSION].format('{}', node, switching_pool))
- res = response.json()
- return_key = {'rfc8040': 'transportpce-portmapping:switching-pool-lcp',
- 'draft-bierman02': 'switching-pool-lcp'}
- switching_pool = res[return_key[RESTCONF_VERSION]]
- return {'status_code': response.status_code,
- 'switching_pool': switching_pool}
-
-
-def portmapping_mc_capa_request(node: str, mc_capa: str):
- url = {'rfc8040': '{}/data/transportpce-portmapping:network/nodes={}/mc-capabilities={}',
- 'draft-bierman02': '{}/config/transportpce-portmapping:network/nodes/{}/mc-capabilities/{}'}
- response = get_request(url[RESTCONF_VERSION].format('{}', node, mc_capa))
+def get_portmapping_node_attr(node: str, attr: str, value: str):
+ # pylint: disable=consider-using-f-string
+ url = {'rfc8040': '{}/data/transportpce-portmapping:network/nodes={}',
+ 'draft-bierman02': '{}/config/transportpce-portmapping:network/nodes/{}'}
+ target_url = url[RESTCONF_VERSION].format('{}', node)
+ if attr is not None:
+ target_url = (target_url + '/{}').format('{}', attr)
+ if value is not None:
+ suffix = {'rfc8040': '={}', 'draft-bierman02': '/{}'}
+ target_url = (target_url + suffix[RESTCONF_VERSION]).format('{}', value)
+ else:
+ attr = 'nodes'
+ response = get_request(target_url)