Esempi di codice per l'API Chrome Management Chrome Browsers

Visita la pagina API Chrome Management Chrome Browsers per una panoramica delle funzionalità dell'API.

Tutte le richieste mostrate in questa pagina utilizzano le seguenti variabili:

  • $TOKEN - Token OAuth 2.0
  • $CUSTOMER - ID del cliente o valore letterale my_customer

Elenca i browser Chrome registrati

Per elencare i browser Chrome registrati, utilizza l'endpoint /chromeBrowsers. Puoi controllare la paginazione utilizzando i parametri pageSize (massimo e predefinito 100) e pageToken. Utilizza orderBy per specificare l'ordinamento dei risultati. Specifica un filter per restringere i risultati. È possibile specificare una maschera di lettura con il parametro di query fields.

La corrispondenza con caratteri jolly (*) (prefisso prefix*, suffisso *suffix, sottostringa *substring* o presenza *) è supportata con = e : solo nei campi machine_name, annotated_asset_id e browser_version.

La ricerca di testo globale (senza specificare un nome di campo) esegue la ricerca in tutti i campi di testo indicizzati. Quando più termini sono separati da AND o spazi bianchi (ad esempio, filter=machine AND 73 o filter=machine 73), ogni termine deve corrispondere ad almeno un campo di testo indicizzato sul dispositivo browser (anche in campi diversi). Se racchiudi più parole in una singola stringa tra virgolette (ad esempio, filter="machine name"), la ricerca viene eseguita per trovare quella frase esatta e contigua all'interno di un singolo campo.

Esempi di query con filtri

# 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

Richiesta

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

Risposta

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

Recuperare un browser Chrome gestito

Per recuperare un singolo browser Chrome registrato, utilizza l'endpoint /chromeBrowsers/{browser_permanent_id}. È possibile specificare una maschera di lettura con il parametro fields.

Richiesta

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

Risposta

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

Aggiornare le informazioni sulle annotazioni per un browser Chrome

Per aggiornare i campi annotati di un browser Chrome registrato, utilizza l'endpoint /chromeBrowsers/{browser_permanent_id} con il metodo HTTP PATCH e fornisci un parametro di query updateMask che specifica i campi da aggiornare.

Richiesta

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

Risposta

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

Spostare i browser Chrome in una nuova unità organizzativa

Per trasferire i browser Chrome gestiti da un'unità organizzativa a un'altra, utilizza l'endpoint /chromeBrowsers:move. È possibile trasferire fino a 600 browser per richiesta. Se si verifica un errore durante lo spostamento di un browser, nessuno dei browser specificati viene spostato.

Richiesta

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

Risposta

{}

Eliminare i dati raccolti da un browser Chrome

Per eliminare i dati raccolti da un browser Chrome gestito, utilizza l'endpoint /chromeBrowsers/{browser_permanent_id} con HTTP DELETE.

Richiesta

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

Risposta

{}