diff --git a/BackupDr/metadata/V1/ProtectionSummary.php b/BackupDr/metadata/V1/ProtectionSummary.php new file mode 100644 index 000000000000..80aaf3b332c1 Binary files /dev/null and b/BackupDr/metadata/V1/ProtectionSummary.php differ diff --git a/BackupDr/samples/V1/BackupDrProtectionSummaryClient/get_iam_policy.php b/BackupDr/samples/V1/BackupDrProtectionSummaryClient/get_iam_policy.php new file mode 100644 index 000000000000..aff12bbc65b2 --- /dev/null +++ b/BackupDr/samples/V1/BackupDrProtectionSummaryClient/get_iam_policy.php @@ -0,0 +1,72 @@ +setResource($resource); + + // Call the API and handle any network failures. + try { + /** @var Policy $response */ + $response = $backupDrProtectionSummaryClient->getIamPolicy($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 +{ + $resource = '[RESOURCE]'; + + get_iam_policy_sample($resource); +} +// [END backupdr_v1_generated_BackupDrProtectionSummary_GetIamPolicy_sync] diff --git a/BackupDr/samples/V1/BackupDrProtectionSummaryClient/get_location.php b/BackupDr/samples/V1/BackupDrProtectionSummaryClient/get_location.php new file mode 100644 index 000000000000..da9dfce7ef3b --- /dev/null +++ b/BackupDr/samples/V1/BackupDrProtectionSummaryClient/get_location.php @@ -0,0 +1,57 @@ +getLocation($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END backupdr_v1_generated_BackupDrProtectionSummary_GetLocation_sync] diff --git a/BackupDr/samples/V1/BackupDrProtectionSummaryClient/list_locations.php b/BackupDr/samples/V1/BackupDrProtectionSummaryClient/list_locations.php new file mode 100644 index 000000000000..126d4f3279ba --- /dev/null +++ b/BackupDr/samples/V1/BackupDrProtectionSummaryClient/list_locations.php @@ -0,0 +1,62 @@ +listLocations($request); + + /** @var Location $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()); + } +} +// [END backupdr_v1_generated_BackupDrProtectionSummary_ListLocations_sync] diff --git a/BackupDr/samples/V1/BackupDrProtectionSummaryClient/list_resource_backup_configs.php b/BackupDr/samples/V1/BackupDrProtectionSummaryClient/list_resource_backup_configs.php new file mode 100644 index 000000000000..49256168ad67 --- /dev/null +++ b/BackupDr/samples/V1/BackupDrProtectionSummaryClient/list_resource_backup_configs.php @@ -0,0 +1,79 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $backupDrProtectionSummaryClient->listResourceBackupConfigs($request); + + /** @var ResourceBackupConfig $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 = BackupDrProtectionSummaryClient::locationName('[PROJECT]', '[LOCATION]'); + + list_resource_backup_configs_sample($formattedParent); +} +// [END backupdr_v1_generated_BackupDrProtectionSummary_ListResourceBackupConfigs_sync] diff --git a/BackupDr/samples/V1/BackupDrProtectionSummaryClient/set_iam_policy.php b/BackupDr/samples/V1/BackupDrProtectionSummaryClient/set_iam_policy.php new file mode 100644 index 000000000000..f3fdeb70501e --- /dev/null +++ b/BackupDr/samples/V1/BackupDrProtectionSummaryClient/set_iam_policy.php @@ -0,0 +1,77 @@ +setResource($resource) + ->setPolicy($policy); + + // Call the API and handle any network failures. + try { + /** @var Policy $response */ + $response = $backupDrProtectionSummaryClient->setIamPolicy($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 +{ + $resource = '[RESOURCE]'; + + set_iam_policy_sample($resource); +} +// [END backupdr_v1_generated_BackupDrProtectionSummary_SetIamPolicy_sync] diff --git a/BackupDr/samples/V1/BackupDrProtectionSummaryClient/test_iam_permissions.php b/BackupDr/samples/V1/BackupDrProtectionSummaryClient/test_iam_permissions.php new file mode 100644 index 000000000000..201f08fb5d4d --- /dev/null +++ b/BackupDr/samples/V1/BackupDrProtectionSummaryClient/test_iam_permissions.php @@ -0,0 +1,84 @@ +setResource($resource) + ->setPermissions($permissions); + + // Call the API and handle any network failures. + try { + /** @var TestIamPermissionsResponse $response */ + $response = $backupDrProtectionSummaryClient->testIamPermissions($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 +{ + $resource = '[RESOURCE]'; + $permissionsElement = '[PERMISSIONS]'; + + test_iam_permissions_sample($resource, $permissionsElement); +} +// [END backupdr_v1_generated_BackupDrProtectionSummary_TestIamPermissions_sync] diff --git a/BackupDr/src/V1/BackupConfigDetails.php b/BackupDr/src/V1/BackupConfigDetails.php new file mode 100644 index 000000000000..348b2668ddaa --- /dev/null +++ b/BackupDr/src/V1/BackupConfigDetails.php @@ -0,0 +1,487 @@ +google.cloud.backupdr.v1.BackupConfigDetails + */ +class BackupConfigDetails extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. The full resource name of the backup config source resource. + * For example, + * "//backupdr.googleapis.com/v1/projects/{project}/locations/{region}/backupPlans/{backupplanId}" + * or + * "//compute.googleapis.com/projects/{project}/locations/{region}/resourcePolicies/{resourcePolicyId}". + * + * Generated from protobuf field string backup_config_source = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $backup_config_source = ''; + /** + * Output only. The display name of the backup config source resource. + * + * Generated from protobuf field string backup_config_source_display_name = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $backup_config_source_display_name = ''; + /** + * Output only. The type of the backup config resource. + * + * Generated from protobuf field .google.cloud.backupdr.v1.BackupConfigDetails.Type type = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $type = 0; + /** + * Output only. The state of the backup config resource. + * + * Generated from protobuf field .google.cloud.backupdr.v1.BackupConfigDetails.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $state = 0; + /** + * Output only. Point in time recovery settings of the backup configuration + * resource. + * + * Generated from protobuf field .google.cloud.backupdr.v1.PitrSettings pitr_settings = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $pitr_settings = null; + /** + * Output only. Timestamp of the latest successful backup created via this + * backup configuration. + * + * Generated from protobuf field .google.protobuf.Timestamp latest_successful_backup_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $latest_successful_backup_time = null; + /** + * Output only. The [full resource + * name](https://cloud.google.com/asset-inventory/docs/resource-name-format) + * of the resource that is applicable for the backup configuration. Example: + * "//compute.googleapis.com/projects/{project}/zones/{zone}/instances/{instance}" + * + * Generated from protobuf field string applicable_resource = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $applicable_resource = ''; + /** + * Output only. The [full resource + * name](https://cloud.google.com/asset-inventory/docs/resource-name-format) + * of the backup vault that will store the backups generated through this + * backup configuration. Example: + * "//backupdr.googleapis.com/v1/projects/{project}/locations/{region}/backupVaults/{backupvaultId}" + * + * Generated from protobuf field string backup_vault = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $backup_vault = ''; + /** + * The locations where the backups are to be stored. + * + * Generated from protobuf field repeated .google.cloud.backupdr.v1.BackupLocation backup_locations = 12; + */ + private $backup_locations; + protected $plan_specific_config; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $backup_config_source + * Output only. The full resource name of the backup config source resource. + * For example, + * "//backupdr.googleapis.com/v1/projects/{project}/locations/{region}/backupPlans/{backupplanId}" + * or + * "//compute.googleapis.com/projects/{project}/locations/{region}/resourcePolicies/{resourcePolicyId}". + * @type string $backup_config_source_display_name + * Output only. The display name of the backup config source resource. + * @type int $type + * Output only. The type of the backup config resource. + * @type int $state + * Output only. The state of the backup config resource. + * @type \Google\Cloud\BackupDR\V1\PitrSettings $pitr_settings + * Output only. Point in time recovery settings of the backup configuration + * resource. + * @type \Google\Protobuf\Timestamp $latest_successful_backup_time + * Output only. Timestamp of the latest successful backup created via this + * backup configuration. + * @type string $applicable_resource + * Output only. The [full resource + * name](https://cloud.google.com/asset-inventory/docs/resource-name-format) + * of the resource that is applicable for the backup configuration. Example: + * "//compute.googleapis.com/projects/{project}/zones/{zone}/instances/{instance}" + * @type string $backup_vault + * Output only. The [full resource + * name](https://cloud.google.com/asset-inventory/docs/resource-name-format) + * of the backup vault that will store the backups generated through this + * backup configuration. Example: + * "//backupdr.googleapis.com/v1/projects/{project}/locations/{region}/backupVaults/{backupvaultId}" + * @type array<\Google\Cloud\BackupDR\V1\BackupLocation>|\Google\Protobuf\Internal\RepeatedField $backup_locations + * The locations where the backups are to be stored. + * @type \Google\Cloud\BackupDR\V1\BackupDrPlanConfig $backup_dr_plan_config + * Google Cloud Backup and DR's Backup Plan specific data. + * @type \Google\Cloud\BackupDR\V1\BackupDrTemplateConfig $backup_dr_template_config + * Google Cloud Backup and DR's Template specific data. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Backupdr\V1\ProtectionSummary::initOnce(); + parent::__construct($data); + } + + /** + * Output only. The full resource name of the backup config source resource. + * For example, + * "//backupdr.googleapis.com/v1/projects/{project}/locations/{region}/backupPlans/{backupplanId}" + * or + * "//compute.googleapis.com/projects/{project}/locations/{region}/resourcePolicies/{resourcePolicyId}". + * + * Generated from protobuf field string backup_config_source = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getBackupConfigSource() + { + return $this->backup_config_source; + } + + /** + * Output only. The full resource name of the backup config source resource. + * For example, + * "//backupdr.googleapis.com/v1/projects/{project}/locations/{region}/backupPlans/{backupplanId}" + * or + * "//compute.googleapis.com/projects/{project}/locations/{region}/resourcePolicies/{resourcePolicyId}". + * + * Generated from protobuf field string backup_config_source = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setBackupConfigSource($var) + { + GPBUtil::checkString($var, True); + $this->backup_config_source = $var; + + return $this; + } + + /** + * Output only. The display name of the backup config source resource. + * + * Generated from protobuf field string backup_config_source_display_name = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getBackupConfigSourceDisplayName() + { + return $this->backup_config_source_display_name; + } + + /** + * Output only. The display name of the backup config source resource. + * + * Generated from protobuf field string backup_config_source_display_name = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setBackupConfigSourceDisplayName($var) + { + GPBUtil::checkString($var, True); + $this->backup_config_source_display_name = $var; + + return $this; + } + + /** + * Output only. The type of the backup config resource. + * + * Generated from protobuf field .google.cloud.backupdr.v1.BackupConfigDetails.Type type = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getType() + { + return $this->type; + } + + /** + * Output only. The type of the backup config resource. + * + * Generated from protobuf field .google.cloud.backupdr.v1.BackupConfigDetails.Type type = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\BackupDR\V1\BackupConfigDetails\Type::class); + $this->type = $var; + + return $this; + } + + /** + * Output only. The state of the backup config resource. + * + * Generated from protobuf field .google.cloud.backupdr.v1.BackupConfigDetails.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getState() + { + return $this->state; + } + + /** + * Output only. The state of the backup config resource. + * + * Generated from protobuf field .google.cloud.backupdr.v1.BackupConfigDetails.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setState($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\BackupDR\V1\BackupConfigDetails\State::class); + $this->state = $var; + + return $this; + } + + /** + * Output only. Point in time recovery settings of the backup configuration + * resource. + * + * Generated from protobuf field .google.cloud.backupdr.v1.PitrSettings pitr_settings = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Cloud\BackupDR\V1\PitrSettings|null + */ + public function getPitrSettings() + { + return $this->pitr_settings; + } + + public function hasPitrSettings() + { + return isset($this->pitr_settings); + } + + public function clearPitrSettings() + { + unset($this->pitr_settings); + } + + /** + * Output only. Point in time recovery settings of the backup configuration + * resource. + * + * Generated from protobuf field .google.cloud.backupdr.v1.PitrSettings pitr_settings = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Cloud\BackupDR\V1\PitrSettings $var + * @return $this + */ + public function setPitrSettings($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\BackupDR\V1\PitrSettings::class); + $this->pitr_settings = $var; + + return $this; + } + + /** + * Output only. Timestamp of the latest successful backup created via this + * backup configuration. + * + * Generated from protobuf field .google.protobuf.Timestamp latest_successful_backup_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getLatestSuccessfulBackupTime() + { + return $this->latest_successful_backup_time; + } + + public function hasLatestSuccessfulBackupTime() + { + return isset($this->latest_successful_backup_time); + } + + public function clearLatestSuccessfulBackupTime() + { + unset($this->latest_successful_backup_time); + } + + /** + * Output only. Timestamp of the latest successful backup created via this + * backup configuration. + * + * Generated from protobuf field .google.protobuf.Timestamp latest_successful_backup_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setLatestSuccessfulBackupTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->latest_successful_backup_time = $var; + + return $this; + } + + /** + * Output only. The [full resource + * name](https://cloud.google.com/asset-inventory/docs/resource-name-format) + * of the resource that is applicable for the backup configuration. Example: + * "//compute.googleapis.com/projects/{project}/zones/{zone}/instances/{instance}" + * + * Generated from protobuf field string applicable_resource = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getApplicableResource() + { + return $this->applicable_resource; + } + + /** + * Output only. The [full resource + * name](https://cloud.google.com/asset-inventory/docs/resource-name-format) + * of the resource that is applicable for the backup configuration. Example: + * "//compute.googleapis.com/projects/{project}/zones/{zone}/instances/{instance}" + * + * Generated from protobuf field string applicable_resource = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setApplicableResource($var) + { + GPBUtil::checkString($var, True); + $this->applicable_resource = $var; + + return $this; + } + + /** + * Output only. The [full resource + * name](https://cloud.google.com/asset-inventory/docs/resource-name-format) + * of the backup vault that will store the backups generated through this + * backup configuration. Example: + * "//backupdr.googleapis.com/v1/projects/{project}/locations/{region}/backupVaults/{backupvaultId}" + * + * Generated from protobuf field string backup_vault = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getBackupVault() + { + return $this->backup_vault; + } + + /** + * Output only. The [full resource + * name](https://cloud.google.com/asset-inventory/docs/resource-name-format) + * of the backup vault that will store the backups generated through this + * backup configuration. Example: + * "//backupdr.googleapis.com/v1/projects/{project}/locations/{region}/backupVaults/{backupvaultId}" + * + * Generated from protobuf field string backup_vault = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setBackupVault($var) + { + GPBUtil::checkString($var, True); + $this->backup_vault = $var; + + return $this; + } + + /** + * The locations where the backups are to be stored. + * + * Generated from protobuf field repeated .google.cloud.backupdr.v1.BackupLocation backup_locations = 12; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getBackupLocations() + { + return $this->backup_locations; + } + + /** + * The locations where the backups are to be stored. + * + * Generated from protobuf field repeated .google.cloud.backupdr.v1.BackupLocation backup_locations = 12; + * @param array<\Google\Cloud\BackupDR\V1\BackupLocation>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setBackupLocations($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\BackupDR\V1\BackupLocation::class); + $this->backup_locations = $arr; + + return $this; + } + + /** + * Google Cloud Backup and DR's Backup Plan specific data. + * + * Generated from protobuf field .google.cloud.backupdr.v1.BackupDrPlanConfig backup_dr_plan_config = 10; + * @return \Google\Cloud\BackupDR\V1\BackupDrPlanConfig|null + */ + public function getBackupDrPlanConfig() + { + return $this->readOneof(10); + } + + public function hasBackupDrPlanConfig() + { + return $this->hasOneof(10); + } + + /** + * Google Cloud Backup and DR's Backup Plan specific data. + * + * Generated from protobuf field .google.cloud.backupdr.v1.BackupDrPlanConfig backup_dr_plan_config = 10; + * @param \Google\Cloud\BackupDR\V1\BackupDrPlanConfig $var + * @return $this + */ + public function setBackupDrPlanConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\BackupDR\V1\BackupDrPlanConfig::class); + $this->writeOneof(10, $var); + + return $this; + } + + /** + * Google Cloud Backup and DR's Template specific data. + * + * Generated from protobuf field .google.cloud.backupdr.v1.BackupDrTemplateConfig backup_dr_template_config = 11; + * @return \Google\Cloud\BackupDR\V1\BackupDrTemplateConfig|null + */ + public function getBackupDrTemplateConfig() + { + return $this->readOneof(11); + } + + public function hasBackupDrTemplateConfig() + { + return $this->hasOneof(11); + } + + /** + * Google Cloud Backup and DR's Template specific data. + * + * Generated from protobuf field .google.cloud.backupdr.v1.BackupDrTemplateConfig backup_dr_template_config = 11; + * @param \Google\Cloud\BackupDR\V1\BackupDrTemplateConfig $var + * @return $this + */ + public function setBackupDrTemplateConfig($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\BackupDR\V1\BackupDrTemplateConfig::class); + $this->writeOneof(11, $var); + + return $this; + } + + /** + * @return string + */ + public function getPlanSpecificConfig() + { + return $this->whichOneof("plan_specific_config"); + } + +} + diff --git a/BackupDr/src/V1/BackupConfigDetails/State.php b/BackupDr/src/V1/BackupConfigDetails/State.php new file mode 100644 index 000000000000..f7e3a48acacf --- /dev/null +++ b/BackupDr/src/V1/BackupConfigDetails/State.php @@ -0,0 +1,73 @@ +google.cloud.backupdr.v1.BackupConfigDetails.State + */ +class State +{ + /** + * Backup config state not set. + * + * Generated from protobuf enum STATE_UNSPECIFIED = 0; + */ + const STATE_UNSPECIFIED = 0; + /** + * The config is in an active state protecting the resource + * + * Generated from protobuf enum ACTIVE = 1; + */ + const ACTIVE = 1; + /** + * The config is currently not protecting the resource. Either because it is + * disabled or the owning project has been deleted without cleanup of the + * actual resource. + * + * Generated from protobuf enum INACTIVE = 2; + */ + const INACTIVE = 2; + /** + * The config still exists but because of some error state it is not + * protecting the resource. Like the source project is deleted. For eg. + * PlanAssociation, BackupPlan is deleted. + * + * Generated from protobuf enum ERROR = 3; + */ + const ERROR = 3; + + private static $valueToName = [ + self::STATE_UNSPECIFIED => 'STATE_UNSPECIFIED', + self::ACTIVE => 'ACTIVE', + self::INACTIVE => 'INACTIVE', + self::ERROR => 'ERROR', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/BackupDr/src/V1/BackupConfigDetails/Type.php b/BackupDr/src/V1/BackupConfigDetails/Type.php new file mode 100644 index 000000000000..86cf13433bf1 --- /dev/null +++ b/BackupDr/src/V1/BackupConfigDetails/Type.php @@ -0,0 +1,77 @@ +google.cloud.backupdr.v1.BackupConfigDetails.Type + */ +class Type +{ + /** + * Backup config type is unspecified. + * + * Generated from protobuf enum TYPE_UNSPECIFIED = 0; + */ + const TYPE_UNSPECIFIED = 0; + /** + * Backup config is Cloud SQL instance's automated backup config. + * + * Generated from protobuf enum CLOUD_SQL_INSTANCE_BACKUP_CONFIG = 1; + */ + const CLOUD_SQL_INSTANCE_BACKUP_CONFIG = 1; + /** + * Backup config is Compute Engine Resource Policy. + * + * Generated from protobuf enum COMPUTE_ENGINE_RESOURCE_POLICY = 2; + */ + const COMPUTE_ENGINE_RESOURCE_POLICY = 2; + /** + * Backup config is Google Cloud Backup and DR's Backup Plan. + * + * Generated from protobuf enum BACKUPDR_BACKUP_PLAN = 3; + */ + const BACKUPDR_BACKUP_PLAN = 3; + /** + * Backup config is Google Cloud Backup and DR's Template. + * + * Generated from protobuf enum BACKUPDR_TEMPLATE = 4; + */ + const BACKUPDR_TEMPLATE = 4; + + private static $valueToName = [ + self::TYPE_UNSPECIFIED => 'TYPE_UNSPECIFIED', + self::CLOUD_SQL_INSTANCE_BACKUP_CONFIG => 'CLOUD_SQL_INSTANCE_BACKUP_CONFIG', + self::COMPUTE_ENGINE_RESOURCE_POLICY => 'COMPUTE_ENGINE_RESOURCE_POLICY', + self::BACKUPDR_BACKUP_PLAN => 'BACKUPDR_BACKUP_PLAN', + self::BACKUPDR_TEMPLATE => 'BACKUPDR_TEMPLATE', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/BackupDr/src/V1/BackupDrPlanConfig.php b/BackupDr/src/V1/BackupDrPlanConfig.php new file mode 100644 index 000000000000..2eab409a784a --- /dev/null +++ b/BackupDr/src/V1/BackupDrPlanConfig.php @@ -0,0 +1,68 @@ +google.cloud.backupdr.v1.BackupDrPlanConfig + */ +class BackupDrPlanConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Backup rules of the backup plan resource. + * + * Generated from protobuf field repeated .google.cloud.backupdr.v1.BackupDrPlanRule backup_dr_plan_rules = 1; + */ + private $backup_dr_plan_rules; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\BackupDR\V1\BackupDrPlanRule>|\Google\Protobuf\Internal\RepeatedField $backup_dr_plan_rules + * Backup rules of the backup plan resource. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Backupdr\V1\ProtectionSummary::initOnce(); + parent::__construct($data); + } + + /** + * Backup rules of the backup plan resource. + * + * Generated from protobuf field repeated .google.cloud.backupdr.v1.BackupDrPlanRule backup_dr_plan_rules = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getBackupDrPlanRules() + { + return $this->backup_dr_plan_rules; + } + + /** + * Backup rules of the backup plan resource. + * + * Generated from protobuf field repeated .google.cloud.backupdr.v1.BackupDrPlanRule backup_dr_plan_rules = 1; + * @param array<\Google\Cloud\BackupDR\V1\BackupDrPlanRule>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setBackupDrPlanRules($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\BackupDR\V1\BackupDrPlanRule::class); + $this->backup_dr_plan_rules = $arr; + + return $this; + } + +} + diff --git a/BackupDr/src/V1/BackupDrPlanRule.php b/BackupDr/src/V1/BackupDrPlanRule.php new file mode 100644 index 000000000000..09ba1c1f6fc9 --- /dev/null +++ b/BackupDr/src/V1/BackupDrPlanRule.php @@ -0,0 +1,115 @@ +google.cloud.backupdr.v1.BackupDrPlanRule + */ +class BackupDrPlanRule extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. Unique Id of the backup rule. + * + * Generated from protobuf field string rule_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $rule_id = ''; + /** + * Output only. Timestamp of the latest successful backup created via this + * backup rule. + * + * Generated from protobuf field .google.protobuf.Timestamp last_successful_backup_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $last_successful_backup_time = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $rule_id + * Output only. Unique Id of the backup rule. + * @type \Google\Protobuf\Timestamp $last_successful_backup_time + * Output only. Timestamp of the latest successful backup created via this + * backup rule. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Backupdr\V1\ProtectionSummary::initOnce(); + parent::__construct($data); + } + + /** + * Output only. Unique Id of the backup rule. + * + * Generated from protobuf field string rule_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getRuleId() + { + return $this->rule_id; + } + + /** + * Output only. Unique Id of the backup rule. + * + * Generated from protobuf field string rule_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setRuleId($var) + { + GPBUtil::checkString($var, True); + $this->rule_id = $var; + + return $this; + } + + /** + * Output only. Timestamp of the latest successful backup created via this + * backup rule. + * + * Generated from protobuf field .google.protobuf.Timestamp last_successful_backup_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getLastSuccessfulBackupTime() + { + return $this->last_successful_backup_time; + } + + public function hasLastSuccessfulBackupTime() + { + return isset($this->last_successful_backup_time); + } + + public function clearLastSuccessfulBackupTime() + { + unset($this->last_successful_backup_time); + } + + /** + * Output only. Timestamp of the latest successful backup created via this + * backup rule. + * + * Generated from protobuf field .google.protobuf.Timestamp last_successful_backup_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setLastSuccessfulBackupTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->last_successful_backup_time = $var; + + return $this; + } + +} + diff --git a/BackupDr/src/V1/BackupDrTemplateConfig.php b/BackupDr/src/V1/BackupDrTemplateConfig.php new file mode 100644 index 000000000000..0adf39a6e397 --- /dev/null +++ b/BackupDr/src/V1/BackupDrTemplateConfig.php @@ -0,0 +1,110 @@ +google.cloud.backupdr.v1.BackupDrTemplateConfig + */ +class BackupDrTemplateConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. The URI of the BackupDr template resource for the first party + * identity users. + * + * Generated from protobuf field string first_party_management_uri = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $first_party_management_uri = ''; + /** + * Output only. The URI of the BackupDr template resource for the third party + * identity users. + * + * Generated from protobuf field string third_party_management_uri = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $third_party_management_uri = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $first_party_management_uri + * Output only. The URI of the BackupDr template resource for the first party + * identity users. + * @type string $third_party_management_uri + * Output only. The URI of the BackupDr template resource for the third party + * identity users. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Backupdr\V1\ProtectionSummary::initOnce(); + parent::__construct($data); + } + + /** + * Output only. The URI of the BackupDr template resource for the first party + * identity users. + * + * Generated from protobuf field string first_party_management_uri = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getFirstPartyManagementUri() + { + return $this->first_party_management_uri; + } + + /** + * Output only. The URI of the BackupDr template resource for the first party + * identity users. + * + * Generated from protobuf field string first_party_management_uri = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setFirstPartyManagementUri($var) + { + GPBUtil::checkString($var, True); + $this->first_party_management_uri = $var; + + return $this; + } + + /** + * Output only. The URI of the BackupDr template resource for the third party + * identity users. + * + * Generated from protobuf field string third_party_management_uri = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getThirdPartyManagementUri() + { + return $this->third_party_management_uri; + } + + /** + * Output only. The URI of the BackupDr template resource for the third party + * identity users. + * + * Generated from protobuf field string third_party_management_uri = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setThirdPartyManagementUri($var) + { + GPBUtil::checkString($var, True); + $this->third_party_management_uri = $var; + + return $this; + } + +} + diff --git a/BackupDr/src/V1/BackupLocation.php b/BackupDr/src/V1/BackupLocation.php new file mode 100644 index 000000000000..7c1b9d745232 --- /dev/null +++ b/BackupDr/src/V1/BackupLocation.php @@ -0,0 +1,101 @@ +google.cloud.backupdr.v1.BackupLocation + */ +class BackupLocation extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. The type of the location. + * + * Generated from protobuf field .google.cloud.backupdr.v1.BackupLocation.Type type = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $type = 0; + /** + * Output only. The id of the cloud location. Example: "us-central1" + * + * Generated from protobuf field string location_id = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $location_id = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $type + * Output only. The type of the location. + * @type string $location_id + * Output only. The id of the cloud location. Example: "us-central1" + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Backupdr\V1\ProtectionSummary::initOnce(); + parent::__construct($data); + } + + /** + * Output only. The type of the location. + * + * Generated from protobuf field .google.cloud.backupdr.v1.BackupLocation.Type type = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getType() + { + return $this->type; + } + + /** + * Output only. The type of the location. + * + * Generated from protobuf field .google.cloud.backupdr.v1.BackupLocation.Type type = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\BackupDR\V1\BackupLocation\Type::class); + $this->type = $var; + + return $this; + } + + /** + * Output only. The id of the cloud location. Example: "us-central1" + * + * Generated from protobuf field string location_id = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getLocationId() + { + return $this->location_id; + } + + /** + * Output only. The id of the cloud location. Example: "us-central1" + * + * Generated from protobuf field string location_id = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setLocationId($var) + { + GPBUtil::checkString($var, True); + $this->location_id = $var; + + return $this; + } + +} + diff --git a/BackupDr/src/V1/BackupLocation/Type.php b/BackupDr/src/V1/BackupLocation/Type.php new file mode 100644 index 000000000000..3f1a6f7b581a --- /dev/null +++ b/BackupDr/src/V1/BackupLocation/Type.php @@ -0,0 +1,69 @@ +google.cloud.backupdr.v1.BackupLocation.Type + */ +class Type +{ + /** + * Location type is unspecified. + * + * Generated from protobuf enum TYPE_UNSPECIFIED = 0; + */ + const TYPE_UNSPECIFIED = 0; + /** + * Location type is zonal. + * + * Generated from protobuf enum ZONAL = 1; + */ + const ZONAL = 1; + /** + * Location type is regional. + * + * Generated from protobuf enum REGIONAL = 2; + */ + const REGIONAL = 2; + /** + * Location type is multi regional. + * + * Generated from protobuf enum MULTI_REGIONAL = 3; + */ + const MULTI_REGIONAL = 3; + + private static $valueToName = [ + self::TYPE_UNSPECIFIED => 'TYPE_UNSPECIFIED', + self::ZONAL => 'ZONAL', + self::REGIONAL => 'REGIONAL', + self::MULTI_REGIONAL => 'MULTI_REGIONAL', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/BackupDr/src/V1/Client/BackupDrProtectionSummaryClient.php b/BackupDr/src/V1/Client/BackupDrProtectionSummaryClient.php new file mode 100644 index 000000000000..5cfd3674df2a --- /dev/null +++ b/BackupDr/src/V1/Client/BackupDrProtectionSummaryClient.php @@ -0,0 +1,416 @@ + listResourceBackupConfigsAsync(ListResourceBackupConfigsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getLocationAsync(GetLocationRequest $request, array $optionalArgs = []) + * @method PromiseInterface listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = []) + * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) + * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + */ +final class BackupDrProtectionSummaryClient +{ + use GapicClientTrait; + use ResourceHelperTrait; + + /** The name of the service. */ + private const SERVICE_NAME = 'google.cloud.backupdr.v1.BackupDrProtectionSummary'; + + /** + * The default address of the service. + * + * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. + */ + private const SERVICE_ADDRESS = 'backupdr.googleapis.com'; + + /** The address template of the service. */ + private const SERVICE_ADDRESS_TEMPLATE = 'backupdr.UNIVERSE_DOMAIN'; + + /** The default port of the service. */ + private const DEFAULT_SERVICE_PORT = 443; + + /** The name of the code generator, to be included in the agent header. */ + private const CODEGEN_NAME = 'gapic'; + + /** The default scopes required by the service. */ + public static $serviceScopes = ['https://www.googleapis.com/auth/cloud-platform']; + + private static function getClientDefaults() + { + return [ + 'serviceName' => self::SERVICE_NAME, + 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, + 'clientConfig' => __DIR__ . '/../resources/backup_dr_protection_summary_client_config.json', + 'descriptorsConfigPath' => __DIR__ . '/../resources/backup_dr_protection_summary_descriptor_config.php', + 'gcpApiConfigPath' => __DIR__ . '/../resources/backup_dr_protection_summary_grpc_config.json', + 'credentialsConfig' => [ + 'defaultScopes' => self::$serviceScopes, + ], + 'transportConfig' => [ + 'rest' => [ + 'restClientConfigPath' => + __DIR__ . '/../resources/backup_dr_protection_summary_rest_client_config.php', + ], + ], + ]; + } + + /** + * Formats a string containing the fully-qualified path to represent a location + * resource. + * + * @param string $project + * @param string $location + * + * @return string The formatted location resource. + */ + public static function locationName(string $project, string $location): string + { + return self::getPathTemplate('location')->render([ + 'project' => $project, + 'location' => $location, + ]); + } + + /** + * Parses a formatted name string and returns an associative array of the components in the name. + * The following name formats are supported: + * Template: Pattern + * - location: projects/{project}/locations/{location} + * + * The optional $template argument can be supplied to specify a particular pattern, + * and must match one of the templates listed above. If no $template argument is + * provided, or if the $template argument does not match one of the templates + * listed, then parseName will check each of the supported templates, and return + * the first match. + * + * @param string $formattedName The formatted name string + * @param ?string $template Optional name of template to match + * + * @return array An associative array from name component IDs to component values. + * + * @throws ValidationException If $formattedName could not be matched. + */ + public static function parseName(string $formattedName, ?string $template = null): array + { + return self::parseFormattedName($formattedName, $template); + } + + /** + * Constructor. + * + * @param array|ClientOptions $options { + * Optional. Options for configuring the service API wrapper. + * + * @type string $apiEndpoint + * The address of the API remote host. May optionally include the port, formatted + * as ":". Default 'backupdr.googleapis.com:443'. + * @type FetchAuthTokenInterface|CredentialsWrapper $credentials + * This option should only be used with a pre-constructed + * {@see FetchAuthTokenInterface} or {@see CredentialsWrapper} object. Note that + * when one of these objects are provided, any settings in $credentialsConfig will + * be ignored. + * **Important**: If you are providing a path to a credentials file, or a decoded + * credentials file as a PHP array, this usage is now DEPRECATED. Providing an + * unvalidated credential configuration to Google APIs can compromise the security + * of your systems and data. It is recommended to create the credentials explicitly + * ``` + * use Google\Auth\Credentials\ServiceAccountCredentials; + * use Google\Cloud\BackupDR\V1\BackupDrProtectionSummaryClient; + * $creds = new ServiceAccountCredentials($scopes, $json); + * $options = new BackupDrProtectionSummaryClient(['credentials' => $creds]); + * ``` + * {@see + * https://cloud.google.com/docs/authentication/external/externally-sourced-credentials} + * @type array $credentialsConfig + * Options used to configure credentials, including auth token caching, for the + * client. For a full list of supporting configuration options, see + * {@see \Google\ApiCore\CredentialsWrapper::build()} . + * @type bool $disableRetries + * Determines whether or not retries defined by the client configuration should be + * disabled. Defaults to `false`. + * @type string|array $clientConfig + * Client method configuration, including retry settings. This option can be either + * a path to a JSON file, or a PHP array containing the decoded JSON data. By + * default this settings points to the default client config file, which is + * provided in the resources folder. + * @type string|TransportInterface $transport + * The transport used for executing network requests. May be either the string + * `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system. + * *Advanced usage*: Additionally, it is possible to pass in an already + * instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note + * that when this object is provided, any settings in $transportConfig, and any + * $apiEndpoint setting, will be ignored. + * @type array $transportConfig + * Configuration options that will be used to construct the transport. Options for + * each supported transport type should be passed in a key for that transport. For + * example: + * $transportConfig = [ + * 'grpc' => [...], + * 'rest' => [...], + * ]; + * See the {@see \Google\ApiCore\Transport\GrpcTransport::build()} and + * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the + * supported options. + * @type callable $clientCertSource + * A callable which returns the client cert as a string. This can be used to + * provide a certificate and private key to the transport layer for mTLS. + * @type false|LoggerInterface $logger + * A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the + * 'GOOGLE_SDK_PHP_LOGGING' environment flag + * @type string $universeDomain + * The service domain for the client. Defaults to 'googleapis.com'. + * } + * + * @throws ValidationException + */ + public function __construct(array|ClientOptions $options = []) + { + $clientOptions = $this->buildClientOptions($options); + $this->setClientOptions($clientOptions); + } + + /** Handles execution of the async variants for each documented method. */ + public function __call($method, $args) + { + if (substr($method, -5) !== 'Async') { + trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); + } + + array_unshift($args, substr($method, 0, -5)); + return call_user_func_array([$this, 'startAsyncCall'], $args); + } + + /** + * Lists ResourceBackupConfigs. + * + * The async variant is + * {@see BackupDrProtectionSummaryClient::listResourceBackupConfigsAsync()} . + * + * @example samples/V1/BackupDrProtectionSummaryClient/list_resource_backup_configs.php + * + * @param ListResourceBackupConfigsRequest $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 listResourceBackupConfigs( + ListResourceBackupConfigsRequest $request, + array $callOptions = [] + ): PagedListResponse { + return $this->startApiCall('ListResourceBackupConfigs', $request, $callOptions); + } + + /** + * Gets information about a location. + * + * The async variant is {@see BackupDrProtectionSummaryClient::getLocationAsync()} + * . + * + * @example samples/V1/BackupDrProtectionSummaryClient/get_location.php + * + * @param GetLocationRequest $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 Location + * + * @throws ApiException Thrown if the API call fails. + */ + public function getLocation(GetLocationRequest $request, array $callOptions = []): Location + { + return $this->startApiCall('GetLocation', $request, $callOptions)->wait(); + } + + /** + * Lists information about the supported locations for this service. + * + * The async variant is + * {@see BackupDrProtectionSummaryClient::listLocationsAsync()} . + * + * @example samples/V1/BackupDrProtectionSummaryClient/list_locations.php + * + * @param ListLocationsRequest $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 listLocations(ListLocationsRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListLocations', $request, $callOptions); + } + + /** + * Gets the access control policy for a resource. Returns an empty policy + if the resource exists and does not have a policy set. + * + * The async variant is {@see BackupDrProtectionSummaryClient::getIamPolicyAsync()} + * . + * + * @example samples/V1/BackupDrProtectionSummaryClient/get_iam_policy.php + * + * @param GetIamPolicyRequest $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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function getIamPolicy(GetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('GetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Sets the access control policy on the specified resource. Replaces + any existing policy. + + Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` + errors. + * + * The async variant is {@see BackupDrProtectionSummaryClient::setIamPolicyAsync()} + * . + * + * @example samples/V1/BackupDrProtectionSummaryClient/set_iam_policy.php + * + * @param SetIamPolicyRequest $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 Policy + * + * @throws ApiException Thrown if the API call fails. + */ + public function setIamPolicy(SetIamPolicyRequest $request, array $callOptions = []): Policy + { + return $this->startApiCall('SetIamPolicy', $request, $callOptions)->wait(); + } + + /** + * Returns permissions that a caller has on the specified resource. If the + resource does not exist, this will return an empty set of + permissions, not a `NOT_FOUND` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + * + * The async variant is + * {@see BackupDrProtectionSummaryClient::testIamPermissionsAsync()} . + * + * @example samples/V1/BackupDrProtectionSummaryClient/test_iam_permissions.php + * + * @param TestIamPermissionsRequest $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 TestIamPermissionsResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function testIamPermissions( + TestIamPermissionsRequest $request, + array $callOptions = [] + ): TestIamPermissionsResponse { + return $this->startApiCall('TestIamPermissions', $request, $callOptions)->wait(); + } +} diff --git a/BackupDr/src/V1/ListResourceBackupConfigsRequest.php b/BackupDr/src/V1/ListResourceBackupConfigsRequest.php new file mode 100644 index 000000000000..cf53f35889e7 --- /dev/null +++ b/BackupDr/src/V1/ListResourceBackupConfigsRequest.php @@ -0,0 +1,240 @@ +google.cloud.backupdr.v1.ListResourceBackupConfigsRequest + */ +class ListResourceBackupConfigsRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The project and location for which to retrieve resource backup + * configs. Format: 'projects/{project_id}/locations/{location}'. In Google + * Cloud Backup and DR, locations map to Google Cloud regions, for example + * **us-central1**. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will use 100 as default. Maximum value is + * 500 and values above 500 will be coerced to 500. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $page_size = 0; + /** + * Optional. A token identifying a page of results the server should return. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $page_token = ''; + /** + * Optional. Filtering results. + * + * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $filter = ''; + /** + * Optional. Hint for how to order the results. + * + * Generated from protobuf field string order_by = 5 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $order_by = ''; + + /** + * @param string $parent Required. The project and location for which to retrieve resource backup + * configs. Format: 'projects/{project_id}/locations/{location}'. In Google + * Cloud Backup and DR, locations map to Google Cloud regions, for example + * **us-central1**. Please see + * {@see BackupDrProtectionSummaryClient::locationName()} for help formatting this field. + * + * @return \Google\Cloud\BackupDR\V1\ListResourceBackupConfigsRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The project and location for which to retrieve resource backup + * configs. Format: 'projects/{project_id}/locations/{location}'. In Google + * Cloud Backup and DR, locations map to Google Cloud regions, for example + * **us-central1**. + * @type int $page_size + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will use 100 as default. Maximum value is + * 500 and values above 500 will be coerced to 500. + * @type string $page_token + * Optional. A token identifying a page of results the server should return. + * @type string $filter + * Optional. Filtering results. + * @type string $order_by + * Optional. Hint for how to order the results. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Backupdr\V1\ProtectionSummary::initOnce(); + parent::__construct($data); + } + + /** + * Required. The project and location for which to retrieve resource backup + * configs. Format: 'projects/{project_id}/locations/{location}'. In Google + * Cloud Backup and DR, locations map to Google Cloud regions, for example + * **us-central1**. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The project and location for which to retrieve resource backup + * configs. Format: 'projects/{project_id}/locations/{location}'. In Google + * Cloud Backup and DR, locations map to Google Cloud regions, for example + * **us-central1**. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will use 100 as default. Maximum value is + * 500 and values above 500 will be coerced to 500. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will use 100 as default. Maximum value is + * 500 and values above 500 will be coerced to 500. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * Optional. A token identifying a page of results the server should return. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * Optional. A token identifying a page of results the server should return. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + + /** + * Optional. Filtering results. + * + * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * Optional. Filtering results. + * + * Generated from protobuf field string filter = 4 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setFilter($var) + { + GPBUtil::checkString($var, True); + $this->filter = $var; + + return $this; + } + + /** + * Optional. Hint for how to order the results. + * + * Generated from protobuf field string order_by = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getOrderBy() + { + return $this->order_by; + } + + /** + * Optional. Hint for how to order the results. + * + * Generated from protobuf field string order_by = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setOrderBy($var) + { + GPBUtil::checkString($var, True); + $this->order_by = $var; + + return $this; + } + +} + diff --git a/BackupDr/src/V1/ListResourceBackupConfigsResponse.php b/BackupDr/src/V1/ListResourceBackupConfigsResponse.php new file mode 100644 index 000000000000..9d8c3ff0870a --- /dev/null +++ b/BackupDr/src/V1/ListResourceBackupConfigsResponse.php @@ -0,0 +1,101 @@ +google.cloud.backupdr.v1.ListResourceBackupConfigsResponse + */ +class ListResourceBackupConfigsResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of ResourceBackupConfigs for the specified scope. + * + * Generated from protobuf field repeated .google.cloud.backupdr.v1.ResourceBackupConfig resource_backup_configs = 1; + */ + private $resource_backup_configs; + /** + * A token identifying a page of results the server should return. + * + * Generated from protobuf field string next_page_token = 2; + */ + protected $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\BackupDR\V1\ResourceBackupConfig>|\Google\Protobuf\Internal\RepeatedField $resource_backup_configs + * The list of ResourceBackupConfigs for the specified scope. + * @type string $next_page_token + * A token identifying a page of results the server should return. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Backupdr\V1\ProtectionSummary::initOnce(); + parent::__construct($data); + } + + /** + * The list of ResourceBackupConfigs for the specified scope. + * + * Generated from protobuf field repeated .google.cloud.backupdr.v1.ResourceBackupConfig resource_backup_configs = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getResourceBackupConfigs() + { + return $this->resource_backup_configs; + } + + /** + * The list of ResourceBackupConfigs for the specified scope. + * + * Generated from protobuf field repeated .google.cloud.backupdr.v1.ResourceBackupConfig resource_backup_configs = 1; + * @param array<\Google\Cloud\BackupDR\V1\ResourceBackupConfig>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setResourceBackupConfigs($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\BackupDR\V1\ResourceBackupConfig::class); + $this->resource_backup_configs = $arr; + + return $this; + } + + /** + * A token identifying a page of results the server should return. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * A token identifying a page of results the server should return. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/BackupDr/src/V1/PitrSettings.php b/BackupDr/src/V1/PitrSettings.php new file mode 100644 index 000000000000..0635fcec0565 --- /dev/null +++ b/BackupDr/src/V1/PitrSettings.php @@ -0,0 +1,67 @@ +google.cloud.backupdr.v1.PitrSettings + */ +class PitrSettings extends \Google\Protobuf\Internal\Message +{ + /** + * Output only. Number of days to retain the backup. + * + * Generated from protobuf field int32 retention_days = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $retention_days = 0; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type int $retention_days + * Output only. Number of days to retain the backup. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Backupdr\V1\ProtectionSummary::initOnce(); + parent::__construct($data); + } + + /** + * Output only. Number of days to retain the backup. + * + * Generated from protobuf field int32 retention_days = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getRetentionDays() + { + return $this->retention_days; + } + + /** + * Output only. Number of days to retain the backup. + * + * Generated from protobuf field int32 retention_days = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setRetentionDays($var) + { + GPBUtil::checkInt32($var); + $this->retention_days = $var; + + return $this; + } + +} + diff --git a/BackupDr/src/V1/ResourceBackupConfig.php b/BackupDr/src/V1/ResourceBackupConfig.php new file mode 100644 index 000000000000..40d95634f63f --- /dev/null +++ b/BackupDr/src/V1/ResourceBackupConfig.php @@ -0,0 +1,400 @@ +google.cloud.backupdr.v1.ResourceBackupConfig + */ +class ResourceBackupConfig extends \Google\Protobuf\Internal\Message +{ + /** + * Identifier. The resource name of the ResourceBackupConfig. + * Format: + * projects/{project}/locations/{location}/resourceBackupConfigs/{uid} + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + */ + protected $name = ''; + /** + * Output only. The unique identifier of the resource backup config. + * + * Generated from protobuf field string uid = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.field_info) = { + */ + protected $uid = ''; + /** + * Output only. The [full resource + * name](https://cloud.google.com/asset-inventory/docs/resource-name-format) + * of the cloud resource that this configuration applies to. Supported + * resource types are + * [ResourceBackupConfig.ResourceType][google.cloud.backupdr.v1.ResourceBackupConfig.ResourceType]. + * + * Generated from protobuf field string target_resource = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $target_resource = ''; + /** + * Output only. The human friendly name of the target resource. + * + * Generated from protobuf field string target_resource_display_name = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $target_resource_display_name = ''; + /** + * Output only. The type of the target resource. + * + * Generated from protobuf field .google.cloud.backupdr.v1.ResourceBackupConfig.ResourceType target_resource_type = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $target_resource_type = 0; + /** + * Labels associated with the target resource. + * + * Generated from protobuf field map target_resource_labels = 6; + */ + private $target_resource_labels; + /** + * Backup configurations applying to the target resource, including those + * targeting its related/child resources. For example, backup configuration + * applicable to Compute Engine disks will be populated in this field for a + * Compute Engine VM which has the disk associated. + * + * Generated from protobuf field repeated .google.cloud.backupdr.v1.BackupConfigDetails backup_configs_details = 7; + */ + private $backup_configs_details; + /** + * Output only. Whether the target resource is configured for backup. This is + * true if the backup_configs_details is not empty. + * + * Generated from protobuf field bool backup_configured = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $backup_configured = false; + /** + * Output only. Whether the target resource is protected by a backup vault. + * This is true if the backup_configs_details is not empty and any of the + * [ResourceBackupConfig.backup_configs_details][google.cloud.backupdr.v1.ResourceBackupConfig.backup_configs_details] + * has a backup configuration with + * [BackupConfigDetails.backup_vault][google.cloud.backupdr.v1.BackupConfigDetails.backup_vault] + * set. set. + * + * Generated from protobuf field bool vaulted = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $vaulted = false; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Identifier. The resource name of the ResourceBackupConfig. + * Format: + * projects/{project}/locations/{location}/resourceBackupConfigs/{uid} + * @type string $uid + * Output only. The unique identifier of the resource backup config. + * @type string $target_resource + * Output only. The [full resource + * name](https://cloud.google.com/asset-inventory/docs/resource-name-format) + * of the cloud resource that this configuration applies to. Supported + * resource types are + * [ResourceBackupConfig.ResourceType][google.cloud.backupdr.v1.ResourceBackupConfig.ResourceType]. + * @type string $target_resource_display_name + * Output only. The human friendly name of the target resource. + * @type int $target_resource_type + * Output only. The type of the target resource. + * @type array|\Google\Protobuf\Internal\MapField $target_resource_labels + * Labels associated with the target resource. + * @type array<\Google\Cloud\BackupDR\V1\BackupConfigDetails>|\Google\Protobuf\Internal\RepeatedField $backup_configs_details + * Backup configurations applying to the target resource, including those + * targeting its related/child resources. For example, backup configuration + * applicable to Compute Engine disks will be populated in this field for a + * Compute Engine VM which has the disk associated. + * @type bool $backup_configured + * Output only. Whether the target resource is configured for backup. This is + * true if the backup_configs_details is not empty. + * @type bool $vaulted + * Output only. Whether the target resource is protected by a backup vault. + * This is true if the backup_configs_details is not empty and any of the + * [ResourceBackupConfig.backup_configs_details][google.cloud.backupdr.v1.ResourceBackupConfig.backup_configs_details] + * has a backup configuration with + * [BackupConfigDetails.backup_vault][google.cloud.backupdr.v1.BackupConfigDetails.backup_vault] + * set. set. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Backupdr\V1\ProtectionSummary::initOnce(); + parent::__construct($data); + } + + /** + * Identifier. The resource name of the ResourceBackupConfig. + * Format: + * projects/{project}/locations/{location}/resourceBackupConfigs/{uid} + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Identifier. The resource name of the ResourceBackupConfig. + * Format: + * projects/{project}/locations/{location}/resourceBackupConfigs/{uid} + * + * 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. The unique identifier of the resource backup config. + * + * Generated from protobuf field string uid = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.field_info) = { + * @return string + */ + public function getUid() + { + return $this->uid; + } + + /** + * Output only. The unique identifier of the resource backup config. + * + * Generated from protobuf field string uid = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.field_info) = { + * @param string $var + * @return $this + */ + public function setUid($var) + { + GPBUtil::checkString($var, True); + $this->uid = $var; + + return $this; + } + + /** + * Output only. The [full resource + * name](https://cloud.google.com/asset-inventory/docs/resource-name-format) + * of the cloud resource that this configuration applies to. Supported + * resource types are + * [ResourceBackupConfig.ResourceType][google.cloud.backupdr.v1.ResourceBackupConfig.ResourceType]. + * + * Generated from protobuf field string target_resource = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getTargetResource() + { + return $this->target_resource; + } + + /** + * Output only. The [full resource + * name](https://cloud.google.com/asset-inventory/docs/resource-name-format) + * of the cloud resource that this configuration applies to. Supported + * resource types are + * [ResourceBackupConfig.ResourceType][google.cloud.backupdr.v1.ResourceBackupConfig.ResourceType]. + * + * Generated from protobuf field string target_resource = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setTargetResource($var) + { + GPBUtil::checkString($var, True); + $this->target_resource = $var; + + return $this; + } + + /** + * Output only. The human friendly name of the target resource. + * + * Generated from protobuf field string target_resource_display_name = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getTargetResourceDisplayName() + { + return $this->target_resource_display_name; + } + + /** + * Output only. The human friendly name of the target resource. + * + * Generated from protobuf field string target_resource_display_name = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setTargetResourceDisplayName($var) + { + GPBUtil::checkString($var, True); + $this->target_resource_display_name = $var; + + return $this; + } + + /** + * Output only. The type of the target resource. + * + * Generated from protobuf field .google.cloud.backupdr.v1.ResourceBackupConfig.ResourceType target_resource_type = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return int + */ + public function getTargetResourceType() + { + return $this->target_resource_type; + } + + /** + * Output only. The type of the target resource. + * + * Generated from protobuf field .google.cloud.backupdr.v1.ResourceBackupConfig.ResourceType target_resource_type = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param int $var + * @return $this + */ + public function setTargetResourceType($var) + { + GPBUtil::checkEnum($var, \Google\Cloud\BackupDR\V1\ResourceBackupConfig\ResourceType::class); + $this->target_resource_type = $var; + + return $this; + } + + /** + * Labels associated with the target resource. + * + * Generated from protobuf field map target_resource_labels = 6; + * @return \Google\Protobuf\Internal\MapField + */ + public function getTargetResourceLabels() + { + return $this->target_resource_labels; + } + + /** + * Labels associated with the target resource. + * + * Generated from protobuf field map target_resource_labels = 6; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setTargetResourceLabels($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->target_resource_labels = $arr; + + return $this; + } + + /** + * Backup configurations applying to the target resource, including those + * targeting its related/child resources. For example, backup configuration + * applicable to Compute Engine disks will be populated in this field for a + * Compute Engine VM which has the disk associated. + * + * Generated from protobuf field repeated .google.cloud.backupdr.v1.BackupConfigDetails backup_configs_details = 7; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getBackupConfigsDetails() + { + return $this->backup_configs_details; + } + + /** + * Backup configurations applying to the target resource, including those + * targeting its related/child resources. For example, backup configuration + * applicable to Compute Engine disks will be populated in this field for a + * Compute Engine VM which has the disk associated. + * + * Generated from protobuf field repeated .google.cloud.backupdr.v1.BackupConfigDetails backup_configs_details = 7; + * @param array<\Google\Cloud\BackupDR\V1\BackupConfigDetails>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setBackupConfigsDetails($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\BackupDR\V1\BackupConfigDetails::class); + $this->backup_configs_details = $arr; + + return $this; + } + + /** + * Output only. Whether the target resource is configured for backup. This is + * true if the backup_configs_details is not empty. + * + * Generated from protobuf field bool backup_configured = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return bool + */ + public function getBackupConfigured() + { + return $this->backup_configured; + } + + /** + * Output only. Whether the target resource is configured for backup. This is + * true if the backup_configs_details is not empty. + * + * Generated from protobuf field bool backup_configured = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param bool $var + * @return $this + */ + public function setBackupConfigured($var) + { + GPBUtil::checkBool($var); + $this->backup_configured = $var; + + return $this; + } + + /** + * Output only. Whether the target resource is protected by a backup vault. + * This is true if the backup_configs_details is not empty and any of the + * [ResourceBackupConfig.backup_configs_details][google.cloud.backupdr.v1.ResourceBackupConfig.backup_configs_details] + * has a backup configuration with + * [BackupConfigDetails.backup_vault][google.cloud.backupdr.v1.BackupConfigDetails.backup_vault] + * set. set. + * + * Generated from protobuf field bool vaulted = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return bool + */ + public function getVaulted() + { + return $this->vaulted; + } + + /** + * Output only. Whether the target resource is protected by a backup vault. + * This is true if the backup_configs_details is not empty and any of the + * [ResourceBackupConfig.backup_configs_details][google.cloud.backupdr.v1.ResourceBackupConfig.backup_configs_details] + * has a backup configuration with + * [BackupConfigDetails.backup_vault][google.cloud.backupdr.v1.BackupConfigDetails.backup_vault] + * set. set. + * + * Generated from protobuf field bool vaulted = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param bool $var + * @return $this + */ + public function setVaulted($var) + { + GPBUtil::checkBool($var); + $this->vaulted = $var; + + return $this; + } + +} + diff --git a/BackupDr/src/V1/ResourceBackupConfig/ResourceType.php b/BackupDr/src/V1/ResourceBackupConfig/ResourceType.php new file mode 100644 index 000000000000..0bb7b0491520 --- /dev/null +++ b/BackupDr/src/V1/ResourceBackupConfig/ResourceType.php @@ -0,0 +1,76 @@ +google.cloud.backupdr.v1.ResourceBackupConfig.ResourceType + */ +class ResourceType +{ + /** + * Resource type not set. + * + * Generated from protobuf enum RESOURCE_TYPE_UNSPECIFIED = 0; + */ + const RESOURCE_TYPE_UNSPECIFIED = 0; + /** + * Cloud SQL instance. + * + * Generated from protobuf enum CLOUD_SQL_INSTANCE = 1; + */ + const CLOUD_SQL_INSTANCE = 1; + /** + * Compute Engine VM. + * + * Generated from protobuf enum COMPUTE_ENGINE_VM = 2; + */ + const COMPUTE_ENGINE_VM = 2; + /** + * Compute Engine Disk. + * + * Generated from protobuf enum COMPUTE_ENGINE_DISK = 3; + */ + const COMPUTE_ENGINE_DISK = 3; + /** + * Compute Engine Regional Disk. + * + * Generated from protobuf enum COMPUTE_ENGINE_REGIONAL_DISK = 4; + */ + const COMPUTE_ENGINE_REGIONAL_DISK = 4; + + private static $valueToName = [ + self::RESOURCE_TYPE_UNSPECIFIED => 'RESOURCE_TYPE_UNSPECIFIED', + self::CLOUD_SQL_INSTANCE => 'CLOUD_SQL_INSTANCE', + self::COMPUTE_ENGINE_VM => 'COMPUTE_ENGINE_VM', + self::COMPUTE_ENGINE_DISK => 'COMPUTE_ENGINE_DISK', + self::COMPUTE_ENGINE_REGIONAL_DISK => 'COMPUTE_ENGINE_REGIONAL_DISK', + ]; + + public static function name($value) + { + if (!isset(self::$valueToName[$value])) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no name defined for value %s', __CLASS__, $value)); + } + return self::$valueToName[$value]; + } + + + public static function value($name) + { + $const = __CLASS__ . '::' . strtoupper($name); + if (!defined($const)) { + throw new UnexpectedValueException(sprintf( + 'Enum %s has no value defined for name %s', __CLASS__, $name)); + } + return constant($const); + } +} + + diff --git a/BackupDr/src/V1/gapic_metadata.json b/BackupDr/src/V1/gapic_metadata.json index c6347536e10c..a82b730bc2b8 100644 --- a/BackupDr/src/V1/gapic_metadata.json +++ b/BackupDr/src/V1/gapic_metadata.json @@ -223,6 +223,45 @@ } } } + }, + "BackupDrProtectionSummary": { + "clients": { + "grpc": { + "libraryClient": "BackupDrProtectionSummaryGapicClient", + "rpcs": { + "ListResourceBackupConfigs": { + "methods": [ + "listResourceBackupConfigs" + ] + }, + "GetLocation": { + "methods": [ + "getLocation" + ] + }, + "ListLocations": { + "methods": [ + "listLocations" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + } + } + } + } } } } \ No newline at end of file diff --git a/BackupDr/src/V1/resources/backup_dr_protection_summary_client_config.json b/BackupDr/src/V1/resources/backup_dr_protection_summary_client_config.json new file mode 100644 index 000000000000..8639ca161445 --- /dev/null +++ b/BackupDr/src/V1/resources/backup_dr_protection_summary_client_config.json @@ -0,0 +1,64 @@ +{ + "interfaces": { + "google.cloud.backupdr.v1.BackupDrProtectionSummary": { + "retry_codes": { + "no_retry_codes": [], + "retry_policy_1_codes": [ + "UNAVAILABLE" + ] + }, + "retry_params": { + "no_retry_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 0, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 0, + "total_timeout_millis": 0 + }, + "retry_policy_1_params": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 10000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 60000 + } + }, + "methods": { + "ListResourceBackupConfigs": { + "timeout_millis": 60000, + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params" + }, + "GetLocation": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "ListLocations": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "GetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "SetIamPolicy": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, + "TestIamPermissions": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + } + } + } + } +} diff --git a/BackupDr/src/V1/resources/backup_dr_protection_summary_descriptor_config.php b/BackupDr/src/V1/resources/backup_dr_protection_summary_descriptor_config.php new file mode 100644 index 000000000000..031fc0a15bc4 --- /dev/null +++ b/BackupDr/src/V1/resources/backup_dr_protection_summary_descriptor_config.php @@ -0,0 +1,124 @@ + [ + 'google.cloud.backupdr.v1.BackupDrProtectionSummary' => [ + 'ListResourceBackupConfigs' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getResourceBackupConfigs', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\BackupDR\V1\ListResourceBackupConfigsResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], + 'GetLocation' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Location\Location', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + 'interfaceOverride' => 'google.cloud.location.Locations', + ], + 'ListLocations' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getLocations', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\Location\ListLocationsResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + 'interfaceOverride' => 'google.cloud.location.Locations', + ], + 'GetIamPolicy' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Iam\V1\Policy', + 'headerParams' => [ + [ + 'keyName' => 'resource', + 'fieldAccessors' => [ + 'getResource', + ], + ], + ], + 'interfaceOverride' => 'google.iam.v1.IAMPolicy', + ], + 'SetIamPolicy' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Iam\V1\Policy', + 'headerParams' => [ + [ + 'keyName' => 'resource', + 'fieldAccessors' => [ + 'getResource', + ], + ], + ], + 'interfaceOverride' => 'google.iam.v1.IAMPolicy', + ], + 'TestIamPermissions' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\Iam\V1\TestIamPermissionsResponse', + 'headerParams' => [ + [ + 'keyName' => 'resource', + 'fieldAccessors' => [ + 'getResource', + ], + ], + ], + 'interfaceOverride' => 'google.iam.v1.IAMPolicy', + ], + 'templateMap' => [ + 'location' => 'projects/{project}/locations/{location}', + ], + ], + ], +]; diff --git a/BackupDr/src/V1/resources/backup_dr_protection_summary_rest_client_config.php b/BackupDr/src/V1/resources/backup_dr_protection_summary_rest_client_config.php new file mode 100644 index 000000000000..b264b89a6ae8 --- /dev/null +++ b/BackupDr/src/V1/resources/backup_dr_protection_summary_rest_client_config.php @@ -0,0 +1,148 @@ + [ + 'google.cloud.backupdr.v1.BackupDrProtectionSummary' => [ + 'ListResourceBackupConfigs' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*}/resourceBackupConfigs', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], + ], + 'google.cloud.location.Locations' => [ + 'GetLocation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListLocations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*}/locations', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + 'google.iam.v1.IAMPolicy' => [ + 'GetIamPolicy' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/managementServers/*}:getIamPolicy', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'SetIamPolicy' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/managementServers/*}:setIamPolicy', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + 'TestIamPermissions' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{resource=projects/*/locations/*/managementServers/*}:testIamPermissions', + 'body' => '*', + 'placeholders' => [ + 'resource' => [ + 'getters' => [ + 'getResource', + ], + ], + ], + ], + ], + 'google.longrunning.Operations' => [ + 'CancelOperation' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/operations/*}:cancel', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'DeleteOperation' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'GetOperation' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/operations/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + 'ListOperations' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*}/operations', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], + ], + ], + 'numericEnums' => true, +]; diff --git a/BackupDr/tests/Unit/V1/Client/BackupDrProtectionSummaryClientTest.php b/BackupDr/tests/Unit/V1/Client/BackupDrProtectionSummaryClientTest.php new file mode 100644 index 000000000000..f0f73706471b --- /dev/null +++ b/BackupDr/tests/Unit/V1/Client/BackupDrProtectionSummaryClientTest.php @@ -0,0 +1,518 @@ +getMockBuilder(CredentialsWrapper::class) + ->disableOriginalConstructor() + ->getMock(); + } + + /** @return BackupDrProtectionSummaryClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new BackupDrProtectionSummaryClient($options); + } + + /** @test */ + public function listResourceBackupConfigsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $resourceBackupConfigsElement = new ResourceBackupConfig(); + $resourceBackupConfigs = [$resourceBackupConfigsElement]; + $expectedResponse = new ListResourceBackupConfigsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setResourceBackupConfigs($resourceBackupConfigs); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $request = (new ListResourceBackupConfigsRequest())->setParent($formattedParent); + $response = $gapicClient->listResourceBackupConfigs($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getResourceBackupConfigs()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame( + '/google.cloud.backupdr.v1.BackupDrProtectionSummary/ListResourceBackupConfigs', + $actualFuncCall + ); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listResourceBackupConfigsExceptionTest() + { + $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 + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $request = (new ListResourceBackupConfigsRequest())->setParent($formattedParent); + try { + $gapicClient->listResourceBackupConfigs($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 getLocationTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $locationId = 'locationId552319461'; + $displayName = 'displayName1615086568'; + $expectedResponse = new Location(); + $expectedResponse->setName($name2); + $expectedResponse->setLocationId($locationId); + $expectedResponse->setDisplayName($displayName); + $transport->addResponse($expectedResponse); + $request = new GetLocationRequest(); + $response = $gapicClient->getLocation($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.location.Locations/GetLocation', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getLocationExceptionTest() + { + $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); + $request = new GetLocationRequest(); + try { + $gapicClient->getLocation($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 listLocationsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $locationsElement = new Location(); + $locations = [$locationsElement]; + $expectedResponse = new ListLocationsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setLocations($locations); + $transport->addResponse($expectedResponse); + $request = new ListLocationsRequest(); + $response = $gapicClient->listLocations($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getLocations()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.location.Locations/ListLocations', $actualFuncCall); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listLocationsExceptionTest() + { + $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); + $request = new ListLocationsRequest(); + try { + $gapicClient->listLocations($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 getIamPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $version = 351608024; + $etag = '21'; + $expectedResponse = new Policy(); + $expectedResponse->setVersion($version); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $resource = 'resource-341064690'; + $request = (new GetIamPolicyRequest())->setResource($resource); + $response = $gapicClient->getIamPolicy($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.iam.v1.IAMPolicy/GetIamPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getResource(); + $this->assertProtobufEquals($resource, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getIamPolicyExceptionTest() + { + $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 + $resource = 'resource-341064690'; + $request = (new GetIamPolicyRequest())->setResource($resource); + try { + $gapicClient->getIamPolicy($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 setIamPolicyTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $version = 351608024; + $etag = '21'; + $expectedResponse = new Policy(); + $expectedResponse->setVersion($version); + $expectedResponse->setEtag($etag); + $transport->addResponse($expectedResponse); + // Mock request + $resource = 'resource-341064690'; + $policy = new Policy(); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); + $response = $gapicClient->setIamPolicy($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.iam.v1.IAMPolicy/SetIamPolicy', $actualFuncCall); + $actualValue = $actualRequestObject->getResource(); + $this->assertProtobufEquals($resource, $actualValue); + $actualValue = $actualRequestObject->getPolicy(); + $this->assertProtobufEquals($policy, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function setIamPolicyExceptionTest() + { + $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 + $resource = 'resource-341064690'; + $policy = new Policy(); + $request = (new SetIamPolicyRequest())->setResource($resource)->setPolicy($policy); + try { + $gapicClient->setIamPolicy($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 testIamPermissionsTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new TestIamPermissionsResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $resource = 'resource-341064690'; + $permissions = []; + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); + $response = $gapicClient->testIamPermissions($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.iam.v1.IAMPolicy/TestIamPermissions', $actualFuncCall); + $actualValue = $actualRequestObject->getResource(); + $this->assertProtobufEquals($resource, $actualValue); + $actualValue = $actualRequestObject->getPermissions(); + $this->assertProtobufEquals($permissions, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function testIamPermissionsExceptionTest() + { + $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 + $resource = 'resource-341064690'; + $permissions = []; + $request = (new TestIamPermissionsRequest())->setResource($resource)->setPermissions($permissions); + try { + $gapicClient->testIamPermissions($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 listResourceBackupConfigsAsyncTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $resourceBackupConfigsElement = new ResourceBackupConfig(); + $resourceBackupConfigs = [$resourceBackupConfigsElement]; + $expectedResponse = new ListResourceBackupConfigsResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setResourceBackupConfigs($resourceBackupConfigs); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); + $request = (new ListResourceBackupConfigsRequest())->setParent($formattedParent); + $response = $gapicClient->listResourceBackupConfigsAsync($request)->wait(); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getResourceBackupConfigs()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame( + '/google.cloud.backupdr.v1.BackupDrProtectionSummary/ListResourceBackupConfigs', + $actualFuncCall + ); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } +}