-
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: add Automation API and Rollback API (#6767)
chore: update platform logs docs: small documentation updates PiperOrigin-RevId: 578872129 Source-Link: googleapis/googleapis@41d7a83 Source-Link: googleapis/googleapis-gen@eb84145 Copy-Tag: eyJwIjoiRGVwbG95Ly5Pd2xCb3QueWFtbCIsImgiOiJlYjg0MTQ1ZmMyNmNmMWY3N2Q2NWFmOWFkODJhMjM5ZGZkZGMxNmJkIn0=
- Loading branch information
1 parent
43b4687
commit 7b2c7b9
Showing
130 changed files
with
12,399 additions
and
527 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
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
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
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
80 changes: 80 additions & 0 deletions
80
Deploy/samples/V1/CloudDeployClient/cancel_automation_run.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,80 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 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_CancelAutomationRun_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\Deploy\V1\CancelAutomationRunRequest; | ||
use Google\Cloud\Deploy\V1\CancelAutomationRunResponse; | ||
use Google\Cloud\Deploy\V1\Client\CloudDeployClient; | ||
|
||
/** | ||
* Cancels an AutomationRun. The `state` of the `AutomationRun` after | ||
* cancelling is `CANCELLED`. `CancelAutomationRun` can be called on | ||
* AutomationRun in the state `IN_PROGRESS` and `PENDING`; AutomationRun | ||
* in a different state returns an `FAILED_PRECONDITION` error. | ||
* | ||
* @param string $formattedName Name of the `AutomationRun`. Format is | ||
* `projects/{project}/locations/{location}/deliveryPipelines/{delivery_pipeline}/automationRuns/{automation_run}`. Please see | ||
* {@see CloudDeployClient::automationRunName()} for help formatting this field. | ||
*/ | ||
function cancel_automation_run_sample(string $formattedName): void | ||
{ | ||
// Create a client. | ||
$cloudDeployClient = new CloudDeployClient(); | ||
|
||
// Prepare the request message. | ||
$request = (new CancelAutomationRunRequest()) | ||
->setName($formattedName); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var CancelAutomationRunResponse $response */ | ||
$response = $cloudDeployClient->cancelAutomationRun($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::automationRunName( | ||
'[PROJECT]', | ||
'[LOCATION]', | ||
'[DELIVERY_PIPELINE]', | ||
'[AUTOMATION_RUN]' | ||
); | ||
|
||
cancel_automation_run_sample($formattedName); | ||
} | ||
// [END clouddeploy_v1_generated_CloudDeploy_CancelAutomationRun_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
107 changes: 107 additions & 0 deletions
107
Deploy/samples/V1/CloudDeployClient/create_automation.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,107 @@ | ||
<?php | ||
/* | ||
* Copyright 2023 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_CreateAutomation_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\ApiCore\OperationResponse; | ||
use Google\Cloud\Deploy\V1\Automation; | ||
use Google\Cloud\Deploy\V1\AutomationResourceSelector; | ||
use Google\Cloud\Deploy\V1\AutomationRule; | ||
use Google\Cloud\Deploy\V1\Client\CloudDeployClient; | ||
use Google\Cloud\Deploy\V1\CreateAutomationRequest; | ||
use Google\Rpc\Status; | ||
|
||
/** | ||
* Creates a new Automation in a given project and location. | ||
* | ||
* @param string $formattedParent The parent collection in which the `Automation` should be | ||
* created. Format should be | ||
* `projects/{project_id}/locations/{location_name}/deliveryPipelines/{pipeline_name}`. Please see | ||
* {@see CloudDeployClient::deliveryPipelineName()} for help formatting this field. | ||
* @param string $automationId ID of the `Automation`. | ||
* @param string $automationServiceAccount Email address of the user-managed IAM service account that | ||
* creates Cloud Deploy release and rollout resources. | ||
*/ | ||
function create_automation_sample( | ||
string $formattedParent, | ||
string $automationId, | ||
string $automationServiceAccount | ||
): void { | ||
// Create a client. | ||
$cloudDeployClient = new CloudDeployClient(); | ||
|
||
// Prepare the request message. | ||
$automationSelector = new AutomationResourceSelector(); | ||
$automationRules = [new AutomationRule()]; | ||
$automation = (new Automation()) | ||
->setServiceAccount($automationServiceAccount) | ||
->setSelector($automationSelector) | ||
->setRules($automationRules); | ||
$request = (new CreateAutomationRequest()) | ||
->setParent($formattedParent) | ||
->setAutomationId($automationId) | ||
->setAutomation($automation); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var OperationResponse $response */ | ||
$response = $cloudDeployClient->createAutomation($request); | ||
$response->pollUntilComplete(); | ||
|
||
if ($response->operationSucceeded()) { | ||
/** @var Automation $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::deliveryPipelineName( | ||
'[PROJECT]', | ||
'[LOCATION]', | ||
'[DELIVERY_PIPELINE]' | ||
); | ||
$automationId = '[AUTOMATION_ID]'; | ||
$automationServiceAccount = '[SERVICE_ACCOUNT]'; | ||
|
||
create_automation_sample($formattedParent, $automationId, $automationServiceAccount); | ||
} | ||
// [END clouddeploy_v1_generated_CloudDeploy_CreateAutomation_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
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
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
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
Oops, something went wrong.