Admin SDK Enterprise License Manager サービス

Admin SDK Enterprise License Manager サービスを使用すると、Apps Script で Admin SDK Enterprise License Manager API を使用できます。この API を使用すると、ドメイン管理者はユーザー ライセンスの割り当て、更新、取得、削除を行うことができます。

リファレンス

このサービスの詳細については、Admin SDK Enterprise License Manager API のリファレンス ドキュメントをご覧ください。Apps Script のすべての高度なサービスと同様に、Admin SDK Enterprise License Manager サービスでは、公開 API と同じオブジェクト、メソッド、パラメータを使用します。詳細については、メソッド シグネチャの決定方法をご覧ください。

問題の報告やその他のサポートについては、Admin SDK Enterprise License Manager のサポートガイドをご覧ください。

サンプルコード

次のサンプルコードでは、API のバージョン 1 を使用しています。

ドメインのライセンス割り当てのリストを取得する

このサンプルでは、ドメイン内のユーザーのライセンス割り当て(プロダクト ID や SKU ID など)をログに記録します。ページトークンを使用して結果の完全なリストにアクセスしていることに注意してください。

advanced/adminSDK.gs
/**
 * Logs the license assignments, including the product ID and the sku ID, for
 * the users in the domain. Notice the use of page tokens to access the full
 * list of results.
 */
function getLicenseAssignments() {
  const productId = 'Google-Apps';
  const customerId = 'example.com';
  let assignments = [];
  let pageToken = null;
  do {
    const response = AdminLicenseManager.LicenseAssignments.listForProduct(productId, customerId, {
      maxResults: 500,
      pageToken: pageToken
    });
    assignments = assignments.concat(response.items);
    pageToken = response.nextPageToken;
  } while (pageToken);
  // Print the productId and skuId
  for (const assignment of assignments) {
    console.log('userId: %s, productId: %s, skuId: %s',
        assignment.userId, assignment.productId, assignment.skuId);
  }
}

ユーザーのライセンス割り当てを挿入する

このサンプルでは、特定のプロダクト ID と SKU ID の組み合わせについて、ユーザーのライセンス割り当てを挿入する方法を示します。

advanced/adminSDK.gs
/**
 * Insert a license assignment for a user, for a given product ID and sku ID
 * combination.
 * For more details follow the link
 * https://developers.google.com/admin-sdk/licensing/reference/rest/v1/licenseAssignments/insert
 */
function insertLicenseAssignment() {
  const productId = 'Google-Apps';
  const skuId = 'Google-Vault';
  const userId = 'marty@hoverboard.net';
  try {
    const results = AdminLicenseManager.LicenseAssignments
        .insert({userId: userId}, productId, skuId);
    console.log(results);
  } catch (e) {
    // TODO (developer) - Handle exception.
    console.log('Failed with an error %s ', e.message);
  }
}