借助 Google Workspace Directory API,您可以管理贵组织内的移动设备。本页包含有关如何列出移动设备、获取特定设备的详细信息以及添加或移除设备的示例。
本文档假定您已成功完成前提条件。 Android 设备需要安装设备政策应用。iOS 设备必须已注册 Google 移动管理服务。
在这些示例中,占位符 customerId 和 resourceId 用于指明您应在何处提供这些 ID。您可以通过 Users.get 方法获取 customerId。resourceId 是设备的唯一 Google 标识符,可在检索所有移动设备方法的响应中找到。
检索所有移动设备
如需检索账号的所有移动设备,请使用以下 GET
请求,并在其中添加为请求授权中所述的授权。为了方便阅读,此示例使用回车断行:
GET https://admin.googleapis.com/admin/directory/v1/customer/{my_customer|customerId} /devices/mobile?projection={BASIC|FULL}&query=query &orderBy=orderBy category&sortOrder={ASCENDING|DESCENDING} &pageToken=token for next results page &maxResults=max number of results per page
如需了解请求和响应属性,请参阅 API 参考文档。
JSON 响应
{ "kind": "directory#mobiledevices", "mobiledevices": [ { "kind": "directory#mobiledevice", "resourceId": "resourceId", "deviceId": "deviceId", "name": [ "Sales" ], "email": [ "sales@example.com" ], "model": "Nexus 4", "os": "Android 4.2.2", "type": "ANDROID", "status": "APPROVED", "hardwareId": "1234567890", "firstSync": "2013-05-15T17:30:04.325Z", "lastSync": "2013-06-05T17:30:04.325Z", "userAgent": "Google Apps Device Policy 4.14", }, { "kind": "directory#mobiledevice", "resourceId": "resourceId", "deviceId": "deviceId", "name": [ "Liz" ], "email": [ "liz@example.com" ], "model": "Galaxy Nexus", "os": "Android 4.2.2", "type": "ANDROID", "status": "APPROVED", "hardwareId": "9123456780", "firstSync": "2013-06-05T17:30:04.325Z", "lastSync": "2013-08-12T17:30:04.325Z", "userAgent": "Google Apps Device Policy 4.14", } ], "nextPageToken": "next_page_token_value" }
检索移动设备
如需检索移动设备的属性,请使用以下 GET
请求,并包含授权请求中所述的授权。为了方便阅读,此示例使用回车断行:
GET https://admin.googleapis.com/admin/directory/v1/customer/{my_customer|customerId} /devices/mobile/resourceId?projection={FULL|BASIC}
如需了解请求和响应属性,请参阅 API 参考文档。
JSON 请求
resourceId 的请求示例如下:
GET https://admin.googleapis.com/admin/directory/v1/customer/my_customer/devices/ mobile/resourceId?projection=FULL
JSON 响应
{ "kind": "directory#mobiledevice", "resourceId": "resourceId", "deviceId": "deviceId", "name": [ "Sales3" ], "email": [ "sales@example.com" ], "model": "Nexus 4", "os": "Android 4.2.2", "type": "ANDROID", "status": "APPROVED", "hardwareId": "1234567890", "firstSync": "2010-05-15T17:30:04.325Z", "lastSync": "2013-06-05T17:30:04.325Z", "userAgent": "Google Apps Device Policy 4.14", }
批准移动设备
如需批准移动设备,请使用以下 POST
请求,并在其中添加为请求授权中所述的授权。
为了方便阅读,此示例使用回车断行:
POST https://admin.googleapis.com/admin/directory/v1/customer/{my_customer|customerId} /devices/mobile/resourceId/action
如需了解请求和响应属性,请参阅 API 参考文档。
JSON 请求
以下 JSON 请求显示了批准设备的示例请求:
POST https://admin.googleapis.com/admin/directory/v1/customer/my_customer/devices /mobile/resourceId/action
请求正文如下:
{ "action": "approve" }
成功的请求会返回 HTTP 200 状态代码。
移除移动设备
如需移除移动设备,请使用以下 DELETE
请求,并在其中添加授权请求中所述的授权。
为了方便阅读,此示例使用回车断行:
DELETE https://admin.googleapis.com/admin/directory/v1/customer/{my_customer|customerId} /devices/mobile/resourceId
如需了解请求和响应属性,请参阅 API 参考文档。
成功的请求会返回 HTTP 200 状态代码。