From f69833637cce759840d52dc7d0bbf206e52b91e3 Mon Sep 17 00:00:00 2001 From: "s.m" Date: Fri, 20 Mar 2020 13:48:24 -0400 Subject: [PATCH] Added working delete function for photos (#159) Co-authored-by: sebastian messier --- pyicloud/services/photos.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pyicloud/services/photos.py b/pyicloud/services/photos.py index 8d329c6..d19f87e 100644 --- a/pyicloud/services/photos.py +++ b/pyicloud/services/photos.py @@ -505,6 +505,35 @@ class PhotoAsset(object): **kwargs ) + def delete(self): + recordName = self._asset_record['recordName'] + recordType = self._asset_record['recordType'] + recordChangeTag = self._master_record['recordChangeTag'] + json_data = ('{"query":{"recordType":"CheckIndexingState"},' + '"zoneID":{"zoneName":"PrimarySync"}}') + + json_data = ('{"operations":[{' + '"operationType":"update",' + '"record":{' + '"recordName":"%s","recordType":"%s",' + '"recordChangeTag":"%s",' + '"fields":{"isDeleted":{"value":1}' + '}}}],' + '"zoneID":{' + '"zoneName":"PrimarySync"' + '},"atomic":true}' + % (recordName, recordType, recordChangeTag)) + + endpoint = self._service._service_endpoint + params = urlencode(self._service.params) + url = ('%s/records/modify?%s' % (endpoint, params)) + + return self._service.session.post( + url, + data=json_data, + headers={'Content-type': 'text/plain'} + ) + def __repr__(self): return "<%s: id=%s>" % ( type(self).__name__,