如何获得Google Team Drive的经理/贡献者/等等? [英] How do I get the managers/contributors/etc of a Google Team Drive?

查看:89
本文介绍了如何获得Google Team Drive的经理/贡献者/等等?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Team Drive具有五个权限级别:

Team Drive has five permission levels:

  • 经理
  • 内容管理器
  • 贡献者
  • 评论员
  • 查看器

文件夹API 仅具有获取文件夹中用户列表的三个功能:

The Folder API, on the other hand, only has three functions for getting a user list of people on a folder:

  • getEditors()
  • getOwner()
  • getViewers()

如果您使用的是我的云端硬盘",则此方法很好,因为它具有完全相同的三个级别:

This works fine if you're using a My Drive, because it has those exact same three levels:

  • 是所有者
  • 可以组织,添加和&修改
  • 只能查看

如何在Google Team Drive中获得5个访问级别中的每个级别?如果我确实调用了这三个功能,那么它们在Team Drive上对应于哪个访问级别?(例如, getEditors 是否返回 Manager 组中的每个人?)

How do I get each of the 5 access levels in a Google Team Drive? If I do call those 3 functions, which access level do they correspond to on a Team Drive? (E.g. does getEditors return everyone in the Manager group?)

我看到有一个权限枚举,其中包含精确的5我正在寻找的权限:

I see there is a Permission enum with the exact 5 permissions I'm looking for:

  • VIEW
  • EDIT
  • COMMENT
  • OWNER
  • 组织者

...,我可以拨打 getAccess() 以获得给定 User email 的访问级别.问题是我不知道将哪个电子邮件传递给该函数.

... and I can call getAccess() to get the access level given a User or email. Problem is I don't know which emails to pass to the function.

如何获取5个类别(例如 Content Manager )中任何一个的人员列表?还是我如何获取Team Drive上所有人员的列表(例如,这样我知道要与 getAccess()一起使用的电子邮件)?

How do I get a list of people in any of the 5 categories (e.g. Content Manager)? Or how do I get a list of all people that are on the Team Drive (e.g. so I know which emails to use with getAccess())?

推荐答案

以下是Team Drive UI中给定的权限,相应的 getAccess()值和您可以调用包含该人的文件夹API方法:

Here is a summary of the mappings between the permissions given in the Team Drive UI, the corresponding getAccess() value, and the Folder API method you can call which contains that person:

+-----------------------+-------------+-------------------+
| Team Drive Permission | getAccess() | Folder API Method |
+-----------------------+-------------+-------------------+
| Manager               | ORGANIZER   | (None)            |
| Content Manager       | NONE        | (None)            |
| Contributor           | EDIT        | getEditors()      |
| Commenter             | COMMENT     | getViewers()      |
| Viewer                | VIEW        | getViewers()      |
| (None)                | NONE        | (None)            |
+-----------------------+-------------+-------------------+

一些结果:

  • 无法知道谁是Team Drive上的内容管理器:请注意,它如何为两个 Content Manager 返回 NONE 和不在团队中的人.因此,即使您知道对方的电子邮件地址,也无法使用 getAccess()方法来知道谁是Team Drive上的内容管理员.这可能是API中的错误吗?
  • 您可以轻松获取所有贡献者:只需调用 getEditors()方法.
  • 您可以获取所有评论者和查看者,但也需要使用 getAccess() :由于评论者和查看者都是通过 getViewers 返回的,则需要将此引用与getAccess()中返回的结果进行交叉引用,以查找实际的Commenters或Viewers.
  • 没有用于获取Manager或Content Manager的API方法:在Folder上返回一组用户的标准API方法均不会返回Manager或Content Manager组中的任何人.因此,您需要知道经理的电子邮件地址,并且只能使用getAccess()来验证他们确实是经理.
  • getOwner()始终返回 null .大概是因为Team Drive上没有单个所有者.即使您只有1个Manager和0个Content Manager,它也会返回 null .
  • There is no way to know who is a Content Manager on the Team Drive: Notice how it returns NONE for both Content Managers and people who aren't on the Team Drive. It is therefore impossible to know who is a Content Manager on the Team Drive using the getAccess() method, even if you know the person's email address. This may be a bug in the API?
  • You can easily get all Contributors: Simply call the getEditors() method.
  • You can get all Commenters and Viewers, but need to use getAccess() too: Since both Commenters and Viewers are return via getViewers, you'll need to cross reference this against the results returned in getAccess() to find the actual Commenters or Viewers.
  • There are no API methods to get the Manager or Content Managers: None of the standard API methods that return a set of users on a Folder will return anyone in the Manager or Content Manager group. You therefore need to know the email address of the managers, and can only use getAccess() to verify that they are indeed Managers.
  • getOwner() always returns null. Presumably this is because there are no single owners on Team Drives. It will return null even if you have exactly 1 Manager and 0 Content Managers.

因此,似乎没有办法在Team Drive(大概是经理>和 Content Managers ).相反,您必须已经知道与用户关联的电子邮件地址是什么,并调用 getAccess().这很不幸.

Therefore, there doesn't seem to be a way to find the OWNERs or ORGANIZERs on a Team Drive (presumably the Managers and Content Managers, respectively) using the standard API. Instead, you must already know what the email address associated with the user is, and call getAccess(). This is unfortunate.

我期望以下解决方法能够正常工作:

I was expecting the following workaround to work:

  • 在团队驱动器内创建一个虚拟文件.由于Team Drive中的 file 权限映射为完全编辑注释查看 getEditors()方法现在应公开Manager和Content Manager.由于它们对文件具有 Edit 权限,因此应该由 getEditors()方法返回它们.
  • Create a dummy file inside the Team Drive. Since file permissions inside a Team Drive map to exactly Edit, Comment, View, the getEditors() method should now expose the Manager and Content Managers. Since they have the Edit permission on the file, they should presumably be returned by the getEditors() method.

不幸的是,这也不起作用.结果与文件夹情况完全相同.Manager和Content Manager处于隐藏状态(即3种方法均未返回).内容管理器的getAccess()仍为NONE,等等.

This unfortunately didn't work either. The results were exactly the same as the folder case. The Manager and Content Manager were hidden (i.e. none of the 3 methods returned them). The Content Manager's getAccess() was still NONE, etc.

那么,我相信唯一的选择是使用高级API,以获得管理者和内容管理者的列表.特别是,它看起来像

To get the list of Managers and Content Managers, then, I believe the only option is to use the advanced API. In particular, it looks like teamDrivePermissionDetails[].role on the Permissions object returns exactly the 5 states that map to Team Drive permissions:

  • 组织者
  • fileOrganizer
  • 作家
  • 评论者
  • 阅读器

这篇关于如何获得Google Team Drive的经理/贡献者/等等?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