Skip to main content

branch_rules

Creates, updates, deletes, gets or lists a branch_rules resource.

Overview

Namebranch_rules
TypeResource
Idgoogle.securesourcemanager.branch_rules

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
namestringOptional. A unique identifier for a BranchRule. The name should be of the format: projects/{project}/locations/{location}/repositories/{repository}/branchRules/{branch_rule}
allowStaleReviewsbooleanOptional. Determines if allow stale reviews or approvals before merging to the branch.
annotationsobjectOptional. 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.
createTimestring (google-datetime)Output only. Create timestamp.
disabledbooleanOptional. Determines if the branch rule is disabled or not.
etagstringOptional. 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.
includePatternstringOptional. 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.
minimumApprovalsCountinteger (int32)Optional. The minimum number of approvals required for the branch rule to be matched.
minimumReviewsCountinteger (int32)Optional. The minimum number of reviews required for the branch rule to be matched.
requireCommentsResolvedbooleanOptional. Determines if require comments resolved before merging to the branch.
requireLinearHistorybooleanOptional. Determines if require linear history before merging to the branch.
requirePullRequestbooleanOptional. Determines if the branch rule requires a pull request or not.
requiredStatusChecksarrayOptional. List of required status checks before merging to the branch.
uidstringOutput only. Unique identifier of the repository.
updateTimestring (google-datetime)Output only. Update timestamp.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectprojectsId, locationsId, repositoriesId, branchRulesIdGetBranchRule gets a branch rule.
listselectprojectsId, locationsId, repositoriesIdpageSize, pageTokenListBranchRules lists branch rules in a given repository.
createinsertprojectsId, locationsId, repositoriesIdbranchRuleIdCreateBranchRule creates a branch rule in a given repository.
patchupdateprojectsId, locationsId, repositoriesId, branchRulesIdvalidateOnly, updateMaskUpdateBranchRule updates a branch rule.
deletedeleteprojectsId, locationsId, repositoriesId, branchRulesIdallowMissingDeleteBranchRule deletes a branch rule.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
branchRulesIdstring
locationsIdstring
projectsIdstring
repositoriesIdstring
allowMissingboolean
branchRuleIdstring
pageSizeinteger (int32)
pageTokenstring
updateMaskstring (google-fieldmask)
validateOnlyboolean

SELECT examples

GetBranchRule gets a branch rule.

SELECT
name,
allowStaleReviews,
annotations,
createTime,
disabled,
etag,
includePattern,
minimumApprovalsCount,
minimumReviewsCount,
requireCommentsResolved,
requireLinearHistory,
requirePullRequest,
requiredStatusChecks,
uid,
updateTime
FROM google.securesourcemanager.branch_rules
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND repositoriesId = '{{ repositoriesId }}' -- required
AND branchRulesId = '{{ branchRulesId }}' -- required;

INSERT examples

CreateBranchRule creates a branch rule in a given repository.

INSERT INTO google.securesourcemanager.branch_rules (
data__name,
data__annotations,
data__etag,
data__includePattern,
data__disabled,
data__requirePullRequest,
data__minimumReviewsCount,
data__minimumApprovalsCount,
data__requireCommentsResolved,
data__allowStaleReviews,
data__requireLinearHistory,
data__requiredStatusChecks,
projectsId,
locationsId,
repositoriesId,
branchRuleId
)
SELECT
'{{ name }}',
'{{ annotations }}',
'{{ etag }}',
'{{ includePattern }}',
{{ disabled }},
{{ requirePullRequest }},
{{ minimumReviewsCount }},
{{ minimumApprovalsCount }},
{{ requireCommentsResolved }},
{{ allowStaleReviews }},
{{ requireLinearHistory }},
'{{ requiredStatusChecks }}',
'{{ projectsId }}',
'{{ locationsId }}',
'{{ repositoriesId }}',
'{{ branchRuleId }}'
RETURNING
name,
done,
error,
metadata,
response
;

UPDATE examples

UpdateBranchRule updates a branch rule.

UPDATE google.securesourcemanager.branch_rules
SET
data__name = '{{ name }}',
data__annotations = '{{ annotations }}',
data__etag = '{{ etag }}',
data__includePattern = '{{ includePattern }}',
data__disabled = {{ disabled }},
data__requirePullRequest = {{ requirePullRequest }},
data__minimumReviewsCount = {{ minimumReviewsCount }},
data__minimumApprovalsCount = {{ minimumApprovalsCount }},
data__requireCommentsResolved = {{ requireCommentsResolved }},
data__allowStaleReviews = {{ allowStaleReviews }},
data__requireLinearHistory = {{ requireLinearHistory }},
data__requiredStatusChecks = '{{ requiredStatusChecks }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND repositoriesId = '{{ repositoriesId }}' --required
AND branchRulesId = '{{ branchRulesId }}' --required
AND validateOnly = {{ validateOnly}}
AND updateMask = '{{ updateMask}}'
RETURNING
name,
done,
error,
metadata,
response;

DELETE examples

DeleteBranchRule deletes a branch rule.

DELETE FROM google.securesourcemanager.branch_rules
WHERE projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND repositoriesId = '{{ repositoriesId }}' --required
AND branchRulesId = '{{ branchRulesId }}' --required
AND allowMissing = '{{ allowMissing }}';