Usługa menedżera licencji dla przedsiębiorstw z pakietu Admin SDK

Usługa Admin SDK Enterprise License Manager umożliwia korzystanie z interfejsu Admin SDK Enterprise License Manager API w Apps Script. Ten interfejs API pozwala administratorom domen przypisywać, aktualizować, pobierać i usuwać licencje użytkowników.

Dokumentacja

Szczegółowe informacje o tej usłudze znajdziesz w dokumentacji interfejsu Admin SDK Enterprise License Manager API. Podobnie jak wszystkie usługi zaawansowane w Apps Script, usługa Admin SDK Enterprise License Manager korzysta z tych samych obiektów, metod i parametrów co publiczny interfejs API. Więcej informacji znajdziesz w artykule Jak określane są podpisy metod.

Aby zgłosić problemy i uzyskać pomoc, zapoznaj się z przewodnikiem pomocy menedżera licencji Admin SDK Enterprise.

Przykładowy kod

Przykładowy kod poniżej wykorzystuje wersję 1 interfejsu API.

Wyświetl listę przypisanych licencji w domenie

Ten przykładowy kod rejestruje przypisania licencji, w tym identyfikator usługi i identyfikator SKU, w przypadku użytkowników w domenie. Zwróć uwagę na fakt, że tokeny stron zapewniają dostęp do pełnej listy wyników.

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

Wstaw przypisanie licencji użytkownikowi

Ten przykład pokazuje, jak wstawić przypisanie licencji użytkownikowi dla danej kombinacji identyfikatora produktu i identyfikatora SKU.

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