|
@@ -3,7 +3,8 @@ import requests
|
|
|
import logging
|
|
|
from xml.etree import ElementTree
|
|
|
from requests_oauthlib import OAuth1
|
|
|
-from .models import (Object, Ingest, Investigation, User, AccessPoint)
|
|
|
+from .models import (Object, Download, Ingest, Investigation, User,
|
|
|
+ AccessPoint)
|
|
|
from .exceptions import (Timeout, PermissionError, NotFoundError,
|
|
|
ArbitraryError, InvalidInput)
|
|
|
|
|
@@ -60,19 +61,29 @@ class Client(object):
|
|
|
def get_objects(self, limit=None):
|
|
|
return [Object(self, oid) for oid in self.get_object_ids(limit)]
|
|
|
|
|
|
- def create_object(self, investigation_id, uploader_id, label=None, note=None):
|
|
|
+ def create_object(self, investigation_id, uploader, label=None, note=None):
|
|
|
url = self.url('basemetadata/investigations', investigation_id, 'digitalObjects')
|
|
|
- return Object(self.post(url, label=label, uploaderId=uploader_id, note=note))
|
|
|
+ return Object(self.post(url, label=label, uploaderId=uploader.id, note=note))
|
|
|
|
|
|
- def delete_object(self, object_id):
|
|
|
- self.delete(self.url('basemetadata/digitalObjects', object_id))
|
|
|
+ def delete_object(self, obj):
|
|
|
+ self.delete(self.url('basemetadata/digitalObjects', obj.id))
|
|
|
|
|
|
- def create_ingest(self, object_id, accesspoint_uuid):
|
|
|
+ def get_download_ids(self, limit=None):
|
|
|
+ return self.get_collection('staging/downloads', 'id', limit)
|
|
|
+
|
|
|
+ def get_downloads(self, limit=None):
|
|
|
+ return [Download(self, oid) for oid in self.get_download_ids(limit)]
|
|
|
+
|
|
|
+ def create_download(self, obj, accesspoint):
|
|
|
+ url = self.url('staging/downloads')
|
|
|
+ return Download(self.post(url, objectId=obj.id, accessPoint=accesspoint.uuid))
|
|
|
+
|
|
|
+ def create_ingest(self, obj, accesspoint):
|
|
|
url = self.url('staging/ingests')
|
|
|
- return Ingest(self.post(url, objectId=object_id, accessPoint=accesspoint_uuid))
|
|
|
+ return Ingest(self.post(url, objectId=obj.uuid, accessPoint=accesspoint.uuid))
|
|
|
|
|
|
- def delete_ingest(self, ingest_id):
|
|
|
- self.delete(self.url('staging/ingests', ingest_id))
|
|
|
+ def delete_ingest(self, ingest):
|
|
|
+ self.delete(self.url('staging/ingests', ingest.id))
|
|
|
|
|
|
def get_accesspoint_ids(self):
|
|
|
return self.get_collection('staging/accesspoints', 'id')
|