एडमिन SDK Enterprise लाइसेंस मैनेजर की सेवा

एडमिन SDK Enterprise लाइसेंस मैनेजर सेवा की मदद से, Apps Script में एडमिन SDK Enterprise लाइसेंस मैनेजर एपीआई का इस्तेमाल किया जा सकता है. इस एपीआई से डोमेन एडमिन, उपयोगकर्ता के लाइसेंस असाइन कर सकते हैं, अपडेट कर सकते हैं, वापस पा सकते हैं, और मिटा सकते हैं.

रेफ़रंस

इस सेवा के बारे में ज़्यादा जानकारी के लिए, Admin SDK Enterprise लाइसेंस मैनेजर एपीआई के रेफ़रंस दस्तावेज़ देखें. Apps Script की सभी बेहतर सेवाओं की तरह, एडमिन SDK एंटरप्राइज़ लाइसेंस मैनेजर सेवा भी उन ऑब्जेक्ट, तरीकों, और पैरामीटर का इस्तेमाल करती है जो सार्वजनिक एपीआई के लिए होती हैं. ज़्यादा जानकारी के लिए, हस्ताक्षर तय करने का तरीका लेख पढ़ें.

समस्याओं की शिकायत करने और अन्य मदद पाने के लिए, Admin SDK Enterprise लाइसेंस मैनेजर की सहायता गाइड देखें.

नमूना कोड

नीचे दिए गए सैंपल कोड में, एपीआई के वर्शन 1 का इस्तेमाल किया गया है.

डोमेन के लिए लाइसेंस असाइनमेंट की सूची पाएं

यह नमूना डोमेन के उपयोगकर्ताओं के लिए प्रॉडक्ट आईडी और SKU आईडी के साथ-साथ लाइसेंस असाइनमेंट लॉग करता है. नतीजों की पूरी सूची देखने के लिए, पेज टोकन के इस्तेमाल पर ध्यान दें.

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

किसी उपयोगकर्ता के लिए लाइसेंस असाइन करने की प्रक्रिया शामिल करें

इस सैंपल में, किसी उपयोगकर्ता के लिए, दिए गए प्रॉडक्ट आईडी और 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);
  }
}