Chrome Management Telemetry API के लिए कोड सैंपल

एपीआई की सुविधाओं के बारे में खास जानकारी पाने के लिए, Chrome Management Telemetry API पर जाएं.

नीचे दिखाए गए सभी अनुरोध में इन वैरिएबल का इस्तेमाल किया गया है:

  • $TOKEN - OAuth 2 टोकन
  • $CUSTOMER - ग्राहक का आईडी या लिटरल my_customer

टेलीमेट्री डिवाइस के डेटा की सूची बनाएं

किसी Chrome डिवाइस का टेलीमेट्री डेटा सूची में शामिल करने के लिए, /telemetry/devices एंडपॉइंट का इस्तेमाल करें. readMask पैरामीटर का इस्तेमाल यह तय करने के लिए किया जाता है कि कौनसे डिवाइस फ़ील्ड दिखाए जाएं. pageSize और pageToken पैरामीटर का इस्तेमाल करके, नतीजों के पेजों को क्रम में लगाने की प्रोसेस को कंट्रोल किया जा सकता है. डिवाइस या रिपोर्ट की शर्तों के आधार पर, नतीजों को और सटीक बनाने के लिए filter तय करें.

अनुरोध

  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"

जवाब

{
  "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"
}

संगठन की किसी एक इकाई के लिए टेलीमेट्री डिवाइस डेटा की सूची बनाना

संगठन की किसी एक इकाई का टेलीमेट्री डेटा शामिल करने के लिए, filter पैरामीटर में orgUnitId वैल्यू का इस्तेमाल करें.

अनुरोध

  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"

जवाब

{
  "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"
        }
      ]
    }
  ]
}

टाइमस्टैंप फ़िल्टर का इस्तेमाल करके, टेलीमेट्री डिवाइस के डेटा की सूची बनाएं

टाइमस्टैंप फ़िल्टर सभी डिवाइसों को दिखाता है. हालांकि, इसमें सिर्फ़ वे रिपोर्ट शामिल होती हैं जो टाइमस्टैंप फ़िल्टर और read_mask के मुताबिक होती हैं.

इस फ़िल्टर का इस्तेमाल करने के लिए, filter पैरामीटर में reports_timestamp वैल्यू डालें. साथ ही, मिलीसेकंड में Unix Epoch में टाइमस्टैंप वैल्यू शामिल करें (यानी. 1679288169623) या RFC 3339 "ज़ुलु" फ़ॉर्मैट किया हुआ समय (ज़्यादा से ज़्यादा नौ फ़्रैक्शनल अंक यानी "2023-02-15T11:18:51.383Z") फ़ॉर्मैट. एपीआई से मिले टाइमस्टैंप, यूटीसी टाइमज़ोन में होते हैं. इसलिए, reports_timestamp फ़िल्टर की वैल्यू भी यूटीसी टाइमज़ोन में होनी चाहिए. संख्या की तुलना करने वाले सभी स्टैंडर्ड ऑपरेटर (<, >, <=, >=, =) काम करते हैं.

सभी रिपोर्ट की सूची बनाएं

reports_timestamp वैल्यू तय न होने पर, सिर्फ़ हाल ही की रिपोर्ट दिखाई जाती हैं. इसलिए, नीचे दिए गए कॉल का इस्तेमाल करके, सभी डिवाइसों के लिए read_mask में शामिल की गई सभी डिवाइस रिपोर्ट को वापस पाया जा सकता है.

अनुरोध

  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"

जवाब

{
  "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"
        }
      ]
    }
  ]
}

किसी खास टाइमस्टैंप के बाद रिपोर्ट की सूची बनाएं

किसी खास टाइमस्टैंप के बाद रिपोर्ट से जुड़ी क्वेरी का अनुरोध करने के लिए, reports_timestamp का इस्तेमाल करें, जैसा कि यहां दिए गए उदाहरण में दिखाया गया है.

अनुरोध

  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\""

जवाब

{
  "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"
        }
      ]
    }
  ]
}

एक से ज़्यादा फ़िल्टर (एक साथ फ़िल्टर करने की सुविधा) का इस्तेमाल करके टेलीमेट्री डिवाइस के डेटा की सूची बनाना

एपीआई से मिले रिस्पॉन्स को कम करने के लिए, एक से ज़्यादा फ़िल्टर का इस्तेमाल करने के लिए, filter पैरामीटर में AND कीवर्ड का इस्तेमाल करें और फ़िल्टर करने के एक से ज़्यादा मानदंड शामिल करें.

अनुरोध

  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"

जवाब

{
  "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"
        }
      ]
    }
  ]
}

टेलीमेट्री उपयोगकर्ता के डेटा की सूची बनाएं

किसी Chrome डिवाइस का टेलीमेट्री डेटा सूची में शामिल करने के लिए, /telemetry/users एंडपॉइंट का इस्तेमाल करें. readMask पैरामीटर का इस्तेमाल यह तय करने के लिए किया जाता है कि कौनसे डिवाइस फ़ील्ड दिखाए जाएं. pageSize और pageToken पैरामीटर का इस्तेमाल करके, नतीजों के पेजों को क्रम में लगाने की प्रोसेस को कंट्रोल किया जा सकता है.

अनुरोध

  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"

जवाब

{
  "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"
}

संगठन की किसी एक इकाई के लिए टेलीमेट्री से जुड़े उपयोगकर्ता डेटा की सूची बनाना

संगठन की किसी एक इकाई का टेलीमेट्री डेटा शामिल करने के लिए, filter पैरामीटर में orgUnitId वैल्यू का इस्तेमाल करें.

अनुरोध

  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"

जवाब

{
  "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",
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

टेलीमेट्री इवेंट के डेटा की सूची बनाएं

किसी ग्राहक के टेलीमेट्री इवेंट की सूची बनाने के लिए, /telemetry/events एंडपॉइंट का इस्तेमाल करें. readMask पैरामीटर का इस्तेमाल, यह बताने के लिए किया जाता है कि कौनसे फ़ील्ड दिखाए जाएं. आने वाले समय में, readMask पैरामीटर ज़रूरी नहीं होगा. साथ ही, कम से कम एक इवेंट टाइप वाला filter पैरामीटर ज़रूरी होगा.

डिफ़ॉल्ट रूप से, इवेंट के name, report_time, और event_type फ़ील्ड, रिस्पॉन्स में शामिल होते हैं. pageSize और pageToken पैरामीटर का इस्तेमाल करके, नतीजों के पेजों को क्रम में लगाने की प्रोसेस को कंट्रोल किया जा सकता है. इसके अलावा, इन पैरामीटर की मदद से भी नतीजे फ़िल्टर किए जा सकते हैं:

  • device_id
  • user_id
  • device_org_unit_id
  • user_org_unit_id
  • टाइमस्टैंप
    • इनपुट वैल्यू EPOCH मिलीसेकंड, जैसे कि timestamp<1667423821001 या 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

अनुरोध

  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"

जवाब

{
  "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>"
}