Admin SDK 网上论坛设置服务

使用 Apps 脚本管理 Google Workspace 网域的群组设置。

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

这是一项高级服务,必须先 启用才能使用

参考

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

如需报告问题并查找其他支持,请参阅 Admin SDK Groups Settings 支持指南

示例代码

以下示例代码使用 API 的第 1 版

获取群组的设置

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

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);
  }
}