# REST Resource: projects.locations.repositories.branchRules

- [Resource: BranchRule](https://docs.cloud.google.com/secure-source-manager/docs/reference/rest/v1/projects.locations.repositories.branchRules#BranchRule)
  - [JSON representation](https://docs.cloud.google.com/secure-source-manager/docs/reference/rest/v1/projects.locations.repositories.branchRules#BranchRule.SCHEMA_REPRESENTATION)
- [Check](https://docs.cloud.google.com/secure-source-manager/docs/reference/rest/v1/projects.locations.repositories.branchRules#Check)
  - [JSON representation](https://docs.cloud.google.com/secure-source-manager/docs/reference/rest/v1/projects.locations.repositories.branchRules#Check.SCHEMA_REPRESENTATION)
- [Methods](https://docs.cloud.google.com/secure-source-manager/docs/reference/rest/v1/projects.locations.repositories.branchRules#METHODS_SUMMARY)

## Resource: BranchRule

Metadata of a BranchRule. BranchRule is the protection rule to enforce pre-defined rules on designated branches within a repository.

| JSON representation |
|---|
| ``` { "name": string, "uid": string, "createTime": string, "updateTime": string, "annotations": { string: string, ... }, "etag": string, "includePattern": string, "disabled": boolean, "requirePullRequest": boolean, "minimumReviewsCount": integer, "minimumApprovalsCount": integer, "requireCodeOwnerApproval": boolean, "requireCommentsResolved": boolean, "allowStaleReviews": boolean, "requireLinearHistory": boolean, "requiredStatusChecks": [ { object (`https://docs.cloud.google.com/secure-source-manager/docs/reference/rest/v1/projects.locations.repositories.branchRules#Check`) } ] } ``` |

| Fields ||
|---|---|
| `name` | `string` Identifier. A unique identifier for a BranchRule. The name should be of the format: `projects/{project}/locations/{location}/repositories/{repository}/branchRules/{branchRule}` |
| `uid` | `string` Output only. Unique identifier of the repository. |
| `createTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Output only. Create timestamp. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `updateTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Output only. Update timestamp. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `annotations` | `map (key: string, value: string)` 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. An object containing a list of `"key": value` pairs. Example: `{ "name": "wrench", "mass": "1.3kg", "count": "3" }`. |
| `etag` | `string` 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. |
| `includePattern` | `string` 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. |
| `disabled` | `boolean` Optional. Determines if the branch rule is disabled or not. |
| `requirePullRequest` | `boolean` Optional. Determines if the branch rule requires a pull request or not. |
| `minimumReviewsCount` | `integer` Optional. The minimum number of reviews required for the branch rule to be matched. |
| `minimumApprovalsCount` | `integer` Optional. The minimum number of approvals required for the branch rule to be matched. |
| `requireCodeOwnerApproval` | `boolean` Optional. Determines if code owners must approve before merging to the branch. |
| `requireCommentsResolved` | `boolean` Optional. Determines if require comments resolved before merging to the branch. |
| `allowStaleReviews` | `boolean` Optional. Determines if allow stale reviews or approvals before merging to the branch. |
| `requireLinearHistory` | `boolean` Optional. Determines if require linear history before merging to the branch. |
| `requiredStatusChecks[]` | ``object (`https://docs.cloud.google.com/secure-source-manager/docs/reference/rest/v1/projects.locations.repositories.branchRules#Check`)`` Optional. List of required status checks before merging to the branch. |

## Check

Check is a type for status check.

| JSON representation |
|---|
| ``` { "context": string } ``` |

| Fields ||
|---|---|
| `context` | `string` Required. The context of the check. |

| ## Methods ||
|---|---|
| ### `https://docs.cloud.google.com/secure-source-manager/docs/reference/rest/v1/projects.locations.repositories.branchRules/create` | CreateBranchRule creates a branch rule in a given repository. |
| ### `https://docs.cloud.google.com/secure-source-manager/docs/reference/rest/v1/projects.locations.repositories.branchRules/delete` | DeleteBranchRule deletes a branch rule. |
| ### `https://docs.cloud.google.com/secure-source-manager/docs/reference/rest/v1/projects.locations.repositories.branchRules/get` | GetBranchRule gets a branch rule. |
| ### `https://docs.cloud.google.com/secure-source-manager/docs/reference/rest/v1/projects.locations.repositories.branchRules/list` | ListBranchRules lists branch rules in a given repository. |
| ### `https://docs.cloud.google.com/secure-source-manager/docs/reference/rest/v1/projects.locations.repositories.branchRules/patch` | UpdateBranchRule updates a branch rule. |