1 /* 2 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package org.openjdk.skara.host; 24 25 import org.openjdk.skara.vcs.Hash; 26 27 import java.net.URI; 28 import java.time.ZonedDateTime; 29 import java.util.*; 30 31 public interface PullRequest { 32 33 HostedRepository repository(); 34 35 /** 36 * The repository-specific identifier. 37 * @return 38 */ 39 String getId(); 40 41 /** 42 * The host-specific author name. 43 * @return 44 */ 45 HostUserDetails getAuthor(); 46 47 /** 48 * List of reviews, in descending chronological order. 49 * @return 50 */ 51 List<Review> getReviews(); 52 53 /** 54 * Adds a review with the given verdict. 55 */ 56 void addReview(Review.Verdict verdict, String body); 57 58 /** 59 * Add a file specific comment. 60 * @param hash 61 * @param path 62 * @param line 63 * @param body 64 * @return 65 */ 66 ReviewComment addReviewComment(Hash base, Hash hash, String path, int line, String body); 67 68 /** 69 * Reply to a file specific comment. 70 * @param parent 71 * @param body 72 * @return 73 */ 74 ReviewComment addReviewCommentReply(ReviewComment parent, String body); 75 76 /** 77 * Get all file specific comments. 78 * @return 79 */ 80 List<ReviewComment> getReviewComments(); 81 82 /** 83 * Hash of the current head of the request. 84 * @return 85 */ 86 Hash getHeadHash(); 87 88 /** 89 * Returns the name of the ref the request is created from. 90 * @return 91 */ 92 String getSourceRef(); 93 94 /** 95 * Returns the name of the ref the request is intended to be merged into. 96 * @return 97 */ 98 String getTargetRef(); 99 100 /** 101 * Returns the current head of the ref the request is intended to be merged into. 102 * @return 103 */ 104 Hash getTargetHash(); 105 106 /** 107 * Title of the request. 108 * @return 109 */ 110 String getTitle(); 111 112 /** 113 * The main body of the request. 114 * @return 115 */ 116 String getBody(); 117 118 /** 119 * Update the main body of the request. 120 * @param body 121 */ 122 void setBody(String body); 123 124 /** 125 * All comments on the issue, in ascending creation time order. 126 * @return 127 */ 128 List<Comment> getComments(); 129 130 /** 131 * Posts a new comment. 132 * @param body 133 */ 134 Comment addComment(String body); 135 136 /** 137 * Updates an existing comment. 138 * @param id 139 * @param body 140 */ 141 Comment updateComment(String id, String body); 142 143 /** 144 * When the request was created. 145 * @return 146 */ 147 ZonedDateTime getCreated(); 148 149 /** 150 * When the request was last updated. 151 * @return 152 */ 153 ZonedDateTime getUpdated(); 154 155 /** 156 * List of completed checks on the given hash. 157 * @return 158 */ 159 Map<String, Check> getChecks(Hash hash); 160 161 /** 162 * Creates a new check. 163 * @param check 164 */ 165 void createCheck(Check check); 166 167 /** 168 * Updates an existing check. 169 * @param check 170 */ 171 void updateCheck(Check check); 172 173 enum State { 174 OPEN, 175 CLOSED 176 } 177 178 /** 179 * Set the state. 180 * @param state Desired state 181 */ 182 void setState(State state); 183 184 /** 185 * Adds the given label. 186 * @param label 187 */ 188 void addLabel(String label); 189 190 /** 191 * Removes the given label. 192 * @param label 193 */ 194 void removeLabel(String label); 195 196 /** 197 * Retrieves all the currently set labels. 198 * @return 199 */ 200 List<String> getLabels(); 201 202 /** 203 * Returns a link that will lead to the PR. 204 */ 205 URI getWebUrl(); 206 207 /** 208 * Returns all usernames assigned to the PR. 209 */ 210 List<HostUserDetails> getAssignees(); 211 212 /** 213 * Update the list of assignees. 214 * @param assignees 215 */ 216 void setAssignees(List<HostUserDetails> assignees); 217 }