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

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

रेफ़रंस

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

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

नमूना कोड

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

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

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

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