mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-05 05:11:35 +00:00
Added ability to transfer data for multiple application (drive, calendar, Google+) in a single API request (#826)
This commit is contained in:
26
src/gam.py
26
src/gam.py
@@ -2119,22 +2119,38 @@ def convertUserIDtoEmail(uid):
|
|||||||
def doCreateDataTransfer():
|
def doCreateDataTransfer():
|
||||||
dt = buildGAPIObject(u'datatransfer')
|
dt = buildGAPIObject(u'datatransfer')
|
||||||
body = {}
|
body = {}
|
||||||
|
|
||||||
old_owner = sys.argv[3]
|
old_owner = sys.argv[3]
|
||||||
body[u'oldOwnerUserId'] = convertToUserID(old_owner)
|
body[u'oldOwnerUserId'] = convertToUserID(old_owner)
|
||||||
serviceName, serviceID = app2appID(dt, sys.argv[4])
|
|
||||||
|
apps = sys.argv[4].split(",")
|
||||||
|
appNameList=[]
|
||||||
|
appIDList = []
|
||||||
|
i = 0
|
||||||
|
while i < len(apps):
|
||||||
|
serviceName, serviceID = app2appID(dt, apps[i])
|
||||||
|
appNameList.append(serviceName)
|
||||||
|
appIDList.append({u'applicationId': serviceID})
|
||||||
|
i += 1
|
||||||
|
body[u'applicationDataTransfers'] = (appIDList)
|
||||||
new_owner = sys.argv[5]
|
new_owner = sys.argv[5]
|
||||||
body[u'newOwnerUserId'] = convertToUserID(new_owner)
|
body[u'newOwnerUserId'] = convertToUserID(new_owner)
|
||||||
|
|
||||||
|
|
||||||
parameters = {}
|
parameters = {}
|
||||||
i = 6
|
i = 6
|
||||||
while i < len(sys.argv):
|
while i < len(sys.argv):
|
||||||
parameters[sys.argv[i].upper()] = sys.argv[i+1].upper().split(u',')
|
parameters[sys.argv[i].upper()] = sys.argv[i+1].upper().split(u',')
|
||||||
i += 2
|
i += 2
|
||||||
body[u'applicationDataTransfers'] = [{u'applicationId': serviceID}]
|
|
||||||
|
i = 0
|
||||||
for key, value in parameters.items():
|
for key, value in parameters.items():
|
||||||
body[u'applicationDataTransfers'][0].setdefault(u'applicationTransferParams', [])
|
body[u'applicationDataTransfers'][i].setdefault(u'applicationTransferParams', [])
|
||||||
body[u'applicationDataTransfers'][0][u'applicationTransferParams'].append({u'key': key, u'value': value})
|
body[u'applicationDataTransfers'][i][u'applicationTransferParams'].append({u'key': key, u'value': value})
|
||||||
|
i += 1
|
||||||
|
|
||||||
result = callGAPI(dt.transfers(), u'insert', body=body, fields=u'id')[u'id']
|
result = callGAPI(dt.transfers(), u'insert', body=body, fields=u'id')[u'id']
|
||||||
print u'Submitted request id %s to transfer %s from %s to %s' % (result, serviceName, old_owner, new_owner)
|
print u'Submitted request id %s to transfer %s from %s to %s' % (result, ','.join(map(str,appNameList)), old_owner, new_owner)
|
||||||
|
|
||||||
def doPrintTransferApps():
|
def doPrintTransferApps():
|
||||||
dt = buildGAPIObject(u'datatransfer')
|
dt = buildGAPIObject(u'datatransfer')
|
||||||
|
|||||||
Reference in New Issue
Block a user