Admin SDK 网上论坛设置服务

通过 Admin SDK 群组设置服务,您可以使用 Admin SDK 的 Apps 脚本中的 Groups Settings API。此 API 供 Google Workspace 网域的管理员 (包括转销商)能够在 其 Google Workspace 账号。

参考

有关此服务的详细信息,请参阅 参考文档 Admin SDK Groups Settings API。与 Apps 脚本中的所有高级服务一样, Admin SDK 群组设置服务使用相同的对象、方法和参数 作为公共 API。如需了解详情,请参阅如何确定方法签名

如需报告问题和寻求其他支持,请参阅 Admin SDK 群组设置支持指南

示例代码

以下示例代码使用的是版本 1 该 API 的高级 API。

获取群组设置

此示例获取群组设置并将其记录到控制台中。

advanced/adminSDK.gs
/**
 * Gets a group's settings and logs them to the console.
 */
function getGroupSettings() {
  // TODO (developer) - Replace groupId value with yours
  const groupId = 'exampleGroup@example.com';
  try {
    const group = AdminGroupsSettings.Groups.get(groupId);
    console.log(JSON.stringify(group, null, 2));
  } catch (err) {
    // TODO (developer)- Handle exception from the API
    console.log('Failed with error %s', err.message);
  }
}

更新群组设置

此示例展示了如何更改群组的设置。此处的说明 修改后,其他各种设置可以采用相同的方式进行更改。

advanced/adminSDK.gs
/**
 * Updates group's settings. Here, the description is modified, but various
 * other settings can be changed in the same way.
 * @see https://developers.google.com/admin-sdk/groups-settings/v1/reference/groups/patch
 */
function updateGroupSettings() {
  const groupId = 'exampleGroup@example.com';
  try {
    const group = AdminGroupsSettings.newGroups();
    group.description = 'Newly changed group description';
    AdminGroupsSettings.Groups.patch(group, groupId);
  } catch (err) {
    // TODO (developer)- Handle exception from the API
    console.log('Failed with error %s', err.message);
  }
}