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\Content;
21 use Google\Service\Script\CreateProjectRequest;
22 use Google\Service\Script\Metrics;
23 use Google\Service\Script\Project;
24 
25 /**
26  * The "projects" collection of methods.
27  * Typical usage is:
28  *  <code>
29  *   $scriptService = new Google\Service\Script(...);
30  *   $projects = $scriptService->projects;
31  *  </code>
32  */
33 class Projects extends \Google\Service\Resource
34 {
35   /**
36    * Creates a new, empty script project with no script files and a base manifest
37    * file. (projects.create)
38    *
39    * @param CreateProjectRequest $postBody
40    * @param array $optParams Optional parameters.
41    * @return Project
42    */
43   public function create(CreateProjectRequest $postBody, $optParams = [])
44   {
45     $params = ['postBody' => $postBody];
46     $params = array_merge($params, $optParams);
47     return $this->call('create', [$params], Project::class);
48   }
49   /**
50    * Gets a script project's metadata. (projects.get)
51    *
52    * @param string $scriptId The script project's Drive ID.
53    * @param array $optParams Optional parameters.
54    * @return Project
55    */
56   public function get($scriptId, $optParams = [])
57   {
58     $params = ['scriptId' => $scriptId];
59     $params = array_merge($params, $optParams);
60     return $this->call('get', [$params], Project::class);
61   }
62   /**
63    * Gets the content of the script project, including the code source and
64    * metadata for each script file. (projects.getContent)
65    *
66    * @param string $scriptId The script project's Drive ID.
67    * @param array $optParams Optional parameters.
68    *
69    * @opt_param int versionNumber The version number of the project to retrieve.
70    * If not provided, the project's HEAD version is returned.
71    * @return Content
72    */
73   public function getContent($scriptId, $optParams = [])
74   {
75     $params = ['scriptId' => $scriptId];
76     $params = array_merge($params, $optParams);
77     return $this->call('getContent', [$params], Content::class);
78   }
79   /**
80    * Get metrics data for scripts, such as number of executions and active users.
81    * (projects.getMetrics)
82    *
83    * @param string $scriptId Required field indicating the script to get metrics
84    * for.
85    * @param array $optParams Optional parameters.
86    *
87    * @opt_param string metricsFilter.deploymentId Optional field indicating a
88    * specific deployment to retrieve metrics from.
89    * @opt_param string metricsGranularity Required field indicating what
90    * granularity of metrics are returned.
91    * @return Metrics
92    */
93   public function getMetrics($scriptId, $optParams = [])
94   {
95     $params = ['scriptId' => $scriptId];
96     $params = array_merge($params, $optParams);
97     return $this->call('getMetrics', [$params], Metrics::class);
98   }
99   /**
100    * Updates the content of the specified script project. This content is stored
101    * as the HEAD version, and is used when the script is executed as a trigger, in
102    * the script editor, in add-on preview mode, or as a web app or Apps Script API
103    * in development mode. This clears all the existing files in the project.
104    * (projects.updateContent)
105    *
106    * @param string $scriptId The script project's Drive ID.
107    * @param Content $postBody
108    * @param array $optParams Optional parameters.
109    * @return Content
110    */
111   public function updateContent($scriptId, Content $postBody, $optParams = [])
112   {
113     $params = ['scriptId' => $scriptId, 'postBody' => $postBody];
114     $params = array_merge($params, $optParams);
115     return $this->call('updateContent', [$params], Content::class);
116   }
117 }
118 
119 // Adding a class alias for backwards compatibility with the previous class name.
120 class_alias(Projects::class, 'Google_Service_Script_Resource_Projects');
121