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\Script\Resource;
|
---|
19 |
|
---|
20 | use Google\Service\Script\ExecutionRequest;
|
---|
21 | use Google\Service\Script\Operation;
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * The "scripts" collection of methods.
|
---|
25 | * Typical usage is:
|
---|
26 | * <code>
|
---|
27 | * $scriptService = new Google\Service\Script(...);
|
---|
28 | * $scripts = $scriptService->scripts;
|
---|
29 | * </code>
|
---|
30 | */
|
---|
31 | class Scripts extends \Google\Service\Resource
|
---|
32 | {
|
---|
33 | /**
|
---|
34 | * Runs a function in an Apps Script project. The script project must be
|
---|
35 | * deployed for use with the Apps Script API and the calling application must
|
---|
36 | * share the same Cloud Platform project. This method requires authorization
|
---|
37 | * with an OAuth 2.0 token that includes at least one of the scopes listed in
|
---|
38 | * the [Authorization](#authorization-scopes) section; script projects that do
|
---|
39 | * not require authorization cannot be executed through this API. To find the
|
---|
40 | * correct scopes to include in the authentication token, open the script
|
---|
41 | * project **Overview** page and scroll down to "Project OAuth Scopes." The
|
---|
42 | * error `403, PERMISSION_DENIED: The caller does not have permission` indicates
|
---|
43 | * that the Cloud Platform project used to authorize the request is not the same
|
---|
44 | * as the one used by the script. (scripts.run)
|
---|
45 | *
|
---|
46 | * @param string $scriptId The script ID of the script to be executed. Find the
|
---|
47 | * script ID on the **Project settings** page under "IDs." As multiple
|
---|
48 | * executable APIs can be deployed in new IDE for same script, this field should
|
---|
49 | * be populated with DeploymentID generated while deploying in new IDE instead
|
---|
50 | * of script ID.
|
---|
51 | * @param ExecutionRequest $postBody
|
---|
52 | * @param array $optParams Optional parameters.
|
---|
53 | * @return Operation
|
---|
54 | * @throws \Google\Service\Exception
|
---|
55 | */
|
---|
56 | public function run($scriptId, ExecutionRequest $postBody, $optParams = [])
|
---|
57 | {
|
---|
58 | $params = ['scriptId' => $scriptId, 'postBody' => $postBody];
|
---|
59 | $params = array_merge($params, $optParams);
|
---|
60 | return $this->call('run', [$params], Operation::class);
|
---|
61 | }
|
---|
62 | }
|
---|
63 |
|
---|
64 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
65 | class_alias(Scripts::class, 'Google_Service_Script_Resource_Scripts');
|
---|