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\DataprocEmpty;
21use Google\Service\Dataproc\GetIamPolicyRequest;
22use Google\Service\Dataproc\InstantiateWorkflowTemplateRequest;
23use Google\Service\Dataproc\ListWorkflowTemplatesResponse;
24use Google\Service\Dataproc\Operation;
25use Google\Service\Dataproc\Policy;
26use Google\Service\Dataproc\SetIamPolicyRequest;
27use Google\Service\Dataproc\TestIamPermissionsRequest;
28use Google\Service\Dataproc\TestIamPermissionsResponse;
29use Google\Service\Dataproc\WorkflowTemplate;
30
31/**
32 * The "workflowTemplates" collection of methods.
33 * Typical usage is:
34 *  <code>
35 *   $dataprocService = new Google\Service\Dataproc(...);
36 *   $workflowTemplates = $dataprocService->workflowTemplates;
37 *  </code>
38 */
39class ProjectsLocationsWorkflowTemplates extends \Google\Service\Resource
40{
41  /**
42   * Creates new workflow template. (workflowTemplates.create)
43   *
44   * @param string $parent Required. The resource name of the region or location,
45   * as described in https://cloud.google.com/apis/design/resource_names. For
46   * projects.regions.workflowTemplates.create, the resource name of the region
47   * has the following format: projects/{project_id}/regions/{region} For
48   * projects.locations.workflowTemplates.create, the resource name of the
49   * location has the following format: projects/{project_id}/locations/{location}
50   * @param WorkflowTemplate $postBody
51   * @param array $optParams Optional parameters.
52   * @return WorkflowTemplate
53   */
54  public function create($parent, WorkflowTemplate $postBody, $optParams = [])
55  {
56    $params = ['parent' => $parent, 'postBody' => $postBody];
57    $params = array_merge($params, $optParams);
58    return $this->call('create', [$params], WorkflowTemplate::class);
59  }
60  /**
61   * Deletes a workflow template. It does not cancel in-progress workflows.
62   * (workflowTemplates.delete)
63   *
64   * @param string $name Required. The resource name of the workflow template, as
65   * described in https://cloud.google.com/apis/design/resource_names. For
66   * projects.regions.workflowTemplates.delete, the resource name of the template
67   * has the following format:
68   * projects/{project_id}/regions/{region}/workflowTemplates/{template_id} For
69   * projects.locations.workflowTemplates.instantiate, the resource name of the
70   * template has the following format:
71   * projects/{project_id}/locations/{location}/workflowTemplates/{template_id}
72   * @param array $optParams Optional parameters.
73   *
74   * @opt_param int version Optional. The version of workflow template to delete.
75   * If specified, will only delete the template if the current server version
76   * matches specified version.
77   * @return DataprocEmpty
78   */
79  public function delete($name, $optParams = [])
80  {
81    $params = ['name' => $name];
82    $params = array_merge($params, $optParams);
83    return $this->call('delete', [$params], DataprocEmpty::class);
84  }
85  /**
86   * Retrieves the latest workflow template.Can retrieve previously instantiated
87   * template by specifying optional version parameter. (workflowTemplates.get)
88   *
89   * @param string $name Required. The resource name of the workflow template, as
90   * described in https://cloud.google.com/apis/design/resource_names. For
91   * projects.regions.workflowTemplates.get, the resource name of the template has
92   * the following format:
93   * projects/{project_id}/regions/{region}/workflowTemplates/{template_id} For
94   * projects.locations.workflowTemplates.get, the resource name of the template
95   * has the following format:
96   * projects/{project_id}/locations/{location}/workflowTemplates/{template_id}
97   * @param array $optParams Optional parameters.
98   *
99   * @opt_param int version Optional. The version of workflow template to
100   * retrieve. Only previously instantiated versions can be retrieved.If
101   * unspecified, retrieves the current version.
102   * @return WorkflowTemplate
103   */
104  public function get($name, $optParams = [])
105  {
106    $params = ['name' => $name];
107    $params = array_merge($params, $optParams);
108    return $this->call('get', [$params], WorkflowTemplate::class);
109  }
110  /**
111   * Gets the access control policy for a resource. Returns an empty policy if the
112   * resource exists and does not have a policy set.
113   * (workflowTemplates.getIamPolicy)
114   *
115   * @param string $resource REQUIRED: The resource for which the policy is being
116   * requested. See the operation documentation for the appropriate value for this
117   * field.
118   * @param GetIamPolicyRequest $postBody
119   * @param array $optParams Optional parameters.
120   * @return Policy
121   */
122  public function getIamPolicy($resource, GetIamPolicyRequest $postBody, $optParams = [])
123  {
124    $params = ['resource' => $resource, 'postBody' => $postBody];
125    $params = array_merge($params, $optParams);
126    return $this->call('getIamPolicy', [$params], Policy::class);
127  }
128  /**
129   * Instantiates a template and begins execution.The returned Operation can be
130   * used to track execution of workflow by polling operations.get. The Operation
131   * will complete when entire workflow is finished.The running workflow can be
132   * aborted via operations.cancel. This will cause any inflight jobs to be
133   * cancelled and workflow-owned clusters to be deleted.The Operation.metadata
134   * will be WorkflowMetadata (https://cloud.google.com/dataproc/docs/reference/rp
135   * c/google.cloud.dataproc.v1#workflowmetadata). Also see Using WorkflowMetadata
136   * (https://cloud.google.com/dataproc/docs/concepts/workflows/debugging#using_wo
137   * rkflowmetadata).On successful completion, Operation.response will be Empty.
138   * (workflowTemplates.instantiate)
139   *
140   * @param string $name Required. The resource name of the workflow template, as
141   * described in https://cloud.google.com/apis/design/resource_names. For
142   * projects.regions.workflowTemplates.instantiate, the resource name of the
143   * template has the following format:
144   * projects/{project_id}/regions/{region}/workflowTemplates/{template_id} For
145   * projects.locations.workflowTemplates.instantiate, the resource name of the
146   * template has the following format:
147   * projects/{project_id}/locations/{location}/workflowTemplates/{template_id}
148   * @param InstantiateWorkflowTemplateRequest $postBody
149   * @param array $optParams Optional parameters.
150   * @return Operation
151   */
152  public function instantiate($name, InstantiateWorkflowTemplateRequest $postBody, $optParams = [])
153  {
154    $params = ['name' => $name, 'postBody' => $postBody];
155    $params = array_merge($params, $optParams);
156    return $this->call('instantiate', [$params], Operation::class);
157  }
158  /**
159   * Instantiates a template and begins execution.This method is equivalent to
160   * executing the sequence CreateWorkflowTemplate, InstantiateWorkflowTemplate,
161   * DeleteWorkflowTemplate.The returned Operation can be used to track execution
162   * of workflow by polling operations.get. The Operation will complete when
163   * entire workflow is finished.The running workflow can be aborted via
164   * operations.cancel. This will cause any inflight jobs to be cancelled and
165   * workflow-owned clusters to be deleted.The Operation.metadata will be
166   * WorkflowMetadata (https://cloud.google.com/dataproc/docs/reference/rpc/google
167   * .cloud.dataproc.v1#workflowmetadata). Also see Using WorkflowMetadata (https:
168   * //cloud.google.com/dataproc/docs/concepts/workflows/debugging#using_workflowm
169   * etadata).On successful completion, Operation.response will be Empty.
170   * (workflowTemplates.instantiateInline)
171   *
172   * @param string $parent Required. The resource name of the region or location,
173   * as described in https://cloud.google.com/apis/design/resource_names. For
174   * projects.regions.workflowTemplates,instantiateinline, the resource name of
175   * the region has the following format: projects/{project_id}/regions/{region}
176   * For projects.locations.workflowTemplates.instantiateinline, the resource name
177   * of the location has the following format:
178   * projects/{project_id}/locations/{location}
179   * @param WorkflowTemplate $postBody
180   * @param array $optParams Optional parameters.
181   *
182   * @opt_param string requestId Optional. A tag that prevents multiple concurrent
183   * workflow instances with the same tag from running. This mitigates risk of
184   * concurrent instances started due to retries.It is recommended to always set
185   * this value to a UUID
186   * (https://en.wikipedia.org/wiki/Universally_unique_identifier).The tag must
187   * contain only letters (a-z, A-Z), numbers (0-9), underscores (_), and hyphens
188   * (-). The maximum length is 40 characters.
189   * @return Operation
190   */
191  public function instantiateInline($parent, WorkflowTemplate $postBody, $optParams = [])
192  {
193    $params = ['parent' => $parent, 'postBody' => $postBody];
194    $params = array_merge($params, $optParams);
195    return $this->call('instantiateInline', [$params], Operation::class);
196  }
197  /**
198   * Lists workflows that match the specified filter in the request.
199   * (workflowTemplates.listProjectsLocationsWorkflowTemplates)
200   *
201   * @param string $parent Required. The resource name of the region or location,
202   * as described in https://cloud.google.com/apis/design/resource_names. For
203   * projects.regions.workflowTemplates,list, the resource name of the region has
204   * the following format: projects/{project_id}/regions/{region} For
205   * projects.locations.workflowTemplates.list, the resource name of the location
206   * has the following format: projects/{project_id}/locations/{location}
207   * @param array $optParams Optional parameters.
208   *
209   * @opt_param int pageSize Optional. The maximum number of results to return in
210   * each response.
211   * @opt_param string pageToken Optional. The page token, returned by a previous
212   * call, to request the next page of results.
213   * @return ListWorkflowTemplatesResponse
214   */
215  public function listProjectsLocationsWorkflowTemplates($parent, $optParams = [])
216  {
217    $params = ['parent' => $parent];
218    $params = array_merge($params, $optParams);
219    return $this->call('list', [$params], ListWorkflowTemplatesResponse::class);
220  }
221  /**
222   * Sets the access control policy on the specified resource. Replaces any
223   * existing policy.Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
224   * errors. (workflowTemplates.setIamPolicy)
225   *
226   * @param string $resource REQUIRED: The resource for which the policy is being
227   * specified. See the operation documentation for the appropriate value for this
228   * field.
229   * @param SetIamPolicyRequest $postBody
230   * @param array $optParams Optional parameters.
231   * @return Policy
232   */
233  public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
234  {
235    $params = ['resource' => $resource, 'postBody' => $postBody];
236    $params = array_merge($params, $optParams);
237    return $this->call('setIamPolicy', [$params], Policy::class);
238  }
239  /**
240   * Returns permissions that a caller has on the specified resource. If the
241   * resource does not exist, this will return an empty set of permissions, not a
242   * NOT_FOUND error.Note: This operation is designed to be used for building
243   * permission-aware UIs and command-line tools, not for authorization checking.
244   * This operation may "fail open" without warning.
245   * (workflowTemplates.testIamPermissions)
246   *
247   * @param string $resource REQUIRED: The resource for which the policy detail is
248   * being requested. See the operation documentation for the appropriate value
249   * for this field.
250   * @param TestIamPermissionsRequest $postBody
251   * @param array $optParams Optional parameters.
252   * @return TestIamPermissionsResponse
253   */
254  public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
255  {
256    $params = ['resource' => $resource, 'postBody' => $postBody];
257    $params = array_merge($params, $optParams);
258    return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
259  }
260  /**
261   * Updates (replaces) workflow template. The updated template must contain
262   * version that matches the current server version. (workflowTemplates.update)
263   *
264   * @param string $name Output only. The resource name of the workflow template,
265   * as described in https://cloud.google.com/apis/design/resource_names. For
266   * projects.regions.workflowTemplates, the resource name of the template has the
267   * following format:
268   * projects/{project_id}/regions/{region}/workflowTemplates/{template_id} For
269   * projects.locations.workflowTemplates, the resource name of the template has
270   * the following format:
271   * projects/{project_id}/locations/{location}/workflowTemplates/{template_id}
272   * @param WorkflowTemplate $postBody
273   * @param array $optParams Optional parameters.
274   * @return WorkflowTemplate
275   */
276  public function update($name, WorkflowTemplate $postBody, $optParams = [])
277  {
278    $params = ['name' => $name, 'postBody' => $postBody];
279    $params = array_merge($params, $optParams);
280    return $this->call('update', [$params], WorkflowTemplate::class);
281  }
282}
283
284// Adding a class alias for backwards compatibility with the previous class name.
285class_alias(ProjectsLocationsWorkflowTemplates::class, 'Google_Service_Dataproc_Resource_ProjectsLocationsWorkflowTemplates');
286