Line data Source code
1 : // Copyright (C) 2013 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.extensions.api.projects; 16 : 17 : import com.google.gerrit.extensions.api.access.ProjectAccessInfo; 18 : import com.google.gerrit.extensions.api.access.ProjectAccessInput; 19 : import com.google.gerrit.extensions.api.config.AccessCheckInfo; 20 : import com.google.gerrit.extensions.api.config.AccessCheckInput; 21 : import com.google.gerrit.extensions.common.BatchLabelInput; 22 : import com.google.gerrit.extensions.common.ChangeInfo; 23 : import com.google.gerrit.extensions.common.LabelDefinitionInfo; 24 : import com.google.gerrit.extensions.common.ProjectInfo; 25 : import com.google.gerrit.extensions.common.SubmitRequirementInfo; 26 : import com.google.gerrit.extensions.restapi.NotImplementedException; 27 : import com.google.gerrit.extensions.restapi.RestApiException; 28 : import java.util.Collection; 29 : import java.util.List; 30 : import java.util.Map; 31 : import java.util.Set; 32 : 33 : public interface ProjectApi { 34 : ProjectApi create() throws RestApiException; 35 : 36 : ProjectApi create(ProjectInput in) throws RestApiException; 37 : 38 : ProjectInfo get() throws RestApiException; 39 : 40 : String description() throws RestApiException; 41 : 42 : void description(DescriptionInput in) throws RestApiException; 43 : 44 : ProjectAccessInfo access() throws RestApiException; 45 : 46 : ProjectAccessInfo access(ProjectAccessInput p) throws RestApiException; 47 : 48 : ChangeInfo accessChange(ProjectAccessInput p) throws RestApiException; 49 : 50 : AccessCheckInfo checkAccess(AccessCheckInput in) throws RestApiException; 51 : 52 : CheckProjectResultInfo check(CheckProjectInput in) throws RestApiException; 53 : 54 : ConfigInfo config() throws RestApiException; 55 : 56 : ConfigInfo config(ConfigInput in) throws RestApiException; 57 : 58 : Map<String, Set<String>> commitsIn(Collection<String> commits, Collection<String> refs) 59 : throws RestApiException; 60 : 61 : ListRefsRequest<BranchInfo> branches(); 62 : 63 : ListRefsRequest<TagInfo> tags(); 64 : 65 : void deleteBranches(DeleteBranchesInput in) throws RestApiException; 66 : 67 : void deleteTags(DeleteTagsInput in) throws RestApiException; 68 : 69 9 : abstract class ListRefsRequest<T extends RefInfo> { 70 : protected int limit; 71 : protected int start; 72 : protected String substring; 73 : protected String regex; 74 : 75 : public abstract List<T> get() throws RestApiException; 76 : 77 : public ListRefsRequest<T> withLimit(int limit) { 78 2 : this.limit = limit; 79 2 : return this; 80 : } 81 : 82 : public ListRefsRequest<T> withStart(int start) { 83 2 : this.start = start; 84 2 : return this; 85 : } 86 : 87 : public ListRefsRequest<T> withSubstring(String substring) { 88 2 : this.substring = substring; 89 2 : return this; 90 : } 91 : 92 : public ListRefsRequest<T> withRegex(String regex) { 93 2 : this.regex = regex; 94 2 : return this; 95 : } 96 : 97 : public int getLimit() { 98 9 : return limit; 99 : } 100 : 101 : public int getStart() { 102 9 : return start; 103 : } 104 : 105 : public String getSubstring() { 106 9 : return substring; 107 : } 108 : 109 : public String getRegex() { 110 9 : return regex; 111 : } 112 : } 113 : 114 : List<ProjectInfo> children() throws RestApiException; 115 : 116 : List<ProjectInfo> children(boolean recursive) throws RestApiException; 117 : 118 : List<ProjectInfo> children(int limit) throws RestApiException; 119 : 120 : ChildProjectApi child(String name) throws RestApiException; 121 : 122 : /** 123 : * Look up a branch by refname. 124 : * 125 : * <p><strong>Note:</strong> This method eagerly reads the branch. Methods that mutate the branch 126 : * do not necessarily re-read the branch. Therefore, calling a getter method on an instance after 127 : * calling a mutation method on that same instance is not guaranteed to reflect the mutation. It 128 : * is not recommended to store references to {@code BranchApi} instances. 129 : * 130 : * @param ref branch name, with or without "refs/heads/" prefix. 131 : * @throws RestApiException if a problem occurred reading the project. 132 : * @return API for accessing the branch. 133 : */ 134 : BranchApi branch(String ref) throws RestApiException; 135 : 136 : /** 137 : * Look up a tag by refname. 138 : * 139 : * <p> 140 : * 141 : * @param ref tag name, with or without "refs/tags/" prefix. 142 : * @throws RestApiException if a problem occurred reading the project. 143 : * @return API for accessing the tag. 144 : */ 145 : TagApi tag(String ref) throws RestApiException; 146 : 147 : /** 148 : * Lookup a commit by its {@code ObjectId} string. 149 : * 150 : * @param commit the {@code ObjectId} string. 151 : * @return API for accessing the commit. 152 : */ 153 : CommitApi commit(String commit) throws RestApiException; 154 : 155 : /** 156 : * Lookup a dashboard by its name. 157 : * 158 : * @param name the name. 159 : * @return API for accessing the dashboard. 160 : */ 161 : DashboardApi dashboard(String name) throws RestApiException; 162 : 163 : /** 164 : * Get the project's default dashboard. 165 : * 166 : * @return API for accessing the dashboard. 167 : */ 168 : DashboardApi defaultDashboard() throws RestApiException; 169 : 170 : /** 171 : * Set the project's default dashboard. 172 : * 173 : * @param name the dashboard to set as default. 174 : */ 175 : void defaultDashboard(String name) throws RestApiException; 176 : 177 : /** Remove the project's default dashboard. */ 178 : void removeDefaultDashboard() throws RestApiException; 179 : 180 1 : abstract class ListDashboardsRequest { 181 : public abstract List<DashboardInfo> get() throws RestApiException; 182 : } 183 : 184 : ListDashboardsRequest dashboards() throws RestApiException; 185 : 186 : /** Get the name of the branch to which {@code HEAD} points. */ 187 : String head() throws RestApiException; 188 : 189 : /** 190 : * Set the project's {@code HEAD}. 191 : * 192 : * @param head the HEAD 193 : */ 194 : void head(String head) throws RestApiException; 195 : 196 : /** Get the name of the project's parent. */ 197 : String parent() throws RestApiException; 198 : 199 : /** 200 : * Set the project's parent. 201 : * 202 : * @param parent the parent 203 : */ 204 : void parent(String parent) throws RestApiException; 205 : 206 : /** 207 : * Reindex the project and children in case {@code indexChildren} is specified. 208 : * 209 : * @param indexChildren decides if children should be indexed recursively 210 : */ 211 : void index(boolean indexChildren) throws RestApiException; 212 : 213 : /** Reindexes all changes of the project. */ 214 : void indexChanges() throws RestApiException; 215 : 216 : ListLabelsRequest labels() throws RestApiException; 217 : 218 2 : abstract class ListLabelsRequest { 219 : protected boolean inherited; 220 : 221 : public abstract List<LabelDefinitionInfo> get() throws RestApiException; 222 : 223 : public ListLabelsRequest withInherited(boolean inherited) { 224 1 : this.inherited = inherited; 225 1 : return this; 226 : } 227 : } 228 : 229 : LabelApi label(String labelName) throws RestApiException; 230 : 231 : ListSubmitRequirementsRequest submitRequirements() throws RestApiException; 232 : 233 1 : abstract class ListSubmitRequirementsRequest { 234 : protected boolean inherited; 235 : 236 : public abstract List<SubmitRequirementInfo> get() throws RestApiException; 237 : 238 : public ListSubmitRequirementsRequest withInherited(boolean inherited) { 239 1 : this.inherited = inherited; 240 1 : return this; 241 : } 242 : } 243 : 244 : SubmitRequirementApi submitRequirement(String name) throws RestApiException; 245 : 246 : /** 247 : * Adds, updates and deletes label definitions in a batch. 248 : * 249 : * @param input input that describes additions, updates and deletions of label definitions 250 : */ 251 : void labels(BatchLabelInput input) throws RestApiException; 252 : 253 : /** 254 : * A default implementation which allows source compatibility when adding new methods to the 255 : * interface. 256 : */ 257 0 : class NotImplemented implements ProjectApi { 258 : @Override 259 : public ProjectApi create() throws RestApiException { 260 0 : throw new NotImplementedException(); 261 : } 262 : 263 : @Override 264 : public ProjectApi create(ProjectInput in) throws RestApiException { 265 0 : throw new NotImplementedException(); 266 : } 267 : 268 : @Override 269 : public ProjectInfo get() throws RestApiException { 270 0 : throw new NotImplementedException(); 271 : } 272 : 273 : @Override 274 : public String description() throws RestApiException { 275 0 : throw new NotImplementedException(); 276 : } 277 : 278 : @Override 279 : public ProjectAccessInfo access() throws RestApiException { 280 0 : throw new NotImplementedException(); 281 : } 282 : 283 : @Override 284 : public ProjectAccessInfo access(ProjectAccessInput p) throws RestApiException { 285 0 : throw new NotImplementedException(); 286 : } 287 : 288 : @Override 289 : public ChangeInfo accessChange(ProjectAccessInput input) throws RestApiException { 290 0 : throw new NotImplementedException(); 291 : } 292 : 293 : @Override 294 : public AccessCheckInfo checkAccess(AccessCheckInput in) throws RestApiException { 295 0 : throw new NotImplementedException(); 296 : } 297 : 298 : @Override 299 : public CheckProjectResultInfo check(CheckProjectInput in) throws RestApiException { 300 0 : throw new NotImplementedException(); 301 : } 302 : 303 : @Override 304 : public ConfigInfo config() throws RestApiException { 305 0 : throw new NotImplementedException(); 306 : } 307 : 308 : @Override 309 : public ConfigInfo config(ConfigInput in) throws RestApiException { 310 0 : throw new NotImplementedException(); 311 : } 312 : 313 : @Override 314 : public Map<String, Set<String>> commitsIn(Collection<String> commits, Collection<String> refs) 315 : throws RestApiException { 316 0 : throw new NotImplementedException(); 317 : } 318 : 319 : @Override 320 : public void description(DescriptionInput in) throws RestApiException { 321 0 : throw new NotImplementedException(); 322 : } 323 : 324 : @Override 325 : public ListRefsRequest<BranchInfo> branches() { 326 0 : throw new NotImplementedException(); 327 : } 328 : 329 : @Override 330 : public ListRefsRequest<TagInfo> tags() { 331 0 : throw new NotImplementedException(); 332 : } 333 : 334 : @Override 335 : public List<ProjectInfo> children() throws RestApiException { 336 0 : throw new NotImplementedException(); 337 : } 338 : 339 : @Override 340 : public List<ProjectInfo> children(boolean recursive) throws RestApiException { 341 0 : throw new NotImplementedException(); 342 : } 343 : 344 : @Override 345 : public List<ProjectInfo> children(int limit) throws RestApiException { 346 0 : throw new NotImplementedException(); 347 : } 348 : 349 : @Override 350 : public ChildProjectApi child(String name) throws RestApiException { 351 0 : throw new NotImplementedException(); 352 : } 353 : 354 : @Override 355 : public BranchApi branch(String ref) throws RestApiException { 356 0 : throw new NotImplementedException(); 357 : } 358 : 359 : @Override 360 : public TagApi tag(String ref) throws RestApiException { 361 0 : throw new NotImplementedException(); 362 : } 363 : 364 : @Override 365 : public void deleteBranches(DeleteBranchesInput in) throws RestApiException { 366 0 : throw new NotImplementedException(); 367 : } 368 : 369 : @Override 370 : public void deleteTags(DeleteTagsInput in) throws RestApiException { 371 0 : throw new NotImplementedException(); 372 : } 373 : 374 : @Override 375 : public CommitApi commit(String commit) throws RestApiException { 376 0 : throw new NotImplementedException(); 377 : } 378 : 379 : @Override 380 : public DashboardApi dashboard(String name) throws RestApiException { 381 0 : throw new NotImplementedException(); 382 : } 383 : 384 : @Override 385 : public DashboardApi defaultDashboard() throws RestApiException { 386 0 : throw new NotImplementedException(); 387 : } 388 : 389 : @Override 390 : public ListDashboardsRequest dashboards() throws RestApiException { 391 0 : throw new NotImplementedException(); 392 : } 393 : 394 : @Override 395 : public void defaultDashboard(String name) throws RestApiException { 396 0 : throw new NotImplementedException(); 397 : } 398 : 399 : @Override 400 : public void removeDefaultDashboard() throws RestApiException { 401 0 : throw new NotImplementedException(); 402 : } 403 : 404 : @Override 405 : public String head() throws RestApiException { 406 0 : throw new NotImplementedException(); 407 : } 408 : 409 : @Override 410 : public void head(String head) throws RestApiException { 411 0 : throw new NotImplementedException(); 412 : } 413 : 414 : @Override 415 : public String parent() throws RestApiException { 416 0 : throw new NotImplementedException(); 417 : } 418 : 419 : @Override 420 : public void parent(String parent) throws RestApiException { 421 0 : throw new NotImplementedException(); 422 : } 423 : 424 : @Override 425 : public void index(boolean indexChildren) throws RestApiException { 426 0 : throw new NotImplementedException(); 427 : } 428 : 429 : @Override 430 : public void indexChanges() throws RestApiException { 431 0 : throw new NotImplementedException(); 432 : } 433 : 434 : @Override 435 : public ListLabelsRequest labels() throws RestApiException { 436 0 : throw new NotImplementedException(); 437 : } 438 : 439 : @Override 440 : public ListSubmitRequirementsRequest submitRequirements() throws RestApiException { 441 0 : throw new NotImplementedException(); 442 : } 443 : 444 : @Override 445 : public LabelApi label(String labelName) throws RestApiException { 446 0 : throw new NotImplementedException(); 447 : } 448 : 449 : @Override 450 : public SubmitRequirementApi submitRequirement(String name) throws RestApiException { 451 0 : throw new NotImplementedException(); 452 : } 453 : 454 : @Override 455 : public void labels(BatchLabelInput input) throws RestApiException { 456 0 : throw new NotImplementedException(); 457 : } 458 : } 459 : }