Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1502 from gsmet/projectv2-payload
Add ProjectsV2Item event payload
- Loading branch information
Showing
9 changed files
with
640 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.kohsuke.github; | ||
|
||
import org.kohsuke.github.internal.EnumUtils; | ||
|
||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.util.Date; | ||
|
||
/** | ||
* A Projects V2 item in the organization. | ||
* <p> | ||
* Projects V2 are not attached to a repository but to an organization, even if it is possible to create shortcuts at | ||
* the repository level. | ||
* <p> | ||
* This event exposes the GraphQL object (more or less - the ids are handled differently for instance) directly. The new | ||
* Projects V2 API is only available through GraphQL so for now you cannot execute any actions on this object. | ||
* | ||
* @author Guillaume Smet | ||
* @see <a href= | ||
* "https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/using-the-api-to-manage-projects">The | ||
* GraphQL API for Projects V2</a> | ||
*/ | ||
public class GHProjectsV2Item extends GHObject { | ||
|
||
private String projectNodeId; | ||
private String contentNodeId; | ||
private String contentType; | ||
|
||
private GHUser creator; | ||
private String archivedAt; | ||
|
||
public String getProjectNodeId() { | ||
return projectNodeId; | ||
} | ||
|
||
public String getContentNodeId() { | ||
return contentNodeId; | ||
} | ||
|
||
public ContentType getContentType() { | ||
return EnumUtils.getEnumOrDefault(ContentType.class, contentType, ContentType.UNKNOWN); | ||
} | ||
|
||
public GHUser getCreator() throws IOException { | ||
return root().intern(creator); | ||
} | ||
|
||
public Date getArchivedAt() { | ||
return GitHubClient.parseDate(archivedAt); | ||
} | ||
|
||
public URL getHtmlUrl() { | ||
throw new IllegalStateException(getClass().getName() + " does not offer a HTML URL."); | ||
} | ||
|
||
public enum ContentType { | ||
ISSUE, DRAFTISSUE, PULLREQUEST, UNKNOWN; | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
src/main/java/org/kohsuke/github/GHProjectsV2ItemChanges.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package org.kohsuke.github; | ||
|
||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
import org.kohsuke.github.internal.EnumUtils; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* An object to track changes in projects_v2_item payloads. | ||
* <p> | ||
* Note that this is best effort only as nothing is documented in the GitHub documentation. | ||
*/ | ||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") | ||
public class GHProjectsV2ItemChanges { | ||
|
||
private FieldValue fieldValue; | ||
|
||
private FromToDate archivedAt; | ||
|
||
private FromTo previousProjectsV2ItemNodeId; | ||
|
||
public FieldValue getFieldValue() { | ||
return fieldValue; | ||
} | ||
|
||
public FromToDate getArchivedAt() { | ||
return archivedAt; | ||
} | ||
|
||
public FromTo getPreviousProjectsV2ItemNodeId() { | ||
return previousProjectsV2ItemNodeId; | ||
} | ||
|
||
public static class FieldValue { | ||
|
||
private String fieldNodeId; | ||
private String fieldType; | ||
|
||
public String getFieldNodeId() { | ||
return fieldNodeId; | ||
} | ||
|
||
public FieldType getFieldType() { | ||
return EnumUtils.getEnumOrDefault(FieldType.class, fieldType, FieldType.UNKNOWN); | ||
} | ||
} | ||
|
||
public static class FromTo { | ||
|
||
private String from; | ||
private String to; | ||
|
||
public String getFrom() { | ||
return from; | ||
} | ||
|
||
public String getTo() { | ||
return to; | ||
} | ||
} | ||
|
||
public static class FromToDate { | ||
|
||
private String from; | ||
private String to; | ||
|
||
public Date getFrom() { | ||
return GitHubClient.parseDate(from); | ||
} | ||
|
||
public Date getTo() { | ||
return GitHubClient.parseDate(to); | ||
} | ||
} | ||
|
||
public enum FieldType { | ||
|
||
TEXT, NUMBER, DATE, SINGLE_SELECT, ITERATION, UNKNOWN; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/test/resources/org/kohsuke/github/GHEventPayloadTest/projectsv2item_archived.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{ | ||
"action": "archived", | ||
"projects_v2_item": { | ||
"id": 8083794, | ||
"node_id": "PVTI_lADOBNft-M4AEjBWzgB7WVI", | ||
"project_node_id": "PVT_kwDOBNft-M4AEjBW", | ||
"content_node_id": "I_kwDOFOkjw85OzN4w", | ||
"content_type": "Issue", | ||
"creator": { | ||
"login": "gsmet", | ||
"id": 1279749, | ||
"node_id": "MDQ6VXNlcjEyNzk3NDk=", | ||
"avatar_url": "https://avatars.githubusercontent.com/u/1279749?v=4", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/gsmet", | ||
"html_url": "https://github.com/gsmet", | ||
"followers_url": "https://api.github.com/users/gsmet/followers", | ||
"following_url": "https://api.github.com/users/gsmet/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/gsmet/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/gsmet/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/gsmet/subscriptions", | ||
"organizations_url": "https://api.github.com/users/gsmet/orgs", | ||
"repos_url": "https://api.github.com/users/gsmet/repos", | ||
"events_url": "https://api.github.com/users/gsmet/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/gsmet/received_events", | ||
"type": "User", | ||
"site_admin": false | ||
}, | ||
"created_at": "2022-08-03T13:13:51Z", | ||
"updated_at": "2022-08-09T23:10:29Z", | ||
"archived_at": "2022-08-09T23:10:29Z" | ||
}, | ||
"changes": { | ||
"archived_at": { | ||
"from": null, | ||
"to": "2022-08-10T01:10:29+02:00" | ||
} | ||
}, | ||
"organization": { | ||
"login": "gsmet-bot-playground", | ||
"id": 81260024, | ||
"node_id": "MDEyOk9yZ2FuaXphdGlvbjgxMjYwMDI0", | ||
"url": "https://api.github.com/orgs/gsmet-bot-playground", | ||
"repos_url": "https://api.github.com/orgs/gsmet-bot-playground/repos", | ||
"events_url": "https://api.github.com/orgs/gsmet-bot-playground/events", | ||
"hooks_url": "https://api.github.com/orgs/gsmet-bot-playground/hooks", | ||
"issues_url": "https://api.github.com/orgs/gsmet-bot-playground/issues", | ||
"members_url": "https://api.github.com/orgs/gsmet-bot-playground/members{/member}", | ||
"public_members_url": "https://api.github.com/orgs/gsmet-bot-playground/public_members{/member}", | ||
"avatar_url": "https://avatars.githubusercontent.com/u/81260024?v=4", | ||
"description": null | ||
}, | ||
"sender": { | ||
"login": "gsmet", | ||
"id": 1279749, | ||
"node_id": "MDQ6VXNlcjEyNzk3NDk=", | ||
"avatar_url": "https://avatars.githubusercontent.com/u/1279749?v=4", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/gsmet", | ||
"html_url": "https://github.com/gsmet", | ||
"followers_url": "https://api.github.com/users/gsmet/followers", | ||
"following_url": "https://api.github.com/users/gsmet/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/gsmet/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/gsmet/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/gsmet/subscriptions", | ||
"organizations_url": "https://api.github.com/users/gsmet/orgs", | ||
"repos_url": "https://api.github.com/users/gsmet/repos", | ||
"events_url": "https://api.github.com/users/gsmet/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/gsmet/received_events", | ||
"type": "User", | ||
"site_admin": false | ||
}, | ||
"installation": { | ||
"id": 16779846, | ||
"node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uMTY3Nzk4NDY=" | ||
} | ||
} |
Oops, something went wrong.