Directory API:移动设备

借助 Google Workspace Directory API,您可以管理组织内的移动设备。当前页面 包括有关如何列出您的移动设备、获取特定设备的详细信息以及 如添加或移除设备

本文档假定您已成功完成 前提条件。 Android 设备需要 Device Policy 应用 已安装。iOS 设备必须向 Google 移动设备管理服务

在这些示例中,占位符 customerIdresourceId 用于 指明提供这些 ID 的位置customerId 可从 Users.get 方法结合使用。通过 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 状态代码