OLD | NEW |
1 // This is a generated file (see the discoveryapis_generator project). | 1 // This is a generated file (see the discoveryapis_generator project). |
2 | 2 |
3 library googleapis.script.v1; | 3 library googleapis.script.v1; |
4 | 4 |
5 import 'dart:core' as core; | 5 import 'dart:core' as core; |
6 import 'dart:async' as async; | 6 import 'dart:async' as async; |
7 import 'dart:convert' as convert; | 7 import 'dart:convert' as convert; |
8 | 8 |
9 import 'package:_discoveryapis_commons/_discoveryapis_commons.dart' as commons; | 9 import 'package:_discoveryapis_commons/_discoveryapis_commons.dart' as commons; |
10 import 'package:http/http.dart' as http; | 10 import 'package:http/http.dart' as http; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } | 59 } |
60 | 60 |
61 | 61 |
62 class ScriptsResourceApi { | 62 class ScriptsResourceApi { |
63 final commons.ApiRequester _requester; | 63 final commons.ApiRequester _requester; |
64 | 64 |
65 ScriptsResourceApi(commons.ApiRequester client) : | 65 ScriptsResourceApi(commons.ApiRequester client) : |
66 _requester = client; | 66 _requester = client; |
67 | 67 |
68 /** | 68 /** |
69 * Runs a function in an Apps Script project that has been deployed for use | 69 * Runs a function in an Apps Script project. The project must be deployed |
70 * with the Apps Script Execution API. This method requires authorization with | 70 * for use with the Apps Script Execution API. |
71 * an OAuth 2.0 token that includes at least one of the scopes listed in the | 71 * |
72 * [Authentication](#authentication) section; script projects that do not | 72 * This method requires authorization with an OAuth 2.0 token that includes at |
73 * require authorization cannot be executed through this API. To find the | 73 * least one of the scopes listed in the [Authorization](#authorization) |
74 * correct scopes to include in the authentication token, open the project in | 74 * section; script projects that do not require authorization cannot be |
75 * the script editor, then select **File > Project properties** and click the | 75 * executed through this API. To find the correct scopes to include in the |
76 * **Scopes** tab. | 76 * authentication token, open the project in the script editor, then select |
| 77 * **File > Project properties** and click the **Scopes** tab. |
77 * | 78 * |
78 * [request] - The metadata request object. | 79 * [request] - The metadata request object. |
79 * | 80 * |
80 * Request parameters: | 81 * Request parameters: |
81 * | 82 * |
82 * [scriptId] - The project key of the script to be executed. To find the | 83 * [scriptId] - The project key of the script to be executed. To find the |
83 * project key, open the project in the script editor, then select **File > | 84 * project key, open |
84 * Project properties**. | 85 * the project in the script editor and select **File > Project properties**. |
85 * | 86 * |
86 * Completes with a [Operation]. | 87 * Completes with a [Operation]. |
87 * | 88 * |
88 * Completes with a [commons.ApiRequestError] if the API endpoint returned an | 89 * Completes with a [commons.ApiRequestError] if the API endpoint returned an |
89 * error. | 90 * error. |
90 * | 91 * |
91 * If the used [http.Client] completes with an error when making a REST call, | 92 * If the used [http.Client] completes with an error when making a REST call, |
92 * this method will complete with the same error. | 93 * this method will complete with the same error. |
93 */ | 94 */ |
94 async.Future<Operation> run(ExecutionRequest request, core.String scriptId) { | 95 async.Future<Operation> run(ExecutionRequest request, core.String scriptId) { |
(...skipping 22 matching lines...) Expand all Loading... |
117 downloadOptions: _downloadOptions); | 118 downloadOptions: _downloadOptions); |
118 return _response.then((data) => new Operation.fromJson(data)); | 119 return _response.then((data) => new Operation.fromJson(data)); |
119 } | 120 } |
120 | 121 |
121 } | 122 } |
122 | 123 |
123 | 124 |
124 | 125 |
125 /** | 126 /** |
126 * An object that provides information about the nature of an error in the Apps | 127 * An object that provides information about the nature of an error in the Apps |
127 * Script Execution API. If an `run` call succeeds but the script function (or | 128 * Script Execution API. If an |
128 * Apps Script itself) throws an exception, the response body's `error` field | 129 * `run` call succeeds but the |
129 * will contain a `Status` object. The `Status` object's `details` field will | 130 * script function (or Apps Script itself) throws an exception, the response |
130 * contain an array with a single one of these `ExecutionError` objects. | 131 * body's `error` field contains a |
| 132 * `Status` object. The `Status` object's `details` field |
| 133 * contains an array with a single one of these `ExecutionError` objects. |
131 */ | 134 */ |
132 class ExecutionError { | 135 class ExecutionError { |
133 /** | 136 /** |
134 * The error message thrown by Apps Script, usually localized into the user's | 137 * The error message thrown by Apps Script, usually localized into the user's |
135 * language. | 138 * language. |
136 */ | 139 */ |
137 core.String errorMessage; | 140 core.String errorMessage; |
138 /** | 141 /** |
139 * The error type, for example `TypeError` or `ReferenceError`. If the error | 142 * The error type, for example `TypeError` or `ReferenceError`. If the error |
140 * type is unavailable, this field is not included. | 143 * type is unavailable, this field is not included. |
(...skipping 29 matching lines...) Expand all Loading... |
170 } | 173 } |
171 if (scriptStackTraceElements != null) { | 174 if (scriptStackTraceElements != null) { |
172 _json["scriptStackTraceElements"] = scriptStackTraceElements.map((value) =
> (value).toJson()).toList(); | 175 _json["scriptStackTraceElements"] = scriptStackTraceElements.map((value) =
> (value).toJson()).toList(); |
173 } | 176 } |
174 return _json; | 177 return _json; |
175 } | 178 } |
176 } | 179 } |
177 | 180 |
178 /** | 181 /** |
179 * A request to run the function in a script. The script is identified by the | 182 * A request to run the function in a script. The script is identified by the |
180 * specified `script_id`. Executing a function on a script will return results | 183 * specified `script_id`. Executing a function on a script returns results |
181 * based on the implementation of the script. | 184 * based on the implementation of the script. |
182 */ | 185 */ |
183 class ExecutionRequest { | 186 class ExecutionRequest { |
184 /** | 187 /** |
185 * If `true` and the user is an owner of the script, the script runs at the | 188 * If `true` and the user is an owner of the script, the script runs at the |
186 * most recently saved version rather than the version deployed for use with | 189 * most recently saved version rather than the version deployed for use with |
187 * the Execution API. Optional; default is `false`. | 190 * the Execution API. Optional; default is `false`. |
188 */ | 191 */ |
189 core.bool devMode; | 192 core.bool devMode; |
190 /** | 193 /** |
191 * The name of the function to execute in the given script. The name does not | 194 * The name of the function to execute in the given script. The name does not |
192 * include parentheses or parameters. | 195 * include parentheses or parameters. |
193 */ | 196 */ |
194 core.String function; | 197 core.String function; |
195 /** | 198 /** |
196 * The parameters to be passed to the function being executed. The type for | 199 * The parameters to be passed to the function being executed. The object type |
197 * each parameter should match the expected type in Apps Script. Parameters | 200 * for each parameter should match the expected type in Apps Script. |
198 * cannot be Apps Script-specific objects (such as a `Document` or | 201 * Parameters cannot be Apps Script-specific object types (such as a |
199 * `Calendar`); they can only be primitive types such as a `string`, `number`, | 202 * `Document` or a `Calendar`); they can only be primitive types such as |
200 * `array`, `object`, or `boolean`. Optional. | 203 * `string`, `number`, `array`, `object`, or `boolean`. Optional. |
201 * | 204 * |
202 * The values for Object must be JSON objects. It can consist of `num`, | 205 * The values for Object must be JSON objects. It can consist of `num`, |
203 * `String`, `bool` and `null` as well as `Map` and `List` values. | 206 * `String`, `bool` and `null` as well as `Map` and `List` values. |
204 */ | 207 */ |
205 core.List<core.Object> parameters; | 208 core.List<core.Object> parameters; |
206 /** This field is not used. */ | 209 /** |
| 210 * For Android add-ons only. An ID that represents the user's current session |
| 211 * in the Android app for Google Docs or Sheets, included as extra data in the |
| 212 * [`Intent`](https://developer.android.com/guide/components/intents-filters.h
tml) |
| 213 * that launches the add-on. When an Android add-on is run with a session |
| 214 * state, it gains the privileges of a |
| 215 * [bound](https://developers.google.com/apps-script/guides/bound) script |
| 216 * — |
| 217 * that is, it can access information like the user's current cursor position |
| 218 * (in Docs) or selected cell (in Sheets). To retrieve the state, call |
| 219 * `Intent.getStringExtra("com.google.android.apps.docs.addons.SessionState")`
. |
| 220 * Optional. |
| 221 */ |
207 core.String sessionState; | 222 core.String sessionState; |
208 | 223 |
209 ExecutionRequest(); | 224 ExecutionRequest(); |
210 | 225 |
211 ExecutionRequest.fromJson(core.Map _json) { | 226 ExecutionRequest.fromJson(core.Map _json) { |
212 if (_json.containsKey("devMode")) { | 227 if (_json.containsKey("devMode")) { |
213 devMode = _json["devMode"]; | 228 devMode = _json["devMode"]; |
214 } | 229 } |
215 if (_json.containsKey("function")) { | 230 if (_json.containsKey("function")) { |
216 function = _json["function"]; | 231 function = _json["function"]; |
(...skipping 19 matching lines...) Expand all Loading... |
236 } | 251 } |
237 if (sessionState != null) { | 252 if (sessionState != null) { |
238 _json["sessionState"] = sessionState; | 253 _json["sessionState"] = sessionState; |
239 } | 254 } |
240 return _json; | 255 return _json; |
241 } | 256 } |
242 } | 257 } |
243 | 258 |
244 /** | 259 /** |
245 * An object that provides the return value of a function executed through the | 260 * An object that provides the return value of a function executed through the |
246 * Apps Script Execution API. If an `run` call succeeds and the script function | 261 * Apps Script Execution API. If a |
247 * returns successfully, the response body's `response` field will contain this | 262 * `run` call succeeds and the |
| 263 * script function returns successfully, the response body's |
| 264 * `response` field contains this |
248 * `ExecutionResponse` object. | 265 * `ExecutionResponse` object. |
249 */ | 266 */ |
250 class ExecutionResponse { | 267 class ExecutionResponse { |
251 /** | 268 /** |
252 * The return value of the script function. The type will match the type | 269 * The return value of the script function. The type matches the object type |
253 * returned in Apps Script. Functions called through the Execution API cannot | 270 * returned in Apps Script. Functions called through the Execution API cannot |
254 * return Apps Script-specific objects (such as a `Document` or `Calendar`); | 271 * return Apps Script-specific objects (such as a `Document` or a `Calendar`); |
255 * they can only return primitive types such as a `string`, `number`, `array`, | 272 * they can only return primitive types such as a `string`, `number`, `array`, |
256 * `object`, or `boolean`. | 273 * `object`, or `boolean`. |
257 * | 274 * |
258 * The values for Object must be JSON objects. It can consist of `num`, | 275 * The values for Object must be JSON objects. It can consist of `num`, |
259 * `String`, `bool` and `null` as well as `Map` and `List` values. | 276 * `String`, `bool` and `null` as well as `Map` and `List` values. |
260 */ | 277 */ |
261 core.Object result; | 278 core.Object result; |
262 /** | |
263 * | |
264 * Possible string values are: | |
265 * - "SUCCESS" : A SUCCESS. | |
266 * - "CANCELED" : A CANCELED. | |
267 */ | |
268 core.String status; | |
269 | 279 |
270 ExecutionResponse(); | 280 ExecutionResponse(); |
271 | 281 |
272 ExecutionResponse.fromJson(core.Map _json) { | 282 ExecutionResponse.fromJson(core.Map _json) { |
273 if (_json.containsKey("result")) { | 283 if (_json.containsKey("result")) { |
274 result = _json["result"]; | 284 result = _json["result"]; |
275 } | 285 } |
276 if (_json.containsKey("status")) { | |
277 status = _json["status"]; | |
278 } | |
279 } | 286 } |
280 | 287 |
281 core.Map toJson() { | 288 core.Map toJson() { |
282 var _json = new core.Map(); | 289 var _json = new core.Map(); |
283 if (result != null) { | 290 if (result != null) { |
284 _json["result"] = result; | 291 _json["result"] = result; |
285 } | 292 } |
286 if (status != null) { | |
287 _json["status"] = status; | |
288 } | |
289 return _json; | 293 return _json; |
290 } | 294 } |
291 } | 295 } |
292 | 296 |
293 /** | 297 /** |
294 * The response will not arrive until the function finishes executing. The | 298 * The response will not arrive until the function finishes executing. The |
295 * maximum runtime is listed in the guide to [limitations in Apps | 299 * maximum runtime is listed in the guide to [limitations in Apps |
296 * Script](https://developers.google.com/apps-script/guides/services/quotas#curr
ent_limitations). | 300 * Script](https://developers.google.com/apps-script/guides/services/quotas#curr
ent_limitations). |
297 * If the script function returns successfully, the `response` field will | 301 * <p>If the script function returns successfully, the `response` field will |
298 * contain an `ExecutionResponse` object with the function's return value in the | 302 * contain an `ExecutionResponse` object with the function's return value in the |
299 * object's `result` field. | 303 * object's `result` field.</p> |
300 * | 304 * <p>If the script function (or Apps Script itself) throws an exception, the |
301 * If the script function (or Apps Script itself) throws an exception, the | |
302 * `error` field will contain a `Status` object. The `Status` object's `details` | 305 * `error` field will contain a `Status` object. The `Status` object's `details` |
303 * field will contain an array with a single `ExecutionError` object that | 306 * field will contain an array with a single `ExecutionError` object that |
304 * provides information about the nature of the error. | 307 * provides information about the nature of the error.</p> |
305 * | 308 * <p>If the `run` call itself fails (for example, because of a malformed |
306 * If the `run` call itself fails (for example, because of a malformed request | 309 * request or an authorization error), the method will return an HTTP response |
307 * or an authorization error), the method will return an HTTP response code in | 310 * code in the 4XX range with a different format for the response body. Client |
308 * the 4XX range with a different format for the response body. Client libraries | 311 * libraries will automatically convert a 4XX response into an exception |
309 * will automatically convert a 4XX response into an exception class. | 312 * class.</p> |
310 */ | 313 */ |
311 class Operation { | 314 class Operation { |
312 /** This field is not used. */ | 315 /** This field is not used. */ |
313 core.bool done; | 316 core.bool done; |
314 /** | 317 /** |
315 * If a `run` call succeeds but the script function (or Apps Script itself) | 318 * If a `run` call succeeds but the script function (or Apps Script itself) |
316 * throws an exception, this field will contain a `Status` object. The | 319 * throws an exception, this field will contain a `Status` object. The |
317 * `Status` object's `details` field will contain an array with a single | 320 * `Status` object's `details` field will contain an array with a single |
318 * `ExecutionError` object that provides information about the nature of the | 321 * `ExecutionError` object that provides information about the nature of the |
319 * error. | 322 * error. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 return _json; | 411 return _json; |
409 } | 412 } |
410 } | 413 } |
411 | 414 |
412 /** | 415 /** |
413 * If a `run` call succeeds but the script function (or Apps Script itself) | 416 * If a `run` call succeeds but the script function (or Apps Script itself) |
414 * throws an exception, the response body's `error` field will contain this | 417 * throws an exception, the response body's `error` field will contain this |
415 * `Status` object. | 418 * `Status` object. |
416 */ | 419 */ |
417 class Status { | 420 class Status { |
418 /** The status code, which should be an enum value of google.rpc.Code. */ | 421 /** |
| 422 * The status code. For this API, this value will always be 3, corresponding |
| 423 * to an INVALID_ARGUMENT error. |
| 424 */ |
419 core.int code; | 425 core.int code; |
420 /** | 426 /** |
421 * An array that contains a single `ExecutionError` object that provides | 427 * An array that contains a single `ExecutionError` object that provides |
422 * information about the nature of the error. | 428 * information about the nature of the error. |
423 * | 429 * |
424 * The values for Object must be JSON objects. It can consist of `num`, | 430 * The values for Object must be JSON objects. It can consist of `num`, |
425 * `String`, `bool` and `null` as well as `Map` and `List` values. | 431 * `String`, `bool` and `null` as well as `Map` and `List` values. |
426 */ | 432 */ |
427 core.List<core.Map<core.String, core.Object>> details; | 433 core.List<core.Map<core.String, core.Object>> details; |
428 /** | 434 /** |
429 * A developer-facing error message, which should be in English. Any | 435 * A developer-facing error message, which is in English. Any user-facing |
430 * user-facing error message should be localized and sent in the | 436 * error message is localized and sent in the |
431 * google.rpc.Status.details field, or localized by the client. | 437 * [`google.rpc.Status.details`](google.rpc.Status.details) field, or |
| 438 * localized by the client. |
432 */ | 439 */ |
433 core.String message; | 440 core.String message; |
434 | 441 |
435 Status(); | 442 Status(); |
436 | 443 |
437 Status.fromJson(core.Map _json) { | 444 Status.fromJson(core.Map _json) { |
438 if (_json.containsKey("code")) { | 445 if (_json.containsKey("code")) { |
439 code = _json["code"]; | 446 code = _json["code"]; |
440 } | 447 } |
441 if (_json.containsKey("details")) { | 448 if (_json.containsKey("details")) { |
(...skipping 11 matching lines...) Expand all Loading... |
453 } | 460 } |
454 if (details != null) { | 461 if (details != null) { |
455 _json["details"] = details; | 462 _json["details"] = details; |
456 } | 463 } |
457 if (message != null) { | 464 if (message != null) { |
458 _json["message"] = message; | 465 _json["message"] = message; |
459 } | 466 } |
460 return _json; | 467 return _json; |
461 } | 468 } |
462 } | 469 } |
OLD | NEW |