diff --git a/src/main/java/org/gitlab4j/api/models/ApprovalRuleParams.java b/src/main/java/org/gitlab4j/api/models/ApprovalRuleParams.java index 59176560a..d61d37015 100644 --- a/src/main/java/org/gitlab4j/api/models/ApprovalRuleParams.java +++ b/src/main/java/org/gitlab4j/api/models/ApprovalRuleParams.java @@ -6,29 +6,95 @@ public class ApprovalRuleParams { + private Integer approvalsRequired; private String name; - private Integer approvalsRequired; - private List userIds; + private Boolean appliesToAllProtectedBranches; private List groupIds; + private List protectedBranchIds; + private String reportType; + private String ruleType; + private List userIds; + private List usernames; + /** + * @param approvalsRequired The number of required approvals for this rule. + * @return this ApprovalRuleParams instance + */ + public ApprovalRuleParams withApprovalsRequired(Integer approvalsRequired) { + this.approvalsRequired = approvalsRequired; + return (this); + } + + /** + * @param name The name of the approval rule. + * @return this ApprovalRuleParams instance + */ public ApprovalRuleParams withName(String name) { - this.name = name; - return (this); + this.name = name; + return (this); } - public ApprovalRuleParams withApprovalsRequired(Integer approvalsRequired) { - this.approvalsRequired = approvalsRequired; - return (this); + /** + * @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. + * @return this ApprovalRuleParams instance + */ + public ApprovalRuleParams withAppliesToAllProtectedBranches(Boolean appliesToAllProtectedBranches) { + this.appliesToAllProtectedBranches = appliesToAllProtectedBranches; + return (this); + } + + /** + * @param groupIds The IDs of groups as approvers. + * @return this ApprovalRuleParams instance + */ + public ApprovalRuleParams withGroupIds(List groupIds) { + this.groupIds = groupIds; + return (this); } + /** + * @param protectedBranchIds The IDs of protected branches to scope the rule by. To identify the ID, use the API. + * @return this ApprovalRuleParams instance + */ + public ApprovalRuleParams withProtectedBranchIds(List protectedBranchIds) { + this.protectedBranchIds = protectedBranchIds; + return (this); + } + + /** + * @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. + * @return this ApprovalRuleParams instance + */ + public ApprovalRuleParams withReportType(String reportType) { + this.reportType = reportType; + return (this); + } + + /** + * @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. + * @return this ApprovalRuleParams instance + */ + public ApprovalRuleParams withRuleType(String ruleType) { + this.ruleType = ruleType; + return (this); + } + + /** + * @param userIds The IDs of users as approvers. If you provide both user_ids and usernames, both lists of users are added. + * @return this ApprovalRuleParams instance + */ public ApprovalRuleParams withUserIds(List userIds) { - this.userIds = userIds; - return (this); + this.userIds = userIds; + return (this); } - public ApprovalRuleParams withGroupIds(List groupIds) { - this.groupIds = groupIds; - return (this); + /** + * @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. + * @return this ApprovalRuleParams instance + */ + public ApprovalRuleParams withUsernames(List usernames) { + this.usernames = usernames; + return (this); } /** @@ -37,10 +103,15 @@ public ApprovalRuleParams withGroupIds(List groupIds) { * @return a GitLabApiForm instance holding the form parameters for this ApprovalRuleParams instance */ public GitLabApiForm getForm() { - return new GitLabApiForm() - .withParam("name", name) + return new GitLabApiForm() .withParam("approvals_required", approvalsRequired, true) + .withParam("name", name, true) + .withParam("applies_to_all_protected_branches", appliesToAllProtectedBranches) + .withParam("group_ids", groupIds) + .withParam("protected_branch_ids", protectedBranchIds) + .withParam("report_type", reportType) + .withParam("rule_type", ruleType) .withParam("user_ids", userIds) - .withParam("group_ids", groupIds); + .withParam("usernames", usernames); } }