Skip to content

Commit 58c36aa

Browse files
committed
2 parents d02e5a1 + c0e2fbd commit 58c36aa

13 files changed

+503
-5
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.1.3
47

58
- Added support for Pipeline permissions.

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>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.azd.abstractions.serializer;
2+
3+
import com.fasterxml.jackson.core.JsonParser;
4+
import com.fasterxml.jackson.core.JsonProcessingException;
5+
import com.fasterxml.jackson.databind.DeserializationContext;
6+
import com.fasterxml.jackson.databind.JsonDeserializer;
7+
import org.azd.enums.VersionControlChangeType;
8+
9+
import java.io.IOException;
10+
import java.util.ArrayList;
11+
import java.util.List;
12+
13+
public class VersionControlChangeTypeDeserializer extends JsonDeserializer<List<VersionControlChangeType>> {
14+
15+
@Override
16+
public List<VersionControlChangeType> deserialize(JsonParser p, DeserializationContext ctxt)
17+
throws IOException, JsonProcessingException {
18+
String text = p.getText();
19+
String[] parts = text.split(",");
20+
List<VersionControlChangeType> types = new ArrayList<>();
21+
for (String part : parts) {
22+
try {
23+
types.add(VersionControlChangeType.valueOf(part.trim().toUpperCase().replace(" ", "_")));
24+
} catch (IllegalArgumentException e) {
25+
// Unknown type, skip or log
26+
}
27+
}
28+
return types;
29+
}
30+
}

azd/src/main/java/org/azd/enums/VersionControlChangeType.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77

88
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
99
import com.fasterxml.jackson.annotation.JsonProperty;
10+
import com.fasterxml.jackson.annotation.JsonFormat;
1011

1112
/**
1213
* None
1314
**/
15+
@JsonFormat(shape = JsonFormat.Shape.STRING)
1416
@JsonIgnoreProperties(ignoreUnknown = true)
1517
public enum VersionControlChangeType {
1618
@JsonProperty("add")

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+
}

azd/src/main/java/org/azd/git/types/GitChange.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77

88
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
99
import com.fasterxml.jackson.annotation.JsonProperty;
10+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
1011
import org.azd.abstractions.serializer.SerializableEntity;
12+
import org.azd.abstractions.serializer.VersionControlChangeTypeDeserializer;
1113
import org.azd.enums.VersionControlChangeType;
1214

15+
import java.util.List;
16+
1317
/**
1418
* None
1519
**/
@@ -24,7 +28,8 @@ public class GitChange extends SerializableEntity {
2428
* The type of change that was made to the item.
2529
**/
2630
@JsonProperty("changeType")
27-
private VersionControlChangeType changeType;
31+
@JsonDeserialize(using = VersionControlChangeTypeDeserializer.class)
32+
private List<VersionControlChangeType> changeType;
2833
/**
2934
* Current version.
3035
**/
@@ -64,12 +69,12 @@ public void setChangeId(Integer changeId) {
6469
this.changeId = changeId;
6570
}
6671

67-
public VersionControlChangeType getChangeType() {
72+
public List<VersionControlChangeType> getChangeType() {
6873
return changeType;
6974
}
7075

71-
public void setChangeType(VersionControlChangeType changeType) {
72-
this.changeType = changeType;
76+
public void setChangeType(List<VersionControlChangeType> changeType) {
77+
this.changeType = List.copyOf(changeType);
7378
}
7479

7580
public GitItem getItem() {
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+
}

0 commit comments

Comments
 (0)