|
21 | 21 | */ |
22 | 22 | class BranchRestrictions extends Api |
23 | 23 | { |
| 24 | + /** |
| 25 | + * Allowed restrictions to create a new branch permission for |
| 26 | + * @var array |
| 27 | + */ |
| 28 | + protected $allowedRestrictionTypes = array( |
| 29 | + 'require_tasks_to_be_completed', |
| 30 | + 'require_passing_builds_to_merge', |
| 31 | + 'force', |
| 32 | + 'require_all_dependencies_merged', |
| 33 | + 'push', |
| 34 | + 'require_approvals_to_merge', |
| 35 | + 'enforce_merge_checks', |
| 36 | + 'restrict_merges', |
| 37 | + 'reset_pullrequest_approvals_on_change', |
| 38 | + 'delete' |
| 39 | + ); |
| 40 | + |
24 | 41 | /** |
25 | 42 | * Get the information associated with a repository's branch restrictions |
26 | 43 | * |
@@ -64,7 +81,7 @@ public function create($account, $repo, $params = array()) |
64 | 81 |
|
65 | 82 | $params = array_merge($defaults, $params); |
66 | 83 |
|
67 | | - if (empty($params['kind']) || !in_array($params['kind'], array('push', 'delete', 'force','restrict_merges'))) { |
| 84 | + if (empty($params['kind']) || !in_array($params['kind'], $this->$allowedRestrictionTypes)) { |
68 | 85 | throw new \InvalidArgumentException('Invalid restriction kind.'); |
69 | 86 | } |
70 | 87 |
|
@@ -142,4 +159,14 @@ public function delete($account, $repo, $id) |
142 | 159 | sprintf('repositories/%s/%s/branch-restrictions/%d', $account, $repo, $id) |
143 | 160 | ); |
144 | 161 | } |
| 162 | + |
| 163 | + /** |
| 164 | + * Add allowed permission types |
| 165 | + * |
| 166 | + * @param array $restrictions |
| 167 | + */ |
| 168 | + public function addAllowedRestrictionType($restrictions = array()) |
| 169 | + { |
| 170 | + $this->allowedRestrictionTypes = array_merge($this->allowedRestrictionTypes, $restrictions); |
| 171 | + } |
145 | 172 | } |
0 commit comments