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

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

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

  • ‫$TOKEN – טוקן OAuth 2.0
  • ‫$CUSTOMER - מזהה הלקוח או הערך המילולי my_customer

רשימת דפדפני Chrome רשומים

כדי לראות את רשימת דפדפני Chrome הרשומים, משתמשים בנקודת הקצה /chromeBrowsers. אפשר לשלוט על חלוקה לדפים באמצעות הפרמטרים pageSize (מקסימום וערך ברירת מחדל 100) ו-pageToken. משתמשים ב-orderBy כדי לציין את סדר התוצאות. מציינים filter כדי לצמצם את התוצאות. אפשר לציין מסכת קריאה באמצעות פרמטר השאילתה fields.

יש תמיכה בהתאמה לתו כללי לחיפוש (*) (קידומת prefix*, סיומת *suffix, מחרוזת משנה *substring* או נוכחות *) עם = ו-: רק בשדות machine_name, annotated_asset_id ו-browser_version.

חיפוש טקסט גלובלי (בלי לציין שם שדה) מחפש בכל שדות הטקסט שעברו אינדוקס. אם מפרידים בין כמה מונחים באמצעות AND או רווח (לדוגמה, filter=machine AND 73 או filter=machine 73), כל מונח צריך להתאים לפחות לשדה טקסט אחד באינדקס במכשיר הדפדפן (גם אם מדובר בשדות שונים). אם מקיפים כמה מילים במירכאות (לדוגמה, filter="machine name"), המערכת תחפש את הביטוי המדויק הזה בשדה אחד.

שאילתות לדוגמה לסינון

# Filter by machine name prefix (using ':' or '=')
filter=machine_name:LIX*

# Filter by annotated asset ID suffix
filter=annotated_asset_id="*1001"

# Filter by browser version substring
filter=browser_version:"*6367*"

# Global search across all indexed text fields (matches browsers containing both "machine" and "73" across any fields)
filter=machine AND 73

# Global search with implicit AND (equivalent to `machine AND 73`)
filter=machine 73

# Filter by machine name prefix and registration time range
filter=machine_name:LIX* AND last_registration_time>=2024-01-01T00:00:00Z

# Filter by Organizational Unit path
filter=org_unit_path=/Marketing

בקשה

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/chromeBrowsers?pageSize=2&orderBy=lastActivityTime+desc&filter=os_platform=WINDOWS"

תשובה

{
  "chromeBrowsers": [
    {
      "name": "customers/<customerId>/chromeBrowsers/<browserPermanentId1>",
      "browserPermanentId": "<browserPermanentId1>",
      "machineName": "CLIENT2024-01",
      "osPlatformType": "WINDOWS",
      "osVersion": "10.0.19045",
      "browserVersion": "124.0.6367.60",
      "annotatedUser": "user1@example.com",
      "annotatedLocation": "US-NYC",
      "annotatedAssetId": "ASSET-1001",
      "annotatedNotes": "Engineering workstation",
      "lastActivityTime": "2024-04-23T22:05:44.214362Z",
      "lastPolicySyncTime": "2024-04-23T22:00:00.000Z",
      "lastStatusReportTime": "2024-04-23T22:05:44.214362Z",
      "enrollmentDate": "2024-01-15T10:30:00.000Z",
      "orgUnitPath": "/Engineering",
      "policyCount": 15,
      "extensionCount": 8
    },
    {
      "name": "customers/<customerId>/chromeBrowsers/<browserPermanentId2>",
      "browserPermanentId": "<browserPermanentId2>",
      "machineName": "CLIENT2024-02",
      "osPlatformType": "WINDOWS",
      "osVersion": "11.0.22631",
      "browserVersion": "124.0.6367.60",
      "annotatedUser": "user2@example.com",
      "annotatedLocation": "US-MTV",
      "lastActivityTime": "2024-04-23T21:45:10.102000Z",
      "lastPolicySyncTime": "2024-04-23T21:40:00.000Z",
      "lastStatusReportTime": "2024-04-23T21:45:10.102000Z",
      "enrollmentDate": "2024-02-10T14:15:00.000Z",
      "orgUnitPath": "/Engineering",
      "policyCount": 12,
      "extensionCount": 5
    }
  ],
  "nextPageToken": "<nextPageToken>"
}

