Skip to content

Commit 3e09c01

Browse files
feat: V1 for Config Delivery (#8433)
1 parent 197e5ce commit 3e09c01

97 files changed

Lines changed: 17975 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ConfigDelivery/.OwlBot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
deep-copy-regex:
2-
- source: /google/cloud/configdelivery/(v1beta)/.*-php/(.*)
2+
- source: /google/cloud/configdelivery/(v1|v1beta)/.*-php/(.*)
33
dest: /owl-bot-staging/ConfigDelivery/$1/$2
44
api-name: ConfigDelivery
19.4 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 configdelivery_v1_generated_ConfigDelivery_AbortRollout_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Cloud\ConfigDelivery\V1\AbortRolloutRequest;
29+
use Google\Cloud\ConfigDelivery\V1\Client\ConfigDeliveryClient;
30+
use Google\Cloud\ConfigDelivery\V1\Rollout;
31+
use Google\Rpc\Status;
32+
33+
/**
34+
* Abort a Rollout.
35+
*
36+
* @param string $formattedName Name of the Rollout. Please see
37+
* {@see ConfigDeliveryClient::rolloutName()} for help formatting this field.
38+
*/
39+
function abort_rollout_sample(string $formattedName): void
40+
{
41+
// Create a client.
42+
$configDeliveryClient = new ConfigDeliveryClient();
43+
44+
// Prepare the request message.
45+
$request = (new AbortRolloutRequest())
46+
->setName($formattedName);
47+
48+
// Call the API and handle any network failures.
49+
try {
50+
/** @var OperationResponse $response */
51+
$response = $configDeliveryClient->abortRollout($request);
52+
$response->pollUntilComplete();
53+
54+
if ($response->operationSucceeded()) {
55+
/** @var Rollout $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 = ConfigDeliveryClient::rolloutName(
80+
'[PROJECT]',
81+
'[LOCATION]',
82+
'[FLEET_PACKAGE]',
83+
'[ROLLOUT]'
84+
);
85+
86+
abort_rollout_sample($formattedName);
87+
}
88+
// [END configdelivery_v1_generated_ConfigDelivery_AbortRollout_sync]
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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 configdelivery_v1_generated_ConfigDelivery_CreateFleetPackage_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Cloud\ConfigDelivery\V1\Client\ConfigDeliveryClient;
29+
use Google\Cloud\ConfigDelivery\V1\CreateFleetPackageRequest;
30+
use Google\Cloud\ConfigDelivery\V1\FleetPackage;
31+
use Google\Cloud\ConfigDelivery\V1\FleetPackage\ResourceBundleSelector;
32+
use Google\Cloud\ConfigDelivery\V1\FleetPackage\VariantSelector;
33+
use Google\Rpc\Status;
34+
35+
/**
36+
* Creates a new FleetPackage in a given project and location.
37+
*
38+
* @param string $formattedParent Value for parent. Please see
39+
* {@see ConfigDeliveryClient::locationName()} for help formatting this field.
40+
* @param string $fleetPackageId Id of the requesting object
41+
* If auto-generating Id server-side, remove this field and
42+
* fleet_package_id from the method_signature of Create RPC
43+
* @param string $fleetPackageVariantSelectorVariantNameTemplate variant_name_template is a template that can refer to
44+
* variables containing cluster membership metadata such as location,
45+
* name, and labels to generate the name of the variant for a target
46+
* cluster. The variable syntax is similar to the unix shell variables.
47+
*
48+
* Available variables are `${membership.name}`, `${membership.location}`,
49+
* `${membership.project}` and `${membership.labels['label_name']}`.
50+
*
51+
* If you want to deploy a specific variant, say "default" to all the
52+
* clusters, you can use "default" (string without any variables) as
53+
* the variant_name_template.
54+
*/
55+
function create_fleet_package_sample(
56+
string $formattedParent,
57+
string $fleetPackageId,
58+
string $fleetPackageVariantSelectorVariantNameTemplate
59+
): void {
60+
// Create a client.
61+
$configDeliveryClient = new ConfigDeliveryClient();
62+
63+
// Prepare the request message.
64+
$fleetPackageResourceBundleSelector = new ResourceBundleSelector();
65+
$fleetPackageVariantSelector = (new VariantSelector())
66+
->setVariantNameTemplate($fleetPackageVariantSelectorVariantNameTemplate);
67+
$fleetPackage = (new FleetPackage())
68+
->setResourceBundleSelector($fleetPackageResourceBundleSelector)
69+
->setVariantSelector($fleetPackageVariantSelector);
70+
$request = (new CreateFleetPackageRequest())
71+
->setParent($formattedParent)
72+
->setFleetPackageId($fleetPackageId)
73+
->setFleetPackage($fleetPackage);
74+
75+
// Call the API and handle any network failures.
76+
try {
77+
/** @var OperationResponse $response */
78+
$response = $configDeliveryClient->createFleetPackage($request);
79+
$response->pollUntilComplete();
80+
81+
if ($response->operationSucceeded()) {
82+
/** @var FleetPackage $result */
83+
$result = $response->getResult();
84+
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
85+
} else {
86+
/** @var Status $error */
87+
$error = $response->getError();
88+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
89+
}
90+
} catch (ApiException $ex) {
91+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
92+
}
93+
}
94+
95+
/**
96+
* Helper to execute the sample.
97+
*
98+
* This sample has been automatically generated and should be regarded as a code
99+
* template only. It will require modifications to work:
100+
* - It may require correct/in-range values for request initialization.
101+
* - It may require specifying regional endpoints when creating the service client,
102+
* please see the apiEndpoint client configuration option for more details.
103+
*/
104+
function callSample(): void
105+
{
106+
$formattedParent = ConfigDeliveryClient::locationName('[PROJECT]', '[LOCATION]');
107+
$fleetPackageId = '[FLEET_PACKAGE_ID]';
108+
$fleetPackageVariantSelectorVariantNameTemplate = '[VARIANT_NAME_TEMPLATE]';
109+
110+
create_fleet_package_sample(
111+
$formattedParent,
112+
$fleetPackageId,
113+
$fleetPackageVariantSelectorVariantNameTemplate
114+
);
115+
}
116+
// [END configdelivery_v1_generated_ConfigDelivery_CreateFleetPackage_sync]
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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 configdelivery_v1_generated_ConfigDelivery_CreateRelease_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Cloud\ConfigDelivery\V1\Client\ConfigDeliveryClient;
29+
use Google\Cloud\ConfigDelivery\V1\CreateReleaseRequest;
30+
use Google\Cloud\ConfigDelivery\V1\Release;
31+
use Google\Rpc\Status;
32+
33+
/**
34+
* Creates a new Release in a given project, location and resource bundle.
35+
*
36+
* @param string $formattedParent Value for parent. Please see
37+
* {@see ConfigDeliveryClient::resourceBundleName()} for help formatting this field.
38+
* @param string $releaseId Id of the requesting object
39+
* If auto-generating Id server-side, remove this field and
40+
* release_id from the method_signature of Create RPC
41+
* @param string $releaseVersion version of the `Release`. This must be v<major>.<minor>.<patch>.
42+
*/
43+
function create_release_sample(
44+
string $formattedParent,
45+
string $releaseId,
46+
string $releaseVersion
47+
): void {
48+
// Create a client.
49+
$configDeliveryClient = new ConfigDeliveryClient();
50+
51+
// Prepare the request message.
52+
$release = (new Release())
53+
->setVersion($releaseVersion);
54+
$request = (new CreateReleaseRequest())
55+
->setParent($formattedParent)
56+
->setReleaseId($releaseId)
57+
->setRelease($release);
58+
59+
// Call the API and handle any network failures.
60+
try {
61+
/** @var OperationResponse $response */
62+
$response = $configDeliveryClient->createRelease($request);
63+
$response->pollUntilComplete();
64+
65+
if ($response->operationSucceeded()) {
66+
/** @var Release $result */
67+
$result = $response->getResult();
68+
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
69+
} else {
70+
/** @var Status $error */
71+
$error = $response->getError();
72+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
73+
}
74+
} catch (ApiException $ex) {
75+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
76+
}
77+
}
78+
79+
/**
80+
* Helper to execute the sample.
81+
*
82+
* This sample has been automatically generated and should be regarded as a code
83+
* template only. It will require modifications to work:
84+
* - It may require correct/in-range values for request initialization.
85+
* - It may require specifying regional endpoints when creating the service client,
86+
* please see the apiEndpoint client configuration option for more details.
87+
*/
88+
function callSample(): void
89+
{
90+
$formattedParent = ConfigDeliveryClient::resourceBundleName(
91+
'[PROJECT]',
92+
'[LOCATION]',
93+
'[RESOURCE_BUNDLE]'
94+
);
95+
$releaseId = '[RELEASE_ID]';
96+
$releaseVersion = '[VERSION]';
97+
98+
create_release_sample($formattedParent, $releaseId, $releaseVersion);
99+
}
100+
// [END configdelivery_v1_generated_ConfigDelivery_CreateRelease_sync]

0 commit comments

Comments
 (0)