Chrome Management Reports API 程式碼範例

如需 API 功能的總覽,請造訪 Chrome Management Reports API

下方顯示的所有要求都使用下列變數:

  • $TOKEN:OAuth 2 權杖
  • $CUSTOMER - 客戶 ID 或常值my_customer
  • $ORG_UNIT_ID:要為其產生要求的特定部分機構單位 ID。

計算日期範圍內使用的 Chrome 版本數

如要查看在特定時間範圍內使用哪些 Chrome 版本,請在 filter 參數中使用 last_active_date 值。您可以使用 pageSizepageToken 參數控制結果分頁。

要求

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/reports:countChromeVersions?filter=last_active_date<2020-11-06+AND+last_active_date>2020-11-04"

回應

{
  "browserVersions": [
    {
      "count": "1",
      "version": "85.0.4183.83",
      "system": "SYSTEM_MAC",
      "channel": "STABLE"
    },
    {
      "count": "1",
      "version": "85.0.4183.102",
      "system": "SYSTEM_WINDOWS",
      "channel": "STABLE"
    },
    {
      "count": "13697",
      "version": "71.0.3578.96",
      "system": "SYSTEM_MAC",
      "channel": "STABLE"
    },
    {
      "count": "1",
      "version": "87.0.4280.40",
      "system": "SYSTEM_MAC",
      "channel": "BETA"
    },
    {
      "count": "1",
      "version": "88.0.4314.0",
      "system": "SYSTEM_MAC",
      "channel": "CANARY"
    },
    {
      "count": "1718"
    },
  ],
  "totalSize": 5
}

使用各種權限的應用程式安裝數分佈情形

如要查看安裝特定應用程式且具有指定數量的裝置數量,請在 filter 參數中使用 number_of_permissions 值。您可以使用 pageSizepageToken 參數控制結果分頁。

如需更多篩選器參數,請造訪參考資料

要求

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/reports:countInstalledApps?filter=number_of_permissions>6"

回應

{
  "totalSize": 1,
  "installedApps": [
    {
      "browserDeviceCount": "2",
      "appSource": "CHROME_WEBSTORE",
      "displayName": "Secure Shell App",
      "description": "Terminal emulator and SSH and SFTP client.",
      "appType": "APP",
      "appInstallType": "ADMIN",
      "appId": "pnhechapfaindjhompbnflcldabbghjo",
      "homepageUri": "https://chrome.google.com/webstore/detail/pnhechapfaindjhompbnflcldabbghjo",
      "permissions": [
        "clipboardRead",
        "clipboardWrite",
        "crashReportPrivate",
        "idle",
        "metricsPrivate",
        "notifications",
        "storage",
        "unlimitedStorage"
      ]
    },
  ]
}

計算已安裝應用程式的裝置數

上例顯示已在 2 部裝置上安裝的應用程式。 如要查看已安裝這個應用程式的裝置,可以使用 findInstalledAppDevices 自訂方法。您可以使用 pageSizepageToken 參數控制結果分頁。

要求

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/reports:findInstalledAppDevices?appType=app&appId=pnhechapfaindjhompbnflcldabbghjo"

回應

{
  "totalSize": 2,
  "devices": [
    {
      "machine": "MACHINEA-A",
      "deviceId": "b472473e-fe50-4c6e-9ac3-03fe0d0753ce"
    },
    {
      "machine": "MACHINE-B",
      "deviceId": "a5f49e54-b07b-409f-bc5c-aaf27c483249"
    }
  ]
}

後續要求

有鑑於上一個範例傳回的裝置 ID,您可以使用 Chrome 瀏覽器適用的 Admin SDK Directory API,取得更多已安裝應用程式的裝置相關資訊。