Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python PyDrive中具有InsertPermission()的可选查询参数_Python_Google Api_Google Drive Api_Google Api Python Client_Pydrive - Fatal编程技术网

Python PyDrive中具有InsertPermission()的可选查询参数

Python PyDrive中具有InsertPermission()的可选查询参数,python,google-api,google-drive-api,google-api-python-client,pydrive,Python,Google Api,Google Drive Api,Google Api Python Client,Pydrive,是否可以使用PyDrive中的InsertPermission()发送可选查询参数的值?PyDrive文档似乎忽略了如何处理切换可选参数,如sendNotificationEmails 我需要在不发送通知电子邮件的情况下为特定用户(而不是任何人)添加文件权限,sendNotificationEmails默认设置为True 我已考虑将files.py的函数定义修改为以下内容,但我不确定这是否可行,并且以前从未编辑过库: def InsertPermission(self, new_permissi

是否可以使用PyDrive中的
InsertPermission()
发送可选查询参数的值?PyDrive文档似乎忽略了如何处理切换可选参数,如
sendNotificationEmails

我需要在不发送通知电子邮件的情况下为特定用户(而不是任何人)添加文件权限,
sendNotificationEmails
默认设置为
True

我已考虑将files.py的函数定义修改为以下内容,但我不确定这是否可行,并且以前从未编辑过库:

def InsertPermission(self, new_permission):
  """Insert a new permission. Re-fetches all permissions after call.

  :param new_permission: The new permission to insert, please see the official Google Drive API guide on permissions.insert for details.

  :type new_permission: object

  :return: The permission object.
  :rtype: object
  """
  file_id = self.metadata.get('id') or self['id']
  try:
    permission = self.auth.service.permissions().insert( fileId=file_id, body=new_permission, sendNotificationEmails=False).execute(http=self.http)
  except errors.HttpError as error:
    raise ApiRequestError(error)
  else:
    self.GetPermissions()  # Update permissions field.

  return permission

现在可以将可选参数指定为
InsertPermission()
函数的附加参数,如下所示:

file1.InsertPermission({'type': 'user',
                        'value': 'insert@email.here',
                        'role': 'reader'}, sendNotificationEmails=False)
所有可用参数请参见官方文件

注意:您当前(2017年4月)需要为此功能安装库的开发版本。此版本的PyDrive可以按如下方式安装:

pip install git+https://github.com/googledrive/PyDrive.git@development#egg=PyDrive

现在可以将可选参数指定为
InsertPermission()
函数的附加参数,如下所示:

file1.InsertPermission({'type': 'user',
                        'value': 'insert@email.here',
                        'role': 'reader'}, sendNotificationEmails=False)
所有可用参数请参见官方文件

注意:您当前(2017年4月)需要为此功能安装库的开发版本。此版本的PyDrive可以按如下方式安装:

pip install git+https://github.com/googledrive/PyDrive.git@development#egg=PyDrive

不要修改库的代码。向PyDrive维护者发送一个功能请求,在实现之前,在您自己的项目中保留一份修改后的代码副本。PyDrive维护者在此处打开一个bug:。您可以分叉库并进行更改。如果它们有效,我非常乐意将它们合并到主库中。不要修改库的代码。向PyDrive维护者发送一个功能请求,在实现之前,在您自己的项目中保留一份修改后的代码副本。PyDrive维护者在此处打开一个bug:。您可以分叉库并进行更改。如果它们有效,我非常乐意将它们合并到主库中。对于google api directly(V3),它是
sendNotificationEmail
,singular对于google api directly(V3),它是
sendNotificationEmail
,singular