דוגמאות קוד ל-Chrome Management Profiles API

במאמר Chrome Management Profiles API מופיעה סקירה כללית של תכונות ה-API.

כל הבקשות שמוצגות בדף הזה משתמשות במשתנים הבאים:

  • $TOKEN – טוקן OAuth 2.0
  • $CUSTOMER - ID of the customer or literal my_customer

הצגת רשימה של פרופילים מנוהלים

כדי להציג את הפרופילים המנוהלים, משתמשים בנקודת הקצה /profiles. אפשר לשלוט על חלוקת התוצאות לדפים באמצעות הפרמטרים pageSize ו-pageToken. משתמשים ב-orderBy כדי לציין את סדר התוצאות. כדי לצמצם עוד יותר את התוצאות, מציינים filter. אפשר לציין מסכת קריאה באמצעות פרמטר השאילתה fields. שימו לב שאפשר לשפר את היעילות על ידי רישום פרופילים עם מסכת קריאה שלא כוללת את השדה reportingData.

בקשה

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/profiles?pageSize=2&orderBy=lastPolicySyncTime&filter=osPlatformType=WINDOWS+AND+affiliationState=PROFILE_ONLY&fields=chromeBrowserProfiles.name,chromeBrowserProfiles.profileId,chromeBrowserProfiles.profilePermanentId,chromeBrowserProfiles.displayName,chromeBrowserProfiles.userEmail,chromeBrowserProfiles.lastActivityTime,chromeBrowserProfiles.osPlatformType,chromeBrowserProfiles.policyCount,chromeBrowserProfiles.reportingData,chromeBrowserProfiles.identityProvider,chromeBrowserProfiles.affiliationState"

תשובה

{
  "chromeBrowserProfiles": [
    {
      "name": "customers/<customerId>/profiles/<profilePermanentId1>",
      "profileId": "<profileId1>",
      "profilePermanentId": "<profilePermanentId1>",
      "displayName": "My profile 1",
      "userEmail": "<userEmail1>",
      "lastActivityTime": "2024-04-23T22:05:44.214362Z",
      "osPlatformType": "WINDOWS",
      "policyCount": "2",
      "reportingData": [
        {
          "browserExecutablePath": "<executablePath1>",
          "profilePath": "<profilePath1>",
          "extensionData":[
            {
              "extensionId": "ghbmnnjooekpmoecnnnilnnbdlolhkhi",
              "version": "1.76.1",
              "name": "Google Docs Offline",
              "extensionType": "EXTENSION",
              "homepageUri": "https://chrome.google.com/webstore/detail/ghbmnnjooekpmoecnnnilnnbdlolhkhi",
              "installationType": "NORMAL",
              "isDisabled": true,
              "isWebstoreExtension": true,
              "manifestVersion": 3
            }
          ],
          "policyData":[
            {
              "source": "MACHINE_PLATFORM",
              "name": "AutoSelectCertificateForUrls",
              "value": "\"********\""
            },
            {
              "source": "USER_CLOUD",
              "name": "BrowserThemeColor",
              "value": "\"#00FF00\""
            }
          ]
        }
      ],
      "identityProvider": "GOOGLE_IDENTITY_PROVIDER",
      "affiliationState": "PROFILE_ONLY"
    },
    {
      "name": "customers/<customerId>/profiles/<profilePermanentId2>",
      "profileId": "<profileId2>",
      "profilePermanentId": "<profilePermanentId2>",
      "displayName": "My profile 2",
      "userEmail": "<userEmail2>",
      "lastActivityTime": "2024-04-23T22:05:44.214362Z",
      "osPlatformType": "WINDOWS",
      "policyCount": "1",
      "reportingData": [
        {
          "browserExecutablePath": "<executablePath2>",
          "profilePath": "<profilePath2>",
          "policyData":[
            {
              "source": "USER_CLOUD",
              "name": "CloudProfileReportingEnabled",
              "value": "true"
            }
          ]
        }
      ],
      "identityProvider": "GOOGLE_IDENTITY_PROVIDER",
      "affiliationState": "PROFILE_ONLY"
    }
  ],
  "next_page_token": "<nextPageToken>",
  "total_size": "120"
}

שליפת פרופיל מנוהל

כדי לאחזר פרופיל מנוהל, משתמשים בנקודת הקצה /profiles/{profile_permanent_id}. אפשר לציין מסכת קריאה באמצעות הפרמטר fields.

בקשה

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/profiles/<profilePermanentId1>?fields=chromeBrowserProfiles.name,chromeBrowserProfiles.profileId,chromeBrowserProfiles.profilePermanentId,chromeBrowserProfiles.displayName,chromeBrowserProfiles.userEmail,chromeBrowserProfiles.lastActivityTime,chromeBrowserProfiles.osPlatformType,chromeBrowserProfiles.policyCount,chromeBrowserProfiles.reportingData,chromeBrowserProfiles.identityProvider,chromeBrowserProfiles.affiliationState"

תשובה

