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:countChromeProfileVersions?filter=last_active_date<2020-11-06+AND+last_active_date>2020-11-04"

响应

{
  "profileBrowserVersions": [
    {
      "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": 6
}

统计在指定日期范围内处于活跃状态的 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,详细了解安装了该应用的设备。

统计安装了应用的个人资料数量

如需查看安装了应用的个人资料列表,您可以使用 findInstalledAppProfiles 自定义方法。 您可以使用 pageSizepageToken 参数控制结果的分页。

请求

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

响应

{
  "totalSize": 2,
  "profiles": [
    {
      "email": "<email1>",
      "profileId": "ca847f92-7988-4ac8-a5a3-d0b8473c8bce",
      "profilePermanentId": "agio5SHt1rlQz3WlnKV41z5Fzxw",
      "profileOrgUnitId": "org_unit_id_1"
    },
    {
      "email": "<email2>",
      "profileId": "g472473e-fe50-4c6e-2ac3-53fe0d0753ce",
      "profilePermanentId": "pgeo2SHt1rlQz1WlnKV41z3Fzxw",
      "profileOrgUnitId": "org_unit_id_2"
    },
  ]
}

后续请求

根据上一个示例中返回的个人资料永久 ID,您可以使用 Chrome Management Profiles API,详细了解安装了该应用的个人资料。