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 |
|
---|
18 | namespace Google\Service\CloudIot\Resource;
|
---|
19 |
|
---|
20 | use Google\Service\CloudIot\CloudiotEmpty;
|
---|
21 | use Google\Service\CloudIot\Device;
|
---|
22 | use Google\Service\CloudIot\DeviceConfig;
|
---|
23 | use Google\Service\CloudIot\ListDevicesResponse;
|
---|
24 | use Google\Service\CloudIot\ModifyCloudToDeviceConfigRequest;
|
---|
25 | use Google\Service\CloudIot\SendCommandToDeviceRequest;
|
---|
26 | use Google\Service\CloudIot\SendCommandToDeviceResponse;
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * The "devices" collection of methods.
|
---|
30 | * Typical usage is:
|
---|
31 | * <code>
|
---|
32 | * $cloudiotService = new Google\Service\CloudIot(...);
|
---|
33 | * $devices = $cloudiotService->projects_locations_registries_devices;
|
---|
34 | * </code>
|
---|
35 | */
|
---|
36 | class ProjectsLocationsRegistriesDevices extends \Google\Service\Resource
|
---|
37 | {
|
---|
38 | /**
|
---|
39 | * Creates a device in a device registry. (devices.create)
|
---|
40 | *
|
---|
41 | * @param string $parent Required. The name of the device registry where this
|
---|
42 | * device should be created. For example, `projects/example-project/locations
|
---|
43 | * /us-central1/registries/my-registry`.
|
---|
44 | * @param Device $postBody
|
---|
45 | * @param array $optParams Optional parameters.
|
---|
46 | * @return Device
|
---|
47 | */
|
---|
48 | public function create($parent, Device $postBody, $optParams = [])
|
---|
49 | {
|
---|
50 | $params = ['parent' => $parent, 'postBody' => $postBody];
|
---|
51 | $params = array_merge($params, $optParams);
|
---|
52 | return $this->call('create', [$params], Device::class);
|
---|
53 | }
|
---|
54 | /**
|
---|
55 | * Deletes a device. (devices.delete)
|
---|
56 | *
|
---|
57 | * @param string $name Required. The name of the device. For example,
|
---|
58 | * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
|
---|
59 | * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
|
---|
60 | * @param array $optParams Optional parameters.
|
---|
61 | * @return CloudiotEmpty
|
---|
62 | */
|
---|
63 | public function delete($name, $optParams = [])
|
---|
64 | {
|
---|
65 | $params = ['name' => $name];
|
---|
66 | $params = array_merge($params, $optParams);
|
---|
67 | return $this->call('delete', [$params], CloudiotEmpty::class);
|
---|
68 | }
|
---|
69 | /**
|
---|
70 | * Gets details about a device. (devices.get)
|
---|
71 | *
|
---|
72 | * @param string $name Required. The name of the device. For example,
|
---|
73 | * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
|
---|
74 | * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
|
---|
75 | * @param array $optParams Optional parameters.
|
---|
76 | *
|
---|
77 | * @opt_param string fieldMask The fields of the `Device` resource to be
|
---|
78 | * returned in the response. If the field mask is unset or empty, all fields are
|
---|
79 | * returned. Fields have to be provided in snake_case format, for example:
|
---|
80 | * `last_heartbeat_time`.
|
---|
81 | * @return Device
|
---|
82 | */
|
---|
83 | public function get($name, $optParams = [])
|
---|
84 | {
|
---|
85 | $params = ['name' => $name];
|
---|
86 | $params = array_merge($params, $optParams);
|
---|
87 | return $this->call('get', [$params], Device::class);
|
---|
88 | }
|
---|
89 | /**
|
---|
90 | * List devices in a device registry.
|
---|
91 | * (devices.listProjectsLocationsRegistriesDevices)
|
---|
92 | *
|
---|
93 | * @param string $parent Required. The device registry path. Required. For
|
---|
94 | * example, `projects/my-project/locations/us-central1/registries/my-registry`.
|
---|
95 | * @param array $optParams Optional parameters.
|
---|
96 | *
|
---|
97 | * @opt_param string deviceIds A list of device string IDs. For example,
|
---|
98 | * `['device0', 'device12']`. If empty, this field is ignored. Maximum IDs:
|
---|
99 | * 10,000
|
---|
100 | * @opt_param string deviceNumIds A list of device numeric IDs. If empty, this
|
---|
101 | * field is ignored. Maximum IDs: 10,000.
|
---|
102 | * @opt_param string fieldMask The fields of the `Device` resource to be
|
---|
103 | * returned in the response. The fields `id` and `num_id` are always returned,
|
---|
104 | * along with any other fields specified in snake_case format, for example:
|
---|
105 | * `last_heartbeat_time`.
|
---|
106 | * @opt_param string gatewayListOptions.associationsDeviceId If set, returns
|
---|
107 | * only the gateways with which the specified device is associated. The device
|
---|
108 | * ID can be numeric (`num_id`) or the user-defined string (`id`). For example,
|
---|
109 | * if `456` is specified, returns only the gateways to which the device with
|
---|
110 | * `num_id` 456 is bound.
|
---|
111 | * @opt_param string gatewayListOptions.associationsGatewayId If set, only
|
---|
112 | * devices associated with the specified gateway are returned. The gateway ID
|
---|
113 | * can be numeric (`num_id`) or the user-defined string (`id`). For example, if
|
---|
114 | * `123` is specified, only devices bound to the gateway with `num_id` 123 are
|
---|
115 | * returned.
|
---|
116 | * @opt_param string gatewayListOptions.gatewayType If `GATEWAY` is specified,
|
---|
117 | * only gateways are returned. If `NON_GATEWAY` is specified, only non-gateway
|
---|
118 | * devices are returned. If `GATEWAY_TYPE_UNSPECIFIED` is specified, all devices
|
---|
119 | * are returned.
|
---|
120 | * @opt_param int pageSize The maximum number of devices to return in the
|
---|
121 | * response. If this value is zero, the service will select a default size. A
|
---|
122 | * call may return fewer objects than requested. A non-empty `next_page_token`
|
---|
123 | * in the response indicates that more data is available.
|
---|
124 | * @opt_param string pageToken The value returned by the last
|
---|
125 | * `ListDevicesResponse`; indicates that this is a continuation of a prior
|
---|
126 | * `ListDevices` call and the system should return the next page of data.
|
---|
127 | * @return ListDevicesResponse
|
---|
128 | */
|
---|
129 | public function listProjectsLocationsRegistriesDevices($parent, $optParams = [])
|
---|
130 | {
|
---|
131 | $params = ['parent' => $parent];
|
---|
132 | $params = array_merge($params, $optParams);
|
---|
133 | return $this->call('list', [$params], ListDevicesResponse::class);
|
---|
134 | }
|
---|
135 | /**
|
---|
136 | * Modifies the configuration for the device, which is eventually sent from the
|
---|
137 | * Cloud IoT Core servers. Returns the modified configuration version and its
|
---|
138 | * metadata. (devices.modifyCloudToDeviceConfig)
|
---|
139 | *
|
---|
140 | * @param string $name Required. The name of the device. For example,
|
---|
141 | * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
|
---|
142 | * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
|
---|
143 | * @param ModifyCloudToDeviceConfigRequest $postBody
|
---|
144 | * @param array $optParams Optional parameters.
|
---|
145 | * @return DeviceConfig
|
---|
146 | */
|
---|
147 | public function modifyCloudToDeviceConfig($name, ModifyCloudToDeviceConfigRequest $postBody, $optParams = [])
|
---|
148 | {
|
---|
149 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
150 | $params = array_merge($params, $optParams);
|
---|
151 | return $this->call('modifyCloudToDeviceConfig', [$params], DeviceConfig::class);
|
---|
152 | }
|
---|
153 | /**
|
---|
154 | * Updates a device. (devices.patch)
|
---|
155 | *
|
---|
156 | * @param string $name The resource path name. For example,
|
---|
157 | * `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or
|
---|
158 | * `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.
|
---|
159 | * When `name` is populated as a response from the service, it always ends in
|
---|
160 | * the device numeric ID.
|
---|
161 | * @param Device $postBody
|
---|
162 | * @param array $optParams Optional parameters.
|
---|
163 | *
|
---|
164 | * @opt_param string updateMask Required. Only updates the `device` fields
|
---|
165 | * indicated by this mask. The field mask must not be empty, and it must not
|
---|
166 | * contain fields that are immutable or only set by the server. Mutable top-
|
---|
167 | * level fields: `credentials`, `blocked`, and `metadata`
|
---|
168 | * @return Device
|
---|
169 | */
|
---|
170 | public function patch($name, Device $postBody, $optParams = [])
|
---|
171 | {
|
---|
172 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
173 | $params = array_merge($params, $optParams);
|
---|
174 | return $this->call('patch', [$params], Device::class);
|
---|
175 | }
|
---|
176 | /**
|
---|
177 | * Sends a command to the specified device. In order for a device to be able to
|
---|
178 | * receive commands, it must: 1) be connected to Cloud IoT Core using the MQTT
|
---|
179 | * protocol, and 2) be subscribed to the group of MQTT topics specified by
|
---|
180 | * /devices/{device-id}/commands/#. This subscription will receive commands at
|
---|
181 | * the top-level topic /devices/{device-id}/commands as well as commands for
|
---|
182 | * subfolders, like /devices/{device-id}/commands/subfolder. Note that
|
---|
183 | * subscribing to specific subfolders is not supported. If the command could not
|
---|
184 | * be delivered to the device, this method will return an error; in particular,
|
---|
185 | * if the device is not subscribed, this method will return FAILED_PRECONDITION.
|
---|
186 | * Otherwise, this method will return OK. If the subscription is QoS 1, at least
|
---|
187 | * once delivery will be guaranteed; for QoS 0, no acknowledgment will be
|
---|
188 | * expected from the device. (devices.sendCommandToDevice)
|
---|
189 | *
|
---|
190 | * @param string $name Required. The name of the device. For example,
|
---|
191 | * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or
|
---|
192 | * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`.
|
---|
193 | * @param SendCommandToDeviceRequest $postBody
|
---|
194 | * @param array $optParams Optional parameters.
|
---|
195 | * @return SendCommandToDeviceResponse
|
---|
196 | */
|
---|
197 | public function sendCommandToDevice($name, SendCommandToDeviceRequest $postBody, $optParams = [])
|
---|
198 | {
|
---|
199 | $params = ['name' => $name, 'postBody' => $postBody];
|
---|
200 | $params = array_merge($params, $optParams);
|
---|
201 | return $this->call('sendCommandToDevice', [$params], SendCommandToDeviceResponse::class);
|
---|
202 | }
|
---|
203 | }
|
---|
204 |
|
---|
205 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
206 | class_alias(ProjectsLocationsRegistriesDevices::class, 'Google_Service_CloudIot_Resource_ProjectsLocationsRegistriesDevices');
|
---|