Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified VmMigration/metadata/V1/Vmmigration.php
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START vmmigration_v1_generated_VmMigration_CancelDiskMigrationJob_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\VMMigration\V1\CancelDiskMigrationJobRequest;
use Google\Cloud\VMMigration\V1\CancelDiskMigrationJobResponse;
use Google\Cloud\VMMigration\V1\Client\VmMigrationClient;
use Google\Rpc\Status;

/**
* Cancels the disk migration job.
*
* @param string $formattedName The name of the DiskMigrationJob. Please see
* {@see VmMigrationClient::diskMigrationJobName()} for help formatting this field.
*/
function cancel_disk_migration_job_sample(string $formattedName): void
{
// Create a client.
$vmMigrationClient = new VmMigrationClient();

// Prepare the request message.
$request = (new CancelDiskMigrationJobRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $vmMigrationClient->cancelDiskMigrationJob($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
/** @var CancelDiskMigrationJobResponse $result */
$result = $response->getResult();
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = VmMigrationClient::diskMigrationJobName(
'[PROJECT]',
'[LOCATION]',
'[SOURCE]',
'[DISK_MIGRATION_JOB]'
);

cancel_disk_migration_job_sample($formattedName);
}
// [END vmmigration_v1_generated_VmMigration_CancelDiskMigrationJob_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START vmmigration_v1_generated_VmMigration_CancelImageImportJob_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\VMMigration\V1\CancelImageImportJobRequest;
use Google\Cloud\VMMigration\V1\CancelImageImportJobResponse;
use Google\Cloud\VMMigration\V1\Client\VmMigrationClient;
use Google\Rpc\Status;

/**
* Initiates the cancellation of a running clone job.
*
* @param string $formattedName The image import job id. Please see
* {@see VmMigrationClient::imageImportJobName()} for help formatting this field.
*/
function cancel_image_import_job_sample(string $formattedName): void
{
// Create a client.
$vmMigrationClient = new VmMigrationClient();

// Prepare the request message.
$request = (new CancelImageImportJobRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $vmMigrationClient->cancelImageImportJob($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
/** @var CancelImageImportJobResponse $result */
$result = $response->getResult();
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = VmMigrationClient::imageImportJobName(
'[PROJECT]',
'[LOCATION]',
'[JOB]',
'[RESULT]'
);

cancel_image_import_job_sample($formattedName);
}
// [END vmmigration_v1_generated_VmMigration_CancelImageImportJob_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?php
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START vmmigration_v1_generated_VmMigration_CreateDiskMigrationJob_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\VMMigration\V1\Client\VmMigrationClient;
use Google\Cloud\VMMigration\V1\ComputeEngineDisk;
use Google\Cloud\VMMigration\V1\ComputeEngineDiskType;
use Google\Cloud\VMMigration\V1\CreateDiskMigrationJobRequest;
use Google\Cloud\VMMigration\V1\DiskMigrationJob;
use Google\Cloud\VMMigration\V1\DiskMigrationJobTargetDetails;
use Google\Rpc\Status;

/**
* Creates a new disk migration job in a given Source.
*
* @param string $formattedParent The DiskMigrationJob's parent. Please see
* {@see VmMigrationClient::sourceName()} for help formatting this field.
* @param string $diskMigrationJobId The DiskMigrationJob identifier.
* The maximum length of this value is 63 characters.
* Valid characters are lower case Latin letters, digits and hyphen.
* It must start with a Latin letter and must not end with a hyphen.
* @param string $formattedDiskMigrationJobTargetDetailsTargetDiskZone The Compute Engine zone in which to create the disk. Should be of
* the form: projects/{target-project}/locations/{zone}
* Please see {@see VmMigrationClient::locationName()} for help formatting this field.
* @param int $diskMigrationJobTargetDetailsTargetDiskDiskType The disk type to use.
* @param string $formattedDiskMigrationJobTargetDetailsTargetProject The name of the resource of type TargetProject which represents
* the Compute Engine project in which to create the disk. Should be of the
* form: projects/{project}/locations/global/targetProjects/{target-project}
* Please see {@see VmMigrationClient::targetProjectName()} for help formatting this field.
*/
function create_disk_migration_job_sample(
string $formattedParent,
string $diskMigrationJobId,
string $formattedDiskMigrationJobTargetDetailsTargetDiskZone,
int $diskMigrationJobTargetDetailsTargetDiskDiskType,
string $formattedDiskMigrationJobTargetDetailsTargetProject
): void {
// Create a client.
$vmMigrationClient = new VmMigrationClient();

// Prepare the request message.
$diskMigrationJobTargetDetailsTargetDisk = (new ComputeEngineDisk())
->setZone($formattedDiskMigrationJobTargetDetailsTargetDiskZone)
->setDiskType($diskMigrationJobTargetDetailsTargetDiskDiskType);
$diskMigrationJobTargetDetails = (new DiskMigrationJobTargetDetails())
->setTargetDisk($diskMigrationJobTargetDetailsTargetDisk)
->setTargetProject($formattedDiskMigrationJobTargetDetailsTargetProject);
$diskMigrationJob = (new DiskMigrationJob())
->setTargetDetails($diskMigrationJobTargetDetails);
$request = (new CreateDiskMigrationJobRequest())
->setParent($formattedParent)
->setDiskMigrationJobId($diskMigrationJobId)
->setDiskMigrationJob($diskMigrationJob);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $vmMigrationClient->createDiskMigrationJob($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
/** @var DiskMigrationJob $result */
$result = $response->getResult();
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = VmMigrationClient::sourceName('[PROJECT]', '[LOCATION]', '[SOURCE]');
$diskMigrationJobId = '[DISK_MIGRATION_JOB_ID]';
$formattedDiskMigrationJobTargetDetailsTargetDiskZone = VmMigrationClient::locationName(
'[PROJECT]',
'[LOCATION]'
);
$diskMigrationJobTargetDetailsTargetDiskDiskType = ComputeEngineDiskType::COMPUTE_ENGINE_DISK_TYPE_UNSPECIFIED;
$formattedDiskMigrationJobTargetDetailsTargetProject = VmMigrationClient::targetProjectName(
'[PROJECT]',
'[LOCATION]',
'[TARGET_PROJECT]'
);

create_disk_migration_job_sample(
$formattedParent,
$diskMigrationJobId,
$formattedDiskMigrationJobTargetDetailsTargetDiskZone,
$diskMigrationJobTargetDetailsTargetDiskDiskType,
$formattedDiskMigrationJobTargetDetailsTargetProject
);
}
// [END vmmigration_v1_generated_VmMigration_CreateDiskMigrationJob_sync]
Loading
Loading