Admin SDK Groups Settings サービス

Google Workspace ドメインのグループ設定を管理する Apps Script。

Admin SDK Groups Settings サービスを使用すると、Google Apps Script で Admin SDK の Groups Settings API を使用できます。この API を使用すると、Google Workspace ドメインの管理者(販売パートナー様を含む)は、Google Workspace アカウントのグループのグループ設定を管理できます。

これは、使用前に有効にする必要がある拡張サービスです。

リファレンス

このサービスの詳細については、Admin SDK Groups Settings API のリファレンス ドキュメントをご覧ください。Apps Script のすべての高度なサービスと同様に、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);
  }
}