Directory API:移动设备

借助 Google Workspace Directory API,您可以管理组织内的移动设备。本页通过一些示例介绍了如何列出您的移动设备、获取特定设备的详细信息,以及添加或移除设备。

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

在这些示例中,占位符 customerIdresourceId 用于指明您应在何处提供这些 ID。您可以从 Users.get 方法获取 customerIdresourceId 是设备的唯一 Google 标识符,可在 Retrieve all mobile devices 方法的响应中找到。

检索所有移动设备

如需检索帐号的所有移动设备,请使用以下 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 状态代码