Admin SDK 网上论坛设置服务

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

参考

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

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

示例代码

以下示例代码使用的是该 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);
  }
}