|
@@ -66,6 +66,13 @@ class Ingest(object):
|
|
|
self.staging_url = node.text
|
|
|
|
|
|
|
|
|
+class AccessPoint(object):
|
|
|
+ def __init__(self, root):
|
|
|
+ entities = {e.tag: e.text for e in root.findall('./entities/entity/*')}
|
|
|
+ self.url = entities['remoteBaseUrl']
|
|
|
+ self.identifier = entities['uniqueIdentifier']
|
|
|
+
|
|
|
+
|
|
|
class Client(object):
|
|
|
def __init__(self, base_url=BASE_URL, key=KEY, secret=SECRET,
|
|
|
token=TOKEN, token_secret=TOKEN_SECRET):
|
|
@@ -77,8 +84,7 @@ class Client(object):
|
|
|
return '/'.join([self.base_url] + [str(arg) for arg in args])
|
|
|
|
|
|
def get_user_credentials(self, ldap_id):
|
|
|
- root = self.get_response(self.url('information/properties'), userId=ldap_id)
|
|
|
- return Credentials(root)
|
|
|
+ return Credentials(self.get_response(self.url('information/properties'), userId=ldap_id))
|
|
|
|
|
|
def get_download_ids(self, limit=None):
|
|
|
return self.get_collection('staging/downloads', 'id', limit)
|
|
@@ -101,10 +107,19 @@ class Client(object):
|
|
|
def get_organization(self, oid):
|
|
|
return Organization(self.get_response(self.url('dataorganization/organization', oid)))
|
|
|
|
|
|
+ def get_accesspoint_ids(self):
|
|
|
+ return self.get_collection('staging/accesspoints', 'id')
|
|
|
+
|
|
|
+ def get_accesspoint(self, oid):
|
|
|
+ return AccessPoint(self.get_response(self.url('staging/accesspoints', oid)))
|
|
|
+
|
|
|
+ def get_accesspoints(self):
|
|
|
+ return [self.get_accesspoint(oid) for oid in self.get_accesspoint_ids()]
|
|
|
+
|
|
|
def get_collection(self, url, id_name, limit=None):
|
|
|
params = {'results': limit} if limit else {}
|
|
|
root = self.get_response(self.url(url), **params)
|
|
|
- return (int(e.text) for e in root.findall('./entities/entity/{}'.format(id_name)))
|
|
|
+ return [int(e.text) for e in root.findall('./entities/entity/{}'.format(id_name))]
|
|
|
|
|
|
def get_response(self, url, **params):
|
|
|
self.log.debug("Accessing {}".format(url))
|