1<?php
2/*
3 * Copyright 2014 Google Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy of
7 * the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17
18namespace Google\Service\AndroidEnterprise\Resource;
19
20use Google\Service\AndroidEnterprise\Device;
21use Google\Service\AndroidEnterprise\DeviceState;
22use Google\Service\AndroidEnterprise\DevicesListResponse;
23
24/**
25 * The "devices" collection of methods.
26 * Typical usage is:
27 *  <code>
28 *   $androidenterpriseService = new Google\Service\AndroidEnterprise(...);
29 *   $devices = $androidenterpriseService->devices;
30 *  </code>
31 */
32class Devices extends \Google\Service\Resource
33{
34  /**
35   * Uploads a report containing any changes in app states on the device since the
36   * last report was generated. You can call this method up to 3 times every 24
37   * hours for a given device. If you exceed the quota, then the Google Play EMM
38   * API returns HTTP 429 Too Many Requests. (devices.forceReportUpload)
39   *
40   * @param string $enterpriseId The ID of the enterprise.
41   * @param string $userId The ID of the user.
42   * @param string $deviceId The ID of the device.
43   * @param array $optParams Optional parameters.
44   */
45  public function forceReportUpload($enterpriseId, $userId, $deviceId, $optParams = [])
46  {
47    $params = ['enterpriseId' => $enterpriseId, 'userId' => $userId, 'deviceId' => $deviceId];
48    $params = array_merge($params, $optParams);
49    return $this->call('forceReportUpload', [$params]);
50  }
51  /**
52   * Retrieves the details of a device. (devices.get)
53   *
54   * @param string $enterpriseId The ID of the enterprise.
55   * @param string $userId The ID of the user.
56   * @param string $deviceId The ID of the device.
57   * @param array $optParams Optional parameters.
58   * @return Device
59   */
60  public function get($enterpriseId, $userId, $deviceId, $optParams = [])
61  {
62    $params = ['enterpriseId' => $enterpriseId, 'userId' => $userId, 'deviceId' => $deviceId];
63    $params = array_merge($params, $optParams);
64    return $this->call('get', [$params], Device::class);
65  }
66  /**
67   * Retrieves whether a device's access to Google services is enabled or
68   * disabled. The device state takes effect only if enforcing EMM policies on
69   * Android devices is enabled in the Google Admin Console. Otherwise, the device
70   * state is ignored and all devices are allowed access to Google services. This
71   * is only supported for Google-managed users. (devices.getState)
72   *
73   * @param string $enterpriseId The ID of the enterprise.
74   * @param string $userId The ID of the user.
75   * @param string $deviceId The ID of the device.
76   * @param array $optParams Optional parameters.
77   * @return DeviceState
78   */
79  public function getState($enterpriseId, $userId, $deviceId, $optParams = [])
80  {
81    $params = ['enterpriseId' => $enterpriseId, 'userId' => $userId, 'deviceId' => $deviceId];
82    $params = array_merge($params, $optParams);
83    return $this->call('getState', [$params], DeviceState::class);
84  }
85  /**
86   * Retrieves the IDs of all of a user's devices. (devices.listDevices)
87   *
88   * @param string $enterpriseId The ID of the enterprise.
89   * @param string $userId The ID of the user.
90   * @param array $optParams Optional parameters.
91   * @return DevicesListResponse
92   */
93  public function listDevices($enterpriseId, $userId, $optParams = [])
94  {
95    $params = ['enterpriseId' => $enterpriseId, 'userId' => $userId];
96    $params = array_merge($params, $optParams);
97    return $this->call('list', [$params], DevicesListResponse::class);
98  }
99  /**
100   * Sets whether a device's access to Google services is enabled or disabled. The
101   * device state takes effect only if enforcing EMM policies on Android devices
102   * is enabled in the Google Admin Console. Otherwise, the device state is
103   * ignored and all devices are allowed access to Google services. This is only
104   * supported for Google-managed users. (devices.setState)
105   *
106   * @param string $enterpriseId The ID of the enterprise.
107   * @param string $userId The ID of the user.
108   * @param string $deviceId The ID of the device.
109   * @param DeviceState $postBody
110   * @param array $optParams Optional parameters.
111   * @return DeviceState
112   */
113  public function setState($enterpriseId, $userId, $deviceId, DeviceState $postBody, $optParams = [])
114  {
115    $params = ['enterpriseId' => $enterpriseId, 'userId' => $userId, 'deviceId' => $deviceId, 'postBody' => $postBody];
116    $params = array_merge($params, $optParams);
117    return $this->call('setState', [$params], DeviceState::class);
118  }
119  /**
120   * Updates the device policy. To ensure the policy is properly enforced, you
121   * need to prevent unmanaged accounts from accessing Google Play by setting the
122   * allowed_accounts in the managed configuration for the Google Play package.
123   * See restrict accounts in Google Play. When provisioning a new device, you
124   * should set the device policy using this method before adding the managed
125   * Google Play Account to the device, otherwise the policy will not be applied
126   * for a short period of time after adding the account to the device.
127   * (devices.update)
128   *
129   * @param string $enterpriseId The ID of the enterprise.
130   * @param string $userId The ID of the user.
131   * @param string $deviceId The ID of the device.
132   * @param Device $postBody
133   * @param array $optParams Optional parameters.
134   *
135   * @opt_param string updateMask Mask that identifies which fields to update. If
136   * not set, all modifiable fields will be modified. When set in a query
137   * parameter, this field should be specified as updateMask=,,...
138   * @return Device
139   */
140  public function update($enterpriseId, $userId, $deviceId, Device $postBody, $optParams = [])
141  {
142    $params = ['enterpriseId' => $enterpriseId, 'userId' => $userId, 'deviceId' => $deviceId, 'postBody' => $postBody];
143    $params = array_merge($params, $optParams);
144    return $this->call('update', [$params], Device::class);
145  }
146}
147
148// Adding a class alias for backwards compatibility with the previous class name.
149class_alias(Devices::class, 'Google_Service_AndroidEnterprise_Resource_Devices');
150