Skip to content

Commit f7fa8a1

Browse files
committed
added indexd query using URLs
1 parent fb4c6b0 commit f7fa8a1

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

expansion/expansion.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,9 +1364,21 @@ def get_record_for_url(self, url, api):
13641364
indexd_endpoint = "{}/index/index/".format(api)
13651365
indexd_query = "{}?url={}".format(indexd_endpoint,url)
13661366
output = requests.get(indexd_query, auth=self._auth_provider).text
1367-
index_record = json.loads(output)
1368-
guid = index_record['did'][0]
1369-
return index_record
1367+
response = json.loads(output)
1368+
index_records = response['records']
1369+
return index_records
1370+
1371+
def get_guid_for_url(self, url, api):
1372+
"""Return the GUID for a file's URL in indexd"""
1373+
index_records = self.get_record_for_url(url=url,api=api)
1374+
if len(index_records) == 1:
1375+
guid = index_records[0]['did']
1376+
return guid
1377+
else:
1378+
guids = []
1379+
for index_record in index_records:
1380+
guids.append(index_record['did'])
1381+
return guids
13701382

13711383
def delete_uploaded_files(self, guids):
13721384
"""

0 commit comments

Comments
 (0)