Mã mẫu cho API Chrome Management Telemetry

Hãy truy cập vào API Quản lý từ xa của Chrome để biết tổng quan về các tính năng API.

Tất cả những yêu cầu được hiển thị bên dưới đều sử dụng các biến sau:

  • $TOKEN - Mã thông báo OAuth 2
  • $CUSTOMER - Mã của khách hàng hoặc giá trị cố định my_customer

Liệt kê dữ liệu thiết bị đo từ xa

Để liệt kê dữ liệu đo từ xa cho một thiết bị Chrome, hãy sử dụng điểm cuối /telemetry/devices. Tham số readMask dùng để chỉ định các trường thiết bị sẽ được trả về. Bạn có thể kiểm soát việc phân trang các kết quả bằng cách sử dụng các tham số pageSizepageToken. Chỉ định filter để thu hẹp thêm kết quả dựa trên các tiêu chí của thiết bị hoặc báo cáo.

Yêu cầu

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/telemetry/devices?readMask=name,customer,orgUnitId,deviceId,serialNumber,cpuInfo,cpuStatusReport,memoryInfo,memoryStatusReport,osUpdateStatus&pageSize=2"

Phản hồi

{
  "devices": [
    {
      "name": "customers/<customer>/telemetry/devices/<deviceId>",
      "customer": "customers/<customer>",
      "orgUnitId": "ABCEDFG",
      "deviceId": "<deviceId>",
      "serialNumber": "0A2B213CDEFG",
      "cpuStatusReport": [
        {
          "reportTime": "2021-04-25T13:23:55.880Z",
          "cpuUtilizationPct": 76
        },
        {
          "reportTime": "2021-04-25T18:25:55.880Z",
          "cpuTemperatureInfo": [
            {
              "temperatureCelsius": 38,
              "label": "Core"
            },
          ]
        }
      ],
      "memoryStatusReport": [
        {
          "reportTime": "2021-04-25T13:23:55.880Z",
          "systemRamFreeBytes": "14358468900"
        }
      ],
      "osUpdateStatus": [
        {
          "lastUpdateTime": "2021-04-25T11:18:51.383Z",
          "lastUpdateCheckTime": "1970-01-01T00:00:00Z",
          "lastRebootTime": "2021-04-25T11:18:51.383Z"
        }
      ]
    },
    {
      "name": "customers/<customer>/telemetry/devices/<deviceId>",
      "customer": "customers/<customer>",
      "orgUnitId": "FEDCBA",
      "deviceId": "<deviceId>",
      "serialNumber": "1B3D817LKUH",
      "cpuStatusReport": [
        {
          "reportTime": "2021-05-25T13:23:55.880Z",
          "cpuUtilizationPct": 50
        },
      ],
      "memoryStatusReport": [
        {
          "reportTime": "2021-05-25T13:23:55.880Z",
          "systemRamFreeBytes": "14358468900"
        }
      ],
      "osUpdateStatus": [
        {
          "lastUpdateTime": "2021-05-25T11:18:51.383Z",
          "lastUpdateCheckTime": "1970-01-01T00:00:00Z",
          "lastRebootTime": "2021-05-25T11:18:51.383Z"
        }
      ]
    }
  ],
  "nextPageToken": "PAGE_TOKEN"
}

Liệt kê dữ liệu thiết bị đo từ xa của một đơn vị tổ chức

Để liệt kê dữ liệu đo từ xa của một đơn vị tổ chức, hãy sử dụng giá trị orgUnitId trong tham số filter.

Yêu cầu

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/telemetry/devices?readMask=name,customer,orgUnitId,deviceId,serialNumber,cpuInfo,cpuStatusReport,memoryInfo,memoryStatusReport,osUpdateStatus&filter=orgUnitId=ABCDEFG"

Phản hồi

{
  "devices": [
    {
      "name": "customers/<customer>/telemetry/devices/<deviceId>",
      "customer": "customers/<customer>",
      "orgUnitId": "ABCEDFG",
      "deviceId": "<deviceId>",
      "serialNumber": "0A2B213CDEFG",
      "cpuStatusReport": [
        {
          "reportTime": "2021-04-25T13:23:55.880Z",
          "cpuUtilizationPct": 76
        },
        {
          "reportTime": "2021-04-25T18:25:55.880Z",
          "cpuTemperatureInfo": [
            {
              "temperatureCelsius": 38,
              "label": "Core"
            },
          ]
        }
      ],
      "memoryStatusReport": [
        {
          "reportTime": "2021-04-25T13:23:55.880Z",
          "systemRamFreeBytes": "14358468900"
        }
      ],
      "osUpdateStatus": [
        {
          "lastUpdateTime": "2021-04-25T11:18:51.383Z",
          "lastUpdateCheckTime": "1970-01-01T00:00:00Z",
          "lastRebootTime": "2021-04-25T11:18:51.383Z"
        }
      ]
    }
  ]
}

