Commit d978fa0f authored by Pauline Gaudet-Chardonnet's avatar Pauline Gaudet-Chardonnet
Browse files

auth_level endpoint parameter handles sub authorities in sfa reg

parent 54b509d4
......@@ -3,3 +3,4 @@ dist
*.egg-info
*.pyc
.idea
.DS_Store
......@@ -77,14 +77,13 @@ class SfaReg(SfaApi):
filtered_entites = []
for record in result:
# TODO: handle no sub-authorities
if entity == 'project':
if record['type'] == 'authority' and len(record['hrn'].split('.'))>2:
if record['type'] == 'authority' and len(record['hrn'].split('.'))>self.endpoint.auth_level:
filtered_entites.append(record)
# TODO: handle no sub-authorities
elif entity == 'authority':
if len(record['hrn'].split('.')) <3:
if len(record['hrn'].split('.')) <= self.endpoint.auth_level:
filtered_entites.append(record)
elif record['type'] == entity:
......@@ -184,8 +183,8 @@ class SfaReg(SfaApi):
for d in data:
if d.get('classtype')=='authority':
a = d.get('hrn')
# TODO: handle no sub-authorities
if a is None or len(a.split('.')) < 3:
if a is None or len(a.split('.')) <= self.endpoint.auth_level:
if d.get('hrn') in l_authorities.keys():
l_authorities[d.get('hrn')].update(d)
else:
......@@ -247,13 +246,13 @@ class SfaReg(SfaApi):
o = d.get('hrn')
a = d.get('authority')
if d.get('classtype')=='authority':
# TODO: handle no sub-authorities
if o is not None and len(o.split('.')) > 2:
if o is not None and len(o.split('.')) > self.endpoint.auth_level:
if d.get('hrn') in l_projects.keys():
l_projects[d.get('hrn')].update(d)
else:
l_projects[d.get('hrn')] = d
elif a is not None and len(a.split('.')) > 2:
elif a is not None and len(a.split('.')) > self.endpoint.auth_level:
if d.get('classtype') in l_projects[d.get('authority')]:
l_projects[d.get('authority')][d.get('classtype')].append(d.get('reg-urn'))
else:
......
......@@ -13,12 +13,12 @@ class Endpoint(object):
"""
def __init__(self, type="AM", protocol="SFA", version=None, url=None, name=None, timeout=None, technologies=None, hasLeases=False, ):
def __init__(self, type="AM", protocol="SFA", version=None, url=None, name=None, timeout=None, technologies=None, hasLeases=False, auth_level=1):
self.name = name
self.type = type
self.protocol = protocol
self.hasLeases = hasLeases
self.auth_level = auth_level
self.version = version
if technologies:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment