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
18namespace Google\Service\Dataproc\Resource;
19
20use Google\Service\Dataproc\Cluster;
21use Google\Service\Dataproc\DiagnoseClusterRequest;
22use Google\Service\Dataproc\GetIamPolicyRequest;
23use Google\Service\Dataproc\InjectCredentialsRequest;
24use Google\Service\Dataproc\ListClustersResponse;
25use Google\Service\Dataproc\Operation;
26use Google\Service\Dataproc\Policy;
27use Google\Service\Dataproc\RepairClusterRequest;
28use Google\Service\Dataproc\SetIamPolicyRequest;
29use Google\Service\Dataproc\StartClusterRequest;
30use Google\Service\Dataproc\StopClusterRequest;
31use Google\Service\Dataproc\TestIamPermissionsRequest;
32use Google\Service\Dataproc\TestIamPermissionsResponse;
33
34/**
35 * The "clusters" collection of methods.
36 * Typical usage is:
37 *  <code>
38 *   $dataprocService = new Google\Service\Dataproc(...);
39 *   $clusters = $dataprocService->clusters;
40 *  </code>
41 */
42class ProjectsRegionsClusters extends \Google\Service\Resource
43{
44  /**
45   * Creates a cluster in a project. The returned Operation.metadata will be
46   * ClusterOperationMetadata (https://cloud.google.com/dataproc/docs/reference/rp
47   * c/google.cloud.dataproc.v1#clusteroperationmetadata). (clusters.create)
48   *
49   * @param string $projectId Required. The ID of the Google Cloud Platform
50   * project that the cluster belongs to.
51   * @param string $region Required. The Dataproc region in which to handle the
52   * request.
53   * @param Cluster $postBody
54   * @param array $optParams Optional parameters.
55   *
56   * @opt_param string actionOnFailedPrimaryWorkers Optional. Failure action when
57   * primary worker creation fails.
58   * @opt_param string requestId Optional. A unique ID used to identify the
59   * request. If the server receives two CreateClusterRequest (https://cloud.googl
60   * e.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#google.cloud.datap
61   * roc.v1.CreateClusterRequest)s with the same id, then the second request will
62   * be ignored and the first google.longrunning.Operation created and stored in
63   * the backend is returned.It is recommended to always set this value to a UUID
64   * (https://en.wikipedia.org/wiki/Universally_unique_identifier).The ID must
65   * contain only letters (a-z, A-Z), numbers (0-9), underscores (_), and hyphens
66   * (-). The maximum length is 40 characters.
67   * @return Operation
68   */
69  public function create($projectId, $region, Cluster $postBody, $optParams = [])
70  {
71    $params = ['projectId' => $projectId, 'region' => $region, 'postBody' => $postBody];
72    $params = array_merge($params, $optParams);
73    return $this->call('create', [$params], Operation::class);
74  }
75  /**
76   * Deletes a cluster in a project. The returned Operation.metadata will be
77   * ClusterOperationMetadata (https://cloud.google.com/dataproc/docs/reference/rp
78   * c/google.cloud.dataproc.v1#clusteroperationmetadata). (clusters.delete)
79   *
80   * @param string $projectId Required. The ID of the Google Cloud Platform
81   * project that the cluster belongs to.
82   * @param string $region Required. The Dataproc region in which to handle the
83   * request.
84   * @param string $clusterName Required. The cluster name.
85   * @param array $optParams Optional parameters.
86   *
87   * @opt_param string clusterUuid Optional. Specifying the cluster_uuid means the
88   * RPC should fail (with error NOT_FOUND) if cluster with specified UUID does
89   * not exist.
90   * @opt_param string requestId Optional. A unique ID used to identify the
91   * request. If the server receives two DeleteClusterRequest (https://cloud.googl
92   * e.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#google.cloud.datap
93   * roc.v1.DeleteClusterRequest)s with the same id, then the second request will
94   * be ignored and the first google.longrunning.Operation created and stored in
95   * the backend is returned.It is recommended to always set this value to a UUID
96   * (https://en.wikipedia.org/wiki/Universally_unique_identifier).The ID must
97   * contain only letters (a-z, A-Z), numbers (0-9), underscores (_), and hyphens
98   * (-). The maximum length is 40 characters.
99   * @return Operation
100   */
101  public function delete($projectId, $region, $clusterName, $optParams = [])
102  {
103    $params = ['projectId' => $projectId, 'region' => $region, 'clusterName' => $clusterName];
104    $params = array_merge($params, $optParams);
105    return $this->call('delete', [$params], Operation::class);
106  }
107  /**
108   * Gets cluster diagnostic information. The returned Operation.metadata will be
109   * ClusterOperationMetadata (https://cloud.google.com/dataproc/docs/reference/rp
110   * c/google.cloud.dataproc.v1#clusteroperationmetadata). After the operation
111   * completes, Operation.response contains DiagnoseClusterResults (https://cloud.
112   * google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#diagnoseclust
113   * erresults). (clusters.diagnose)
114   *
115   * @param string $projectId Required. The ID of the Google Cloud Platform
116   * project that the cluster belongs to.
117   * @param string $region Required. The Dataproc region in which to handle the
118   * request.
119   * @param string $clusterName Required. The cluster name.
120   * @param DiagnoseClusterRequest $postBody
121   * @param array $optParams Optional parameters.
122   * @return Operation
123   */
124  public function diagnose($projectId, $region, $clusterName, DiagnoseClusterRequest $postBody, $optParams = [])
125  {
126    $params = ['projectId' => $projectId, 'region' => $region, 'clusterName' => $clusterName, 'postBody' => $postBody];
127    $params = array_merge($params, $optParams);
128    return $this->call('diagnose', [$params], Operation::class);
129  }
130  /**
131   * Gets the resource representation for a cluster in a project. (clusters.get)
132   *
133   * @param string $projectId Required. The ID of the Google Cloud Platform
134   * project that the cluster belongs to.
135   * @param string $region Required. The Dataproc region in which to handle the
136   * request.
137   * @param string $clusterName Required. The cluster name.
138   * @param array $optParams Optional parameters.
139   * @return Cluster
140   */
141  public function get($projectId, $region, $clusterName, $optParams = [])
142  {
143    $params = ['projectId' => $projectId, 'region' => $region, 'clusterName' => $clusterName];
144    $params = array_merge($params, $optParams);
145    return $this->call('get', [$params], Cluster::class);
146  }
147  /**
148   * Gets the access control policy for a resource. Returns an empty policy if the
149   * resource exists and does not have a policy set. (clusters.getIamPolicy)
150   *
151   * @param string $resource REQUIRED: The resource for which the policy is being
152   * requested. See the operation documentation for the appropriate value for this
153   * field.
154   * @param GetIamPolicyRequest $postBody
155   * @param array $optParams Optional parameters.
156   * @return Policy
157   */
158  public function getIamPolicy($resource, GetIamPolicyRequest $postBody, $optParams = [])
159  {
160    $params = ['resource' => $resource, 'postBody' => $postBody];
161    $params = array_merge($params, $optParams);
162    return $this->call('getIamPolicy', [$params], Policy::class);
163  }
164  /**
165   * Inject encrypted credentials into all of the VMs in a cluster.The target
166   * cluster must be a personal auth cluster assigned to the user who is issuing
167   * the RPC. (clusters.injectCredentials)
168   *
169   * @param string $project Required. The ID of the Google Cloud Platform project
170   * the cluster belongs to, of the form projects/.
171   * @param string $region Required. The region containing the cluster, of the
172   * form regions/.
173   * @param string $cluster Required. The cluster, in the form clusters/.
174   * @param InjectCredentialsRequest $postBody
175   * @param array $optParams Optional parameters.
176   * @return Operation
177   */
178  public function injectCredentials($project, $region, $cluster, InjectCredentialsRequest $postBody, $optParams = [])
179  {
180    $params = ['project' => $project, 'region' => $region, 'cluster' => $cluster, 'postBody' => $postBody];
181    $params = array_merge($params, $optParams);
182    return $this->call('injectCredentials', [$params], Operation::class);
183  }
184  /**
185   * Lists all regions/{region}/clusters in a project alphabetically.
186   * (clusters.listProjectsRegionsClusters)
187   *
188   * @param string $projectId Required. The ID of the Google Cloud Platform
189   * project that the cluster belongs to.
190   * @param string $region Required. The Dataproc region in which to handle the
191   * request.
192   * @param array $optParams Optional parameters.
193   *
194   * @opt_param string filter Optional. A filter constraining the clusters to
195   * list. Filters are case-sensitive and have the following syntax:field = value
196   * AND field = value ...where field is one of status.state, clusterName, or
197   * labels.[KEY], and [KEY] is a label key. value can be * to match all values.
198   * status.state can be one of the following: ACTIVE, INACTIVE, CREATING,
199   * RUNNING, ERROR, DELETING, or UPDATING. ACTIVE contains the CREATING,
200   * UPDATING, and RUNNING states. INACTIVE contains the DELETING and ERROR
201   * states. clusterName is the name of the cluster provided at creation time.
202   * Only the logical AND operator is supported; space-separated items are treated
203   * as having an implicit AND operator.Example filter:status.state = ACTIVE AND
204   * clusterName = mycluster AND labels.env = staging AND labels.starred = *
205   * @opt_param int pageSize Optional. The standard List page size.
206   * @opt_param string pageToken Optional. The standard List page token.
207   * @return ListClustersResponse
208   */
209  public function listProjectsRegionsClusters($projectId, $region, $optParams = [])
210  {
211    $params = ['projectId' => $projectId, 'region' => $region];
212    $params = array_merge($params, $optParams);
213    return $this->call('list', [$params], ListClustersResponse::class);
214  }
215  /**
216   * Updates a cluster in a project. The returned Operation.metadata will be
217   * ClusterOperationMetadata (https://cloud.google.com/dataproc/docs/reference/rp
218   * c/google.cloud.dataproc.v1#clusteroperationmetadata). The cluster must be in
219   * a RUNNING state or an error is returned. (clusters.patch)
220   *
221   * @param string $projectId Required. The ID of the Google Cloud Platform
222   * project the cluster belongs to.
223   * @param string $region Required. The Dataproc region in which to handle the
224   * request.
225   * @param string $clusterName Required. The cluster name.
226   * @param Cluster $postBody
227   * @param array $optParams Optional parameters.
228   *
229   * @opt_param string gracefulDecommissionTimeout Optional. Timeout for graceful
230   * YARN decomissioning. Graceful decommissioning allows removing nodes from the
231   * cluster without interrupting jobs in progress. Timeout specifies how long to
232   * wait for jobs in progress to finish before forcefully removing nodes (and
233   * potentially interrupting jobs). Default timeout is 0 (for forceful
234   * decommission), and the maximum allowed timeout is 1 day. (see JSON
235   * representation of Duration (https://developers.google.com/protocol-
236   * buffers/docs/proto3#json)).Only supported on Dataproc image versions 1.2 and
237   * higher.
238   * @opt_param string requestId Optional. A unique ID used to identify the
239   * request. If the server receives two UpdateClusterRequest (https://cloud.googl
240   * e.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#google.cloud.datap
241   * roc.v1.UpdateClusterRequest)s with the same id, then the second request will
242   * be ignored and the first google.longrunning.Operation created and stored in
243   * the backend is returned.It is recommended to always set this value to a UUID
244   * (https://en.wikipedia.org/wiki/Universally_unique_identifier).The ID must
245   * contain only letters (a-z, A-Z), numbers (0-9), underscores (_), and hyphens
246   * (-). The maximum length is 40 characters.
247   * @opt_param string updateMask Required. Specifies the path, relative to
248   * Cluster, of the field to update. For example, to change the number of workers
249   * in a cluster to 5, the update_mask parameter would be specified as
250   * config.worker_config.num_instances, and the PATCH request body would specify
251   * the new value, as follows: { "config":{ "workerConfig":{ "numInstances":"5" }
252   * } } Similarly, to change the number of preemptible workers in a cluster to 5,
253   * the update_mask parameter would be
254   * config.secondary_worker_config.num_instances, and the PATCH request body
255   * would be set as follows: { "config":{ "secondaryWorkerConfig":{
256   * "numInstances":"5" } } } *Note:* Currently, only the following fields can be
257   * updated: *Mask* *Purpose* *labels* Update labels
258   * *config.worker_config.num_instances* Resize primary worker group
259   * *config.secondary_worker_config.num_instances* Resize secondary worker group
260   * config.autoscaling_config.policy_uri Use, stop using, or change autoscaling
261   * policies
262   * @return Operation
263   */
264  public function patch($projectId, $region, $clusterName, Cluster $postBody, $optParams = [])
265  {
266    $params = ['projectId' => $projectId, 'region' => $region, 'clusterName' => $clusterName, 'postBody' => $postBody];
267    $params = array_merge($params, $optParams);
268    return $this->call('patch', [$params], Operation::class);
269  }
270  /**
271   * Repairs a cluster. (clusters.repair)
272   *
273   * @param string $projectId Required. The ID of the Google Cloud Platform
274   * project the cluster belongs to.
275   * @param string $region Required. The Dataproc region in which to handle the
276   * request.
277   * @param string $clusterName Required. The cluster name.
278   * @param RepairClusterRequest $postBody
279   * @param array $optParams Optional parameters.
280   * @return Operation
281   */
282  public function repair($projectId, $region, $clusterName, RepairClusterRequest $postBody, $optParams = [])
283  {
284    $params = ['projectId' => $projectId, 'region' => $region, 'clusterName' => $clusterName, 'postBody' => $postBody];
285    $params = array_merge($params, $optParams);
286    return $this->call('repair', [$params], Operation::class);
287  }
288  /**
289   * Sets the access control policy on the specified resource. Replaces any
290   * existing policy.Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
291   * errors. (clusters.setIamPolicy)
292   *
293   * @param string $resource REQUIRED: The resource for which the policy is being
294   * specified. See the operation documentation for the appropriate value for this
295   * field.
296   * @param SetIamPolicyRequest $postBody
297   * @param array $optParams Optional parameters.
298   * @return Policy
299   */
300  public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
301  {
302    $params = ['resource' => $resource, 'postBody' => $postBody];
303    $params = array_merge($params, $optParams);
304    return $this->call('setIamPolicy', [$params], Policy::class);
305  }
306  /**
307   * Starts a cluster in a project. (clusters.start)
308   *
309   * @param string $projectId Required. The ID of the Google Cloud Platform
310   * project the cluster belongs to.
311   * @param string $region Required. The Dataproc region in which to handle the
312   * request.
313   * @param string $clusterName Required. The cluster name.
314   * @param StartClusterRequest $postBody
315   * @param array $optParams Optional parameters.
316   * @return Operation
317   */
318  public function start($projectId, $region, $clusterName, StartClusterRequest $postBody, $optParams = [])
319  {
320    $params = ['projectId' => $projectId, 'region' => $region, 'clusterName' => $clusterName, 'postBody' => $postBody];
321    $params = array_merge($params, $optParams);
322    return $this->call('start', [$params], Operation::class);
323  }
324  /**
325   * Stops a cluster in a project. (clusters.stop)
326   *
327   * @param string $projectId Required. The ID of the Google Cloud Platform
328   * project the cluster belongs to.
329   * @param string $region Required. The Dataproc region in which to handle the
330   * request.
331   * @param string $clusterName Required. The cluster name.
332   * @param StopClusterRequest $postBody
333   * @param array $optParams Optional parameters.
334   * @return Operation
335   */
336  public function stop($projectId, $region, $clusterName, StopClusterRequest $postBody, $optParams = [])
337  {
338    $params = ['projectId' => $projectId, 'region' => $region, 'clusterName' => $clusterName, 'postBody' => $postBody];
339    $params = array_merge($params, $optParams);
340    return $this->call('stop', [$params], Operation::class);
341  }
342  /**
343   * Returns permissions that a caller has on the specified resource. If the
344   * resource does not exist, this will return an empty set of permissions, not a
345   * NOT_FOUND error.Note: This operation is designed to be used for building
346   * permission-aware UIs and command-line tools, not for authorization checking.
347   * This operation may "fail open" without warning. (clusters.testIamPermissions)
348   *
349   * @param string $resource REQUIRED: The resource for which the policy detail is
350   * being requested. See the operation documentation for the appropriate value
351   * for this field.
352   * @param TestIamPermissionsRequest $postBody
353   * @param array $optParams Optional parameters.
354   * @return TestIamPermissionsResponse
355   */
356  public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
357  {
358    $params = ['resource' => $resource, 'postBody' => $postBody];
359    $params = array_merge($params, $optParams);
360    return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
361  }
362}
363
364// Adding a class alias for backwards compatibility with the previous class name.
365class_alias(ProjectsRegionsClusters::class, 'Google_Service_Dataproc_Resource_ProjectsRegionsClusters');
366