diff --git a/Config/metadata/V1/Config.php b/Config/metadata/V1/Config.php index 6cb6772390c1..7fadb2e813b0 100644 Binary files a/Config/metadata/V1/Config.php and b/Config/metadata/V1/Config.php differ diff --git a/Config/samples/V1/ConfigClient/get_auto_migration_config.php b/Config/samples/V1/ConfigClient/get_auto_migration_config.php new file mode 100644 index 000000000000..3ed7a61f1e5e --- /dev/null +++ b/Config/samples/V1/ConfigClient/get_auto_migration_config.php @@ -0,0 +1,73 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var AutoMigrationConfig $response */ + $response = $configClient->getAutoMigrationConfig($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::autoMigrationConfigName('[PROJECT]', '[LOCATION]'); + + get_auto_migration_config_sample($formattedName); +} +// [END config_v1_generated_Config_GetAutoMigrationConfig_sync] diff --git a/Config/samples/V1/ConfigClient/update_auto_migration_config.php b/Config/samples/V1/ConfigClient/update_auto_migration_config.php new file mode 100644 index 000000000000..92cd992b1620 --- /dev/null +++ b/Config/samples/V1/ConfigClient/update_auto_migration_config.php @@ -0,0 +1,71 @@ +setAutoMigrationConfig($autoMigrationConfig); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $configClient->updateAutoMigrationConfig($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var AutoMigrationConfig $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()); + } +} +// [END config_v1_generated_Config_UpdateAutoMigrationConfig_sync] diff --git a/Config/src/V1/AutoMigrationConfig.php b/Config/src/V1/AutoMigrationConfig.php new file mode 100644 index 000000000000..8d68a9c15012 --- /dev/null +++ b/Config/src/V1/AutoMigrationConfig.php @@ -0,0 +1,153 @@ +google.cloud.config.v1.AutoMigrationConfig + */ +class AutoMigrationConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Identifier. The name of the AutoMigrationConfig. + * Format: + * 'projects/{project_id}/locations/{location}/AutoMigrationConfig'. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + */ + protected $name = ''; + /** + * Output only. Time the AutoMigrationConfig was last updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $update_time = null; + /** + * Optional. Whether the auto migration is enabled for the project. + * + * Generated from protobuf field bool auto_migration_enabled = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $auto_migration_enabled = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Identifier. The name of the AutoMigrationConfig. + * Format: + * 'projects/{project_id}/locations/{location}/AutoMigrationConfig'. + * @type \Google\Protobuf\Timestamp $update_time + * Output only. Time the AutoMigrationConfig was last updated. + * @type bool $auto_migration_enabled + * Optional. Whether the auto migration is enabled for the project. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Config\V1\Config::initOnce(); + parent::__construct($data); + } + + /** + * Identifier. The name of the AutoMigrationConfig. + * Format: + * 'projects/{project_id}/locations/{location}/AutoMigrationConfig'. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Identifier. The name of the AutoMigrationConfig. + * Format: + * 'projects/{project_id}/locations/{location}/AutoMigrationConfig'. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Output only. Time the AutoMigrationConfig was last updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getUpdateTime() + { + return $this->update_time; + } + + public function hasUpdateTime() + { + return isset($this->update_time); + } + + public function clearUpdateTime() + { + unset($this->update_time); + } + + /** + * Output only. Time the AutoMigrationConfig was last updated. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + + /** + * Optional. Whether the auto migration is enabled for the project. + * + * Generated from protobuf field bool auto_migration_enabled = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getAutoMigrationEnabled() + { + return $this->auto_migration_enabled; + } + + /** + * Optional. Whether the auto migration is enabled for the project. + * + * Generated from protobuf field bool auto_migration_enabled = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setAutoMigrationEnabled($var) + { + GPBUtil::checkBool($var); + $this->auto_migration_enabled = $var; + + return $this; + } + +} + diff --git a/Config/src/V1/Client/ConfigClient.php b/Config/src/V1/Client/ConfigClient.php index c8936cb0fdeb..a9a275a45919 100644 --- a/Config/src/V1/Client/ConfigClient.php +++ b/Config/src/V1/Client/ConfigClient.php @@ -35,6 +35,7 @@ use Google\ApiCore\Transport\TransportInterface; use Google\ApiCore\ValidationException; use Google\Auth\FetchAuthTokenInterface; +use Google\Cloud\Config\V1\AutoMigrationConfig; use Google\Cloud\Config\V1\CreateDeploymentRequest; use Google\Cloud\Config\V1\CreatePreviewRequest; use Google\Cloud\Config\V1\DeleteDeploymentRequest; @@ -46,6 +47,7 @@ use Google\Cloud\Config\V1\ExportPreviewResultRequest; use Google\Cloud\Config\V1\ExportPreviewResultResponse; use Google\Cloud\Config\V1\ExportRevisionStatefileRequest; +use Google\Cloud\Config\V1\GetAutoMigrationConfigRequest; use Google\Cloud\Config\V1\GetDeploymentRequest; use Google\Cloud\Config\V1\GetPreviewRequest; use Google\Cloud\Config\V1\GetResourceChangeRequest; @@ -71,6 +73,7 @@ use Google\Cloud\Config\V1\Statefile; use Google\Cloud\Config\V1\TerraformVersion; use Google\Cloud\Config\V1\UnlockDeploymentRequest; +use Google\Cloud\Config\V1\UpdateAutoMigrationConfigRequest; use Google\Cloud\Config\V1\UpdateDeploymentRequest; use Google\Cloud\Iam\V1\GetIamPolicyRequest; use Google\Cloud\Iam\V1\Policy; @@ -106,6 +109,7 @@ * @method PromiseInterface exportLockInfoAsync(ExportLockInfoRequest $request, array $optionalArgs = []) * @method PromiseInterface exportPreviewResultAsync(ExportPreviewResultRequest $request, array $optionalArgs = []) * @method PromiseInterface exportRevisionStatefileAsync(ExportRevisionStatefileRequest $request, array $optionalArgs = []) + * @method PromiseInterface getAutoMigrationConfigAsync(GetAutoMigrationConfigRequest $request, array $optionalArgs = []) * @method PromiseInterface getDeploymentAsync(GetDeploymentRequest $request, array $optionalArgs = []) * @method PromiseInterface getPreviewAsync(GetPreviewRequest $request, array $optionalArgs = []) * @method PromiseInterface getResourceAsync(GetResourceRequest $request, array $optionalArgs = []) @@ -123,6 +127,7 @@ * @method PromiseInterface listTerraformVersionsAsync(ListTerraformVersionsRequest $request, array $optionalArgs = []) * @method PromiseInterface lockDeploymentAsync(LockDeploymentRequest $request, array $optionalArgs = []) * @method PromiseInterface unlockDeploymentAsync(UnlockDeploymentRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateAutoMigrationConfigAsync(UpdateAutoMigrationConfigRequest $request, array $optionalArgs = []) * @method PromiseInterface updateDeploymentAsync(UpdateDeploymentRequest $request, array $optionalArgs = []) * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) @@ -226,6 +231,23 @@ private function createOperationsClient(array $options) return new OperationsClient($options); } + /** + * Formats a string containing the fully-qualified path to represent a + * auto_migration_config resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted auto_migration_config resource. + */ + public static function autoMigrationConfigName(string $project, string $location): string + { + return self::getPathTemplate('autoMigrationConfig')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + /** * Formats a string containing the fully-qualified path to represent a deployment * resource. @@ -439,6 +461,7 @@ public static function workerPoolName(string $project, string $location, string * Parses a formatted name string and returns an associative array of the components in the name. * The following name formats are supported: * Template: Pattern + * - autoMigrationConfig: projects/{project}/locations/{location}/autoMigrationConfig * - deployment: projects/{project}/locations/{location}/deployments/{deployment} * - location: projects/{project}/locations/{location} * - preview: projects/{project}/locations/{location}/previews/{preview} @@ -790,6 +813,34 @@ public function exportRevisionStatefile(ExportRevisionStatefileRequest $request, return $this->startApiCall('ExportRevisionStatefile', $request, $callOptions)->wait(); } + /** + * Get the AutoMigrationConfig for a given project and location. + * + * The async variant is {@see ConfigClient::getAutoMigrationConfigAsync()} . + * + * @example samples/V1/ConfigClient/get_auto_migration_config.php + * + * @param GetAutoMigrationConfigRequest $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 AutoMigrationConfig + * + * @throws ApiException Thrown if the API call fails. + */ + public function getAutoMigrationConfig( + GetAutoMigrationConfigRequest $request, + array $callOptions = [] + ): AutoMigrationConfig { + return $this->startApiCall('GetAutoMigrationConfig', $request, $callOptions)->wait(); + } + /** * Gets details about a [Deployment][google.cloud.config.v1.Deployment]. * @@ -1240,6 +1291,34 @@ public function unlockDeployment(UnlockDeploymentRequest $request, array $callOp return $this->startApiCall('UnlockDeployment', $request, $callOptions)->wait(); } + /** + * Updates the AutoMigrationConfig for a given project and location. + * + * The async variant is {@see ConfigClient::updateAutoMigrationConfigAsync()} . + * + * @example samples/V1/ConfigClient/update_auto_migration_config.php + * + * @param UpdateAutoMigrationConfigRequest $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 OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateAutoMigrationConfig( + UpdateAutoMigrationConfigRequest $request, + array $callOptions = [] + ): OperationResponse { + return $this->startApiCall('UpdateAutoMigrationConfig', $request, $callOptions)->wait(); + } + /** * Updates a [Deployment][google.cloud.config.v1.Deployment]. * diff --git a/Config/src/V1/Deployment/ErrorCode.php b/Config/src/V1/Deployment/ErrorCode.php index eca3f8048d6c..296f2eccfa28 100644 --- a/Config/src/V1/Deployment/ErrorCode.php +++ b/Config/src/V1/Deployment/ErrorCode.php @@ -58,6 +58,12 @@ class ErrorCode * Generated from protobuf enum BUCKET_CREATION_FAILED = 8; */ const BUCKET_CREATION_FAILED = 8; + /** + * Failed to import values from an external source. + * + * Generated from protobuf enum EXTERNAL_VALUE_SOURCE_IMPORT_FAILED = 10; + */ + const EXTERNAL_VALUE_SOURCE_IMPORT_FAILED = 10; private static $valueToName = [ self::ERROR_CODE_UNSPECIFIED => 'ERROR_CODE_UNSPECIFIED', @@ -67,6 +73,7 @@ class ErrorCode self::DELETE_BUILD_RUN_FAILED => 'DELETE_BUILD_RUN_FAILED', self::BUCKET_CREATION_PERMISSION_DENIED => 'BUCKET_CREATION_PERMISSION_DENIED', self::BUCKET_CREATION_FAILED => 'BUCKET_CREATION_FAILED', + self::EXTERNAL_VALUE_SOURCE_IMPORT_FAILED => 'EXTERNAL_VALUE_SOURCE_IMPORT_FAILED', ]; public static function name($value) diff --git a/Config/src/V1/GetAutoMigrationConfigRequest.php b/Config/src/V1/GetAutoMigrationConfigRequest.php new file mode 100644 index 000000000000..dca79ece5635 --- /dev/null +++ b/Config/src/V1/GetAutoMigrationConfigRequest.php @@ -0,0 +1,91 @@ +google.cloud.config.v1.GetAutoMigrationConfigRequest + */ +class GetAutoMigrationConfigRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the AutoMigrationConfig. + * Format: + * 'projects/{project_id}/locations/{location}/AutoMigrationConfig'. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. The name of the AutoMigrationConfig. + * Format: + * 'projects/{project_id}/locations/{location}/AutoMigrationConfig'. Please see + * {@see ConfigClient::autoMigrationConfigName()} for help formatting this field. + * + * @return \Google\Cloud\Config\V1\GetAutoMigrationConfigRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The name of the AutoMigrationConfig. + * Format: + * 'projects/{project_id}/locations/{location}/AutoMigrationConfig'. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Config\V1\Config::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the AutoMigrationConfig. + * Format: + * 'projects/{project_id}/locations/{location}/AutoMigrationConfig'. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. The name of the AutoMigrationConfig. + * Format: + * 'projects/{project_id}/locations/{location}/AutoMigrationConfig'. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/Config/src/V1/Preview/ErrorCode.php b/Config/src/V1/Preview/ErrorCode.php index e9a35c86d9a3..0c2a4d303857 100644 --- a/Config/src/V1/Preview/ErrorCode.php +++ b/Config/src/V1/Preview/ErrorCode.php @@ -55,6 +55,12 @@ class ErrorCode * Generated from protobuf enum PREVIEW_BUILD_RUN_FAILED = 6; */ const PREVIEW_BUILD_RUN_FAILED = 6; + /** + * Failed to import values from an external source. + * + * Generated from protobuf enum EXTERNAL_VALUE_SOURCE_IMPORT_FAILED = 7; + */ + const EXTERNAL_VALUE_SOURCE_IMPORT_FAILED = 7; private static $valueToName = [ self::ERROR_CODE_UNSPECIFIED => 'ERROR_CODE_UNSPECIFIED', @@ -64,6 +70,7 @@ class ErrorCode self::DEPLOYMENT_LOCK_ACQUIRE_FAILED => 'DEPLOYMENT_LOCK_ACQUIRE_FAILED', self::PREVIEW_BUILD_API_FAILED => 'PREVIEW_BUILD_API_FAILED', self::PREVIEW_BUILD_RUN_FAILED => 'PREVIEW_BUILD_RUN_FAILED', + self::EXTERNAL_VALUE_SOURCE_IMPORT_FAILED => 'EXTERNAL_VALUE_SOURCE_IMPORT_FAILED', ]; public static function name($value) diff --git a/Config/src/V1/Revision/ErrorCode.php b/Config/src/V1/Revision/ErrorCode.php index 3c53f564698b..d1012db4984b 100644 --- a/Config/src/V1/Revision/ErrorCode.php +++ b/Config/src/V1/Revision/ErrorCode.php @@ -46,6 +46,12 @@ class ErrorCode * Generated from protobuf enum QUOTA_VALIDATION_FAILED = 7; */ const QUOTA_VALIDATION_FAILED = 7; + /** + * Failed to import values from an external source. + * + * Generated from protobuf enum EXTERNAL_VALUE_SOURCE_IMPORT_FAILED = 8; + */ + const EXTERNAL_VALUE_SOURCE_IMPORT_FAILED = 8; private static $valueToName = [ self::ERROR_CODE_UNSPECIFIED => 'ERROR_CODE_UNSPECIFIED', @@ -53,6 +59,7 @@ class ErrorCode self::APPLY_BUILD_API_FAILED => 'APPLY_BUILD_API_FAILED', self::APPLY_BUILD_RUN_FAILED => 'APPLY_BUILD_RUN_FAILED', self::QUOTA_VALIDATION_FAILED => 'QUOTA_VALIDATION_FAILED', + self::EXTERNAL_VALUE_SOURCE_IMPORT_FAILED => 'EXTERNAL_VALUE_SOURCE_IMPORT_FAILED', ]; public static function name($value) diff --git a/Config/src/V1/UpdateAutoMigrationConfigRequest.php b/Config/src/V1/UpdateAutoMigrationConfigRequest.php new file mode 100644 index 000000000000..27c3e1c5d96a --- /dev/null +++ b/Config/src/V1/UpdateAutoMigrationConfigRequest.php @@ -0,0 +1,141 @@ +google.cloud.config.v1.UpdateAutoMigrationConfigRequest + */ +class UpdateAutoMigrationConfigRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. The update mask applies to the resource. See + * [google.protobuf.FieldMask][google.protobuf.FieldMask]. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $update_mask = null; + /** + * Required. The AutoMigrationConfig to update. + * + * Generated from protobuf field .google.cloud.config.v1.AutoMigrationConfig auto_migration_config = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $auto_migration_config = null; + + /** + * @param \Google\Cloud\Config\V1\AutoMigrationConfig $autoMigrationConfig Required. The AutoMigrationConfig to update. + * @param \Google\Protobuf\FieldMask $updateMask Optional. The update mask applies to the resource. See + * [google.protobuf.FieldMask][google.protobuf.FieldMask]. + * + * @return \Google\Cloud\Config\V1\UpdateAutoMigrationConfigRequest + * + * @experimental + */ + public static function build(\Google\Cloud\Config\V1\AutoMigrationConfig $autoMigrationConfig, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setAutoMigrationConfig($autoMigrationConfig) + ->setUpdateMask($updateMask); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Protobuf\FieldMask $update_mask + * Optional. The update mask applies to the resource. See + * [google.protobuf.FieldMask][google.protobuf.FieldMask]. + * @type \Google\Cloud\Config\V1\AutoMigrationConfig $auto_migration_config + * Required. The AutoMigrationConfig to update. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Config\V1\Config::initOnce(); + parent::__construct($data); + } + + /** + * Optional. The update mask applies to the resource. See + * [google.protobuf.FieldMask][google.protobuf.FieldMask]. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\FieldMask|null + */ + public function getUpdateMask() + { + return $this->update_mask; + } + + public function hasUpdateMask() + { + return isset($this->update_mask); + } + + public function clearUpdateMask() + { + unset($this->update_mask); + } + + /** + * Optional. The update mask applies to the resource. See + * [google.protobuf.FieldMask][google.protobuf.FieldMask]. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setUpdateMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->update_mask = $var; + + return $this; + } + + /** + * Required. The AutoMigrationConfig to update. + * + * Generated from protobuf field .google.cloud.config.v1.AutoMigrationConfig auto_migration_config = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\Config\V1\AutoMigrationConfig|null + */ + public function getAutoMigrationConfig() + { + return $this->auto_migration_config; + } + + public function hasAutoMigrationConfig() + { + return isset($this->auto_migration_config); + } + + public function clearAutoMigrationConfig() + { + unset($this->auto_migration_config); + } + + /** + * Required. The AutoMigrationConfig to update. + * + * Generated from protobuf field .google.cloud.config.v1.AutoMigrationConfig auto_migration_config = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\Config\V1\AutoMigrationConfig $var + * @return $this + */ + public function setAutoMigrationConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Config\V1\AutoMigrationConfig::class); + $this->auto_migration_config = $var; + + return $this; + } + +} + diff --git a/Config/src/V1/gapic_metadata.json b/Config/src/V1/gapic_metadata.json index 63cb9e090c1a..b9845aa6e5b7 100644 --- a/Config/src/V1/gapic_metadata.json +++ b/Config/src/V1/gapic_metadata.json @@ -55,6 +55,11 @@ "exportRevisionStatefile" ] }, + "GetAutoMigrationConfig": { + "methods": [ + "getAutoMigrationConfig" + ] + }, "GetDeployment": { "methods": [ "getDeployment" @@ -140,6 +145,11 @@ "unlockDeployment" ] }, + "UpdateAutoMigrationConfig": { + "methods": [ + "updateAutoMigrationConfig" + ] + }, "UpdateDeployment": { "methods": [ "updateDeployment" diff --git a/Config/src/V1/resources/config_client_config.json b/Config/src/V1/resources/config_client_config.json index e3d764843df4..3f708b92828a 100644 --- a/Config/src/V1/resources/config_client_config.json +++ b/Config/src/V1/resources/config_client_config.json @@ -73,6 +73,11 @@ "retry_codes_name": "retry_policy_1_codes", "retry_params_name": "retry_policy_1_params" }, + "GetAutoMigrationConfig": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, "GetDeployment": { "timeout_millis": 60000, "retry_codes_name": "retry_policy_1_codes", @@ -158,6 +163,11 @@ "retry_codes_name": "retry_policy_1_codes", "retry_params_name": "retry_policy_1_params" }, + "UpdateAutoMigrationConfig": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, "UpdateDeployment": { "timeout_millis": 60000, "retry_codes_name": "retry_policy_1_codes", diff --git a/Config/src/V1/resources/config_descriptor_config.php b/Config/src/V1/resources/config_descriptor_config.php index 93a0a7d4820e..5f3e82dfdf2a 100644 --- a/Config/src/V1/resources/config_descriptor_config.php +++ b/Config/src/V1/resources/config_descriptor_config.php @@ -137,6 +137,26 @@ ], ], ], + 'UpdateAutoMigrationConfig' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\Config\V1\AutoMigrationConfig', + 'metadataReturnType' => '\Google\Cloud\Config\V1\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'auto_migration_config.name', + 'fieldAccessors' => [ + 'getAutoMigrationConfig', + 'getName', + ], + ], + ], + ], 'UpdateDeployment' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\Config\V1\Deployment', @@ -217,6 +237,18 @@ ], ], ], + 'GetAutoMigrationConfig' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Config\V1\AutoMigrationConfig', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'GetDeployment' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Cloud\Config\V1\Deployment', @@ -527,6 +559,7 @@ 'interfaceOverride' => 'google.iam.v1.IAMPolicy', ], 'templateMap' => [ + 'autoMigrationConfig' => 'projects/{project}/locations/{location}/autoMigrationConfig', 'deployment' => 'projects/{project}/locations/{location}/deployments/{deployment}', 'location' => 'projects/{project}/locations/{location}', 'preview' => 'projects/{project}/locations/{location}/previews/{preview}', diff --git a/Config/src/V1/resources/config_rest_client_config.php b/Config/src/V1/resources/config_rest_client_config.php index 870141fcd3d7..d43e4d776eb1 100644 --- a/Config/src/V1/resources/config_rest_client_config.php +++ b/Config/src/V1/resources/config_rest_client_config.php @@ -131,6 +131,17 @@ ], ], ], + 'GetAutoMigrationConfig' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/autoMigrationConfig}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], 'GetDeployment' => [ 'method' => 'get', 'uriTemplate' => '/v1/{name=projects/*/locations/*/deployments/*}', @@ -321,6 +332,19 @@ ], ], ], + 'UpdateAutoMigrationConfig' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{auto_migration_config.name=projects/*/locations/*/autoMigrationConfig}', + 'body' => 'auto_migration_config', + 'placeholders' => [ + 'auto_migration_config.name' => [ + 'getters' => [ + 'getAutoMigrationConfig', + 'getName', + ], + ], + ], + ], 'UpdateDeployment' => [ 'method' => 'patch', 'uriTemplate' => '/v1/{deployment.name=projects/*/locations/*/deployments/*}', diff --git a/Config/tests/Unit/V1/Client/ConfigClientTest.php b/Config/tests/Unit/V1/Client/ConfigClientTest.php index d789c55b923d..6e1ddd36e44f 100644 --- a/Config/tests/Unit/V1/Client/ConfigClientTest.php +++ b/Config/tests/Unit/V1/Client/ConfigClientTest.php @@ -26,6 +26,7 @@ use Google\ApiCore\CredentialsWrapper; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; +use Google\Cloud\Config\V1\AutoMigrationConfig; use Google\Cloud\Config\V1\Client\ConfigClient; use Google\Cloud\Config\V1\CreateDeploymentRequest; use Google\Cloud\Config\V1\CreatePreviewRequest; @@ -38,6 +39,7 @@ use Google\Cloud\Config\V1\ExportPreviewResultRequest; use Google\Cloud\Config\V1\ExportPreviewResultResponse; use Google\Cloud\Config\V1\ExportRevisionStatefileRequest; +use Google\Cloud\Config\V1\GetAutoMigrationConfigRequest; use Google\Cloud\Config\V1\GetDeploymentRequest; use Google\Cloud\Config\V1\GetPreviewRequest; use Google\Cloud\Config\V1\GetResourceChangeRequest; @@ -70,6 +72,7 @@ use Google\Cloud\Config\V1\Statefile; use Google\Cloud\Config\V1\TerraformVersion; use Google\Cloud\Config\V1\UnlockDeploymentRequest; +use Google\Cloud\Config\V1\UpdateAutoMigrationConfigRequest; use Google\Cloud\Config\V1\UpdateDeploymentRequest; use Google\Cloud\Iam\V1\GetIamPolicyRequest; use Google\Cloud\Iam\V1\Policy; @@ -1052,6 +1055,73 @@ public function exportRevisionStatefileExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function getAutoMigrationConfigTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $autoMigrationEnabled = true; + $expectedResponse = new AutoMigrationConfig(); + $expectedResponse->setName($name2); + $expectedResponse->setAutoMigrationEnabled($autoMigrationEnabled); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->autoMigrationConfigName('[PROJECT]', '[LOCATION]'); + $request = (new GetAutoMigrationConfigRequest())->setName($formattedName); + $response = $gapicClient->getAutoMigrationConfig($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.config.v1.Config/GetAutoMigrationConfig', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getAutoMigrationConfigExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->autoMigrationConfigName('[PROJECT]', '[LOCATION]'); + $request = (new GetAutoMigrationConfigRequest())->setName($formattedName); + try { + $gapicClient->getAutoMigrationConfig($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function getDeploymentTest() { @@ -2441,6 +2511,132 @@ public function unlockDeploymentExceptionTest() $this->assertTrue($operationsTransport->isExhausted()); } + /** @test */ + public function updateAutoMigrationConfigTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateAutoMigrationConfigTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $autoMigrationEnabled = true; + $expectedResponse = new AutoMigrationConfig(); + $expectedResponse->setName($name); + $expectedResponse->setAutoMigrationEnabled($autoMigrationEnabled); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/updateAutoMigrationConfigTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $autoMigrationConfig = new AutoMigrationConfig(); + $request = (new UpdateAutoMigrationConfigRequest())->setAutoMigrationConfig($autoMigrationConfig); + $response = $gapicClient->updateAutoMigrationConfig($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.config.v1.Config/UpdateAutoMigrationConfig', $actualApiFuncCall); + $actualValue = $actualApiRequestObject->getAutoMigrationConfig(); + $this->assertProtobufEquals($autoMigrationConfig, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateAutoMigrationConfigTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateAutoMigrationConfigExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateAutoMigrationConfigTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $operationsTransport->addResponse(null, $status); + // Mock request + $autoMigrationConfig = new AutoMigrationConfig(); + $request = (new UpdateAutoMigrationConfigRequest())->setAutoMigrationConfig($autoMigrationConfig); + $response = $gapicClient->updateAutoMigrationConfig($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateAutoMigrationConfigTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + /** @test */ public function updateDeploymentTest() {