שחזור של דפדפן Chrome מנוהל

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

בקשה

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/chromeBrowsers/<browserPermanentId1>"

תשובה

{
  "name": "customers/<customerId>/chromeBrowsers/<browserPermanentId1>",
  "browserPermanentId": "<browserPermanentId1>",
  "machineName": "CLIENT2024-01",
  "osPlatformType": "WINDOWS",
  "osVersion": "10.0.19045",
  "browserVersion": "124.0.6367.60",
  "annotatedUser": "user1@example.com",
  "annotatedLocation": "US-NYC",
  "annotatedAssetId": "ASSET-1001",
  "annotatedNotes": "Engineering workstation",
  "lastActivityTime": "2024-04-23T22:05:44.214362Z",
  "lastPolicySyncTime": "2024-04-23T22:00:00.000Z",
  "lastStatusReportTime": "2024-04-23T22:05:44.214362Z",
  "enrollmentDate": "2024-01-15T10:30:00.000Z",
  "orgUnitPath": "/Engineering",
  "policyCount": 15,
  "extensionCount": 8
}

עדכון פרטי ההערות בדפדפן Chrome

כדי לעדכן שדות עם הערות בדפדפן Chrome רשום, צריך להשתמש בנקודת הקצה /chromeBrowsers/{browser_permanent_id} עם שיטת ה-HTTP PATCH ולספק פרמטר שאילתה updateMask שמציין את השדות לעדכון.

בקשה

  curl -X PATCH \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/chromeBrowsers/<browserPermanentId1>?updateMask=annotatedUser,annotatedNotes" \
  -d '{
    "annotatedUser": "newuser@example.com",
    "annotatedNotes": "Updated primary workstation"
  }'

תשובה

{
  "name": "customers/<customerId>/chromeBrowsers/<browserPermanentId1>",
  "browserPermanentId": "<browserPermanentId1>",
  "machineName": "CLIENT2024-01",
  "osPlatformType": "WINDOWS",
  "osVersion": "10.0.19045",
  "browserVersion": "124.0.6367.60",
  "annotatedUser": "newuser@example.com",
  "annotatedLocation": "US-NYC",
  "annotatedAssetId": "ASSET-1001",
  "annotatedNotes": "Updated primary workstation",
  "lastActivityTime": "2024-04-23T22:05:44.214362Z",
  "orgUnitPath": "/Engineering"
}

העברת דפדפני Chrome ליחידה ארגונית חדשה

כדי להעביר דפדפני Chrome מנוהלים מיחידה ארגונית אחת ליחידה ארגונית אחרת, משתמשים בנקודת הקצה /chromeBrowsers:move. אפשר להעביר עד 600 דפדפנים לכל בקשה. אם יש שגיאה בהעברה של דפדפן כלשהו, אף אחד מהדפדפנים שצוינו לא יועבר.

בקשה

  curl -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/chromeBrowsers:move" \
  -d '{
    "destinationOrgUnitId": "03ph8a2z3v",
    "resourceIds": [
      "customers/$CUSTOMER/chromeBrowsers/<browserPermanentId1>",
      "customers/$CUSTOMER/chromeBrowsers/<browserPermanentId2>"
    ]
  }'

תשובה

{}

מחיקת הנתונים שנאספו מדפדפן Chrome

כדי למחוק את הנתונים שנאספו מדפדפן Chrome מנוהל, משתמשים בנקודת הקצה /chromeBrowsers/{browser_permanent_id} עם HTTP DELETE.

בקשה

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

תשובה

{}