Skip to content

Commit 159be13

Browse files
feat: [NetworkConnectivity] introduce DataTransfer APIs (#8567)
* feat: introduce DataTransfer APIs PiperOrigin-RevId: 803093347 Source-Link: googleapis/googleapis@a195f5b Source-Link: googleapis/googleapis-gen@a4ce123 Copy-Tag: eyJwIjoiTmV0d29ya0Nvbm5lY3Rpdml0eS8uT3dsQm90LnlhbWwiLCJoIjoiYTRjZTEyMzU2YmIxZGYyMWU0ZDFiYTc4MzZiZmRmMDRhNmU4Y2MwNyJ9 * 🦉 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 fd78680 commit 159be13

49 files changed

Lines changed: 9505 additions & 0 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.
11.2 KB
Binary file not shown.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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 networkconnectivity_v1_generated_DataTransferService_CreateDestination_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Cloud\NetworkConnectivity\V1\Client\DataTransferServiceClient;
29+
use Google\Cloud\NetworkConnectivity\V1\CreateDestinationRequest;
30+
use Google\Cloud\NetworkConnectivity\V1\Destination;
31+
use Google\Cloud\NetworkConnectivity\V1\Destination\DestinationEndpoint;
32+
use Google\Rpc\Status;
33+
34+
/**
35+
* Creates a `Destination` resource in a specified project and location.
36+
*
37+
* @param string $formattedParent The name of the parent resource. Please see
38+
* {@see DataTransferServiceClient::multicloudDataTransferConfigName()} for help formatting this field.
39+
* @param string $destinationId The ID to use for the `Destination` resource, which becomes the
40+
* final component of the `Destination` resource name.
41+
* @param string $destinationIpPrefix Immutable. The IP prefix that represents your workload on another
42+
* CSP.
43+
* @param int $destinationEndpointsAsn The ASN of the remote IP prefix.
44+
* @param string $destinationEndpointsCsp The CSP of the remote IP prefix.
45+
*/
46+
function create_destination_sample(
47+
string $formattedParent,
48+
string $destinationId,
49+
string $destinationIpPrefix,
50+
int $destinationEndpointsAsn,
51+
string $destinationEndpointsCsp
52+
): void {
53+
// Create a client.
54+
$dataTransferServiceClient = new DataTransferServiceClient();
55+
56+
// Prepare the request message.
57+
$destinationEndpoint = (new DestinationEndpoint())
58+
->setAsn($destinationEndpointsAsn)
59+
->setCsp($destinationEndpointsCsp);
60+
$destinationEndpoints = [$destinationEndpoint,];
61+
$destination = (new Destination())
62+
->setIpPrefix($destinationIpPrefix)
63+
->setEndpoints($destinationEndpoints);
64+
$request = (new CreateDestinationRequest())
65+
->setParent($formattedParent)
66+
->setDestinationId($destinationId)
67+
->setDestination($destination);
68+
69+
// Call the API and handle any network failures.
70+
try {
71+
/** @var OperationResponse $response */
72+
$response = $dataTransferServiceClient->createDestination($request);
73+
$response->pollUntilComplete();
74+
75+
if ($response->operationSucceeded()) {
76+
/** @var Destination $result */
77+
$result = $response->getResult();
78+
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
79+
} else {
80+
/** @var Status $error */
81+
$error = $response->getError();
82+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
83+
}
84+
} catch (ApiException $ex) {
85+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
86+
}
87+
}
88+
89+
/**
90+
* Helper to execute the sample.
91+
*
92+
* This sample has been automatically generated and should be regarded as a code
93+
* template only. It will require modifications to work:
94+
* - It may require correct/in-range values for request initialization.
95+
* - It may require specifying regional endpoints when creating the service client,
96+
* please see the apiEndpoint client configuration option for more details.
97+
*/
98+
function callSample(): void
99+
{
100+
$formattedParent = DataTransferServiceClient::multicloudDataTransferConfigName(
101+
'[PROJECT]',
102+
'[LOCATION]',
103+
'[MULTICLOUD_DATA_TRANSFER_CONFIG]'
104+
);
105+
$destinationId = '[DESTINATION_ID]';
106+
$destinationIpPrefix = '[IP_PREFIX]';
107+
$destinationEndpointsAsn = 0;
108+
$destinationEndpointsCsp = '[CSP]';
109+
110+
create_destination_sample(
111+
$formattedParent,
112+
$destinationId,
113+
$destinationIpPrefix,
114+
$destinationEndpointsAsn,
115+
$destinationEndpointsCsp
116+
);
117+
}
118+
// [END networkconnectivity_v1_generated_DataTransferService_CreateDestination_sync]
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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 networkconnectivity_v1_generated_DataTransferService_CreateMulticloudDataTransferConfig_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Cloud\NetworkConnectivity\V1\Client\DataTransferServiceClient;
29+
use Google\Cloud\NetworkConnectivity\V1\CreateMulticloudDataTransferConfigRequest;
30+
use Google\Cloud\NetworkConnectivity\V1\MulticloudDataTransferConfig;
31+
use Google\Rpc\Status;
32+
33+
/**
34+
* Creates a `MulticloudDataTransferConfig` resource in a specified project
35+
* and location.
36+
*
37+
* @param string $formattedParent The name of the parent resource. Please see
38+
* {@see DataTransferServiceClient::locationName()} for help formatting this field.
39+
* @param string $multicloudDataTransferConfigId The ID to use for the `MulticloudDataTransferConfig` resource,
40+
* which becomes the final component of the `MulticloudDataTransferConfig`
41+
* resource name.
42+
*/
43+
function create_multicloud_data_transfer_config_sample(
44+
string $formattedParent,
45+
string $multicloudDataTransferConfigId
46+
): void {
47+
// Create a client.
48+
$dataTransferServiceClient = new DataTransferServiceClient();
49+
50+
// Prepare the request message.
51+
$multicloudDataTransferConfig = new MulticloudDataTransferConfig();
52+
$request = (new CreateMulticloudDataTransferConfigRequest())
53+
->setParent($formattedParent)
54+
->setMulticloudDataTransferConfigId($multicloudDataTransferConfigId)
55+
->setMulticloudDataTransferConfig($multicloudDataTransferConfig);
56+
57+
// Call the API and handle any network failures.
58+
try {
59+
/** @var OperationResponse $response */
60+
$response = $dataTransferServiceClient->createMulticloudDataTransferConfig($request);
61+
$response->pollUntilComplete();
62+
63+
if ($response->operationSucceeded()) {
64+
/** @var MulticloudDataTransferConfig $result */
65+
$result = $response->getResult();
66+
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
67+
} else {
68+
/** @var Status $error */
69+
$error = $response->getError();
70+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
71+
}
72+
} catch (ApiException $ex) {
73+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
74+
}
75+
}
76+
77+
/**
78+
* Helper to execute the sample.
79+
*
80+
* This sample has been automatically generated and should be regarded as a code
81+
* template only. It will require modifications to work:
82+
* - It may require correct/in-range values for request initialization.
83+
* - It may require specifying regional endpoints when creating the service client,
84+
* please see the apiEndpoint client configuration option for more details.
85+
*/
86+
function callSample(): void
87+
{
88+
$formattedParent = DataTransferServiceClient::locationName('[PROJECT]', '[LOCATION]');
89+
$multicloudDataTransferConfigId = '[MULTICLOUD_DATA_TRANSFER_CONFIG_ID]';
90+
91+
create_multicloud_data_transfer_config_sample($formattedParent, $multicloudDataTransferConfigId);
92+
}
93+
// [END networkconnectivity_v1_generated_DataTransferService_CreateMulticloudDataTransferConfig_sync]
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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 networkconnectivity_v1_generated_DataTransferService_DeleteDestination_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Cloud\NetworkConnectivity\V1\Client\DataTransferServiceClient;
29+
use Google\Cloud\NetworkConnectivity\V1\DeleteDestinationRequest;
30+
use Google\Rpc\Status;
31+
32+
/**
33+
* Deletes a `Destination` resource.
34+
*
35+
* @param string $formattedName The name of the `Destination` resource to delete. Please see
36+
* {@see DataTransferServiceClient::destinationName()} for help formatting this field.
37+
*/
38+
function delete_destination_sample(string $formattedName): void
39+
{
40+
// Create a client.
41+
$dataTransferServiceClient = new DataTransferServiceClient();
42+
43+
// Prepare the request message.
44+
$request = (new DeleteDestinationRequest())
45+
->setName($formattedName);
46+
47+
// Call the API and handle any network failures.
48+
try {
49+
/** @var OperationResponse $response */
50+
$response = $dataTransferServiceClient->deleteDestination($request);
51+
$response->pollUntilComplete();
52+
53+
if ($response->operationSucceeded()) {
54+
printf('Operation completed successfully.' . PHP_EOL);
55+
} else {
56+
/** @var Status $error */
57+
$error = $response->getError();
58+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
59+
}
60+
} catch (ApiException $ex) {
61+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
62+
}
63+
}
64+
65+
/**
66+
* Helper to execute the sample.
67+
*
68+
* This sample has been automatically generated and should be regarded as a code
69+
* template only. It will require modifications to work:
70+
* - It may require correct/in-range values for request initialization.
71+
* - It may require specifying regional endpoints when creating the service client,
72+
* please see the apiEndpoint client configuration option for more details.
73+
*/
74+
function callSample(): void
75+
{
76+
$formattedName = DataTransferServiceClient::destinationName(
77+
'[PROJECT]',
78+
'[LOCATION]',
79+
'[MULTICLOUD_DATA_TRANSFER_CONFIG]',
80+
'[DESTINATION]'
81+
);
82+
83+
delete_destination_sample($formattedName);
84+
}
85+
// [END networkconnectivity_v1_generated_DataTransferService_DeleteDestination_sync]
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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 networkconnectivity_v1_generated_DataTransferService_DeleteMulticloudDataTransferConfig_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Cloud\NetworkConnectivity\V1\Client\DataTransferServiceClient;
29+
use Google\Cloud\NetworkConnectivity\V1\DeleteMulticloudDataTransferConfigRequest;
30+
use Google\Rpc\Status;
31+
32+
/**
33+
* Deletes a `MulticloudDataTransferConfig` resource.
34+
*
35+
* @param string $formattedName The name of the `MulticloudDataTransferConfig` resource to
36+
* delete. Please see
37+
* {@see DataTransferServiceClient::multicloudDataTransferConfigName()} for help formatting this field.
38+
*/
39+
function delete_multicloud_data_transfer_config_sample(string $formattedName): void
40+
{
41+
// Create a client.
42+
$dataTransferServiceClient = new DataTransferServiceClient();
43+
44+
// Prepare the request message.
45+
$request = (new DeleteMulticloudDataTransferConfigRequest())
46+
->setName($formattedName);
47+
48+
// Call the API and handle any network failures.
49+
try {
50+
/** @var OperationResponse $response */
51+
$response = $dataTransferServiceClient->deleteMulticloudDataTransferConfig($request);
52+
$response->pollUntilComplete();
53+
54+
if ($response->operationSucceeded()) {
55+
printf('Operation completed successfully.' . PHP_EOL);
56+
} else {
57+
/** @var Status $error */
58+
$error = $response->getError();
59+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
60+
}
61+
} catch (ApiException $ex) {
62+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
63+
}
64+
}
65+
66+
/**
67+
* Helper to execute the sample.
68+
*
69+
* This sample has been automatically generated and should be regarded as a code
70+
* template only. It will require modifications to work:
71+
* - It may require correct/in-range values for request initialization.
72+
* - It may require specifying regional endpoints when creating the service client,
73+
* please see the apiEndpoint client configuration option for more details.
74+
*/
75+
function callSample(): void
76+
{
77+
$formattedName = DataTransferServiceClient::multicloudDataTransferConfigName(
78+
'[PROJECT]',
79+
'[LOCATION]',
80+
'[MULTICLOUD_DATA_TRANSFER_CONFIG]'
81+
);
82+
83+
delete_multicloud_data_transfer_config_sample($formattedName);
84+
}
85+
// [END networkconnectivity_v1_generated_DataTransferService_DeleteMulticloudDataTransferConfig_sync]

0 commit comments

Comments
 (0)