6
6
7
7
public class ApprovalRuleParams {
8
8
9
+ private Integer approvalsRequired ;
9
10
private String name ;
10
- private Integer approvalsRequired ;
11
- private List <Long > userIds ;
11
+ private Boolean appliesToAllProtectedBranches ;
12
12
private List <Long > groupIds ;
13
+ private List <Long > protectedBranchIds ;
14
+ private String reportType ;
15
+ private String ruleType ;
16
+ private List <Long > userIds ;
17
+ private List <String > usernames ;
13
18
19
+ /**
20
+ * @param approvalsRequired The number of required approvals for this rule.
21
+ * @return this ApprovalRuleParams instance
22
+ */
23
+ public ApprovalRuleParams withApprovalsRequired (Integer approvalsRequired ) {
24
+ this .approvalsRequired = approvalsRequired ;
25
+ return (this );
26
+ }
27
+
28
+ /**
29
+ * @param name The name of the approval rule.
30
+ * @return this ApprovalRuleParams instance
31
+ */
14
32
public ApprovalRuleParams withName (String name ) {
15
- this .name = name ;
16
- return (this );
33
+ this .name = name ;
34
+ return (this );
17
35
}
18
36
19
- public ApprovalRuleParams withApprovalsRequired (Integer approvalsRequired ) {
20
- this .approvalsRequired = approvalsRequired ;
21
- return (this );
37
+ /**
38
+ * @param appliesToAllProtectedBranches Whether the rule is applied to all protected branches. If set to true, the value of protected_branch_ids is ignored. Default is false. Introduced in GitLab 15.3.
39
+ * @return this ApprovalRuleParams instance
40
+ */
41
+ public ApprovalRuleParams withAppliesToAllProtectedBranches (Boolean appliesToAllProtectedBranches ) {
42
+ this .appliesToAllProtectedBranches = appliesToAllProtectedBranches ;
43
+ return (this );
44
+ }
45
+
46
+ /**
47
+ * @param groupIds The IDs of groups as approvers.
48
+ * @return this ApprovalRuleParams instance
49
+ */
50
+ public ApprovalRuleParams withGroupIds (List <Long > groupIds ) {
51
+ this .groupIds = groupIds ;
52
+ return (this );
22
53
}
23
54
55
+ /**
56
+ * @param protectedBranchIds The IDs of protected branches to scope the rule by. To identify the ID, use the API.
57
+ * @return this ApprovalRuleParams instance
58
+ */
59
+ public ApprovalRuleParams withProtectedBranchIds (List <Long > protectedBranchIds ) {
60
+ this .protectedBranchIds = protectedBranchIds ;
61
+ return (this );
62
+ }
63
+
64
+ /**
65
+ * @param reportType The report type required when the rule type is report_approver. The supported report types are license_scanning (Deprecated in GitLab 15.9) and code_coverage.
66
+ * @return this ApprovalRuleParams instance
67
+ */
68
+ public ApprovalRuleParams withReportType (String reportType ) {
69
+ this .reportType = reportType ;
70
+ return (this );
71
+ }
72
+
73
+ /**
74
+ * @param ruleType The type of rule. any_approver is a pre-configured default rule with approvals_required at 0. Other rules are regular and report_approver.
75
+ * @return this ApprovalRuleParams instance
76
+ */
77
+ public ApprovalRuleParams withRuleType (String ruleType ) {
78
+ this .ruleType = ruleType ;
79
+ return (this );
80
+ }
81
+
82
+ /**
83
+ * @param userIds The IDs of users as approvers. If you provide both user_ids and usernames, both lists of users are added.
84
+ * @return this ApprovalRuleParams instance
85
+ */
24
86
public ApprovalRuleParams withUserIds (List <Long > userIds ) {
25
- this .userIds = userIds ;
26
- return (this );
87
+ this .userIds = userIds ;
88
+ return (this );
27
89
}
28
90
29
- public ApprovalRuleParams withGroupIds (List <Long > groupIds ) {
30
- this .groupIds = groupIds ;
31
- return (this );
91
+ /**
92
+ * @param usernames The usernames of approvers for this rule (same as user_ids but requires a list of usernames). If you provide both user_ids and usernames, both lists of users are added.
93
+ * @return this ApprovalRuleParams instance
94
+ */
95
+ public ApprovalRuleParams withUsernames (List <String > usernames ) {
96
+ this .usernames = usernames ;
97
+ return (this );
32
98
}
33
99
34
100
/**
@@ -37,10 +103,15 @@ public ApprovalRuleParams withGroupIds(List<Long> groupIds) {
37
103
* @return a GitLabApiForm instance holding the form parameters for this ApprovalRuleParams instance
38
104
*/
39
105
public GitLabApiForm getForm () {
40
- return new GitLabApiForm ()
41
- .withParam ("name" , name )
106
+ return new GitLabApiForm ()
42
107
.withParam ("approvals_required" , approvalsRequired , true )
108
+ .withParam ("name" , name , true )
109
+ .withParam ("applies_to_all_protected_branches" , appliesToAllProtectedBranches )
110
+ .withParam ("group_ids" , groupIds )
111
+ .withParam ("protected_branch_ids" , protectedBranchIds )
112
+ .withParam ("report_type" , reportType )
113
+ .withParam ("rule_type" , ruleType )
43
114
.withParam ("user_ids" , userIds )
44
- .withParam ("group_ids " , groupIds );
115
+ .withParam ("usernames " , usernames );
45
116
}
46
117
}
0 commit comments