-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added support for deploy policies (#7528)
feat: added support for configuring a proxy_url to a Kubernetes server docs: small corrections to Cloud Deploy API documentation PiperOrigin-RevId: 652560914 Source-Link: googleapis/googleapis@b0c32da Source-Link: googleapis/googleapis-gen@d8a10c3 Copy-Tag: eyJwIjoiRGVwbG95Ly5Pd2xCb3QueWFtbCIsImgiOiJkOGExMGMzOGVkNGM0NjIwNDA0NGI3YjAxYjNiYWFlZTc2OTc1ZjYzIn0= Co-authored-by: Brent Shaffer <[email protected]>
- Loading branch information
1 parent
b506231
commit ca1b29a
Showing
43 changed files
with
4,937 additions
and
17 deletions.
There are no files selected for viewing
Binary file not shown.
96 changes: 96 additions & 0 deletions
96
Deploy/samples/V1/CloudDeployClient/create_deploy_policy.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
/* | ||
* Copyright 2024 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 clouddeploy_v1_generated_CloudDeploy_CreateDeployPolicy_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\ApiCore\OperationResponse; | ||
use Google\Cloud\Deploy\V1\Client\CloudDeployClient; | ||
use Google\Cloud\Deploy\V1\CreateDeployPolicyRequest; | ||
use Google\Cloud\Deploy\V1\DeployPolicy; | ||
use Google\Cloud\Deploy\V1\DeployPolicyResourceSelector; | ||
use Google\Cloud\Deploy\V1\PolicyRule; | ||
use Google\Rpc\Status; | ||
|
||
/** | ||
* Creates a new DeployPolicy in a given project and location. | ||
* | ||
* @param string $formattedParent The parent collection in which the `DeployPolicy` should be | ||
* created. Format should be | ||
* `projects/{project_id}/locations/{location_name}`. Please see | ||
* {@see CloudDeployClient::locationName()} for help formatting this field. | ||
* @param string $deployPolicyId ID of the `DeployPolicy`. | ||
*/ | ||
function create_deploy_policy_sample(string $formattedParent, string $deployPolicyId): void | ||
{ | ||
// Create a client. | ||
$cloudDeployClient = new CloudDeployClient(); | ||
|
||
// Prepare the request message. | ||
$deployPolicySelectors = [new DeployPolicyResourceSelector()]; | ||
$deployPolicyRules = [new PolicyRule()]; | ||
$deployPolicy = (new DeployPolicy()) | ||
->setSelectors($deployPolicySelectors) | ||
->setRules($deployPolicyRules); | ||
$request = (new CreateDeployPolicyRequest()) | ||
->setParent($formattedParent) | ||
->setDeployPolicyId($deployPolicyId) | ||
->setDeployPolicy($deployPolicy); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var OperationResponse $response */ | ||
$response = $cloudDeployClient->createDeployPolicy($request); | ||
$response->pollUntilComplete(); | ||
|
||
if ($response->operationSucceeded()) { | ||
/** @var DeployPolicy $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 = CloudDeployClient::locationName('[PROJECT]', '[LOCATION]'); | ||
$deployPolicyId = '[DEPLOY_POLICY_ID]'; | ||
|
||
create_deploy_policy_sample($formattedParent, $deployPolicyId); | ||
} | ||
// [END clouddeploy_v1_generated_CloudDeploy_CreateDeployPolicy_sync] |
81 changes: 81 additions & 0 deletions
81
Deploy/samples/V1/CloudDeployClient/delete_deploy_policy.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
/* | ||
* Copyright 2024 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 clouddeploy_v1_generated_CloudDeploy_DeleteDeployPolicy_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\ApiCore\OperationResponse; | ||
use Google\Cloud\Deploy\V1\Client\CloudDeployClient; | ||
use Google\Cloud\Deploy\V1\DeleteDeployPolicyRequest; | ||
use Google\Rpc\Status; | ||
|
||
/** | ||
* Deletes a single DeployPolicy. | ||
* | ||
* @param string $formattedName The name of the `DeployPolicy` to delete. Format should be | ||
* `projects/{project_id}/locations/{location_name}/deployPolicies/{deploy_policy_name}`. Please see | ||
* {@see CloudDeployClient::deployPolicyName()} for help formatting this field. | ||
*/ | ||
function delete_deploy_policy_sample(string $formattedName): void | ||
{ | ||
// Create a client. | ||
$cloudDeployClient = new CloudDeployClient(); | ||
|
||
// Prepare the request message. | ||
$request = (new DeleteDeployPolicyRequest()) | ||
->setName($formattedName); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var OperationResponse $response */ | ||
$response = $cloudDeployClient->deleteDeployPolicy($request); | ||
$response->pollUntilComplete(); | ||
|
||
if ($response->operationSucceeded()) { | ||
printf('Operation completed successfully.' . PHP_EOL); | ||
} 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 = CloudDeployClient::deployPolicyName('[PROJECT]', '[LOCATION]', '[DEPLOY_POLICY]'); | ||
|
||
delete_deploy_policy_sample($formattedName); | ||
} | ||
// [END clouddeploy_v1_generated_CloudDeploy_DeleteDeployPolicy_sync] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
/* | ||
* Copyright 2024 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 clouddeploy_v1_generated_CloudDeploy_GetDeployPolicy_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\Deploy\V1\Client\CloudDeployClient; | ||
use Google\Cloud\Deploy\V1\DeployPolicy; | ||
use Google\Cloud\Deploy\V1\GetDeployPolicyRequest; | ||
|
||
/** | ||
* Gets details of a single DeployPolicy. | ||
* | ||
* @param string $formattedName Name of the `DeployPolicy`. Format must be | ||
* `projects/{project_id}/locations/{location_name}/deployPolicies/{deploy_policy_name}`. Please see | ||
* {@see CloudDeployClient::deployPolicyName()} for help formatting this field. | ||
*/ | ||
function get_deploy_policy_sample(string $formattedName): void | ||
{ | ||
// Create a client. | ||
$cloudDeployClient = new CloudDeployClient(); | ||
|
||
// Prepare the request message. | ||
$request = (new GetDeployPolicyRequest()) | ||
->setName($formattedName); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var DeployPolicy $response */ | ||
$response = $cloudDeployClient->getDeployPolicy($request); | ||
printf('Response data: %s' . PHP_EOL, $response->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 = CloudDeployClient::deployPolicyName('[PROJECT]', '[LOCATION]', '[DEPLOY_POLICY]'); | ||
|
||
get_deploy_policy_sample($formattedName); | ||
} | ||
// [END clouddeploy_v1_generated_CloudDeploy_GetDeployPolicy_sync] |
77 changes: 77 additions & 0 deletions
77
Deploy/samples/V1/CloudDeployClient/list_deploy_policies.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
/* | ||
* Copyright 2024 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 clouddeploy_v1_generated_CloudDeploy_ListDeployPolicies_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\ApiCore\PagedListResponse; | ||
use Google\Cloud\Deploy\V1\Client\CloudDeployClient; | ||
use Google\Cloud\Deploy\V1\DeployPolicy; | ||
use Google\Cloud\Deploy\V1\ListDeployPoliciesRequest; | ||
|
||
/** | ||
* Lists DeployPolicies in a given project and location. | ||
* | ||
* @param string $formattedParent The parent, which owns this collection of deploy policies. Format | ||
* must be `projects/{project_id}/locations/{location_name}`. Please see | ||
* {@see CloudDeployClient::locationName()} for help formatting this field. | ||
*/ | ||
function list_deploy_policies_sample(string $formattedParent): void | ||
{ | ||
// Create a client. | ||
$cloudDeployClient = new CloudDeployClient(); | ||
|
||
// Prepare the request message. | ||
$request = (new ListDeployPoliciesRequest()) | ||
->setParent($formattedParent); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var PagedListResponse $response */ | ||
$response = $cloudDeployClient->listDeployPolicies($request); | ||
|
||
/** @var DeployPolicy $element */ | ||
foreach ($response as $element) { | ||
printf('Element data: %s' . PHP_EOL, $element->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 = CloudDeployClient::locationName('[PROJECT]', '[LOCATION]'); | ||
|
||
list_deploy_policies_sample($formattedParent); | ||
} | ||
// [END clouddeploy_v1_generated_CloudDeploy_ListDeployPolicies_sync] |
Oops, something went wrong.