Skip to content

Commit

Permalink
feat: Infrastructure Manager supports the deployment of infrastructur…
Browse files Browse the repository at this point in the history
…e from Terraform configurations in a private Git repository (#7161)

feat: Infrastructure Manager can validate and enforce quota limits, preventing infrastructure that exceeds quota limits from being deployed
feat: Infrastructure manager supports the following versions of Terraform when creating a deployment: Terraform version 1.2.3, 1.3.10, 1.4.7, 1.5.7
docs: A comment for field `page_size` in message `.google.cloud.config.v1.ListDeploymentsRequest` is changed
docs: A comment for field `page_size` in message `.google.cloud.config.v1.ListRevisionsRequest` is changed
docs: A comment for field `page_size` in message `.google.cloud.config.v1.ListResourcesRequest` is changed
docs: A comment for field `service_account` in message `.google.cloud.config.v1.Preview` is changed
docs: A comment for field `page_size` in message `.google.cloud.config.v1.ListPreviewsRequest` is changed
PiperOrigin-RevId: 616858321
Source-Link: googleapis/googleapis@7e02769
Source-Link: googleapis/googleapis-gen@d71ec59
Copy-Tag: eyJwIjoiQ29uZmlnLy5Pd2xCb3QueWFtbCIsImgiOiJkNzFlYzU5ZDFkNzQyODNjNTk5MjQ5NTVlMDNhMzM5MzA4MGJhYzNmIn0=
  • Loading branch information
gcf-owl-bot[bot] committed Mar 22, 2024
1 parent a7f8970 commit 5541f21
Show file tree
Hide file tree
Showing 25 changed files with 1,716 additions and 44 deletions.
Binary file modified Config/metadata/V1/Config.php
Binary file not shown.
77 changes: 77 additions & 0 deletions Config/samples/V1/ConfigClient/get_terraform_version.php
@@ -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 config_v1_generated_Config_GetTerraformVersion_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\GetTerraformVersionRequest;
use Google\Cloud\Config\V1\TerraformVersion;

/**
* Gets details about a
* [TerraformVersion][google.cloud.config.v1.TerraformVersion].
*
* @param string $formattedName The name of the TerraformVersion. Format:
* 'projects/{project_id}/locations/{location}/terraformVersions/{terraform_version}'
* Please see {@see ConfigClient::terraformVersionName()} for help formatting this field.
*/
function get_terraform_version_sample(string $formattedName): void
{
// Create a client.
$configClient = new ConfigClient();

// Prepare the request message.
$request = (new GetTerraformVersionRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var TerraformVersion $response */
$response = $configClient->getTerraformVersion($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 = ConfigClient::terraformVersionName(
'[PROJECT]',
'[LOCATION]',
'[TERRAFORM_VERSION]'
);

get_terraform_version_sample($formattedName);
}
// [END config_v1_generated_Config_GetTerraformVersion_sync]
79 changes: 79 additions & 0 deletions Config/samples/V1/ConfigClient/list_terraform_versions.php
@@ -0,0 +1,79 @@
<?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 config_v1_generated_Config_ListTerraformVersions_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\ListTerraformVersionsRequest;
use Google\Cloud\Config\V1\TerraformVersion;

/**
* Lists [TerraformVersion][google.cloud.config.v1.TerraformVersion]s in a
* given project and location.
*
* @param string $formattedParent The parent in whose context the TerraformVersions are listed. The
* parent value is in the format:
* 'projects/{project_id}/locations/{location}'. Please see
* {@see ConfigClient::locationName()} for help formatting this field.
*/
function list_terraform_versions_sample(string $formattedParent): void
{
// Create a client.
$configClient = new ConfigClient();

// Prepare the request message.
$request = (new ListTerraformVersionsRequest())
->setParent($formattedParent);

// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $configClient->listTerraformVersions($request);

/** @var TerraformVersion $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 = ConfigClient::locationName('[PROJECT]', '[LOCATION]');

list_terraform_versions_sample($formattedParent);
}
// [END config_v1_generated_Config_ListTerraformVersions_sync]
81 changes: 81 additions & 0 deletions Config/src/V1/Client/ConfigClient.php
Expand Up @@ -50,17 +50,20 @@
use Google\Cloud\Config\V1\GetPreviewRequest;
use Google\Cloud\Config\V1\GetResourceRequest;
use Google\Cloud\Config\V1\GetRevisionRequest;
use Google\Cloud\Config\V1\GetTerraformVersionRequest;
use Google\Cloud\Config\V1\ImportStatefileRequest;
use Google\Cloud\Config\V1\ListDeploymentsRequest;
use Google\Cloud\Config\V1\ListPreviewsRequest;
use Google\Cloud\Config\V1\ListResourcesRequest;
use Google\Cloud\Config\V1\ListRevisionsRequest;
use Google\Cloud\Config\V1\ListTerraformVersionsRequest;
use Google\Cloud\Config\V1\LockDeploymentRequest;
use Google\Cloud\Config\V1\LockInfo;
use Google\Cloud\Config\V1\Preview;
use Google\Cloud\Config\V1\Resource;
use Google\Cloud\Config\V1\Revision;
use Google\Cloud\Config\V1\Statefile;
use Google\Cloud\Config\V1\TerraformVersion;
use Google\Cloud\Config\V1\UnlockDeploymentRequest;
use Google\Cloud\Config\V1\UpdateDeploymentRequest;
use Google\Cloud\Iam\V1\GetIamPolicyRequest;
Expand Down Expand Up @@ -99,11 +102,13 @@
* @method PromiseInterface getPreviewAsync(GetPreviewRequest $request, array $optionalArgs = [])
* @method PromiseInterface getResourceAsync(GetResourceRequest $request, array $optionalArgs = [])
* @method PromiseInterface getRevisionAsync(GetRevisionRequest $request, array $optionalArgs = [])
* @method PromiseInterface getTerraformVersionAsync(GetTerraformVersionRequest $request, array $optionalArgs = [])
* @method PromiseInterface importStatefileAsync(ImportStatefileRequest $request, array $optionalArgs = [])
* @method PromiseInterface listDeploymentsAsync(ListDeploymentsRequest $request, array $optionalArgs = [])
* @method PromiseInterface listPreviewsAsync(ListPreviewsRequest $request, array $optionalArgs = [])
* @method PromiseInterface listResourcesAsync(ListResourcesRequest $request, array $optionalArgs = [])
* @method PromiseInterface listRevisionsAsync(ListRevisionsRequest $request, array $optionalArgs = [])
* @method PromiseInterface listTerraformVersionsAsync(ListTerraformVersionsRequest $request, array $optionalArgs = [])
* @method PromiseInterface lockDeploymentAsync(LockDeploymentRequest $request, array $optionalArgs = [])
* @method PromiseInterface unlockDeploymentAsync(UnlockDeploymentRequest $request, array $optionalArgs = [])
* @method PromiseInterface updateDeploymentAsync(UpdateDeploymentRequest $request, array $optionalArgs = [])
Expand Down Expand Up @@ -313,6 +318,25 @@ public static function serviceAccountName(string $project, string $serviceAccoun
]);
}

/**
* Formats a string containing the fully-qualified path to represent a
* terraform_version resource.
*
* @param string $project
* @param string $location
* @param string $terraformVersion
*
* @return string The formatted terraform_version resource.
*/
public static function terraformVersionName(string $project, string $location, string $terraformVersion): string
{
return self::getPathTemplate('terraformVersion')->render([
'project' => $project,
'location' => $location,
'terraform_version' => $terraformVersion,
]);
}

/**
* Formats a string containing the fully-qualified path to represent a worker_pool
* resource.
Expand Down Expand Up @@ -342,6 +366,7 @@ public static function workerPoolName(string $project, string $location, string
* - resource: projects/{project}/locations/{location}/deployments/{deployment}/revisions/{revision}/resources/{resource}
* - revision: projects/{project}/locations/{location}/deployments/{deployment}/revisions/{revision}
* - serviceAccount: projects/{project}/serviceAccounts/{service_account}
* - terraformVersion: projects/{project}/locations/{location}/terraformVersions/{terraform_version}
* - workerPool: projects/{project}/locations/{location}/workerPools/{worker_pool}
*
* The optional $template argument can be supplied to specify a particular pattern,
Expand Down Expand Up @@ -775,6 +800,33 @@ public function getRevision(GetRevisionRequest $request, array $callOptions = []
return $this->startApiCall('GetRevision', $request, $callOptions)->wait();
}

/**
* Gets details about a
* [TerraformVersion][google.cloud.config.v1.TerraformVersion].
*
* The async variant is {@see ConfigClient::getTerraformVersionAsync()} .
*
* @example samples/V1/ConfigClient/get_terraform_version.php
*
* @param GetTerraformVersionRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
* {@see RetrySettings} for example usage.
* }
*
* @return TerraformVersion
*
* @throws ApiException Thrown if the API call fails.
*/
public function getTerraformVersion(GetTerraformVersionRequest $request, array $callOptions = []): TerraformVersion
{
return $this->startApiCall('GetTerraformVersion', $request, $callOptions)->wait();
}

/**
* Imports Terraform state file in a given deployment. The state file does not
* take effect until the Deployment has been unlocked.
Expand Down Expand Up @@ -908,6 +960,35 @@ public function listRevisions(ListRevisionsRequest $request, array $callOptions
return $this->startApiCall('ListRevisions', $request, $callOptions);
}

/**
* Lists [TerraformVersion][google.cloud.config.v1.TerraformVersion]s in a
* given project and location.
*
* The async variant is {@see ConfigClient::listTerraformVersionsAsync()} .
*
* @example samples/V1/ConfigClient/list_terraform_versions.php
*
* @param ListTerraformVersionsRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
* {@see RetrySettings} for example usage.
* }
*
* @return PagedListResponse
*
* @throws ApiException Thrown if the API call fails.
*/
public function listTerraformVersions(
ListTerraformVersionsRequest $request,
array $callOptions = []
): PagedListResponse {
return $this->startApiCall('ListTerraformVersions', $request, $callOptions);
}

/**
* Locks a deployment.
*
Expand Down

0 comments on commit 5541f21

Please sign in to comment.