{
  "name": "customers/<customerId>/profiles/<profilePermanentId1>",
  "profileId": "<profileId1>",
  "profilePermanentId": "<profilePermanentId1>",
  "displayName": "My profile 1",
  "userEmail": "<userEmail1>",
  "lastActivityTime": "2024-04-23T22:05:44.214362Z",
  "osPlatformType": "WINDOWS",
  "policyCount": "2",
  "reportingData": [
    {
      "browserExecutablePath": "<executablePath1>",
      "profilePath": "<profilePath1>",
      "extensionData":[
        {
          "extensionId": "ghbmnnjooekpmoecnnnilnnbdlolhkhi",
          "version": "1.76.1",
          "name": "Google Docs Offline",
          "extensionType": "EXTENSION",
          "homepageUri": "https://chrome.google.com/webstore/detail/ghbmnnjooekpmoecnnnilnnbdlolhkhi",
          "installationType": "NORMAL",
          "isDisabled": true,
          "isWebstoreExtension": true,
          "manifestVersion": 3
        }
      ],
      "policyData":[
        {
          "source": "MACHINE_PLATFORM",
          "name": "AutoSelectCertificateForUrls",
          "value": "\"********\""
        },
        {
          "source": "USER_CLOUD",
          "name": "BrowserThemeColor",
          "value": "\"#00FF00\""
        }
      ]
    }
  ],
  "identityProvider": "GOOGLE_IDENTITY_PROVIDER",
  "affiliationState": "PROFILE_ONLY"
}

מחיקת הנתונים שנאספו מפרופיל מנוהל

כדי למחוק את הנתונים שנאספו מפרופיל מנוהל, צריך להשתמש בנקודת הקצה /profiles/{profile_permanent_id}.

בקשה

  curl -X DELETE \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/profiles/<profilePermanentId1>"

הפעלת פקודה מרחוק בפרופיל מנוהל

כדי להנפיק פקודה מרחוק לפרופיל מנוהל, משתמשים בנקודת הקצה /profiles/{profile_permanent_id}/commands/.

בקשה

  curl -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"command_type":"clearBrowsingData", "payload":{clearCache:true, clearCookies:true}}' \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/profiles/<profilePermanentId1>/commands"

תשובה

{
  "name": "customers/<customerId>/profiles/<profilePermanentId1>/commands/<commandId1>",
  "commandType": "clear_browsing_data",
  "payload": {
    "clear_cache": true,
    "clear_cookies": true
  },
  "commandState": "PENDING",
  "issueTime": "2025-04-05T16:43:37.668Z",
  "validDuration": "86400s"
}

אחזור פקודה מרחוק שהונפקה לפרופיל מנוהל

כדי לאחזר פקודה מרחוק שהונפקה לפרופיל מנוהל, משתמשים בנקודת הקצה /profiles/{profile_permanent_id}/commands/{command_id}.

בקשה

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/profiles/<profilePermanentId1>/commands/<commandId1>"

תשובה

{
  "name": "customers/<customerId>/profiles/<profilePermanentId1>/commands/<commandId1>",
  "commandType": "clear_browsing_data",
  "payload": {
    "clear_cache": true,
    "clear_cookies": true
  },
  "commandState": "EXECUTED_BY_CLIENT",
  "commandResult": {
    "resultType": "SUCCESS",
    "clientExecutionTime": "2025-04-05T14:01:51.082Z"
  },
  "issueTime": "2025-04-05T14:01:49.914Z",
  "validDuration": "86400s"
}

רשימת פקודות מרחוק שהונפקו לפרופיל מנוהל

כדי להציג רשימה של פקודות מרוחקות שהונפקו לפרופיל מנוהל, משתמשים בנקודת הקצה /profiles/{profile_permanent_id}/commands.

בקשה

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/profiles/<profilePermanentId1>/commands?pageSize=2"

תשובה

{
  "chromeBrowserProfileCommands": [
    {
      "name": "customers/<customerId>/profiles/<profilePermanentId1>/commands/<commandId1>",
      "commandType": "clear_browsing_data",
      "payload": {
        "clear_cache": true,
        "clear_cookies": true
      },
      "commandState": "EXECUTED_BY_CLIENT",
      "commandResult": {
        "resultType": "SUCCESS",
        "clientExecutionTime": "2025-04-05T14:01:51.082Z"
      },
      "issueTime": "2025-04-05T14:01:49.914Z",
      "validDuration": "86400s"
    },
    {
      "name": "customers/<customerId>/profiles/<profilePermanentId1>/commands/<commandId2>",
      "commandType": "clear_browsing_data",
      "payload": {
        "clear_cache": true,
        "clear_cookies": false
      },
      "commandState": "EXECUTED_BY_CLIENT",
      "commandResult": {
        "resultType": "SUCCESS",
        "clientExecutionTime": "2025-04-05T14:02:59.981Z"
      },
      "issueTime": "2025-04-05T14:02:59.192Z",
      "validDuration": "86400s"
    }
  ],
  "nextPageToken": "<nextPageToken>",
  "totalSize": "10"
}