Liệt kê dữ liệu thiết bị đo từ xa bằng bộ lọc dấu thời gian

Bộ lọc dấu thời gian trả về tất cả thiết bị, nhưng chỉ bao gồm các báo cáo phù hợp với bộ lọc dấu thời gian và read_mask đã chỉ định.

Để sử dụng bộ lọc này, hãy chỉ định giá trị reports_timestamp trong tham số filter và bao gồm giá trị dấu thời gian trong Unix Epoch tính bằng mili giây (tức là 1679288169623) hoặc thời gian định dạng "Zulu" theo RFC 3339 (tối đa 9 chữ số phân số, tức là "2023-02-15T11:18:51.383Z"). Dấu thời gian mà API trả về nằm theo múi giờ UTC. Vì vậy, các giá trị bộ lọc reports_timestamp cũng phải nằm trong múi giờ UTC. Tất cả toán tử so sánh số chuẩn (<, >, <=, >=, =) đều được hỗ trợ.

Liệt kê tất cả báo cáo

Vì chỉ có các báo cáo gần đây được trả về khi không có giá trị reports_timestamp nào được chỉ định, nên bạn có thể sử dụng lệnh gọi sau để truy xuất tất cả báo cáo thiết bị có trong read_mask cho mọi thiết bị.

Yêu cầu

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/telemetry/devices?readMask=name,customer,orgUnitId,deviceId,serialNumber,audioStatusReport,cpuStatusReport,heartbeatStatusReport,memoryStatusReport&filter=reports_timestamp>=0"

Phản hồi

{
  "devices": [
    {
      "name": "customers/<customer>/telemetry/devices/<deviceId>",
      "customer": "customers/<customer>",
      "orgUnitId": "ABCEDFG",
      "deviceId": "<deviceId>",
      "serialNumber": "0A2B213CDEFG",
      "audioStatusReport": [
        {
          "reportTime": "2009-01-01T12:37:51.383Z",
          "inputMute": true,
          "inputDevice": "example input device 2009",
        },
        {
          "reportTime": "2010-02-01T12:37:51.383Z",
          "inputMute": false,
          "inputDevice": "example input device 2010",
        },
        {
          "reportTime": "2011-03-01T12:37:51.383Z",
          "inputMute": true,
          "inputDevice": "example input device 2011",
        },
        {
          "reportTime": "2024-01-01T12:37:51.383Z",
          "inputMute": false,
          "inputDevice": "example input device 2024",
        }
      ],
      "cpuStatusReport": [
        {
          "reportTime": "1960-10-15T01:18:51.383Z",
          "cpuUtilizationPct": 76
        },
        {
          "reportTime": "1997-10-31T11:18:51.383Z",
          "cpuTemperatureInfo": [
            {
              "temperatureCelsius": 38,
              "label": "Core"
            },
          ]
        }
      ]
    },
    {
      "name": "customers/<customer>/telemetry/devices/<deviceId 1>",
      "customer": "customers/<customer>",
      "orgUnitId": "ABCEDFG",
      "deviceId": "<deviceId 1>",
      "serialNumber": "HGFEDCBA",
      "heartbeatStatusReport": [
        {
          "reportTime": "2001-02-15T11:18:51.383Z",
          "state": "ONLINE"
        },
        {
          "reportTime": "2002-07-22T11:18:51.383Z",
          "state": "OFFLINE"
        },
        {
          "reportTime": "2012-01-04T11:18:51.383Z",
          "state": "UNKNOWN"
        },
        {
          "reportTime": "2024-02-29T11:18:51.383Z",
          "state": "ONLINE"
        }
      ],
      "memoryStatusReport": [
        {
          "reportTime": "2024-03-20T11:18:51.383Z",
          "systemRamFreeBytes": "112233445566778"
        }
      ]
    }
  ]
}

Báo cáo danh sách sau một dấu thời gian cụ thể

Để đưa ra yêu cầu truy vấn báo cáo sau một dấu thời gian cụ thể, hãy sử dụng reports_timestamp như minh hoạ trong ví dụ sau.

