Skip to content

Commit 8616bac

Browse files
feat: [VmMigration] Azure as a source (#8568)
* feat: Azure as a source feat: CMEK support feat: VM disk migration feat: Image Import feat: Machine Image Import feat: Cutover forecast feat: OS capabilities detection feat: Multiple additional supported target details feat: Migration warnings in addition to errors feat: API for extending the time to live (TTL) of a Migrating VM fix: Changed field behavior for an existing field `key` in message `.google.cloud.vmmigration.v1.AwsSourceDetails` to `required` to protect from incorrect input fix: Changed field behavior for an existing field `value` in message `.google.cloud.vmmigration.v1.AwsSourceDetails` to `required` to protect from incorrect input fix: Changed field behavior for an existing field `project` in message `.google.cloud.vmmigration.v1.TargetProject` to `required` to protect from incorrect input docs: Updated comments and descriptions to improve clarity PiperOrigin-RevId: 803163128 Source-Link: googleapis/googleapis@b7cf972 Source-Link: googleapis/googleapis-gen@be7d781 Copy-Tag: eyJwIjoiVm1NaWdyYXRpb24vLk93bEJvdC55YW1sIiwiaCI6ImJlN2Q3ODE4ZGY5OTFkOTFhMDc5MTI2OTllOWE4NTU4ZmFmNWM2NmMifQ== * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 159be13 commit 8616bac

161 files changed

Lines changed: 19648 additions & 574 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
23.7 KB
Binary file not shown.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
/*
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://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,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START vmmigration_v1_generated_VmMigration_CancelDiskMigrationJob_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Cloud\VMMigration\V1\CancelDiskMigrationJobRequest;
29+
use Google\Cloud\VMMigration\V1\CancelDiskMigrationJobResponse;
30+
use Google\Cloud\VMMigration\V1\Client\VmMigrationClient;
31+
use Google\Rpc\Status;
32+
33+
/**
34+
* Cancels the disk migration job.
35+
*
36+
* @param string $formattedName The name of the DiskMigrationJob. Please see
37+
* {@see VmMigrationClient::diskMigrationJobName()} for help formatting this field.
38+
*/
39+
function cancel_disk_migration_job_sample(string $formattedName): void
40+
{
41+
// Create a client.
42+
$vmMigrationClient = new VmMigrationClient();
43+
44+
// Prepare the request message.
45+
$request = (new CancelDiskMigrationJobRequest())
46+
->setName($formattedName);
47+
48+
// Call the API and handle any network failures.
49+
try {
50+
/** @var OperationResponse $response */
51+
$response = $vmMigrationClient->cancelDiskMigrationJob($request);
52+
$response->pollUntilComplete();
53+
54+
if ($response->operationSucceeded()) {
55+
/** @var CancelDiskMigrationJobResponse $result */
56+
$result = $response->getResult();
57+
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
58+
} else {
59+
/** @var Status $error */
60+
$error = $response->getError();
61+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
62+
}
63+
} catch (ApiException $ex) {
64+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
65+
}
66+
}
67+
68+
/**
69+
* Helper to execute the sample.
70+
*
71+
* This sample has been automatically generated and should be regarded as a code
72+
* template only. It will require modifications to work:
73+
* - It may require correct/in-range values for request initialization.
74+
* - It may require specifying regional endpoints when creating the service client,
75+
* please see the apiEndpoint client configuration option for more details.
76+
*/
77+
function callSample(): void
78+
{
79+
$formattedName = VmMigrationClient::diskMigrationJobName(
80+
'[PROJECT]',
81+
'[LOCATION]',
82+
'[SOURCE]',
83+
'[DISK_MIGRATION_JOB]'
84+
);
85+
86+
cancel_disk_migration_job_sample($formattedName);
87+
}
88+
// [END vmmigration_v1_generated_VmMigration_CancelDiskMigrationJob_sync]
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
/*
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://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,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START vmmigration_v1_generated_VmMigration_CancelImageImportJob_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Cloud\VMMigration\V1\CancelImageImportJobRequest;
29+
use Google\Cloud\VMMigration\V1\CancelImageImportJobResponse;
30+
use Google\Cloud\VMMigration\V1\Client\VmMigrationClient;
31+
use Google\Rpc\Status;
32+
33+
/**
34+
* Initiates the cancellation of a running clone job.
35+
*
36+
* @param string $formattedName The image import job id. Please see
37+
* {@see VmMigrationClient::imageImportJobName()} for help formatting this field.
38+
*/
39+
function cancel_image_import_job_sample(string $formattedName): void
40+
{
41+
// Create a client.
42+
$vmMigrationClient = new VmMigrationClient();
43+
44+
// Prepare the request message.
45+
$request = (new CancelImageImportJobRequest())
46+
->setName($formattedName);
47+
48+
// Call the API and handle any network failures.
49+
try {
50+
/** @var OperationResponse $response */
51+
$response = $vmMigrationClient->cancelImageImportJob($request);
52+
$response->pollUntilComplete();
53+
54+
if ($response->operationSucceeded()) {
55+
/** @var CancelImageImportJobResponse $result */
56+
$result = $response->getResult();
57+
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
58+
} else {
59+
/** @var Status $error */
60+
$error = $response->getError();
61+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
62+
}
63+
} catch (ApiException $ex) {
64+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
65+
}
66+
}
67+
68+
/**
69+
* Helper to execute the sample.
70+
*
71+
* This sample has been automatically generated and should be regarded as a code
72+
* template only. It will require modifications to work:
73+
* - It may require correct/in-range values for request initialization.
74+
* - It may require specifying regional endpoints when creating the service client,
75+
* please see the apiEndpoint client configuration option for more details.
76+
*/
77+
function callSample(): void
78+
{
79+
$formattedName = VmMigrationClient::imageImportJobName(
80+
'[PROJECT]',
81+
'[LOCATION]',
82+
'[JOB]',
83+
'[RESULT]'
84+
);
85+
86+
cancel_image_import_job_sample($formattedName);
87+
}
88+
// [END vmmigration_v1_generated_VmMigration_CancelImageImportJob_sync]
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<?php
2+
/*
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://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,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START vmmigration_v1_generated_VmMigration_CreateDiskMigrationJob_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Cloud\VMMigration\V1\Client\VmMigrationClient;
29+
use Google\Cloud\VMMigration\V1\ComputeEngineDisk;
30+
use Google\Cloud\VMMigration\V1\ComputeEngineDiskType;
31+
use Google\Cloud\VMMigration\V1\CreateDiskMigrationJobRequest;
32+
use Google\Cloud\VMMigration\V1\DiskMigrationJob;
33+
use Google\Cloud\VMMigration\V1\DiskMigrationJobTargetDetails;
34+
use Google\Rpc\Status;
35+
36+
/**
37+
* Creates a new disk migration job in a given Source.
38+
*
39+
* @param string $formattedParent The DiskMigrationJob's parent. Please see
40+
* {@see VmMigrationClient::sourceName()} for help formatting this field.
41+
* @param string $diskMigrationJobId The DiskMigrationJob identifier.
42+
* The maximum length of this value is 63 characters.
43+
* Valid characters are lower case Latin letters, digits and hyphen.
44+
* It must start with a Latin letter and must not end with a hyphen.
45+
* @param string $formattedDiskMigrationJobTargetDetailsTargetDiskZone The Compute Engine zone in which to create the disk. Should be of
46+
* the form: projects/{target-project}/locations/{zone}
47+
* Please see {@see VmMigrationClient::locationName()} for help formatting this field.
48+
* @param int $diskMigrationJobTargetDetailsTargetDiskDiskType The disk type to use.
49+
* @param string $formattedDiskMigrationJobTargetDetailsTargetProject The name of the resource of type TargetProject which represents
50+
* the Compute Engine project in which to create the disk. Should be of the
51+
* form: projects/{project}/locations/global/targetProjects/{target-project}
52+
* Please see {@see VmMigrationClient::targetProjectName()} for help formatting this field.
53+
*/
54+
function create_disk_migration_job_sample(
55+
string $formattedParent,
56+
string $diskMigrationJobId,
57+
string $formattedDiskMigrationJobTargetDetailsTargetDiskZone,
58+
int $diskMigrationJobTargetDetailsTargetDiskDiskType,
59+
string $formattedDiskMigrationJobTargetDetailsTargetProject
60+
): void {
61+
// Create a client.
62+
$vmMigrationClient = new VmMigrationClient();
63+
64+
// Prepare the request message.
65+
$diskMigrationJobTargetDetailsTargetDisk = (new ComputeEngineDisk())
66+
->setZone($formattedDiskMigrationJobTargetDetailsTargetDiskZone)
67+
->setDiskType($diskMigrationJobTargetDetailsTargetDiskDiskType);
68+
$diskMigrationJobTargetDetails = (new DiskMigrationJobTargetDetails())
69+
->setTargetDisk($diskMigrationJobTargetDetailsTargetDisk)
70+
->setTargetProject($formattedDiskMigrationJobTargetDetailsTargetProject);
71+
$diskMigrationJob = (new DiskMigrationJob())
72+
->setTargetDetails($diskMigrationJobTargetDetails);
73+
$request = (new CreateDiskMigrationJobRequest())
74+
->setParent($formattedParent)
75+
->setDiskMigrationJobId($diskMigrationJobId)
76+
->setDiskMigrationJob($diskMigrationJob);
77+
78+
// Call the API and handle any network failures.
79+
try {
80+
/** @var OperationResponse $response */
81+
$response = $vmMigrationClient->createDiskMigrationJob($request);
82+
$response->pollUntilComplete();
83+
84+
if ($response->operationSucceeded()) {
85+
/** @var DiskMigrationJob $result */
86+
$result = $response->getResult();
87+
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
88+
} else {
89+
/** @var Status $error */
90+
$error = $response->getError();
91+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
92+
}
93+
} catch (ApiException $ex) {
94+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
95+
}
96+
}
97+
98+
/**
99+
* Helper to execute the sample.
100+
*
101+
* This sample has been automatically generated and should be regarded as a code
102+
* template only. It will require modifications to work:
103+
* - It may require correct/in-range values for request initialization.
104+
* - It may require specifying regional endpoints when creating the service client,
105+
* please see the apiEndpoint client configuration option for more details.
106+
*/
107+
function callSample(): void
108+
{
109+
$formattedParent = VmMigrationClient::sourceName('[PROJECT]', '[LOCATION]', '[SOURCE]');
110+
$diskMigrationJobId = '[DISK_MIGRATION_JOB_ID]';
111+
$formattedDiskMigrationJobTargetDetailsTargetDiskZone = VmMigrationClient::locationName(
112+
'[PROJECT]',
113+
'[LOCATION]'
114+
);
115+
$diskMigrationJobTargetDetailsTargetDiskDiskType = ComputeEngineDiskType::COMPUTE_ENGINE_DISK_TYPE_UNSPECIFIED;
116+
$formattedDiskMigrationJobTargetDetailsTargetProject = VmMigrationClient::targetProjectName(
117+
'[PROJECT]',
118+
'[LOCATION]',
119+
'[TARGET_PROJECT]'
120+
);
121+
122+
create_disk_migration_job_sample(
123+
$formattedParent,
124+
$diskMigrationJobId,
125+
$formattedDiskMigrationJobTargetDetailsTargetDiskZone,
126+
$diskMigrationJobTargetDetailsTargetDiskDiskType,
127+
$formattedDiskMigrationJobTargetDetailsTargetProject
128+
);
129+
}
130+
// [END vmmigration_v1_generated_VmMigration_CreateDiskMigrationJob_sync]

0 commit comments

Comments
 (0)