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 umożliwia administratorom domen przypisywanie, aktualizowanie, pobieranie i usuwanie licencji użytkowników.

Plik referencyjny

Szczegółowe informacje o tej usłudze znajdziesz w dokumentacji referencyjnej 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ą sygnatury metod.

Aby zgłosić problemy i uzyskać pomoc, zapoznaj się z przewodnikiem pomocy dotyczącym narzędzia Admin SDK Enterprise License Manager.

Przykładowy kod

Poniższy przykładowy kod korzysta z wersji 1 interfejsu API.

Pobieranie listy przypisań licencji w domenie

Ten przykładowy skrypt rejestruje przypisania licencji, w tym identyfikator produktu i identyfikator SKU, dla użytkowników w domenie. Zwróć uwagę na użycie tokenów strony, aby uzyskać 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,
    );
  }
}

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