Yêu cầu

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/telemetry/devices?readMask=name,customer,orgUnitId,deviceId,serialNumber,cpuStatusReport,memoryStatusReport,osUpdateStatus&filter=reports_timestamp>=\"2023-02-15T11:18:51.383Z\""

Phản hồi

{
  "devices": [
    {
      "name": "customers/<customer>/telemetry/devices/<deviceId>",
      "customer": "customers/<customer>",
      "orgUnitId": "ABCEDFG",
      "deviceId": "<deviceId>",
      "serialNumber": "0A2B213CDEFG",
      "cpuStatusReport": [
        {
          "reportTime": "2023-02-15T11:18:51.383Z",
          "cpuUtilizationPct": 76
        },
        {
          "reportTime": "2023-03-19T11:18:51.383Z",
          "cpuTemperatureInfo": [
            {
              "temperatureCelsius": 38,
              "label": "Core"
            },
          ]
        }
      ],
      "memoryStatusReport": [
        {
          "reportTime": "2023-04-19T11:18:51.383Z",
          "systemRamFreeBytes": "14358468900"
        }
      ]
    },
    {
      "name": "customers/<customer>/telemetry/devices/<deviceId 1>",
      "customer": "customers/<customer>",
      "orgUnitId": "ABCEDFG",
      "deviceId": "<deviceId 1>",
      "serialNumber": "HGFEDCBA",
      "memoryStatusReport": [
        {
          "reportTime": "2024-02-15T11:18:51.383Z",
          "systemRamFreeBytes": "112233445566778"
        }
      ]
    }
  ]
}

Liệt kê dữ liệu thiết bị đo từ xa bằng nhiều bộ lọc (Lọc liên kết)

Để sử dụng nhiều bộ lọc nhằm thu hẹp phản hồi mà API trả về, hãy dùng từ khoá AND trong tham số filter và thêm nhiều tiêu chí lọc.

Yêu cầu

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/telemetry/devices?readMask=name,customer,orgUnitId,deviceId,serialNumber,cpuStatusReport,memoryStatusReport,osUpdateStatus&filter=reports_timestamp=\"2023-02-15T11:18:51.383Z\" AND serialNumber=HGFEDCBA"

Phản hồi

{
  "devices": [
    {
      "name": "customers/<customer>/telemetry/devices/<deviceId 1>",
      "customer": "customers/<customer>",
      "orgUnitId": "ABCEDFG",
      "deviceId": "<deviceId 1>",
      "serialNumber": "HGFEDCBA",
      "memoryStatusReport": [
        {
          "reportTime": "2023-02-15T11:18:51.383Z",
          "systemRamFreeBytes": "112233445566778"
        }
      ]
    }
  ]
}

Liệt kê dữ liệu người dùng đo từ xa

Để liệt kê dữ liệu đo từ xa cho một thiết bị Chrome, hãy sử dụng điểm cuối /telemetry/users. Tham số readMask dùng để chỉ định các trường thiết bị sẽ được trả về. Bạn có thể kiểm soát việc phân trang các kết quả bằng cách sử dụng các tham số pageSizepageToken.

Yêu cầu

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/telemetry/users?readMask=name,customer,orgUnitId,userId,userEmail,user_device.device_id,user_device.audio_status_report,user_device.peripherals_report&pageSize=2"

Phản hồi

