OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * Client for the GCD REST API. | 7 * Client for the GCD REST API. |
8 * TODO: Add link to GCD docs. | 8 * TODO: Add link to GCD docs. |
9 */ | 9 */ |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 * deviceId: string, | 25 * deviceId: string, |
26 * deviceDraft: Object | 26 * deviceDraft: Object |
27 * }} | 27 * }} |
28 */ | 28 */ |
29 remoting.gcd.RegistrationTicket; | 29 remoting.gcd.RegistrationTicket; |
30 | 30 |
31 /** | 31 /** |
32 * TODO: Flesh out with typical fields. | 32 * TODO: Flesh out with typical fields. |
33 * @typedef {{ | 33 * @typedef {{ |
34 * id:string, | 34 * id:string, |
35 * name:string | 35 * name:string, |
| 36 * state:(!Object|undefined), |
| 37 * tags:(!Array<string>|undefined) |
36 * }} | 38 * }} |
37 */ | 39 */ |
38 remoting.gcd.Device; | 40 remoting.gcd.Device; |
39 | 41 |
40 /** | 42 /** |
41 * @typedef {!Object} | 43 * @typedef {!Object} |
42 */ | 44 */ |
43 remoting.gcd.DevicePatch; | 45 remoting.gcd.DevicePatch; |
44 | 46 |
45 /** | 47 /** |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 console.error('error finalizing registration ticket'); | 201 console.error('error finalizing registration ticket'); |
200 throw remoting.Error.unexpected(); | 202 throw remoting.Error.unexpected(); |
201 } | 203 } |
202 return responseAsGcdRegistrationTicket(response); | 204 return responseAsGcdRegistrationTicket(response); |
203 }); | 205 }); |
204 }; | 206 }; |
205 | 207 |
206 /** | 208 /** |
207 * Lists devices user has access to. | 209 * Lists devices user has access to. |
208 * TODO: Add link to GCD docs. | 210 * TODO: Add link to GCD docs. |
209 * @param {string=} opt_nameSubstring If present, the list of devices | |
210 * is filtered by GCD such that every device returned contains | |
211 * this string as as a substring of its |name| or |displayName|. | |
212 * @return {!Promise<!Array<remoting.gcd.Device>>} | 211 * @return {!Promise<!Array<remoting.gcd.Device>>} |
213 */ | 212 */ |
214 remoting.gcd.Client.prototype.listDevices = function(opt_nameSubstring) { | 213 remoting.gcd.Client.prototype.listDevices = function() { |
215 return new remoting.Xhr({ | 214 return new remoting.Xhr({ |
216 method: 'GET', | 215 method: 'GET', |
217 url: this.apiBaseUrl_ + '/devices', | 216 url: this.apiBaseUrl_ + '/devices', |
218 urlParams: { | |
219 nameSubstring: opt_nameSubstring || null | |
220 }, | |
221 useIdentity: true, | 217 useIdentity: true, |
222 acceptJson: true | 218 acceptJson: true |
223 }).start().then(function(response) { | 219 }).start().then(function(response) { |
224 if (response.isError()) { | 220 if (response.isError()) { |
225 console.error('error getting device list'); | 221 console.error('error getting device list'); |
226 throw remoting.Error.unexpected(); | 222 throw remoting.Error.unexpected(); |
227 } | 223 } |
228 var hosts = responseAsGcdDeviceListResponse(response); | 224 var hosts = responseAsGcdDeviceListResponse(response); |
229 return hosts.devices || []; | 225 return hosts.devices || []; |
230 }); | 226 }); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 }).start().then(function(response) { | 267 }).start().then(function(response) { |
272 if (response.isError()) { | 268 if (response.isError()) { |
273 console.error('error patching device'); | 269 console.error('error patching device'); |
274 throw remoting.Error.unexpected(); | 270 throw remoting.Error.unexpected(); |
275 } | 271 } |
276 return responseAsGcdDevice(response); | 272 return responseAsGcdDevice(response); |
277 }); | 273 }); |
278 }; | 274 }; |
279 | 275 |
280 })(); | 276 })(); |
OLD | NEW |