Skip to content

Commit 0690f24

Browse files
authored
Feature: add Git pull request iteration models and builder (#89)
* Feature: add Git pull request iteration models and builder * readme update * readme update
1 parent 81f9c9b commit 0690f24

File tree

9 files changed

+392
-1
lines changed

9 files changed

+392
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
# 6.0.4
4+
- Added support for Pull Request Iterations in **GitApi**.
5+
36
# 6.0.3
47

58
- Fixes issues:

azd/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.hkarthik7</groupId>
88
<artifactId>azd</artifactId>
9-
<version>6.0.3</version>
9+
<version>6.0.4</version>
1010
<packaging>jar</packaging>
1111

1212
<name>azd</name>

azd/src/main/java/org/azd/git/pullrequest/PullRequestBaseRequestBuilder.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,14 @@ public PullRequestReviewersRequestBuilder reviewers() {
5353
public PullRequestStatusRequestBuilder statuses() {
5454
return new PullRequestStatusRequestBuilder(organizationUrl, accessTokenCredential);
5555
}
56+
57+
/**
58+
* Provides functionality to manage Pull request iterations Api.
59+
*
60+
* @return PullRequestIterationsBuilder {@link PullRequestIterationsBuilder}
61+
*/
62+
public PullRequestIterationsBuilder iterations() {
63+
return new PullRequestIterationsBuilder(organizationUrl, accessTokenCredential);
64+
}
5665
}
5766

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package org.azd.git.pullrequest;
2+
3+
import org.azd.abstractions.BaseRequestBuilder;
4+
import org.azd.authentication.AccessTokenCredential;
5+
import org.azd.common.ApiVersion;
6+
import org.azd.exceptions.AzDException;
7+
import org.azd.git.types.GitPullRequestIteration;
8+
import org.azd.git.types.GitPullRequestIterations;
9+
10+
import java.util.concurrent.CompletableFuture;
11+
12+
public class PullRequestIterationsBuilder extends BaseRequestBuilder {
13+
14+
public PullRequestIterationsBuilder(String organizationUrl, AccessTokenCredential accessTokenCredential) {
15+
super(organizationUrl, accessTokenCredential, "git", "4e080c62-fa21-4fbc-8fef-2a10a2b38049", ApiVersion.GIT);
16+
}
17+
18+
public CompletableFuture<GitPullRequestIteration> getAsync(String repositoryId, int pullRequestId, int iterationId) throws AzDException {
19+
return builder()
20+
.serviceEndpoint("repositoryId", repositoryId)
21+
.serviceEndpoint("pullRequestId", pullRequestId)
22+
.serviceEndpoint("iterationId", iterationId)
23+
.build()
24+
.executeAsync(GitPullRequestIteration.class);
25+
}
26+
27+
public CompletableFuture<GitPullRequestIterations> listAsync(String repositoryId, int pullRequestId) throws AzDException {
28+
return builder()
29+
.serviceEndpoint("repositoryId", repositoryId)
30+
.serviceEndpoint("pullRequestId", pullRequestId)
31+
.build()
32+
.executeAsync(GitPullRequestIterations.class);
33+
}
34+
35+
public GitPullRequestIteration get(String repositoryId, int pullRequestId, int iterationId) throws AzDException {
36+
return builder()
37+
.serviceEndpoint("repositoryId", repositoryId)
38+
.serviceEndpoint("pullRequestId", pullRequestId)
39+
.serviceEndpoint("iterationId", iterationId)
40+
.build()
41+
.execute(GitPullRequestIteration.class);
42+
}
43+
44+
public GitPullRequestIterations list(String repositoryId, int pullRequestId) throws AzDException {
45+
return builder()
46+
.serviceEndpoint("repositoryId", repositoryId)
47+
.serviceEndpoint("pullRequestId", pullRequestId)
48+
.build()
49+
.execute(GitPullRequestIterations.class);
50+
}
51+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.azd.git.types;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import org.azd.abstractions.serializer.SerializableEntity;
5+
import org.azd.enums.VersionControlChangeType;
6+
7+
public class GitPullRequestChange extends SerializableEntity {
8+
@JsonProperty("changeId")
9+
public int changeId;
10+
11+
@JsonProperty("changeTrackingId")
12+
public int changeTrackingId;
13+
14+
@JsonProperty("changeType")
15+
public VersionControlChangeType changeType;
16+
17+
@JsonProperty("item")
18+
public String item;
19+
20+
@JsonProperty("newContent")
21+
public ItemContent newContent;
22+
23+
@JsonProperty("newContentTemplate")
24+
public GitTemplate newContentTemplate;
25+
26+
@JsonProperty("originalPath")
27+
public String originalPath;
28+
29+
@JsonProperty("sourceServerItem")
30+
public String sourceServerItem;
31+
32+
@JsonProperty("url")
33+
public String url;
34+
}
Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
package org.azd.git.types;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import org.azd.abstractions.serializer.SerializableEntity;
5+
import org.azd.common.types.ReferenceLinks;
6+
import org.azd.test.types.IdentityRef;
7+
8+
public class GitPullRequestIteration extends SerializableEntity {
9+
10+
/**
11+
* A collection of related REST reference links..
12+
**/
13+
@JsonProperty("_links")
14+
private ReferenceLinks links;
15+
16+
/**
17+
* Author of the pull request iteration.
18+
**/
19+
@JsonProperty("author")
20+
private IdentityRef author;
21+
22+
/**
23+
* Changes included with the pull request iteration.
24+
*/
25+
@JsonProperty("changeList")
26+
private GitPullRequestChange changeList;
27+
28+
/**
29+
* The commits included with the pull request iteration.
30+
*/
31+
@JsonProperty("commits")
32+
private GitCommitRef[] commits;
33+
34+
/**
35+
* The first common Git commit of the source and target refs.
36+
*/
37+
@JsonProperty("commonRefCommit")
38+
private GitCommitRef commonRefCommit;
39+
40+
/**
41+
* The creation date of the pull request iteration.
42+
**/
43+
@JsonProperty("createdDate")
44+
private String createdDate;
45+
46+
/**
47+
* Description of the pull request iteration.
48+
**/
49+
@JsonProperty("description")
50+
private String description;
51+
52+
/**
53+
* Indicates if the Commits property contains a truncated list of commits in this pull request iteration.
54+
**/
55+
@JsonProperty("hasMoreCommits")
56+
private boolean hasMoreCommits;
57+
58+
/**
59+
* ID of the pull request iteration. Iterations are created as a result of creating and pushing updates to a pull request.
60+
**/
61+
@JsonProperty("id")
62+
private int id;
63+
64+
/**
65+
* If the iteration reason is Retarget, this is the refName of the new target
66+
**/
67+
@JsonProperty("newTargetRefName")
68+
private String newTargetRefName;
69+
70+
/**
71+
* If the iteration reason is Retarget, this is the original target refName
72+
**/
73+
@JsonProperty("oldTargetRefName")
74+
private String oldTargetRefName;
75+
76+
/**
77+
* The Git push information associated with this pull request iteration.
78+
*/
79+
@JsonProperty("push")
80+
private GitPushRef push;
81+
82+
/**
83+
* The reason for which the pull request iteration was created.
84+
*/
85+
@JsonProperty("reason")
86+
private IterationReason reason;
87+
88+
/**
89+
* The source Git commit of this iteration.
90+
*/
91+
@JsonProperty("sourceRefCommit")
92+
private GitCommitRef sourceRefCommit;
93+
94+
/**
95+
* The target Git commit of this iteration.
96+
*/
97+
@JsonProperty("targetRefCommit")
98+
private GitCommitRef targetRefCommit;
99+
100+
/**
101+
* The updated date of the pull request iteration.
102+
*/
103+
@JsonProperty("updatedDate")
104+
private String updatedDate;
105+
106+
public ReferenceLinks getLinks() {
107+
return links;
108+
}
109+
110+
public void setLinks(ReferenceLinks links) {
111+
this.links = links;
112+
}
113+
114+
public IdentityRef getAuthor() {
115+
return author;
116+
}
117+
118+
public void setAuthor(IdentityRef author) {
119+
this.author = author;
120+
}
121+
122+
public GitPullRequestChange getChangeList() {
123+
return changeList;
124+
}
125+
126+
public void setChangeList(GitPullRequestChange changeList) {
127+
this.changeList = changeList;
128+
}
129+
130+
public GitCommitRef[] getCommits() {
131+
return commits;
132+
}
133+
134+
public void setCommits(GitCommitRef[] commits) {
135+
this.commits = commits;
136+
}
137+
138+
public GitCommitRef getCommonRefCommit() {
139+
return commonRefCommit;
140+
}
141+
142+
public void setCommonRefCommit(GitCommitRef commonRefCommit) {
143+
this.commonRefCommit = commonRefCommit;
144+
}
145+
146+
public String getCreatedDate() {
147+
return createdDate;
148+
}
149+
150+
public void setCreatedDate(String createdDate) {
151+
this.createdDate = createdDate;
152+
}
153+
154+
public String getDescription() {
155+
return description;
156+
}
157+
158+
public void setDescription(String description) {
159+
this.description = description;
160+
}
161+
162+
public boolean isHasMoreCommits() {
163+
return hasMoreCommits;
164+
}
165+
166+
public void setHasMoreCommits(boolean hasMoreCommits) {
167+
this.hasMoreCommits = hasMoreCommits;
168+
}
169+
170+
public int getId() {
171+
return id;
172+
}
173+
174+
public void setId(int id) {
175+
this.id = id;
176+
}
177+
178+
public String getNewTargetRefName() {
179+
return newTargetRefName;
180+
}
181+
182+
public void setNewTargetRefName(String newTargetRefName) {
183+
this.newTargetRefName = newTargetRefName;
184+
}
185+
186+
public String getOldTargetRefName() {
187+
return oldTargetRefName;
188+
}
189+
190+
public void setOldTargetRefName(String oldTargetRefName) {
191+
this.oldTargetRefName = oldTargetRefName;
192+
}
193+
194+
public GitPushRef getPush() {
195+
return push;
196+
}
197+
198+
public void setPush(GitPushRef push) {
199+
this.push = push;
200+
}
201+
202+
public IterationReason getReason() {
203+
return reason;
204+
}
205+
206+
public void setReason(IterationReason reason) {
207+
this.reason = reason;
208+
}
209+
210+
public GitCommitRef getSourceRefCommit() {
211+
return sourceRefCommit;
212+
}
213+
214+
public void setSourceRefCommit(GitCommitRef sourceRefCommit) {
215+
this.sourceRefCommit = sourceRefCommit;
216+
}
217+
218+
public GitCommitRef getTargetRefCommit() {
219+
return targetRefCommit;
220+
}
221+
222+
public void setTargetRefCommit(GitCommitRef targetRefCommit) {
223+
this.targetRefCommit = targetRefCommit;
224+
}
225+
226+
public String getUpdatedDate() {
227+
return updatedDate;
228+
}
229+
230+
public void setUpdatedDate(String updatedDate) {
231+
this.updatedDate = updatedDate;
232+
}
233+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.azd.git.types;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import org.azd.abstractions.serializer.SerializableEntity;
5+
6+
import java.util.List;
7+
8+
public class GitPullRequestIterations extends SerializableEntity {
9+
10+
@JsonProperty("value")
11+
private List<GitPullRequestIteration> iterations;
12+
13+
public List<GitPullRequestIteration> getIterations() {
14+
return iterations;
15+
}
16+
17+
public void setIterations(List<GitPullRequestIteration> iterations) {
18+
this.iterations = iterations;
19+
}
20+
}

0 commit comments

Comments
 (0)