{
  "telemetryUsers": [
    {
      "name": "customers/<customer>/telemetry/users/<userId>",
      "customer": "customers/<customer>",
      "orgUnitId": "ABCEDFG",
      "userEmail": "<userId>",
      "userEmail": "user@mytestdomain.com",
      "userDevice": [
        {
          "deviceId": "HIJKLMNOP",
          "audioStatusReport": [
            {
              "reportTime": "2021-04-25T13:23:55.880Z",
              "outputMute": true,
              "inputMute": true,
            }
          ],
          "peripheralsReport": [
            {
              "reportTime": "2021-04-25T18:25:55.880Z",
              "usbPeripheralReport": [
                {
                  "vendor": "Vendor",
                  "name": "Microphone",
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "customers/<customer>/telemetry/users/<userId>",
      "customer": "customers/<customer>",
      "orgUnitId": "QRSTUV",
      "userEmail": "<userId>",
      "userEmail": "user2@mytestdomain.com",
      "userDevice": [
        {
          "deviceId": "WXYZ",
          "audioStatusReport": [
            {
              "reportTime": "2021-04-25T13:23:55.880Z",
              "outputMute": true,
              "inputMute": true,
            }
          ],
          "peripheralsReport": [
            {
              "reportTime": "2021-04-25T18:25:55.880Z",
              "usbPeripheralReport": [
                {
                  "vendor": "Vendor",
                  "name": "Microphone",
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "nextPageToken": "PAGE_TOKEN"
}

Liệt kê dữ liệu người dùng đo từ xa cho một đơn vị tổ chức

Để liệt kê dữ liệu đo từ xa của một đơn vị tổ chức, hãy sử dụng giá trị orgUnitId trong tham số filter.

Yêu cầu

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/telemetry/users?readMask=name,customer,orgUnitId,userId,userEmail,user_device.device_id,user_device.audio_status_report,user_device.peripherals_report&pageSize=2&filter=orgUnitId=ABCDEFG"

Phản hồi

{
  "telemetryUsers": [
    {
      "name": "customers/<customer>/telemetry/users/<userId>",
      "customer": "customers/<customer>",
      "orgUnitId": "ABCEDFG",
      "userEmail": "<userId>",
      "userEmail": "user@mytestdomain.com",
      "userDevice": [
        {
          "deviceId": "HIJKLMNOP",
          "audioStatusReport": [
            {
              "reportTime": "2021-04-25T13:23:55.880Z",
              "outputMute": true,
              "inputMute": true,
            }
          ],
          "peripheralsReport": [
            {
              "reportTime": "2021-04-25T18:25:55.880Z",
              "usbPeripheralReport": [
                {
                  "vendor": "Vendor",
                  "name": "Microphone",
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

Liệt kê dữ liệu sự kiện đo từ xa

Để liệt kê các sự kiện đo từ xa cho một khách hàng, hãy sử dụng điểm cuối /telemetry/events. Tham số readMask dùng để chỉ định những trường sẽ được trả về. Trong tương lai gần, thông số readMask sẽ trở thành thông số không bắt buộc và bạn sẽ bắt buộc phải sử dụng thông số filter có ít nhất 1 loại sự kiện.

Theo mặc định, các trường name, report_timeevent_type của sự kiện sẽ có trong phản hồi. Bạn có thể kiểm soát việc phân trang kết quả bằng cách sử dụng các tham số pageSizepageToken. Ngoài ra, bạn có thể lọc kết quả bằng các tham số sau:

  • device_id
  • user_id
  • device_org_unit_id
  • user_org_unit_id
  • dấu thời gian
    • Giá trị đầu vào có thể là EPOCH mili giây, tức là timestamp<1667423821001 hoặc RFC 3339. timestamp<"2022-11-02T20:08:32.386Z"
  • event_type
    • audio_severe_underrun
    • network_connection_state_change
    • usb_added
    • usb_removed
    • network_htps_latency_change

Yêu cầu

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/telemetry/events?readMask=device,usb_peripherals_event&filter=event_type=usb_added&pageSize=3"

Phản hồi

{
  "telemetryEvents": [
    {
      "name": "customers/<customer>/telemetry/events/<event id>",
      "device": {
        "deviceId": "<device id>",
        "orgUnitId": "<device’s org unit id>"
      },
      "reportTime": "2022-11-02T11:14:09.034Z",
      "eventType": "USB_ADDED",
      "usbPeripheralsEvent": {
        "usbPeripheralReport": [
          {
            "vendor": "Microdia",
            "name": "Integrated_Webcam_HD",
            "vid": <vid>,
            "pid": <pid>
          }
        ]
      }
    },
    {
      "name": "customers/<customer>/telemetry/events/<event id>",
      "device": {
        "deviceId": "<device id>",
        "orgUnitId": "<device’s org unit id>"
      },
      "reportTime": "2022-11-02T10:10:36.481Z",
      "eventType": "USB_ADDED",
      "usbPeripheralsEvent": {
        "usbPeripheralReport": [
          {
            "vendor": "Hewlett-Packard",
            "name": "x304m",
            "vid": <vid>,
            "pid": <pid>,
            "categories": [
              "Mass storage"
            ]
          }
        ]
      }
    },
    {
      "name": "customers/<customer>/telemetry/events/<event id>",
      "device": {
        "deviceId": "<device id>",
        "orgUnitId": "<device’s org unit id>"
      },
      "reportTime": "2022-11-02T09:58:48.249Z",
      "eventType": "USB_ADDED",
      "usbPeripheralsEvent": {
        "usbPeripheralReport": [
          {
            "vendor": "Realtek Semiconductor Corp.",
            "name": "USB 10/100/1000 LAN",
            "vid": <vid>,
            "pid": <pid>,
            "categories": [
              "Vendor Specific"
            ]
          }
        ]
      }
    }
  ],
  "nextPageToken": "<page token>"
}