From be3a11c9f4b18c20264399206e6aa2c7716adb6a Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 18:28:14 -0700 Subject: [PATCH] feat: Add branch rule APIs (#7754) feat: Add field `psc_allowed_projects` to message `.google.cloud.securesourcemanager.v1.Instance` docs: A comment for field `instance` in message `.google.cloud.securesourcemanager.v1.Repository` is changed PiperOrigin-RevId: 688170540 Source-Link: https://github.com/googleapis/googleapis/commit/b6a9d807da8fb0f767a7b5b5b2d773e41e7d52b5 Source-Link: https://github.com/googleapis/googleapis-gen/commit/d9406c5e840d1e8289232ca089827b71c7601c00 Copy-Tag: eyJwIjoiU2VjdXJlU291cmNlTWFuYWdlci8uT3dsQm90LnlhbWwiLCJoIjoiZDk0MDZjNWU4NDBkMWU4Mjg5MjMyY2EwODk4MjdiNzFjNzYwMWMwMCJ9 --- .../metadata/V1/SecureSourceManager.php | Bin 8281 -> 11360 bytes .../create_branch_rule.php | 91 +++ .../delete_branch_rule.php | 84 +++ .../get_branch_rule.php | 78 +++ .../list_branch_rules.php | 79 +++ .../update_branch_rule.php | 74 ++ SecureSourceManager/src/V1/BranchRule.php | 620 +++++++++++++++++ .../src/V1/BranchRule/Check.php | 68 ++ .../V1/Client/SecureSourceManagerClient.php | 167 +++++ .../src/V1/CreateBranchRuleRequest.php | 141 ++++ .../src/V1/DeleteBranchRuleRequest.php | 111 +++ .../src/V1/GetBranchRuleRequest.php | 91 +++ .../src/V1/Instance/PrivateConfig.php | 42 ++ .../src/V1/ListBranchRulesRequest.php | 127 ++++ .../src/V1/ListBranchRulesResponse.php | 101 +++ SecureSourceManager/src/V1/Repository.php | 20 +- .../src/V1/UpdateBranchRuleRequest.php | 187 +++++ .../src/V1/gapic_metadata.json | 25 + .../secure_source_manager_client_config.json | 25 + ...ecure_source_manager_descriptor_config.php | 91 +++ ...cure_source_manager_rest_client_config.php | 64 ++ .../Client/SecureSourceManagerClientTest.php | 657 +++++++++++++++++- 22 files changed, 2912 insertions(+), 31 deletions(-) create mode 100644 SecureSourceManager/samples/V1/SecureSourceManagerClient/create_branch_rule.php create mode 100644 SecureSourceManager/samples/V1/SecureSourceManagerClient/delete_branch_rule.php create mode 100644 SecureSourceManager/samples/V1/SecureSourceManagerClient/get_branch_rule.php create mode 100644 SecureSourceManager/samples/V1/SecureSourceManagerClient/list_branch_rules.php create mode 100644 SecureSourceManager/samples/V1/SecureSourceManagerClient/update_branch_rule.php create mode 100644 SecureSourceManager/src/V1/BranchRule.php create mode 100644 SecureSourceManager/src/V1/BranchRule/Check.php create mode 100644 SecureSourceManager/src/V1/CreateBranchRuleRequest.php create mode 100644 SecureSourceManager/src/V1/DeleteBranchRuleRequest.php create mode 100644 SecureSourceManager/src/V1/GetBranchRuleRequest.php create mode 100644 SecureSourceManager/src/V1/ListBranchRulesRequest.php create mode 100644 SecureSourceManager/src/V1/ListBranchRulesResponse.php create mode 100644 SecureSourceManager/src/V1/UpdateBranchRuleRequest.php diff --git a/SecureSourceManager/metadata/V1/SecureSourceManager.php b/SecureSourceManager/metadata/V1/SecureSourceManager.php index a5a3a2cde5fd977498dd55c2ee03a3f237994ed9..ce998e64e2ba268ced99505696b5ac159bc773c9 100644 GIT binary patch delta 1812 zcma)6&2QX99F^_e?d~|6-F2MUyW7yjg-x^yyXqDW4OJAUNf93*C=y=@l9}vI6BDm( z>~TtpstT@vR5T|<{{|>pi8HxXxzGx6AQGa7UVsCfk&qaBKgMe=+&nXHe!usg-*0|i zef;+Q6CroqL{?`L`iJBaUnjSP961qQ;~#AGN~vY8I=AmQ`xa`to`ape;70RC2sgSR zem%X&{nYEGzvsF8y+(GDyC}^A+4b87v@GW)>KOFa`>2h5H8UqH=GKJAI@i0JyOOH^ zngL+VgLeC1JFt*c0x27Ik;=_+1DI3Da!SrnSY^DuJ12?y#B-ok2Ei>>Wql!%hgpeM)H5={zWycH0U%$Z#RX$g|aR>~tDr zJEjl!EYwl6bUWLxLxppCVrE|pPa{Q@S&)ua zk_^tZ9UG$$G5fE4r3H%Y&ybB=Ew_A^`(6Kx1J4qelF5Wvm|%saT>`-(+0B>B&Am}x z{N_jfh2hck^!)sjOi9}X@{0(wtK`qAwF_*iJ>Y z4w21nbJ{JStRoAJ5v5|{_g|3DU)H{(ir#QLV~Vz;9O9&saIgkSmPe#eUr7bzY3j_d zj^WtWaU^>X^XGsVL>>AQ|1e$FNAE>+TRR5Im{R0#Bj2TSiKGoM5wpmrDF_EOvNNvb zo>UfEe^+}u@^4v1`jiL7(ov_f;F&(} zLXS?(QjAahoBqB}etbgsO>KpU(;E4@T5QDgwj7Uz^a}?H3C$9DFH<9bDJhw`ON|KM z1YC*OhljPX!@f(})|sB^vx_LKN+SwS#VJUq9LSFc{9}0`vGar4sInf~=9wP7tE0jv z)AQt;>SQfmxLLm~eNIhJCTU=LayvBrt*`!<=}O$~Sd1b%@3dZS9$gw6setParent($formattedParent) + ->setBranchRule($branchRule) + ->setBranchRuleId($branchRuleId); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $secureSourceManagerClient->createBranchRule($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var BranchRule $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = SecureSourceManagerClient::repositoryName( + '[PROJECT]', + '[LOCATION]', + '[REPOSITORY]' + ); + $branchRuleId = '[BRANCH_RULE_ID]'; + + create_branch_rule_sample($formattedParent, $branchRuleId); +} +// [END securesourcemanager_v1_generated_SecureSourceManager_CreateBranchRule_sync] diff --git a/SecureSourceManager/samples/V1/SecureSourceManagerClient/delete_branch_rule.php b/SecureSourceManager/samples/V1/SecureSourceManagerClient/delete_branch_rule.php new file mode 100644 index 000000000000..ea41d7e97423 --- /dev/null +++ b/SecureSourceManager/samples/V1/SecureSourceManagerClient/delete_branch_rule.php @@ -0,0 +1,84 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $secureSourceManagerClient->deleteBranchRule($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + printf('Operation completed successfully.' . PHP_EOL); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = SecureSourceManagerClient::branchRuleName( + '[PROJECT]', + '[LOCATION]', + '[REPOSITORY]', + '[BRANCH_RULE]' + ); + + delete_branch_rule_sample($formattedName); +} +// [END securesourcemanager_v1_generated_SecureSourceManager_DeleteBranchRule_sync] diff --git a/SecureSourceManager/samples/V1/SecureSourceManagerClient/get_branch_rule.php b/SecureSourceManager/samples/V1/SecureSourceManagerClient/get_branch_rule.php new file mode 100644 index 000000000000..92d58064f39b --- /dev/null +++ b/SecureSourceManager/samples/V1/SecureSourceManagerClient/get_branch_rule.php @@ -0,0 +1,78 @@ +setName($formattedName); + + // Call the API and handle any network failures. + try { + /** @var BranchRule $response */ + $response = $secureSourceManagerClient->getBranchRule($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample has been automatically generated and should be regarded as a code + * template only. It will require modifications to work: + * - It may require correct/in-range values for request initialization. + * - It may require specifying regional endpoints when creating the service client, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = SecureSourceManagerClient::branchRuleName( + '[PROJECT]', + '[LOCATION]', + '[REPOSITORY]', + '[BRANCH_RULE]' + ); + + get_branch_rule_sample($formattedName); +} +// [END securesourcemanager_v1_generated_SecureSourceManager_GetBranchRule_sync] diff --git a/SecureSourceManager/samples/V1/SecureSourceManagerClient/list_branch_rules.php b/SecureSourceManager/samples/V1/SecureSourceManagerClient/list_branch_rules.php new file mode 100644 index 000000000000..22314e1df0b1 --- /dev/null +++ b/SecureSourceManager/samples/V1/SecureSourceManagerClient/list_branch_rules.php @@ -0,0 +1,79 @@ +setParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $secureSourceManagerClient->listBranchRules($request); + + /** @var BranchRule $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 = SecureSourceManagerClient::repositoryName( + '[PROJECT]', + '[LOCATION]', + '[REPOSITORY]' + ); + + list_branch_rules_sample($formattedParent); +} +// [END securesourcemanager_v1_generated_SecureSourceManager_ListBranchRules_sync] diff --git a/SecureSourceManager/samples/V1/SecureSourceManagerClient/update_branch_rule.php b/SecureSourceManager/samples/V1/SecureSourceManagerClient/update_branch_rule.php new file mode 100644 index 000000000000..6baafcb1d6b8 --- /dev/null +++ b/SecureSourceManager/samples/V1/SecureSourceManagerClient/update_branch_rule.php @@ -0,0 +1,74 @@ +setBranchRule($branchRule) + ->setUpdateMask($updateMask); + + // Call the API and handle any network failures. + try { + /** @var OperationResponse $response */ + $response = $secureSourceManagerClient->updateBranchRule($request); + $response->pollUntilComplete(); + + if ($response->operationSucceeded()) { + /** @var BranchRule $result */ + $result = $response->getResult(); + printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString()); + } else { + /** @var Status $error */ + $error = $response->getError(); + printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} +// [END securesourcemanager_v1_generated_SecureSourceManager_UpdateBranchRule_sync] diff --git a/SecureSourceManager/src/V1/BranchRule.php b/SecureSourceManager/src/V1/BranchRule.php new file mode 100644 index 000000000000..8bb18a7dca9a --- /dev/null +++ b/SecureSourceManager/src/V1/BranchRule.php @@ -0,0 +1,620 @@ +google.cloud.securesourcemanager.v1.BranchRule + */ +class BranchRule extends \Google\Protobuf\Internal\Message +{ + /** + * Optional. A unique identifier for a BranchRule. The name should be of the + * format: + * `projects/{project}/locations/{location}/repositories/{repository}/branchRules/{branch_rule}` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $name = ''; + /** + * Output only. Unique identifier of the repository. + * + * Generated from protobuf field string uid = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $uid = ''; + /** + * Output only. Create timestamp. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $create_time = null; + /** + * Output only. Update timestamp. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + */ + protected $update_time = null; + /** + * Optional. User annotations. These attributes can only be set and used by + * the user. See https://google.aip.dev/128#annotations for more details such + * as format and size limitations. + * + * Generated from protobuf field map annotations = 5 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $annotations; + /** + * Optional. This checksum is computed by the server based on the value of + * other fields, and may be sent on update and delete requests to ensure the + * client has an up-to-date value before proceeding. + * + * Generated from protobuf field string etag = 6 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $etag = ''; + /** + * Optional. The pattern of the branch that can match to this BranchRule. + * Specified as regex. + * .* for all branches. Examples: main, (main|release.*). + * Current MVP phase only support `.*` for wildcard. + * + * Generated from protobuf field string include_pattern = 7 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $include_pattern = ''; + /** + * Optional. Determines if the branch rule is disabled or not. + * + * Generated from protobuf field bool disabled = 8 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $disabled = false; + /** + * Optional. Determines if the branch rule requires a pull request or not. + * + * Generated from protobuf field bool require_pull_request = 9 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $require_pull_request = false; + /** + * Optional. The minimum number of reviews required for the branch rule to be + * matched. + * + * Generated from protobuf field int32 minimum_reviews_count = 10 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $minimum_reviews_count = 0; + /** + * Optional. The minimum number of approvals required for the branch rule to + * be matched. + * + * Generated from protobuf field int32 minimum_approvals_count = 11 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $minimum_approvals_count = 0; + /** + * Optional. Determines if require comments resolved before merging to the + * branch. + * + * Generated from protobuf field bool require_comments_resolved = 12 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $require_comments_resolved = false; + /** + * Optional. Determines if allow stale reviews or approvals before merging to + * the branch. + * + * Generated from protobuf field bool allow_stale_reviews = 15 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $allow_stale_reviews = false; + /** + * Optional. Determines if require linear history before merging to the + * branch. + * + * Generated from protobuf field bool require_linear_history = 13 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $require_linear_history = false; + /** + * Optional. List of required status checks before merging to the branch. + * + * Generated from protobuf field repeated .google.cloud.securesourcemanager.v1.BranchRule.Check required_status_checks = 14 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $required_status_checks; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Optional. A unique identifier for a BranchRule. The name should be of the + * format: + * `projects/{project}/locations/{location}/repositories/{repository}/branchRules/{branch_rule}` + * @type string $uid + * Output only. Unique identifier of the repository. + * @type \Google\Protobuf\Timestamp $create_time + * Output only. Create timestamp. + * @type \Google\Protobuf\Timestamp $update_time + * Output only. Update timestamp. + * @type array|\Google\Protobuf\Internal\MapField $annotations + * Optional. User annotations. These attributes can only be set and used by + * the user. See https://google.aip.dev/128#annotations for more details such + * as format and size limitations. + * @type string $etag + * Optional. This checksum is computed by the server based on the value of + * other fields, and may be sent on update and delete requests to ensure the + * client has an up-to-date value before proceeding. + * @type string $include_pattern + * Optional. The pattern of the branch that can match to this BranchRule. + * Specified as regex. + * .* for all branches. Examples: main, (main|release.*). + * Current MVP phase only support `.*` for wildcard. + * @type bool $disabled + * Optional. Determines if the branch rule is disabled or not. + * @type bool $require_pull_request + * Optional. Determines if the branch rule requires a pull request or not. + * @type int $minimum_reviews_count + * Optional. The minimum number of reviews required for the branch rule to be + * matched. + * @type int $minimum_approvals_count + * Optional. The minimum number of approvals required for the branch rule to + * be matched. + * @type bool $require_comments_resolved + * Optional. Determines if require comments resolved before merging to the + * branch. + * @type bool $allow_stale_reviews + * Optional. Determines if allow stale reviews or approvals before merging to + * the branch. + * @type bool $require_linear_history + * Optional. Determines if require linear history before merging to the + * branch. + * @type array<\Google\Cloud\SecureSourceManager\V1\BranchRule\Check>|\Google\Protobuf\Internal\RepeatedField $required_status_checks + * Optional. List of required status checks before merging to the branch. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Securesourcemanager\V1\SecureSourceManager::initOnce(); + parent::__construct($data); + } + + /** + * Optional. A unique identifier for a BranchRule. The name should be of the + * format: + * `projects/{project}/locations/{location}/repositories/{repository}/branchRules/{branch_rule}` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Optional. A unique identifier for a BranchRule. The name should be of the + * format: + * `projects/{project}/locations/{location}/repositories/{repository}/branchRules/{branch_rule}` + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Output only. Unique identifier of the repository. + * + * Generated from protobuf field string uid = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return string + */ + public function getUid() + { + return $this->uid; + } + + /** + * Output only. Unique identifier of the repository. + * + * Generated from protobuf field string uid = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param string $var + * @return $this + */ + public function setUid($var) + { + GPBUtil::checkString($var, True); + $this->uid = $var; + + return $this; + } + + /** + * Output only. Create timestamp. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getCreateTime() + { + return $this->create_time; + } + + public function hasCreateTime() + { + return isset($this->create_time); + } + + public function clearCreateTime() + { + unset($this->create_time); + } + + /** + * Output only. Create timestamp. + * + * Generated from protobuf field .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setCreateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->create_time = $var; + + return $this; + } + + /** + * Output only. Update timestamp. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @return \Google\Protobuf\Timestamp|null + */ + public function getUpdateTime() + { + return $this->update_time; + } + + public function hasUpdateTime() + { + return isset($this->update_time); + } + + public function clearUpdateTime() + { + unset($this->update_time); + } + + /** + * Output only. Update timestamp. + * + * Generated from protobuf field .google.protobuf.Timestamp update_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * @param \Google\Protobuf\Timestamp $var + * @return $this + */ + public function setUpdateTime($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class); + $this->update_time = $var; + + return $this; + } + + /** + * Optional. User annotations. These attributes can only be set and used by + * the user. See https://google.aip.dev/128#annotations for more details such + * as format and size limitations. + * + * Generated from protobuf field map annotations = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\MapField + */ + public function getAnnotations() + { + return $this->annotations; + } + + /** + * Optional. User annotations. These attributes can only be set and used by + * the user. See https://google.aip.dev/128#annotations for more details such + * as format and size limitations. + * + * Generated from protobuf field map annotations = 5 [(.google.api.field_behavior) = OPTIONAL]; + * @param array|\Google\Protobuf\Internal\MapField $var + * @return $this + */ + public function setAnnotations($var) + { + $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::STRING); + $this->annotations = $arr; + + return $this; + } + + /** + * Optional. This checksum is computed by the server based on the value of + * other fields, and may be sent on update and delete requests to ensure the + * client has an up-to-date value before proceeding. + * + * Generated from protobuf field string etag = 6 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getEtag() + { + return $this->etag; + } + + /** + * Optional. This checksum is computed by the server based on the value of + * other fields, and may be sent on update and delete requests to ensure the + * client has an up-to-date value before proceeding. + * + * Generated from protobuf field string etag = 6 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setEtag($var) + { + GPBUtil::checkString($var, True); + $this->etag = $var; + + return $this; + } + + /** + * Optional. The pattern of the branch that can match to this BranchRule. + * Specified as regex. + * .* for all branches. Examples: main, (main|release.*). + * Current MVP phase only support `.*` for wildcard. + * + * Generated from protobuf field string include_pattern = 7 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getIncludePattern() + { + return $this->include_pattern; + } + + /** + * Optional. The pattern of the branch that can match to this BranchRule. + * Specified as regex. + * .* for all branches. Examples: main, (main|release.*). + * Current MVP phase only support `.*` for wildcard. + * + * Generated from protobuf field string include_pattern = 7 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setIncludePattern($var) + { + GPBUtil::checkString($var, True); + $this->include_pattern = $var; + + return $this; + } + + /** + * Optional. Determines if the branch rule is disabled or not. + * + * Generated from protobuf field bool disabled = 8 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getDisabled() + { + return $this->disabled; + } + + /** + * Optional. Determines if the branch rule is disabled or not. + * + * Generated from protobuf field bool disabled = 8 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setDisabled($var) + { + GPBUtil::checkBool($var); + $this->disabled = $var; + + return $this; + } + + /** + * Optional. Determines if the branch rule requires a pull request or not. + * + * Generated from protobuf field bool require_pull_request = 9 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getRequirePullRequest() + { + return $this->require_pull_request; + } + + /** + * Optional. Determines if the branch rule requires a pull request or not. + * + * Generated from protobuf field bool require_pull_request = 9 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setRequirePullRequest($var) + { + GPBUtil::checkBool($var); + $this->require_pull_request = $var; + + return $this; + } + + /** + * Optional. The minimum number of reviews required for the branch rule to be + * matched. + * + * Generated from protobuf field int32 minimum_reviews_count = 10 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getMinimumReviewsCount() + { + return $this->minimum_reviews_count; + } + + /** + * Optional. The minimum number of reviews required for the branch rule to be + * matched. + * + * Generated from protobuf field int32 minimum_reviews_count = 10 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setMinimumReviewsCount($var) + { + GPBUtil::checkInt32($var); + $this->minimum_reviews_count = $var; + + return $this; + } + + /** + * Optional. The minimum number of approvals required for the branch rule to + * be matched. + * + * Generated from protobuf field int32 minimum_approvals_count = 11 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getMinimumApprovalsCount() + { + return $this->minimum_approvals_count; + } + + /** + * Optional. The minimum number of approvals required for the branch rule to + * be matched. + * + * Generated from protobuf field int32 minimum_approvals_count = 11 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setMinimumApprovalsCount($var) + { + GPBUtil::checkInt32($var); + $this->minimum_approvals_count = $var; + + return $this; + } + + /** + * Optional. Determines if require comments resolved before merging to the + * branch. + * + * Generated from protobuf field bool require_comments_resolved = 12 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getRequireCommentsResolved() + { + return $this->require_comments_resolved; + } + + /** + * Optional. Determines if require comments resolved before merging to the + * branch. + * + * Generated from protobuf field bool require_comments_resolved = 12 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setRequireCommentsResolved($var) + { + GPBUtil::checkBool($var); + $this->require_comments_resolved = $var; + + return $this; + } + + /** + * Optional. Determines if allow stale reviews or approvals before merging to + * the branch. + * + * Generated from protobuf field bool allow_stale_reviews = 15 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getAllowStaleReviews() + { + return $this->allow_stale_reviews; + } + + /** + * Optional. Determines if allow stale reviews or approvals before merging to + * the branch. + * + * Generated from protobuf field bool allow_stale_reviews = 15 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setAllowStaleReviews($var) + { + GPBUtil::checkBool($var); + $this->allow_stale_reviews = $var; + + return $this; + } + + /** + * Optional. Determines if require linear history before merging to the + * branch. + * + * Generated from protobuf field bool require_linear_history = 13 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getRequireLinearHistory() + { + return $this->require_linear_history; + } + + /** + * Optional. Determines if require linear history before merging to the + * branch. + * + * Generated from protobuf field bool require_linear_history = 13 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setRequireLinearHistory($var) + { + GPBUtil::checkBool($var); + $this->require_linear_history = $var; + + return $this; + } + + /** + * Optional. List of required status checks before merging to the branch. + * + * Generated from protobuf field repeated .google.cloud.securesourcemanager.v1.BranchRule.Check required_status_checks = 14 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getRequiredStatusChecks() + { + return $this->required_status_checks; + } + + /** + * Optional. List of required status checks before merging to the branch. + * + * Generated from protobuf field repeated .google.cloud.securesourcemanager.v1.BranchRule.Check required_status_checks = 14 [(.google.api.field_behavior) = OPTIONAL]; + * @param array<\Google\Cloud\SecureSourceManager\V1\BranchRule\Check>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setRequiredStatusChecks($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\SecureSourceManager\V1\BranchRule\Check::class); + $this->required_status_checks = $arr; + + return $this; + } + +} + diff --git a/SecureSourceManager/src/V1/BranchRule/Check.php b/SecureSourceManager/src/V1/BranchRule/Check.php new file mode 100644 index 000000000000..f222c46b9575 --- /dev/null +++ b/SecureSourceManager/src/V1/BranchRule/Check.php @@ -0,0 +1,68 @@ +google.cloud.securesourcemanager.v1.BranchRule.Check + */ +class Check extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The context of the check. + * + * Generated from protobuf field string context = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $context = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $context + * Required. The context of the check. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Securesourcemanager\V1\SecureSourceManager::initOnce(); + parent::__construct($data); + } + + /** + * Required. The context of the check. + * + * Generated from protobuf field string context = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getContext() + { + return $this->context; + } + + /** + * Required. The context of the check. + * + * Generated from protobuf field string context = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setContext($var) + { + GPBUtil::checkString($var, True); + $this->context = $var; + + return $this; + } + +} + + diff --git a/SecureSourceManager/src/V1/Client/SecureSourceManagerClient.php b/SecureSourceManager/src/V1/Client/SecureSourceManagerClient.php index aea6eda4a9e4..74d9b8633cd0 100644 --- a/SecureSourceManager/src/V1/Client/SecureSourceManagerClient.php +++ b/SecureSourceManager/src/V1/Client/SecureSourceManagerClient.php @@ -42,16 +42,22 @@ use Google\Cloud\Location\GetLocationRequest; use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\Location; +use Google\Cloud\SecureSourceManager\V1\BranchRule; +use Google\Cloud\SecureSourceManager\V1\CreateBranchRuleRequest; use Google\Cloud\SecureSourceManager\V1\CreateInstanceRequest; use Google\Cloud\SecureSourceManager\V1\CreateRepositoryRequest; +use Google\Cloud\SecureSourceManager\V1\DeleteBranchRuleRequest; use Google\Cloud\SecureSourceManager\V1\DeleteInstanceRequest; use Google\Cloud\SecureSourceManager\V1\DeleteRepositoryRequest; +use Google\Cloud\SecureSourceManager\V1\GetBranchRuleRequest; use Google\Cloud\SecureSourceManager\V1\GetInstanceRequest; use Google\Cloud\SecureSourceManager\V1\GetRepositoryRequest; use Google\Cloud\SecureSourceManager\V1\Instance; +use Google\Cloud\SecureSourceManager\V1\ListBranchRulesRequest; use Google\Cloud\SecureSourceManager\V1\ListInstancesRequest; use Google\Cloud\SecureSourceManager\V1\ListRepositoriesRequest; use Google\Cloud\SecureSourceManager\V1\Repository; +use Google\Cloud\SecureSourceManager\V1\UpdateBranchRuleRequest; use Google\LongRunning\Client\OperationsClient; use Google\LongRunning\Operation; use GuzzleHttp\Promise\PromiseInterface; @@ -86,17 +92,22 @@ * name, and additionally a parseName method to extract the individual identifiers * contained within formatted names that are returned by the API. * + * @method PromiseInterface createBranchRuleAsync(CreateBranchRuleRequest $request, array $optionalArgs = []) * @method PromiseInterface createInstanceAsync(CreateInstanceRequest $request, array $optionalArgs = []) * @method PromiseInterface createRepositoryAsync(CreateRepositoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface deleteBranchRuleAsync(DeleteBranchRuleRequest $request, array $optionalArgs = []) * @method PromiseInterface deleteInstanceAsync(DeleteInstanceRequest $request, array $optionalArgs = []) * @method PromiseInterface deleteRepositoryAsync(DeleteRepositoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface getBranchRuleAsync(GetBranchRuleRequest $request, array $optionalArgs = []) * @method PromiseInterface getIamPolicyRepoAsync(GetIamPolicyRequest $request, array $optionalArgs = []) * @method PromiseInterface getInstanceAsync(GetInstanceRequest $request, array $optionalArgs = []) * @method PromiseInterface getRepositoryAsync(GetRepositoryRequest $request, array $optionalArgs = []) + * @method PromiseInterface listBranchRulesAsync(ListBranchRulesRequest $request, array $optionalArgs = []) * @method PromiseInterface listInstancesAsync(ListInstancesRequest $request, array $optionalArgs = []) * @method PromiseInterface listRepositoriesAsync(ListRepositoriesRequest $request, array $optionalArgs = []) * @method PromiseInterface setIamPolicyRepoAsync(SetIamPolicyRequest $request, array $optionalArgs = []) * @method PromiseInterface testIamPermissionsRepoAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) + * @method PromiseInterface updateBranchRuleAsync(UpdateBranchRuleRequest $request, array $optionalArgs = []) * @method PromiseInterface getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = []) * @method PromiseInterface setIamPolicyAsync(SetIamPolicyRequest $request, array $optionalArgs = []) * @method PromiseInterface testIamPermissionsAsync(TestIamPermissionsRequest $request, array $optionalArgs = []) @@ -201,6 +212,31 @@ private function createOperationsClient(array $options) return new OperationsClient($options); } + /** + * Formats a string containing the fully-qualified path to represent a branch_rule + * resource. + * + * @param string $project + * @param string $location + * @param string $repository + * @param string $branchRule + * + * @return string The formatted branch_rule resource. + */ + public static function branchRuleName( + string $project, + string $location, + string $repository, + string $branchRule + ): string { + return self::getPathTemplate('branchRule')->render([ + 'project' => $project, + 'location' => $location, + 'repository' => $repository, + 'branch_rule' => $branchRule, + ]); + } + /** * Formats a string containing the fully-qualified path to represent a ca_pool * resource. @@ -319,6 +355,7 @@ public static function serviceAttachmentName(string $project, string $region, st * Parses a formatted name string and returns an associative array of the components in the name. * The following name formats are supported: * Template: Pattern + * - branchRule: projects/{project}/locations/{location}/repositories/{repository}/branchRules/{branch_rule} * - caPool: projects/{project}/locations/{location}/caPools/{ca_pool} * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} * - instance: projects/{project}/locations/{location}/instances/{instance} @@ -416,6 +453,32 @@ public function __call($method, $args) return call_user_func_array([$this, 'startAsyncCall'], $args); } + /** + * CreateBranchRule creates a branch rule in a given repository. + * + * The async variant is {@see SecureSourceManagerClient::createBranchRuleAsync()} . + * + * @example samples/V1/SecureSourceManagerClient/create_branch_rule.php + * + * @param CreateBranchRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function createBranchRule(CreateBranchRuleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('CreateBranchRule', $request, $callOptions)->wait(); + } + /** * Creates a new instance in a given project and location. * @@ -470,6 +533,32 @@ public function createRepository(CreateRepositoryRequest $request, array $callOp return $this->startApiCall('CreateRepository', $request, $callOptions)->wait(); } + /** + * DeleteBranchRule deletes a branch rule. + * + * The async variant is {@see SecureSourceManagerClient::deleteBranchRuleAsync()} . + * + * @example samples/V1/SecureSourceManagerClient/delete_branch_rule.php + * + * @param DeleteBranchRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function deleteBranchRule(DeleteBranchRuleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('DeleteBranchRule', $request, $callOptions)->wait(); + } + /** * Deletes a single instance. * @@ -524,6 +613,32 @@ public function deleteRepository(DeleteRepositoryRequest $request, array $callOp return $this->startApiCall('DeleteRepository', $request, $callOptions)->wait(); } + /** + * GetBranchRule gets a branch rule. + * + * The async variant is {@see SecureSourceManagerClient::getBranchRuleAsync()} . + * + * @example samples/V1/SecureSourceManagerClient/get_branch_rule.php + * + * @param GetBranchRuleRequest $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 BranchRule + * + * @throws ApiException Thrown if the API call fails. + */ + public function getBranchRule(GetBranchRuleRequest $request, array $callOptions = []): BranchRule + { + return $this->startApiCall('GetBranchRule', $request, $callOptions)->wait(); + } + /** * Get IAM policy for a repository. * @@ -604,6 +719,32 @@ public function getRepository(GetRepositoryRequest $request, array $callOptions return $this->startApiCall('GetRepository', $request, $callOptions)->wait(); } + /** + * ListBranchRules lists branch rules in a given repository. + * + * The async variant is {@see SecureSourceManagerClient::listBranchRulesAsync()} . + * + * @example samples/V1/SecureSourceManagerClient/list_branch_rules.php + * + * @param ListBranchRulesRequest $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 listBranchRules(ListBranchRulesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListBranchRules', $request, $callOptions); + } + /** * Lists Instances in a given project and location. * @@ -714,6 +855,32 @@ public function testIamPermissionsRepo( return $this->startApiCall('TestIamPermissionsRepo', $request, $callOptions)->wait(); } + /** + * UpdateBranchRule updates a branch rule. + * + * The async variant is {@see SecureSourceManagerClient::updateBranchRuleAsync()} . + * + * @example samples/V1/SecureSourceManagerClient/update_branch_rule.php + * + * @param UpdateBranchRuleRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return OperationResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function updateBranchRule(UpdateBranchRuleRequest $request, array $callOptions = []): OperationResponse + { + return $this->startApiCall('UpdateBranchRule', $request, $callOptions)->wait(); + } + /** * Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set. diff --git a/SecureSourceManager/src/V1/CreateBranchRuleRequest.php b/SecureSourceManager/src/V1/CreateBranchRuleRequest.php new file mode 100644 index 000000000000..2afd8aa99c0e --- /dev/null +++ b/SecureSourceManager/src/V1/CreateBranchRuleRequest.php @@ -0,0 +1,141 @@ +google.cloud.securesourcemanager.v1.CreateBranchRuleRequest + */ +class CreateBranchRuleRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Generated from protobuf field .google.cloud.securesourcemanager.v1.BranchRule branch_rule = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $branch_rule = null; + /** + * Generated from protobuf field string branch_rule_id = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $branch_rule_id = ''; + + /** + * @param string $parent Please see {@see SecureSourceManagerClient::repositoryName()} for help formatting this field. + * @param \Google\Cloud\SecureSourceManager\V1\BranchRule $branchRule + * @param string $branchRuleId + * + * @return \Google\Cloud\SecureSourceManager\V1\CreateBranchRuleRequest + * + * @experimental + */ + public static function build(string $parent, \Google\Cloud\SecureSourceManager\V1\BranchRule $branchRule, string $branchRuleId): self + { + return (new self()) + ->setParent($parent) + ->setBranchRule($branchRule) + ->setBranchRuleId($branchRuleId); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * @type \Google\Cloud\SecureSourceManager\V1\BranchRule $branch_rule + * @type string $branch_rule_id + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Securesourcemanager\V1\SecureSourceManager::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * 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; + } + + /** + * Generated from protobuf field .google.cloud.securesourcemanager.v1.BranchRule branch_rule = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\SecureSourceManager\V1\BranchRule|null + */ + public function getBranchRule() + { + return $this->branch_rule; + } + + public function hasBranchRule() + { + return isset($this->branch_rule); + } + + public function clearBranchRule() + { + unset($this->branch_rule); + } + + /** + * Generated from protobuf field .google.cloud.securesourcemanager.v1.BranchRule branch_rule = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\SecureSourceManager\V1\BranchRule $var + * @return $this + */ + public function setBranchRule($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\SecureSourceManager\V1\BranchRule::class); + $this->branch_rule = $var; + + return $this; + } + + /** + * Generated from protobuf field string branch_rule_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return string + */ + public function getBranchRuleId() + { + return $this->branch_rule_id; + } + + /** + * Generated from protobuf field string branch_rule_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param string $var + * @return $this + */ + public function setBranchRuleId($var) + { + GPBUtil::checkString($var, True); + $this->branch_rule_id = $var; + + return $this; + } + +} + diff --git a/SecureSourceManager/src/V1/DeleteBranchRuleRequest.php b/SecureSourceManager/src/V1/DeleteBranchRuleRequest.php new file mode 100644 index 000000000000..e69e241dd971 --- /dev/null +++ b/SecureSourceManager/src/V1/DeleteBranchRuleRequest.php @@ -0,0 +1,111 @@ +google.cloud.securesourcemanager.v1.DeleteBranchRuleRequest + */ +class DeleteBranchRuleRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + /** + * Optional. If set to true, and the branch rule is not found, the request + * will succeed but no action will be taken on the server. + * + * Generated from protobuf field bool allow_missing = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $allow_missing = false; + + /** + * @param string $name Please see {@see SecureSourceManagerClient::branchRuleName()} for help formatting this field. + * + * @return \Google\Cloud\SecureSourceManager\V1\DeleteBranchRuleRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * @type bool $allow_missing + * Optional. If set to true, and the branch rule is not found, the request + * will succeed but no action will be taken on the server. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Securesourcemanager\V1\SecureSourceManager::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Optional. If set to true, and the branch rule is not found, the request + * will succeed but no action will be taken on the server. + * + * Generated from protobuf field bool allow_missing = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getAllowMissing() + { + return $this->allow_missing; + } + + /** + * Optional. If set to true, and the branch rule is not found, the request + * will succeed but no action will be taken on the server. + * + * Generated from protobuf field bool allow_missing = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setAllowMissing($var) + { + GPBUtil::checkBool($var); + $this->allow_missing = $var; + + return $this; + } + +} + diff --git a/SecureSourceManager/src/V1/GetBranchRuleRequest.php b/SecureSourceManager/src/V1/GetBranchRuleRequest.php new file mode 100644 index 000000000000..99448568e4c7 --- /dev/null +++ b/SecureSourceManager/src/V1/GetBranchRuleRequest.php @@ -0,0 +1,91 @@ +google.cloud.securesourcemanager.v1.GetBranchRuleRequest + */ +class GetBranchRuleRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. Name of the repository to retrieve. + * The format is + * `projects/{project}/locations/{location}/repositories/{repository}/branchRules/{branch_rule}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $name = ''; + + /** + * @param string $name Required. Name of the repository to retrieve. + * The format is + * `projects/{project}/locations/{location}/repositories/{repository}/branchRules/{branch_rule}`. Please see + * {@see SecureSourceManagerClient::branchRuleName()} for help formatting this field. + * + * @return \Google\Cloud\SecureSourceManager\V1\GetBranchRuleRequest + * + * @experimental + */ + public static function build(string $name): self + { + return (new self()) + ->setName($name); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. Name of the repository to retrieve. + * The format is + * `projects/{project}/locations/{location}/repositories/{repository}/branchRules/{branch_rule}`. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Securesourcemanager\V1\SecureSourceManager::initOnce(); + parent::__construct($data); + } + + /** + * Required. Name of the repository to retrieve. + * The format is + * `projects/{project}/locations/{location}/repositories/{repository}/branchRules/{branch_rule}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. Name of the repository to retrieve. + * The format is + * `projects/{project}/locations/{location}/repositories/{repository}/branchRules/{branch_rule}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + +} + diff --git a/SecureSourceManager/src/V1/Instance/PrivateConfig.php b/SecureSourceManager/src/V1/Instance/PrivateConfig.php index e3d8cec08fb0..23b157197bd8 100644 --- a/SecureSourceManager/src/V1/Instance/PrivateConfig.php +++ b/SecureSourceManager/src/V1/Instance/PrivateConfig.php @@ -42,6 +42,14 @@ class PrivateConfig extends \Google\Protobuf\Internal\Message * Generated from protobuf field string ssh_service_attachment = 4 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { */ protected $ssh_service_attachment = ''; + /** + * Optional. Additional allowed projects for setting up PSC connections. + * Instance host project is automatically allowed and does not need to be + * included in this list. + * + * Generated from protobuf field repeated string psc_allowed_projects = 6 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $psc_allowed_projects; /** * Constructor. @@ -60,6 +68,10 @@ class PrivateConfig extends \Google\Protobuf\Internal\Message * @type string $ssh_service_attachment * Output only. Service Attachment for SSH, resource is in the format of * `projects/{project}/regions/{region}/serviceAttachments/{service_attachment}`. + * @type array|\Google\Protobuf\Internal\RepeatedField $psc_allowed_projects + * Optional. Additional allowed projects for setting up PSC connections. + * Instance host project is automatically allowed and does not need to be + * included in this list. * } */ public function __construct($data = NULL) { @@ -177,6 +189,36 @@ public function setSshServiceAttachment($var) return $this; } + /** + * Optional. Additional allowed projects for setting up PSC connections. + * Instance host project is automatically allowed and does not need to be + * included in this list. + * + * Generated from protobuf field repeated string psc_allowed_projects = 6 [(.google.api.field_behavior) = OPTIONAL]; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getPscAllowedProjects() + { + return $this->psc_allowed_projects; + } + + /** + * Optional. Additional allowed projects for setting up PSC connections. + * Instance host project is automatically allowed and does not need to be + * included in this list. + * + * Generated from protobuf field repeated string psc_allowed_projects = 6 [(.google.api.field_behavior) = OPTIONAL]; + * @param array|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setPscAllowedProjects($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); + $this->psc_allowed_projects = $arr; + + return $this; + } + } diff --git a/SecureSourceManager/src/V1/ListBranchRulesRequest.php b/SecureSourceManager/src/V1/ListBranchRulesRequest.php new file mode 100644 index 000000000000..209d3240ebb7 --- /dev/null +++ b/SecureSourceManager/src/V1/ListBranchRulesRequest.php @@ -0,0 +1,127 @@ +google.cloud.securesourcemanager.v1.ListBranchRulesRequest + */ +class ListBranchRulesRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + protected $parent = ''; + /** + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $page_size = 0; + /** + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $page_token = ''; + + /** + * @param string $parent Please see {@see SecureSourceManagerClient::repositoryName()} for help formatting this field. + * + * @return \Google\Cloud\SecureSourceManager\V1\ListBranchRulesRequest + * + * @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 + * @type int $page_size + * @type string $page_token + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Securesourcemanager\V1\SecureSourceManager::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * 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; + } + + /** + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * 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; + } + + /** + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * 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; + } + +} + diff --git a/SecureSourceManager/src/V1/ListBranchRulesResponse.php b/SecureSourceManager/src/V1/ListBranchRulesResponse.php new file mode 100644 index 000000000000..f0b2969182dd --- /dev/null +++ b/SecureSourceManager/src/V1/ListBranchRulesResponse.php @@ -0,0 +1,101 @@ +google.cloud.securesourcemanager.v1.ListBranchRulesResponse + */ +class ListBranchRulesResponse extends \Google\Protobuf\Internal\Message +{ + /** + * The list of branch rules. + * + * Generated from protobuf field repeated .google.cloud.securesourcemanager.v1.BranchRule branch_rules = 1; + */ + private $branch_rules; + /** + * 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\SecureSourceManager\V1\BranchRule>|\Google\Protobuf\Internal\RepeatedField $branch_rules + * The list of branch rules. + * @type string $next_page_token + * A token identifying a page of results the server should return. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Securesourcemanager\V1\SecureSourceManager::initOnce(); + parent::__construct($data); + } + + /** + * The list of branch rules. + * + * Generated from protobuf field repeated .google.cloud.securesourcemanager.v1.BranchRule branch_rules = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getBranchRules() + { + return $this->branch_rules; + } + + /** + * The list of branch rules. + * + * Generated from protobuf field repeated .google.cloud.securesourcemanager.v1.BranchRule branch_rules = 1; + * @param array<\Google\Cloud\SecureSourceManager\V1\BranchRule>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setBranchRules($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\SecureSourceManager\V1\BranchRule::class); + $this->branch_rules = $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/SecureSourceManager/src/V1/Repository.php b/SecureSourceManager/src/V1/Repository.php index c43a041a3fff..114d1759a1fa 100644 --- a/SecureSourceManager/src/V1/Repository.php +++ b/SecureSourceManager/src/V1/Repository.php @@ -36,9 +36,8 @@ class Repository extends \Google\Protobuf\Internal\Message * `projects/{project_number}/locations/{location_id}/instances/{instance_id}` * When creating repository via * securesourcemanager.googleapis.com (Control Plane API), this field is used - * as input. - * When creating repository via *.sourcemanager.dev (Data Plane API), this - * field is output only. + * as input. When creating repository via *.sourcemanager.dev (Data Plane + * API), this field is output only. * * Generated from protobuf field string instance = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ @@ -101,9 +100,8 @@ class Repository extends \Google\Protobuf\Internal\Message * `projects/{project_number}/locations/{location_id}/instances/{instance_id}` * When creating repository via * securesourcemanager.googleapis.com (Control Plane API), this field is used - * as input. - * When creating repository via *.sourcemanager.dev (Data Plane API), this - * field is output only. + * as input. When creating repository via *.sourcemanager.dev (Data Plane + * API), this field is output only. * @type string $uid * Output only. Unique identifier of the repository. * @type \Google\Protobuf\Timestamp $create_time @@ -189,9 +187,8 @@ public function setDescription($var) * `projects/{project_number}/locations/{location_id}/instances/{instance_id}` * When creating repository via * securesourcemanager.googleapis.com (Control Plane API), this field is used - * as input. - * When creating repository via *.sourcemanager.dev (Data Plane API), this - * field is output only. + * as input. When creating repository via *.sourcemanager.dev (Data Plane + * API), this field is output only. * * Generated from protobuf field string instance = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { * @return string @@ -207,9 +204,8 @@ public function getInstance() * `projects/{project_number}/locations/{location_id}/instances/{instance_id}` * When creating repository via * securesourcemanager.googleapis.com (Control Plane API), this field is used - * as input. - * When creating repository via *.sourcemanager.dev (Data Plane API), this - * field is output only. + * as input. When creating repository via *.sourcemanager.dev (Data Plane + * API), this field is output only. * * Generated from protobuf field string instance = 3 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { * @param string $var diff --git a/SecureSourceManager/src/V1/UpdateBranchRuleRequest.php b/SecureSourceManager/src/V1/UpdateBranchRuleRequest.php new file mode 100644 index 000000000000..be3e12441d0a --- /dev/null +++ b/SecureSourceManager/src/V1/UpdateBranchRuleRequest.php @@ -0,0 +1,187 @@ +google.cloud.securesourcemanager.v1.UpdateBranchRuleRequest + */ +class UpdateBranchRuleRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Generated from protobuf field .google.cloud.securesourcemanager.v1.BranchRule branch_rule = 1 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $branch_rule = null; + /** + * Optional. If set, validate the request and preview the review, but do not + * actually post it. (https://google.aip.dev/163, for declarative friendly) + * + * Generated from protobuf field bool validate_only = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + protected $validate_only = false; + /** + * Required. Field mask is used to specify the fields to be overwritten in the + * branchRule resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. + * The special value "*" means full replacement. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; + */ + protected $update_mask = null; + + /** + * @param \Google\Cloud\SecureSourceManager\V1\BranchRule $branchRule + * @param \Google\Protobuf\FieldMask $updateMask Required. Field mask is used to specify the fields to be overwritten in the + * branchRule resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. + * The special value "*" means full replacement. + * + * @return \Google\Cloud\SecureSourceManager\V1\UpdateBranchRuleRequest + * + * @experimental + */ + public static function build(\Google\Cloud\SecureSourceManager\V1\BranchRule $branchRule, \Google\Protobuf\FieldMask $updateMask): self + { + return (new self()) + ->setBranchRule($branchRule) + ->setUpdateMask($updateMask); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\SecureSourceManager\V1\BranchRule $branch_rule + * @type bool $validate_only + * Optional. If set, validate the request and preview the review, but do not + * actually post it. (https://google.aip.dev/163, for declarative friendly) + * @type \Google\Protobuf\FieldMask $update_mask + * Required. Field mask is used to specify the fields to be overwritten in the + * branchRule resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. + * The special value "*" means full replacement. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Securesourcemanager\V1\SecureSourceManager::initOnce(); + parent::__construct($data); + } + + /** + * Generated from protobuf field .google.cloud.securesourcemanager.v1.BranchRule branch_rule = 1 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\SecureSourceManager\V1\BranchRule|null + */ + public function getBranchRule() + { + return $this->branch_rule; + } + + public function hasBranchRule() + { + return isset($this->branch_rule); + } + + public function clearBranchRule() + { + unset($this->branch_rule); + } + + /** + * Generated from protobuf field .google.cloud.securesourcemanager.v1.BranchRule branch_rule = 1 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\SecureSourceManager\V1\BranchRule $var + * @return $this + */ + public function setBranchRule($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\SecureSourceManager\V1\BranchRule::class); + $this->branch_rule = $var; + + return $this; + } + + /** + * Optional. If set, validate the request and preview the review, but do not + * actually post it. (https://google.aip.dev/163, for declarative friendly) + * + * Generated from protobuf field bool validate_only = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return bool + */ + public function getValidateOnly() + { + return $this->validate_only; + } + + /** + * Optional. If set, validate the request and preview the review, but do not + * actually post it. (https://google.aip.dev/163, for declarative friendly) + * + * Generated from protobuf field bool validate_only = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param bool $var + * @return $this + */ + public function setValidateOnly($var) + { + GPBUtil::checkBool($var); + $this->validate_only = $var; + + return $this; + } + + /** + * Required. Field mask is used to specify the fields to be overwritten in the + * branchRule resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. + * The special value "*" means full replacement. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Protobuf\FieldMask|null + */ + public function getUpdateMask() + { + return $this->update_mask; + } + + public function hasUpdateMask() + { + return isset($this->update_mask); + } + + public function clearUpdateMask() + { + unset($this->update_mask); + } + + /** + * Required. Field mask is used to specify the fields to be overwritten in the + * branchRule resource by the update. + * The fields specified in the update_mask are relative to the resource, not + * the full request. A field will be overwritten if it is in the mask. + * The special value "*" means full replacement. + * + * Generated from protobuf field .google.protobuf.FieldMask update_mask = 3 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Protobuf\FieldMask $var + * @return $this + */ + public function setUpdateMask($var) + { + GPBUtil::checkMessage($var, \Google\Protobuf\FieldMask::class); + $this->update_mask = $var; + + return $this; + } + +} + diff --git a/SecureSourceManager/src/V1/gapic_metadata.json b/SecureSourceManager/src/V1/gapic_metadata.json index af0aaf0c1662..765eced17b9b 100644 --- a/SecureSourceManager/src/V1/gapic_metadata.json +++ b/SecureSourceManager/src/V1/gapic_metadata.json @@ -10,6 +10,11 @@ "grpc": { "libraryClient": "SecureSourceManagerGapicClient", "rpcs": { + "CreateBranchRule": { + "methods": [ + "createBranchRule" + ] + }, "CreateInstance": { "methods": [ "createInstance" @@ -20,6 +25,11 @@ "createRepository" ] }, + "DeleteBranchRule": { + "methods": [ + "deleteBranchRule" + ] + }, "DeleteInstance": { "methods": [ "deleteInstance" @@ -30,6 +40,11 @@ "deleteRepository" ] }, + "GetBranchRule": { + "methods": [ + "getBranchRule" + ] + }, "GetIamPolicyRepo": { "methods": [ "getIamPolicyRepo" @@ -45,6 +60,11 @@ "getRepository" ] }, + "ListBranchRules": { + "methods": [ + "listBranchRules" + ] + }, "ListInstances": { "methods": [ "listInstances" @@ -65,6 +85,11 @@ "testIamPermissionsRepo" ] }, + "UpdateBranchRule": { + "methods": [ + "updateBranchRule" + ] + }, "GetIamPolicy": { "methods": [ "getIamPolicy" diff --git a/SecureSourceManager/src/V1/resources/secure_source_manager_client_config.json b/SecureSourceManager/src/V1/resources/secure_source_manager_client_config.json index ad14bc6042a2..deeb50b01083 100644 --- a/SecureSourceManager/src/V1/resources/secure_source_manager_client_config.json +++ b/SecureSourceManager/src/V1/resources/secure_source_manager_client_config.json @@ -28,6 +28,11 @@ } }, "methods": { + "CreateBranchRule": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "CreateInstance": { "timeout_millis": 60000, "retry_codes_name": "no_retry_codes", @@ -38,6 +43,11 @@ "retry_codes_name": "no_retry_codes", "retry_params_name": "no_retry_params" }, + "DeleteBranchRule": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "DeleteInstance": { "timeout_millis": 60000, "retry_codes_name": "no_retry_codes", @@ -48,6 +58,11 @@ "retry_codes_name": "no_retry_codes", "retry_params_name": "no_retry_params" }, + "GetBranchRule": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "GetIamPolicyRepo": { "timeout_millis": 60000, "retry_codes_name": "retry_policy_1_codes", @@ -63,6 +78,11 @@ "retry_codes_name": "retry_policy_1_codes", "retry_params_name": "retry_policy_1_params" }, + "ListBranchRules": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "ListInstances": { "timeout_millis": 60000, "retry_codes_name": "retry_policy_1_codes", @@ -83,6 +103,11 @@ "retry_codes_name": "no_retry_codes", "retry_params_name": "no_retry_params" }, + "UpdateBranchRule": { + "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", diff --git a/SecureSourceManager/src/V1/resources/secure_source_manager_descriptor_config.php b/SecureSourceManager/src/V1/resources/secure_source_manager_descriptor_config.php index 4f4cb90c3153..30aede09a29d 100644 --- a/SecureSourceManager/src/V1/resources/secure_source_manager_descriptor_config.php +++ b/SecureSourceManager/src/V1/resources/secure_source_manager_descriptor_config.php @@ -23,6 +23,25 @@ return [ 'interfaces' => [ 'google.cloud.securesourcemanager.v1.SecureSourceManager' => [ + 'CreateBranchRule' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\SecureSourceManager\V1\BranchRule', + 'metadataReturnType' => '\Google\Cloud\SecureSourceManager\V1\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], 'CreateInstance' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Cloud\SecureSourceManager\V1\Instance', @@ -61,6 +80,25 @@ ], ], ], + 'DeleteBranchRule' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Protobuf\GPBEmpty', + 'metadataReturnType' => '\Google\Cloud\SecureSourceManager\V1\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'DeleteInstance' => [ 'longRunning' => [ 'operationReturnType' => '\Google\Protobuf\GPBEmpty', @@ -99,6 +137,38 @@ ], ], ], + 'UpdateBranchRule' => [ + 'longRunning' => [ + 'operationReturnType' => '\Google\Cloud\SecureSourceManager\V1\BranchRule', + 'metadataReturnType' => '\Google\Cloud\SecureSourceManager\V1\OperationMetadata', + 'initialPollDelayMillis' => '500', + 'pollDelayMultiplier' => '1.5', + 'maxPollDelayMillis' => '5000', + 'totalPollTimeoutMillis' => '300000', + ], + 'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL, + 'headerParams' => [ + [ + 'keyName' => 'branch_rule.name', + 'fieldAccessors' => [ + 'getBranchRule', + 'getName', + ], + ], + ], + ], + 'GetBranchRule' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\SecureSourceManager\V1\BranchRule', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'GetIamPolicyRepo' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Cloud\Iam\V1\Policy', @@ -135,6 +205,26 @@ ], ], ], + 'ListBranchRules' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getBranchRules', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\SecureSourceManager\V1\ListBranchRulesResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], 'ListInstances' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -273,6 +363,7 @@ 'interfaceOverride' => 'google.cloud.location.Locations', ], 'templateMap' => [ + 'branchRule' => 'projects/{project}/locations/{location}/repositories/{repository}/branchRules/{branch_rule}', 'caPool' => 'projects/{project}/locations/{location}/caPools/{ca_pool}', 'cryptoKey' => 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}', 'instance' => 'projects/{project}/locations/{location}/instances/{instance}', diff --git a/SecureSourceManager/src/V1/resources/secure_source_manager_rest_client_config.php b/SecureSourceManager/src/V1/resources/secure_source_manager_rest_client_config.php index 75f081095832..38d22efe24dc 100644 --- a/SecureSourceManager/src/V1/resources/secure_source_manager_rest_client_config.php +++ b/SecureSourceManager/src/V1/resources/secure_source_manager_rest_client_config.php @@ -47,6 +47,21 @@ ], ], 'google.cloud.securesourcemanager.v1.SecureSourceManager' => [ + 'CreateBranchRule' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*/repositories/*}/branchRules', + 'body' => 'branch_rule', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + 'queryParams' => [ + 'branch_rule_id', + ], + ], 'CreateInstance' => [ 'method' => 'post', 'uriTemplate' => '/v1/{parent=projects/*/locations/*}/instances', @@ -77,6 +92,17 @@ 'repository_id', ], ], + 'DeleteBranchRule' => [ + 'method' => 'delete', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/repositories/*/branchRules/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], 'DeleteInstance' => [ 'method' => 'delete', 'uriTemplate' => '/v1/{name=projects/*/locations/*/instances/*}', @@ -99,6 +125,17 @@ ], ], ], + 'GetBranchRule' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{name=projects/*/locations/*/repositories/*/branchRules/*}', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], 'GetIamPolicyRepo' => [ 'method' => 'get', 'uriTemplate' => '/v1/{resource=projects/*/locations/*/repositories/*}:getIamPolicy', @@ -132,6 +169,17 @@ ], ], ], + 'ListBranchRules' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/locations/*/repositories/*}/branchRules', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], 'ListInstances' => [ 'method' => 'get', 'uriTemplate' => '/v1/{parent=projects/*/locations/*}/instances', @@ -178,6 +226,22 @@ ], ], ], + 'UpdateBranchRule' => [ + 'method' => 'patch', + 'uriTemplate' => '/v1/{branch_rule.name=projects/*/locations/*/repositories/*/branchRules/*}', + 'body' => 'branch_rule', + 'placeholders' => [ + 'branch_rule.name' => [ + 'getters' => [ + 'getBranchRule', + 'getName', + ], + ], + ], + 'queryParams' => [ + 'update_mask', + ], + ], ], 'google.iam.v1.IAMPolicy' => [ 'GetIamPolicy' => [ diff --git a/SecureSourceManager/tests/Unit/V1/Client/SecureSourceManagerClientTest.php b/SecureSourceManager/tests/Unit/V1/Client/SecureSourceManagerClientTest.php index 5376a56ca926..e4c0d3de71b8 100644 --- a/SecureSourceManager/tests/Unit/V1/Client/SecureSourceManagerClientTest.php +++ b/SecureSourceManager/tests/Unit/V1/Client/SecureSourceManagerClientTest.php @@ -35,23 +35,31 @@ use Google\Cloud\Location\ListLocationsRequest; use Google\Cloud\Location\ListLocationsResponse; use Google\Cloud\Location\Location; +use Google\Cloud\SecureSourceManager\V1\BranchRule; use Google\Cloud\SecureSourceManager\V1\Client\SecureSourceManagerClient; +use Google\Cloud\SecureSourceManager\V1\CreateBranchRuleRequest; use Google\Cloud\SecureSourceManager\V1\CreateInstanceRequest; use Google\Cloud\SecureSourceManager\V1\CreateRepositoryRequest; +use Google\Cloud\SecureSourceManager\V1\DeleteBranchRuleRequest; use Google\Cloud\SecureSourceManager\V1\DeleteInstanceRequest; use Google\Cloud\SecureSourceManager\V1\DeleteRepositoryRequest; +use Google\Cloud\SecureSourceManager\V1\GetBranchRuleRequest; use Google\Cloud\SecureSourceManager\V1\GetInstanceRequest; use Google\Cloud\SecureSourceManager\V1\GetRepositoryRequest; use Google\Cloud\SecureSourceManager\V1\Instance; +use Google\Cloud\SecureSourceManager\V1\ListBranchRulesRequest; +use Google\Cloud\SecureSourceManager\V1\ListBranchRulesResponse; use Google\Cloud\SecureSourceManager\V1\ListInstancesRequest; use Google\Cloud\SecureSourceManager\V1\ListInstancesResponse; use Google\Cloud\SecureSourceManager\V1\ListRepositoriesRequest; use Google\Cloud\SecureSourceManager\V1\ListRepositoriesResponse; use Google\Cloud\SecureSourceManager\V1\Repository; +use Google\Cloud\SecureSourceManager\V1\UpdateBranchRuleRequest; use Google\LongRunning\Client\OperationsClient; use Google\LongRunning\GetOperationRequest; use Google\LongRunning\Operation; use Google\Protobuf\Any; +use Google\Protobuf\FieldMask; use Google\Protobuf\GPBEmpty; use Google\Rpc\Code; use stdClass; @@ -86,6 +94,167 @@ private function createClient(array $options = []) return new SecureSourceManagerClient($options); } + /** @test */ + public function createBranchRuleTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createBranchRuleTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $uid = 'uid115792'; + $etag = 'etag3123477'; + $includePattern = 'includePattern-1182351623'; + $disabled = true; + $requirePullRequest = false; + $minimumReviewsCount = 672799098; + $minimumApprovalsCount = 579210129; + $requireCommentsResolved = false; + $allowStaleReviews = false; + $requireLinearHistory = true; + $expectedResponse = new BranchRule(); + $expectedResponse->setName($name); + $expectedResponse->setUid($uid); + $expectedResponse->setEtag($etag); + $expectedResponse->setIncludePattern($includePattern); + $expectedResponse->setDisabled($disabled); + $expectedResponse->setRequirePullRequest($requirePullRequest); + $expectedResponse->setMinimumReviewsCount($minimumReviewsCount); + $expectedResponse->setMinimumApprovalsCount($minimumApprovalsCount); + $expectedResponse->setRequireCommentsResolved($requireCommentsResolved); + $expectedResponse->setAllowStaleReviews($allowStaleReviews); + $expectedResponse->setRequireLinearHistory($requireLinearHistory); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/createBranchRuleTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedParent = $gapicClient->repositoryName('[PROJECT]', '[LOCATION]', '[REPOSITORY]'); + $branchRule = new BranchRule(); + $branchRuleId = 'branchRuleId786871201'; + $request = (new CreateBranchRuleRequest()) + ->setParent($formattedParent) + ->setBranchRule($branchRule) + ->setBranchRuleId($branchRuleId); + $response = $gapicClient->createBranchRule($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame( + '/google.cloud.securesourcemanager.v1.SecureSourceManager/CreateBranchRule', + $actualApiFuncCall + ); + $actualValue = $actualApiRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $actualValue = $actualApiRequestObject->getBranchRule(); + $this->assertProtobufEquals($branchRule, $actualValue); + $actualValue = $actualApiRequestObject->getBranchRuleId(); + $this->assertProtobufEquals($branchRuleId, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createBranchRuleTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function createBranchRuleExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/createBranchRuleTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->repositoryName('[PROJECT]', '[LOCATION]', '[REPOSITORY]'); + $branchRule = new BranchRule(); + $branchRuleId = 'branchRuleId786871201'; + $request = (new CreateBranchRuleRequest()) + ->setParent($formattedParent) + ->setBranchRule($branchRule) + ->setBranchRuleId($branchRuleId); + $response = $gapicClient->createBranchRule($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/createBranchRuleTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + /** @test */ public function createInstanceTest() { @@ -378,6 +547,131 @@ public function createRepositoryExceptionTest() $this->assertTrue($operationsTransport->isExhausted()); } + /** @test */ + public function deleteBranchRuleTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteBranchRuleTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $expectedResponse = new GPBEmpty(); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/deleteBranchRuleTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $formattedName = $gapicClient->branchRuleName('[PROJECT]', '[LOCATION]', '[REPOSITORY]', '[BRANCH_RULE]'); + $request = (new DeleteBranchRuleRequest())->setName($formattedName); + $response = $gapicClient->deleteBranchRule($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame( + '/google.cloud.securesourcemanager.v1.SecureSourceManager/DeleteBranchRule', + $actualApiFuncCall + ); + $actualValue = $actualApiRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteBranchRuleTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function deleteBranchRuleExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/deleteBranchRuleTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $operationsTransport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->branchRuleName('[PROJECT]', '[LOCATION]', '[REPOSITORY]', '[BRANCH_RULE]'); + $request = (new DeleteBranchRuleRequest())->setName($formattedName); + $response = $gapicClient->deleteBranchRule($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/deleteBranchRuleTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + /** @test */ public function deleteInstanceTest() { @@ -628,6 +922,91 @@ public function deleteRepositoryExceptionTest() $this->assertTrue($operationsTransport->isExhausted()); } + /** @test */ + public function getBranchRuleTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $name2 = 'name2-1052831874'; + $uid = 'uid115792'; + $etag = 'etag3123477'; + $includePattern = 'includePattern-1182351623'; + $disabled = true; + $requirePullRequest = false; + $minimumReviewsCount = 672799098; + $minimumApprovalsCount = 579210129; + $requireCommentsResolved = false; + $allowStaleReviews = false; + $requireLinearHistory = true; + $expectedResponse = new BranchRule(); + $expectedResponse->setName($name2); + $expectedResponse->setUid($uid); + $expectedResponse->setEtag($etag); + $expectedResponse->setIncludePattern($includePattern); + $expectedResponse->setDisabled($disabled); + $expectedResponse->setRequirePullRequest($requirePullRequest); + $expectedResponse->setMinimumReviewsCount($minimumReviewsCount); + $expectedResponse->setMinimumApprovalsCount($minimumApprovalsCount); + $expectedResponse->setRequireCommentsResolved($requireCommentsResolved); + $expectedResponse->setAllowStaleReviews($allowStaleReviews); + $expectedResponse->setRequireLinearHistory($requireLinearHistory); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->branchRuleName('[PROJECT]', '[LOCATION]', '[REPOSITORY]', '[BRANCH_RULE]'); + $request = (new GetBranchRuleRequest())->setName($formattedName); + $response = $gapicClient->getBranchRule($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.securesourcemanager.v1.SecureSourceManager/GetBranchRule', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function getBranchRuleExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->branchRuleName('[PROJECT]', '[LOCATION]', '[REPOSITORY]', '[BRANCH_RULE]'); + $request = (new GetBranchRuleRequest())->setName($formattedName); + try { + $gapicClient->getBranchRule($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 getIamPolicyRepoTest() { @@ -835,6 +1214,77 @@ public function getRepositoryExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function listBranchRulesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $branchRulesElement = new BranchRule(); + $branchRules = [$branchRulesElement]; + $expectedResponse = new ListBranchRulesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setBranchRules($branchRules); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->repositoryName('[PROJECT]', '[LOCATION]', '[REPOSITORY]'); + $request = (new ListBranchRulesRequest())->setParent($formattedParent); + $response = $gapicClient->listBranchRules($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getBranchRules()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.securesourcemanager.v1.SecureSourceManager/ListBranchRules', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listBranchRulesExceptionTest() + { + $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->repositoryName('[PROJECT]', '[LOCATION]', '[REPOSITORY]'); + $request = (new ListBranchRulesRequest())->setParent($formattedParent); + try { + $gapicClient->listBranchRules($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 listInstancesTest() { @@ -1118,6 +1568,157 @@ public function testIamPermissionsRepoExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function updateBranchRuleTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateBranchRuleTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $name = 'name3373707'; + $uid = 'uid115792'; + $etag = 'etag3123477'; + $includePattern = 'includePattern-1182351623'; + $disabled = true; + $requirePullRequest = false; + $minimumReviewsCount = 672799098; + $minimumApprovalsCount = 579210129; + $requireCommentsResolved = false; + $allowStaleReviews = false; + $requireLinearHistory = true; + $expectedResponse = new BranchRule(); + $expectedResponse->setName($name); + $expectedResponse->setUid($uid); + $expectedResponse->setEtag($etag); + $expectedResponse->setIncludePattern($includePattern); + $expectedResponse->setDisabled($disabled); + $expectedResponse->setRequirePullRequest($requirePullRequest); + $expectedResponse->setMinimumReviewsCount($minimumReviewsCount); + $expectedResponse->setMinimumApprovalsCount($minimumApprovalsCount); + $expectedResponse->setRequireCommentsResolved($requireCommentsResolved); + $expectedResponse->setAllowStaleReviews($allowStaleReviews); + $expectedResponse->setRequireLinearHistory($requireLinearHistory); + $anyResponse = new Any(); + $anyResponse->setValue($expectedResponse->serializeToString()); + $completeOperation = new Operation(); + $completeOperation->setName('operations/updateBranchRuleTest'); + $completeOperation->setDone(true); + $completeOperation->setResponse($anyResponse); + $operationsTransport->addResponse($completeOperation); + // Mock request + $branchRule = new BranchRule(); + $updateMask = new FieldMask(); + $request = (new UpdateBranchRuleRequest())->setBranchRule($branchRule)->setUpdateMask($updateMask); + $response = $gapicClient->updateBranchRule($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $apiRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($apiRequests)); + $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); + $this->assertSame(0, count($operationsRequestsEmpty)); + $actualApiFuncCall = $apiRequests[0]->getFuncCall(); + $actualApiRequestObject = $apiRequests[0]->getRequestObject(); + $this->assertSame( + '/google.cloud.securesourcemanager.v1.SecureSourceManager/UpdateBranchRule', + $actualApiFuncCall + ); + $actualValue = $actualApiRequestObject->getBranchRule(); + $this->assertProtobufEquals($branchRule, $actualValue); + $actualValue = $actualApiRequestObject->getUpdateMask(); + $this->assertProtobufEquals($updateMask, $actualValue); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateBranchRuleTest'); + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + $this->assertTrue($response->isDone()); + $this->assertEquals($expectedResponse, $response->getResult()); + $apiRequestsEmpty = $transport->popReceivedCalls(); + $this->assertSame(0, count($apiRequestsEmpty)); + $operationsRequests = $operationsTransport->popReceivedCalls(); + $this->assertSame(1, count($operationsRequests)); + $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); + $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); + $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); + $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + + /** @test */ + public function updateBranchRuleExceptionTest() + { + $operationsTransport = $this->createTransport(); + $operationsClient = new OperationsClient([ + 'apiEndpoint' => '', + 'transport' => $operationsTransport, + 'credentials' => $this->createCredentials(), + ]); + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + 'operationsClient' => $operationsClient, + ]); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + // Mock response + $incompleteOperation = new Operation(); + $incompleteOperation->setName('operations/updateBranchRuleTest'); + $incompleteOperation->setDone(false); + $transport->addResponse($incompleteOperation); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode( + [ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], + JSON_PRETTY_PRINT + ); + $operationsTransport->addResponse(null, $status); + // Mock request + $branchRule = new BranchRule(); + $updateMask = new FieldMask(); + $request = (new UpdateBranchRuleRequest())->setBranchRule($branchRule)->setUpdateMask($updateMask); + $response = $gapicClient->updateBranchRule($request); + $this->assertFalse($response->isDone()); + $this->assertNull($response->getResult()); + $expectedOperationsRequestObject = new GetOperationRequest(); + $expectedOperationsRequestObject->setName('operations/updateBranchRuleTest'); + try { + $response->pollUntilComplete([ + 'initialPollDelayMillis' => 1, + ]); + // If the pollUntilComplete() method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stubs are exhausted + $transport->popReceivedCalls(); + $operationsTransport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + $this->assertTrue($operationsTransport->isExhausted()); + } + /** @test */ public function getIamPolicyTest() { @@ -1452,7 +2053,7 @@ public function listLocationsExceptionTest() } /** @test */ - public function createInstanceAsyncTest() + public function createBranchRuleAsyncTest() { $operationsTransport = $this->createTransport(); $operationsClient = new OperationsClient([ @@ -1469,30 +2070,48 @@ public function createInstanceAsyncTest() $this->assertTrue($operationsTransport->isExhausted()); // Mock response $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/createInstanceTest'); + $incompleteOperation->setName('operations/createBranchRuleTest'); $incompleteOperation->setDone(false); $transport->addResponse($incompleteOperation); $name = 'name3373707'; - $kmsKey = 'kmsKey-591635343'; - $expectedResponse = new Instance(); + $uid = 'uid115792'; + $etag = 'etag3123477'; + $includePattern = 'includePattern-1182351623'; + $disabled = true; + $requirePullRequest = false; + $minimumReviewsCount = 672799098; + $minimumApprovalsCount = 579210129; + $requireCommentsResolved = false; + $allowStaleReviews = false; + $requireLinearHistory = true; + $expectedResponse = new BranchRule(); $expectedResponse->setName($name); - $expectedResponse->setKmsKey($kmsKey); + $expectedResponse->setUid($uid); + $expectedResponse->setEtag($etag); + $expectedResponse->setIncludePattern($includePattern); + $expectedResponse->setDisabled($disabled); + $expectedResponse->setRequirePullRequest($requirePullRequest); + $expectedResponse->setMinimumReviewsCount($minimumReviewsCount); + $expectedResponse->setMinimumApprovalsCount($minimumApprovalsCount); + $expectedResponse->setRequireCommentsResolved($requireCommentsResolved); + $expectedResponse->setAllowStaleReviews($allowStaleReviews); + $expectedResponse->setRequireLinearHistory($requireLinearHistory); $anyResponse = new Any(); $anyResponse->setValue($expectedResponse->serializeToString()); $completeOperation = new Operation(); - $completeOperation->setName('operations/createInstanceTest'); + $completeOperation->setName('operations/createBranchRuleTest'); $completeOperation->setDone(true); $completeOperation->setResponse($anyResponse); $operationsTransport->addResponse($completeOperation); // Mock request - $formattedParent = $gapicClient->locationName('[PROJECT]', '[LOCATION]'); - $instanceId = 'instanceId-2101995259'; - $instance = new Instance(); - $request = (new CreateInstanceRequest()) + $formattedParent = $gapicClient->repositoryName('[PROJECT]', '[LOCATION]', '[REPOSITORY]'); + $branchRule = new BranchRule(); + $branchRuleId = 'branchRuleId786871201'; + $request = (new CreateBranchRuleRequest()) ->setParent($formattedParent) - ->setInstanceId($instanceId) - ->setInstance($instance); - $response = $gapicClient->createInstanceAsync($request)->wait(); + ->setBranchRule($branchRule) + ->setBranchRuleId($branchRuleId); + $response = $gapicClient->createBranchRuleAsync($request)->wait(); $this->assertFalse($response->isDone()); $this->assertNull($response->getResult()); $apiRequests = $transport->popReceivedCalls(); @@ -1502,17 +2121,17 @@ public function createInstanceAsyncTest() $actualApiFuncCall = $apiRequests[0]->getFuncCall(); $actualApiRequestObject = $apiRequests[0]->getRequestObject(); $this->assertSame( - '/google.cloud.securesourcemanager.v1.SecureSourceManager/CreateInstance', + '/google.cloud.securesourcemanager.v1.SecureSourceManager/CreateBranchRule', $actualApiFuncCall ); $actualValue = $actualApiRequestObject->getParent(); $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getInstanceId(); - $this->assertProtobufEquals($instanceId, $actualValue); - $actualValue = $actualApiRequestObject->getInstance(); - $this->assertProtobufEquals($instance, $actualValue); + $actualValue = $actualApiRequestObject->getBranchRule(); + $this->assertProtobufEquals($branchRule, $actualValue); + $actualValue = $actualApiRequestObject->getBranchRuleId(); + $this->assertProtobufEquals($branchRuleId, $actualValue); $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createInstanceTest'); + $expectedOperationsRequestObject->setName('operations/createBranchRuleTest'); $response->pollUntilComplete([ 'initialPollDelayMillis' => 1, ]);