Skip to content

Commit

Permalink
feat: add Automation API and Rollback API (#6767)
Browse files Browse the repository at this point in the history
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
gcf-owl-bot[bot] authored Nov 5, 2023
1 parent 43b4687 commit 7b2c7b9
Show file tree
Hide file tree
Showing 130 changed files with 12,399 additions and 527 deletions.
34 changes: 34 additions & 0 deletions Deploy/metadata/V1/AutomationPayload.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions Deploy/metadata/V1/AutomationrunPayload.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Deploy/metadata/V1/CloudDeploy.php
Binary file not shown.
8 changes: 5 additions & 3 deletions Deploy/metadata/V1/ReleaseRenderPayload.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Deploy/metadata/V1/RolloutUpdatePayload.php
Binary file not shown.
3 changes: 1 addition & 2 deletions Deploy/samples/V1/CloudDeployClient/abandon_release.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
* Abandons a Release in the Delivery Pipeline.
*
* @param string $formattedName Name of the Release. Format is
* projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/
* releases/{release}. Please see
* `projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/releases/{release}`. Please see
* {@see CloudDeployClient::releaseName()} for help formatting this field.
*/
function abandon_release_sample(string $formattedName): void
Expand Down
3 changes: 1 addition & 2 deletions Deploy/samples/V1/CloudDeployClient/advance_rollout.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
* Advances a Rollout in a given project and location.
*
* @param string $formattedName Name of the Rollout. Format is
* projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/
* releases/{release}/rollouts/{rollout}. Please see
* `projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/releases/{release}/rollouts/{rollout}`. Please see
* {@see CloudDeployClient::rolloutName()} for help formatting this field.
* @param string $phaseId The phase ID to advance the `Rollout` to.
*/
Expand Down
3 changes: 1 addition & 2 deletions Deploy/samples/V1/CloudDeployClient/approve_rollout.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
* Approves a Rollout.
*
* @param string $formattedName Name of the Rollout. Format is
* projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/
* releases/{release}/rollouts/{rollout}. Please see
* `projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/releases/{release}/rollouts/{rollout}`. Please see
* {@see CloudDeployClient::rolloutName()} for help formatting this field.
* @param bool $approved True = approve; false = reject
*/
Expand Down
80 changes: 80 additions & 0 deletions Deploy/samples/V1/CloudDeployClient/cancel_automation_run.php
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]
3 changes: 1 addition & 2 deletions Deploy/samples/V1/CloudDeployClient/cancel_rollout.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
* Cancels a Rollout in a given project and location.
*
* @param string $formattedName Name of the Rollout. Format is
* projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/
* releases/{release}/rollouts/{rollout}. Please see
* `projects/{project}/locations/{location}/deliveryPipelines/{deliveryPipeline}/releases/{release}/rollouts/{rollout}`. Please see
* {@see CloudDeployClient::rolloutName()} for help formatting this field.
*/
function cancel_rollout_sample(string $formattedName): void
Expand Down
107 changes: 107 additions & 0 deletions Deploy/samples/V1/CloudDeployClient/create_automation.php
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]
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
* Creates a new DeliveryPipeline in a given project and location.
*
* @param string $formattedParent The parent collection in which the `DeliveryPipeline` should be
* created. Format should be projects/{project_id}/locations/{location_name}. Please see
* created. Format should be
* `projects/{project_id}/locations/{location_name}`. Please see
* {@see CloudDeployClient::locationName()} for help formatting this field.
* @param string $deliveryPipelineId ID of the `DeliveryPipeline`.
*/
Expand Down
2 changes: 1 addition & 1 deletion Deploy/samples/V1/CloudDeployClient/create_release.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*
* @param string $formattedParent The parent collection in which the `Release` should be created.
* Format should be
* projects/{project_id}/locations/{location_name}/deliveryPipelines/{pipeline_name}. Please see
* `projects/{project_id}/locations/{location_name}/deliveryPipelines/{pipeline_name}`. Please see
* {@see CloudDeployClient::deliveryPipelineName()} for help formatting this field.
* @param string $releaseId ID of the `Release`.
*/
Expand Down
2 changes: 1 addition & 1 deletion Deploy/samples/V1/CloudDeployClient/create_rollout.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*
* @param string $formattedParent The parent collection in which the `Rollout` should be created.
* Format should be
* projects/{project_id}/locations/{location_name}/deliveryPipelines/{pipeline_name}/releases/{release_name}. Please see
* `projects/{project_id}/locations/{location_name}/deliveryPipelines/{pipeline_name}/releases/{release_name}`. Please see
* {@see CloudDeployClient::releaseName()} for help formatting this field.
* @param string $rolloutId ID of the `Rollout`.
* @param string $rolloutTargetId The ID of Target to which this `Rollout` is deploying.
Expand Down
2 changes: 1 addition & 1 deletion Deploy/samples/V1/CloudDeployClient/create_target.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*
* @param string $formattedParent The parent collection in which the `Target` should be created.
* Format should be
* projects/{project_id}/locations/{location_name}. Please see
* `projects/{project_id}/locations/{location_name}`. Please see
* {@see CloudDeployClient::locationName()} for help formatting this field.
* @param string $targetId ID of the `Target`.
*/
Expand Down
Loading

0 comments on commit 7b2c7b9

Please sign in to comment.