שירות Admin SDK Enterprise License Manager

השירות Admin SDK Enterprise License Manager מאפשר להשתמש ב-Admin SDK Enterprise License Manager API ב-Apps Script. ה-API הזה מאפשר לאדמינים של דומיינים להקצות, לעדכן, לאחזר ולמחוק רישיונות משתמשים.

חומר עזר

מידע מפורט על השירות הזה זמין במסמכי התיעוד של Admin SDK Enterprise License Manager API. בדומה לכל השירותים המתקדמים ב-Apps Script, גם השירות של Admin SDK Enterprise License Manager משתמש באותם אובייקטים, שיטות ופרמטרים כמו ה-API הציבורי. מידע נוסף זמין במאמר איך נקבעות חתימות של שיטות.

כדי לדווח על בעיות ולקבל תמיכה אחרת, תוכלו להיעזר במדריך התמיכה ל-Admin SDK Enterprise License Manager.

קוד לדוגמה

בקוד לדוגמה שבהמשך משתמשים בגרסה 1 של ה-API.

קבלת רשימה של הקצאות רישיונות לדומיין

הדוגמה הבאה רושמת ביומן את ההקצאות של הרישיונות, כולל מזהה המוצר ומזהה המק"ט, של המשתמשים בדומיין. שימו לב לשימוש באסימוני דפים כדי לגשת לרשימת התוצאות המלאה.

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

הוספה של הקצאת רישיון למשתמש

הדוגמה הזו מדגימה איך להוסיף הקצאת רישיון למשתמש לשילוב נתון של מזהה מוצר ומזהה מק"ט.

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