|
| 1 | +package org.gitlab4j.api.models; |
| 2 | + |
| 3 | +import org.gitlab4j.api.Constants.ProjectOrderBy; |
| 4 | +import org.gitlab4j.api.Constants.SortOrder; |
| 5 | +import org.gitlab4j.api.Constants; |
| 6 | +import org.gitlab4j.api.GitLabApiForm; |
| 7 | + |
| 8 | +/** |
| 9 | + * This class is used to filter Projects when getting lists of projects for a specified group. |
| 10 | + */ |
| 11 | +public class ProjectOfGroupFilter { |
| 12 | + |
| 13 | + private Boolean archived; |
| 14 | + private Visibility visibility; |
| 15 | + private ProjectOrderBy orderBy; |
| 16 | + private SortOrder sort; |
| 17 | + private String search; |
| 18 | + private Boolean simple; |
| 19 | + private Boolean owned; |
| 20 | + private Boolean starred; |
| 21 | + private Boolean withCustomAttributes; |
| 22 | + private Boolean withIssuesEnabled; |
| 23 | + private Boolean withMergeRequestsEnabled; |
| 24 | + |
| 25 | + /** |
| 26 | + * Limit by archived status. |
| 27 | + * |
| 28 | + * @param archived if true will only return archived projects |
| 29 | + * @return the reference to this ProjectFilter instance |
| 30 | + */ |
| 31 | + public ProjectOfGroupFilter withArchived(Boolean archived) { |
| 32 | + this.archived = archived; |
| 33 | + return (this); |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * Limit by visibility public, internal, or private. |
| 38 | + * |
| 39 | + * @param visibility the visibility to match |
| 40 | + * @return the reference to this ProjectFilter instance |
| 41 | + */ |
| 42 | + public ProjectOfGroupFilter withVisibility(Visibility visibility) { |
| 43 | + this.visibility = visibility; |
| 44 | + return (this); |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields. Default is created_at. |
| 49 | + * |
| 50 | + * @param orderBy specifies what field to order by |
| 51 | + * @return the reference to this ProjectFilter instance |
| 52 | + */ |
| 53 | + public ProjectOfGroupFilter withOrderBy(ProjectOrderBy orderBy) { |
| 54 | + this.orderBy = orderBy; |
| 55 | + return (this); |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * Return projects sorted in asc or desc order. Default is desc. |
| 60 | + * |
| 61 | + * @param sort sort direction, ASC or DESC |
| 62 | + * @return the reference to this ProjectFilter instance |
| 63 | + */ |
| 64 | + public ProjectOfGroupFilter withSortOder(SortOrder sort) { |
| 65 | + this.sort = sort; |
| 66 | + return (this); |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * Return list of projects matching the search criteria. |
| 71 | + * |
| 72 | + * @param search the search criteria |
| 73 | + * @return the reference to this ProjectFilter instance |
| 74 | + */ |
| 75 | + public ProjectOfGroupFilter withSearch(String search) { |
| 76 | + this.search = search; |
| 77 | + return (this); |
| 78 | + } |
| 79 | + |
| 80 | + /** |
| 81 | + * Return only limited fields for each project. This is a no-op without |
| 82 | + * authentication as then only simple fields are returned. |
| 83 | + * |
| 84 | + * @param simple if true, return only limited fields for each project |
| 85 | + * @return the reference to this ProjectFilter instance |
| 86 | + */ |
| 87 | + public ProjectOfGroupFilter withSimple(Boolean simple) { |
| 88 | + this.simple = simple; |
| 89 | + return (this); |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * Limit by projects explicitly owned by the current user |
| 94 | + * |
| 95 | + * @param owned if true, limit to projects explicitly owned by the current user |
| 96 | + * @return the reference to this ProjectFilter instance |
| 97 | + */ |
| 98 | + public ProjectOfGroupFilter withOwned(Boolean owned) { |
| 99 | + this.owned = owned; |
| 100 | + return (this); |
| 101 | + } |
| 102 | + |
| 103 | + /** |
| 104 | + * Limit by projects starred by the current user. |
| 105 | + * |
| 106 | + * @param starred if true, limit by projects starred by the current user |
| 107 | + * @return the reference to this ProjectFilter instance |
| 108 | + */ |
| 109 | + public ProjectOfGroupFilter withStarred(Boolean starred) { |
| 110 | + this.starred = starred; |
| 111 | + return (this); |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + * Include custom attributes in response (admins only). |
| 116 | + * |
| 117 | + * @param withCustomAttributes if true, include custom attributes in the repsonse |
| 118 | + * @return the reference to this ProjectFilter instance |
| 119 | + */ |
| 120 | + public ProjectOfGroupFilter withCustomAttributes(Boolean withCustomAttributes) { |
| 121 | + this.withCustomAttributes = withCustomAttributes; |
| 122 | + return (this); |
| 123 | + } |
| 124 | + |
| 125 | + /** |
| 126 | + * Limit by enabled issues feature |
| 127 | + * |
| 128 | + * @param withIssuesEnabled if true, limit by enabled issues feature |
| 129 | + * @return the reference to this ProjectFilter instance |
| 130 | + */ |
| 131 | + public ProjectOfGroupFilter withIssuesEnabled(Boolean withIssuesEnabled) { |
| 132 | + this.withIssuesEnabled = withIssuesEnabled; |
| 133 | + return (this); |
| 134 | + } |
| 135 | + |
| 136 | + /** |
| 137 | + * Limit by enabled merge requests feature |
| 138 | + * |
| 139 | + * @param withMergeRequestsEnabled if true, imit by enabled merge requests feature |
| 140 | + * @return the reference to this ProjectFilter instance |
| 141 | + */ |
| 142 | + public ProjectOfGroupFilter withMergeRequestsEnabled(Boolean withMergeRequestsEnabled) { |
| 143 | + this.withMergeRequestsEnabled = withMergeRequestsEnabled; |
| 144 | + return (this); |
| 145 | + } |
| 146 | + |
| 147 | + /** |
| 148 | + * Get the query params specified by this filter. |
| 149 | + * |
| 150 | + * @return a GitLabApiForm instance holding the query parameters for this ProjectFilter instance |
| 151 | + */ |
| 152 | + public GitLabApiForm getQueryParams() { |
| 153 | + return (new GitLabApiForm() |
| 154 | + .withParam("archived", archived) |
| 155 | + .withParam("visibility", visibility) |
| 156 | + .withParam("order_by", orderBy) |
| 157 | + .withParam("sort", sort) |
| 158 | + .withParam("search", search) |
| 159 | + .withParam("simple", simple) |
| 160 | + .withParam("owned", owned) |
| 161 | + .withParam("starred", starred) |
| 162 | + .withParam("with_custom_attributes", withCustomAttributes) |
| 163 | + .withParam("with_issues_enabled", withIssuesEnabled) |
| 164 | + .withParam("with_merge_requests_enabled ", withMergeRequestsEnabled) |
| 165 | + ); |
| 166 | + } |
| 167 | +} |
0 commit comments