-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateDevice.gs
22 lines (21 loc) · 1.04 KB
/
updateDevice.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function updateCB(sernum,ouUpdate,assetUpdate) {
var serno = sernum;
// Since we provided serial numbers, convert each to device-id
var sernoquery = "id:" + serno;
// Use AdminSDK API to check if the cros device exists. Else the update will fail
var chromebooklist = AdminDirectory.Chromeosdevices.list('my_customer', { query: sernoquery }).chromeosdevices;
if (!chromebooklist) {
} else if (chromebooklist.length !== 1) {
} else {
var id = chromebooklist[0].deviceId;
// For each line, try to update the device with given data, and log the result
try {
//AdminDirectory.Chromeosdevices.update({ orgUnitPath: ou }, 'my_customer', id);
// AdminDirectory.Chromeosdevices.update({orgUnitPath:ou, notes:note, annotatedUser:user, annotatedAssetId:asset, annotatedLocation:room},'my_customer',id);
AdminDirectory.Chromeosdevices.update({orgUnitPath:ouUpdate, annotatedAssetId:assetUpdate},'my_customer',id);
} catch (err) {
return [serno, "couldn't be updated"];
}
}
return [serno, "has been updated"];
}