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\DatabaseMigrationService\Resource;
19
20use Google\Service\DatabaseMigrationService\GenerateSshScriptRequest;
21use Google\Service\DatabaseMigrationService\ListMigrationJobsResponse;
22use Google\Service\DatabaseMigrationService\MigrationJob;
23use Google\Service\DatabaseMigrationService\Operation;
24use Google\Service\DatabaseMigrationService\Policy;
25use Google\Service\DatabaseMigrationService\PromoteMigrationJobRequest;
26use Google\Service\DatabaseMigrationService\RestartMigrationJobRequest;
27use Google\Service\DatabaseMigrationService\ResumeMigrationJobRequest;
28use Google\Service\DatabaseMigrationService\SetIamPolicyRequest;
29use Google\Service\DatabaseMigrationService\SshScript;
30use Google\Service\DatabaseMigrationService\StartMigrationJobRequest;
31use Google\Service\DatabaseMigrationService\StopMigrationJobRequest;
32use Google\Service\DatabaseMigrationService\TestIamPermissionsRequest;
33use Google\Service\DatabaseMigrationService\TestIamPermissionsResponse;
34use Google\Service\DatabaseMigrationService\VerifyMigrationJobRequest;
35
36/**
37 * The "migrationJobs" collection of methods.
38 * Typical usage is:
39 *  <code>
40 *   $datamigrationService = new Google\Service\DatabaseMigrationService(...);
41 *   $migrationJobs = $datamigrationService->migrationJobs;
42 *  </code>
43 */
44class ProjectsLocationsMigrationJobs extends \Google\Service\Resource
45{
46  /**
47   * Creates a new migration job in a given project and location.
48   * (migrationJobs.create)
49   *
50   * @param string $parent Required. The parent, which owns this collection of
51   * migration jobs.
52   * @param MigrationJob $postBody
53   * @param array $optParams Optional parameters.
54   *
55   * @opt_param string migrationJobId Required. The ID of the instance to create.
56   * @opt_param string requestId A unique id used to identify the request. If the
57   * server receives two requests with the same id, then the second request will
58   * be ignored. It is recommended to always set this value to a UUID. The id must
59   * contain only letters (a-z, A-Z), numbers (0-9), underscores (_), and hyphens
60   * (-). The maximum length is 40 characters.
61   * @return Operation
62   */
63  public function create($parent, MigrationJob $postBody, $optParams = [])
64  {
65    $params = ['parent' => $parent, 'postBody' => $postBody];
66    $params = array_merge($params, $optParams);
67    return $this->call('create', [$params], Operation::class);
68  }
69  /**
70   * Deletes a single migration job. (migrationJobs.delete)
71   *
72   * @param string $name Required. Name of the migration job resource to delete.
73   * @param array $optParams Optional parameters.
74   *
75   * @opt_param bool force The destination CloudSQL connection profile is always
76   * deleted with the migration job. In case of force delete, the destination
77   * CloudSQL replica database is also deleted.
78   * @opt_param string requestId A unique id used to identify the request. If the
79   * server receives two requests with the same id, then the second request will
80   * be ignored. It is recommended to always set this value to a UUID. The id must
81   * contain only letters (a-z, A-Z), numbers (0-9), underscores (_), and hyphens
82   * (-). The maximum length is 40 characters.
83   * @return Operation
84   */
85  public function delete($name, $optParams = [])
86  {
87    $params = ['name' => $name];
88    $params = array_merge($params, $optParams);
89    return $this->call('delete', [$params], Operation::class);
90  }
91  /**
92   * Generate a SSH configuration script to configure the reverse SSH
93   * connectivity. (migrationJobs.generateSshScript)
94   *
95   * @param string $migrationJob Name of the migration job resource to generate
96   * the SSH script.
97   * @param GenerateSshScriptRequest $postBody
98   * @param array $optParams Optional parameters.
99   * @return SshScript
100   */
101  public function generateSshScript($migrationJob, GenerateSshScriptRequest $postBody, $optParams = [])
102  {
103    $params = ['migrationJob' => $migrationJob, 'postBody' => $postBody];
104    $params = array_merge($params, $optParams);
105    return $this->call('generateSshScript', [$params], SshScript::class);
106  }
107  /**
108   * Gets details of a single migration job. (migrationJobs.get)
109   *
110   * @param string $name Required. Name of the migration job resource to get.
111   * @param array $optParams Optional parameters.
112   * @return MigrationJob
113   */
114  public function get($name, $optParams = [])
115  {
116    $params = ['name' => $name];
117    $params = array_merge($params, $optParams);
118    return $this->call('get', [$params], MigrationJob::class);
119  }
120  /**
121   * Gets the access control policy for a resource. Returns an empty policy if the
122   * resource exists and does not have a policy set. (migrationJobs.getIamPolicy)
123   *
124   * @param string $resource REQUIRED: The resource for which the policy is being
125   * requested. See the operation documentation for the appropriate value for this
126   * field.
127   * @param array $optParams Optional parameters.
128   *
129   * @opt_param int options.requestedPolicyVersion Optional. The maximum policy
130   * version that will be used to format the policy. Valid values are 0, 1, and 3.
131   * Requests specifying an invalid value will be rejected. Requests for policies
132   * with any conditional role bindings must specify version 3. Policies with no
133   * conditional role bindings may specify any valid value or leave the field
134   * unset. The policy in the response might use the policy version that you
135   * specified, or it might use a lower policy version. For example, if you
136   * specify version 3, but the policy has no conditional role bindings, the
137   * response uses version 1. To learn which resources support conditions in their
138   * IAM policies, see the [IAM
139   * documentation](https://cloud.google.com/iam/help/conditions/resource-
140   * policies).
141   * @return Policy
142   */
143  public function getIamPolicy($resource, $optParams = [])
144  {
145    $params = ['resource' => $resource];
146    $params = array_merge($params, $optParams);
147    return $this->call('getIamPolicy', [$params], Policy::class);
148  }
149  /**
150   * Lists migration jobs in a given project and location.
151   * (migrationJobs.listProjectsLocationsMigrationJobs)
152   *
153   * @param string $parent Required. The parent, which owns this collection of
154   * migrationJobs.
155   * @param array $optParams Optional parameters.
156   *
157   * @opt_param string filter A filter expression that filters migration jobs
158   * listed in the response. The expression must specify the field name, a
159   * comparison operator, and the value that you want to use for filtering. The
160   * value must be a string, a number, or a boolean. The comparison operator must
161   * be either =, !=, >, or <. For example, list migration jobs created this year
162   * by specifying **createTime %gt; 2020-01-01T00:00:00.000000000Z.** You can
163   * also filter nested fields. For example, you could specify
164   * **reverseSshConnectivity.vmIp = "1.2.3.4"** to select all migration jobs
165   * connecting through the specific SSH tunnel bastion.
166   * @opt_param string orderBy Sort the results based on the migration job name.
167   * Valid values are: "name", "name asc", and "name desc".
168   * @opt_param int pageSize The maximum number of migration jobs to return. The
169   * service may return fewer than this value. If unspecified, at most 50
170   * migration jobs will be returned. The maximum value is 1000; values above 1000
171   * will be coerced to 1000.
172   * @opt_param string pageToken The nextPageToken value received in the previous
173   * call to migrationJobs.list, used in the subsequent request to retrieve the
174   * next page of results. On first call this should be left blank. When
175   * paginating, all other parameters provided to migrationJobs.list must match
176   * the call that provided the page token.
177   * @return ListMigrationJobsResponse
178   */
179  public function listProjectsLocationsMigrationJobs($parent, $optParams = [])
180  {
181    $params = ['parent' => $parent];
182    $params = array_merge($params, $optParams);
183    return $this->call('list', [$params], ListMigrationJobsResponse::class);
184  }
185  /**
186   * Updates the parameters of a single migration job. (migrationJobs.patch)
187   *
188   * @param string $name The name (URI) of this migration job resource, in the
189   * form of:
190   * projects/{project}/locations/{location}/migrationJobs/{migrationJob}.
191   * @param MigrationJob $postBody
192   * @param array $optParams Optional parameters.
193   *
194   * @opt_param string requestId A unique id used to identify the request. If the
195   * server receives two requests with the same id, then the second request will
196   * be ignored. It is recommended to always set this value to a UUID. The id must
197   * contain only letters (a-z, A-Z), numbers (0-9), underscores (_), and hyphens
198   * (-). The maximum length is 40 characters.
199   * @opt_param string updateMask Required. Field mask is used to specify the
200   * fields to be overwritten in the migration job resource by the update.
201   * @return Operation
202   */
203  public function patch($name, MigrationJob $postBody, $optParams = [])
204  {
205    $params = ['name' => $name, 'postBody' => $postBody];
206    $params = array_merge($params, $optParams);
207    return $this->call('patch', [$params], Operation::class);
208  }
209  /**
210   * Promote a migration job, stopping replication to the destination and
211   * promoting the destination to be a standalone database.
212   * (migrationJobs.promote)
213   *
214   * @param string $name Name of the migration job resource to promote.
215   * @param PromoteMigrationJobRequest $postBody
216   * @param array $optParams Optional parameters.
217   * @return Operation
218   */
219  public function promote($name, PromoteMigrationJobRequest $postBody, $optParams = [])
220  {
221    $params = ['name' => $name, 'postBody' => $postBody];
222    $params = array_merge($params, $optParams);
223    return $this->call('promote', [$params], Operation::class);
224  }
225  /**
226   * Restart a stopped or failed migration job, resetting the destination instance
227   * to its original state and starting the migration process from scratch.
228   * (migrationJobs.restart)
229   *
230   * @param string $name Name of the migration job resource to restart.
231   * @param RestartMigrationJobRequest $postBody
232   * @param array $optParams Optional parameters.
233   * @return Operation
234   */
235  public function restart($name, RestartMigrationJobRequest $postBody, $optParams = [])
236  {
237    $params = ['name' => $name, 'postBody' => $postBody];
238    $params = array_merge($params, $optParams);
239    return $this->call('restart', [$params], Operation::class);
240  }
241  /**
242   * Resume a migration job that is currently stopped and is resumable (was
243   * stopped during CDC phase). (migrationJobs.resume)
244   *
245   * @param string $name Name of the migration job resource to resume.
246   * @param ResumeMigrationJobRequest $postBody
247   * @param array $optParams Optional parameters.
248   * @return Operation
249   */
250  public function resume($name, ResumeMigrationJobRequest $postBody, $optParams = [])
251  {
252    $params = ['name' => $name, 'postBody' => $postBody];
253    $params = array_merge($params, $optParams);
254    return $this->call('resume', [$params], Operation::class);
255  }
256  /**
257   * Sets the access control policy on the specified resource. Replaces any
258   * existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and
259   * `PERMISSION_DENIED` errors. (migrationJobs.setIamPolicy)
260   *
261   * @param string $resource REQUIRED: The resource for which the policy is being
262   * specified. See the operation documentation for the appropriate value for this
263   * field.
264   * @param SetIamPolicyRequest $postBody
265   * @param array $optParams Optional parameters.
266   * @return Policy
267   */
268  public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = [])
269  {
270    $params = ['resource' => $resource, 'postBody' => $postBody];
271    $params = array_merge($params, $optParams);
272    return $this->call('setIamPolicy', [$params], Policy::class);
273  }
274  /**
275   * Start an already created migration job. (migrationJobs.start)
276   *
277   * @param string $name Name of the migration job resource to start.
278   * @param StartMigrationJobRequest $postBody
279   * @param array $optParams Optional parameters.
280   * @return Operation
281   */
282  public function start($name, StartMigrationJobRequest $postBody, $optParams = [])
283  {
284    $params = ['name' => $name, 'postBody' => $postBody];
285    $params = array_merge($params, $optParams);
286    return $this->call('start', [$params], Operation::class);
287  }
288  /**
289   * Stops a running migration job. (migrationJobs.stop)
290   *
291   * @param string $name Name of the migration job resource to stop.
292   * @param StopMigrationJobRequest $postBody
293   * @param array $optParams Optional parameters.
294   * @return Operation
295   */
296  public function stop($name, StopMigrationJobRequest $postBody, $optParams = [])
297  {
298    $params = ['name' => $name, 'postBody' => $postBody];
299    $params = array_merge($params, $optParams);
300    return $this->call('stop', [$params], Operation::class);
301  }
302  /**
303   * Returns permissions that a caller has on the specified resource. If the
304   * resource does not exist, this will return an empty set of permissions, not a
305   * `NOT_FOUND` error. Note: This operation is designed to be used for building
306   * permission-aware UIs and command-line tools, not for authorization checking.
307   * This operation may "fail open" without warning.
308   * (migrationJobs.testIamPermissions)
309   *
310   * @param string $resource REQUIRED: The resource for which the policy detail is
311   * being requested. See the operation documentation for the appropriate value
312   * for this field.
313   * @param TestIamPermissionsRequest $postBody
314   * @param array $optParams Optional parameters.
315   * @return TestIamPermissionsResponse
316   */
317  public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = [])
318  {
319    $params = ['resource' => $resource, 'postBody' => $postBody];
320    $params = array_merge($params, $optParams);
321    return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class);
322  }
323  /**
324   * Verify a migration job, making sure the destination can reach the source and
325   * that all configuration and prerequisites are met. (migrationJobs.verify)
326   *
327   * @param string $name Name of the migration job resource to verify.
328   * @param VerifyMigrationJobRequest $postBody
329   * @param array $optParams Optional parameters.
330   * @return Operation
331   */
332  public function verify($name, VerifyMigrationJobRequest $postBody, $optParams = [])
333  {
334    $params = ['name' => $name, 'postBody' => $postBody];
335    $params = array_merge($params, $optParams);
336    return $this->call('verify', [$params], Operation::class);
337  }
338}
339
340// Adding a class alias for backwards compatibility with the previous class name.
341class_alias(ProjectsLocationsMigrationJobs::class, 'Google_Service_DatabaseMigrationService_Resource_ProjectsLocationsMigrationJobs');
342