package org.mian.gitnex.interfaces; import com.google.gson.JsonElement; import org.mian.gitnex.models.AddEmail; import org.mian.gitnex.models.Branches; import org.mian.gitnex.models.Collaborators; import org.mian.gitnex.models.Commits; import org.mian.gitnex.models.CreateIssue; import org.mian.gitnex.models.CreateLabel; import org.mian.gitnex.models.Emails; import org.mian.gitnex.models.ExploreRepositories; import org.mian.gitnex.models.Files; import org.mian.gitnex.models.GiteaVersion; import org.mian.gitnex.models.IssueComments; import org.mian.gitnex.models.Issues; import org.mian.gitnex.models.Labels; import org.mian.gitnex.models.MergePullRequest; import org.mian.gitnex.models.Milestones; import org.mian.gitnex.models.NewFile; import org.mian.gitnex.models.NotificationThread; import org.mian.gitnex.models.OrgOwner; import org.mian.gitnex.models.Organization; import org.mian.gitnex.models.OrganizationRepository; import org.mian.gitnex.models.Permission; import org.mian.gitnex.models.PullRequests; import org.mian.gitnex.models.Releases; import org.mian.gitnex.models.Teams; import org.mian.gitnex.models.UpdateIssueAssignees; import org.mian.gitnex.models.UpdateIssueState; import org.mian.gitnex.models.UserInfo; import org.mian.gitnex.models.UserOrganizations; import org.mian.gitnex.models.UserRepositories; import org.mian.gitnex.models.UserSearch; import org.mian.gitnex.models.UserTokens; import org.mian.gitnex.models.WatchInfo; import java.util.List; import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.http.Body; import retrofit2.http.DELETE; import retrofit2.http.GET; import retrofit2.http.Header; import retrofit2.http.PATCH; import retrofit2.http.POST; import retrofit2.http.PUT; import retrofit2.http.Path; import retrofit2.http.Query; /** * Author M M Arif */ public interface ApiInterface { @GET("version") // gitea version API Call getGiteaVersionWithBasic(@Header("Authorization") String authorization); @GET("version") // gitea version API Call getGiteaVersionWithOTP(@Header("Authorization") String authorization, @Header("X-Gitea-OTP") int loginOTP); @GET("version") // gitea version API Call getGiteaVersionWithToken(@Header("Authorization") String token); @GET("user") // username, full name, email Call getUserInfo(@Header("Authorization") String token); @GET("users/{username}/tokens") // get user token Call> getUserTokens(@Header("Authorization") String authorization, @Path("username") String loginUid); @GET("users/{username}/tokens") // get user token with 2fa otp Call> getUserTokensWithOTP(@Header("Authorization") String authorization, @Header("X-Gitea-OTP") int loginOTP, @Path("username") String loginUid); @POST("users/{username}/tokens") // create new token Call createNewToken(@Header("Authorization") String authorization, @Path("username") String loginUid, @Body UserTokens jsonStr); @POST("users/{username}/tokens") // create new token with 2fa otp Call createNewTokenWithOTP(@Header("Authorization") String authorization, @Header("X-Gitea-OTP") int loginOTP, @Path("username") String loginUid, @Body UserTokens jsonStr); @GET("notifications") // List users's notification threads Call> getNotificationThreads(@Header("Authorization") String token, @Query("all") Boolean all, @Query("status-types") String[] statusTypes, @Query("since") String since, @Query("before") String before, @Query("page") Integer page, @Query("limit") Integer limit); @PUT("notifications") // Mark notification threads as read, pinned or unread Call markNotificationThreadsAsRead(@Header("Authorization") String token, @Query("last_read_at") String last_read_at, @Query("all") Boolean all, @Query("status-types") String[] statusTypes, @Query("to-status") String toStatus); @GET("notifications/new") // Check if unread notifications exist Call checkUnreadNotifications(@Header("Authorization") String token); @GET("notifications/threads/{id}") // Get notification thread by ID Call getNotificationThread(@Header("Authorization") String token, @Path("id") Integer id); @PATCH("notifications/threads/{id}") // Mark notification thread as read by ID Call markNotificationThreadAsRead(@Header("Authorization") String token, @Path("id") Integer id, @Query("to-status") String toStatus); @GET("repos/{owner}/{repo}/notifications") // List users's notification threads on a specific repo Call> getRepoNotificationThreads(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("all") String all, @Query("status-types") String[] statusTypes, @Query("since") String since, @Query("before") String before, @Query("page") String page, @Query("limit") String limit); @PUT("repos/{owner}/{repo}/notifications") // Mark notification threads as read, pinned or unread on a specific repo Call markRepoNotificationThreadsAsRead(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("all") Boolean all, @Query("status-types") String[] statusTypes, @Query("to-status") String toStatus, @Query("last_read_at") String last_read_at); @GET("user/orgs") // get user organizations Call> getUserOrgs(@Header("Authorization") String token); @POST("orgs") // create new organization Call createNewOrganization(@Header("Authorization") String token, @Body UserOrganizations jsonStr); @POST("org/{org}/repos") // create new repository under org Call createNewUserOrgRepository(@Header("Authorization") String token, @Path("org") String orgName, @Body OrganizationRepository jsonStr); @GET("user/orgs") // get user organizations Call> getOrgOwners(@Header("Authorization") String token); @GET("user/repos") // get user repositories Call> getUserRepositories(@Header("Authorization") String token, @Query("page") int page, @Query("limit") int limit); @POST("user/repos") // create new repository Call createNewUserRepository(@Header("Authorization") String token, @Body OrganizationRepository jsonStr); @GET("repos/{owner}/{repo}") // get repo information Call getUserRepository(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName); @GET("repos/{owner}/{repo}/issues") // get issues by repo Call> getIssues(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("page") int page, @Query("limit") int limit, @Query("type") String requestType, @Query("state") String issueState); @GET("repos/{owner}/{repo}/issues/{index}") // get issue by id Call getIssueByIndex(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("index") int issueIndex); @GET("repos/{owner}/{repo}/issues/{index}/comments") // get issue comments Call> getIssueComments(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("index") int issueIndex); @POST("repos/{owner}/{repo}/issues/{index}/comments") // reply to issue Call replyCommentToIssue(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("index") int issueIndex, @Body Issues jsonStr); @GET("repos/{owner}/{repo}/milestones") // get milestones by repo Call> getMilestones(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Query("page") int page, @Query("limit") int limit, @Query("state") String state); @GET("repos/{owner}/{repo}/branches") // get branches Call> getBranches(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName); @GET("repos/{owner}/{repo}/releases") // get releases Call> getReleases(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName); @GET("repos/{owner}/{repo}/collaborators") // get collaborators list Call> getCollaborators(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName); @POST("repos/{owner}/{repo}/milestones") // create new milestone Call createMilestone(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Body Milestones jsonStr); @POST("repos/{owner}/{repo}/issues") // create new issue Call createNewIssue(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Body CreateIssue jsonStr); @GET("repos/{owner}/{repo}/labels") // get labels list Call> getlabels(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName); @GET("users/{username}/repos") // get current logged in user repositories Call> getCurrentUserRepositories(@Header("Authorization") String token, @Path("username") String username, @Query("page") int page, @Query("limit") int limit); @POST("repos/{owner}/{repo}/labels") // create label Call createLabel(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Body CreateLabel jsonStr); @DELETE("repos/{owner}/{repo}/labels/{index}") // delete a label Call deleteLabel(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("index") int labelIndex); @PATCH("repos/{owner}/{repo}/labels/{index}") // update / patch a label Call patchLabel(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("index") int labelIndex, @Body CreateLabel jsonStr); @GET("user/starred") // get user starred repositories Call> getUserStarredRepos(@Header("Authorization") String token, @Query("page") int page, @Query("limit") int limit); @GET("orgs/{orgName}/repos") // get repositories by org Call> getReposByOrg(@Header("Authorization") String token, @Path("orgName") String orgName, @Query("page") int page, @Query("limit") int limit); @GET("orgs/{orgName}/teams") // get teams by org Call> getTeamsByOrg(@Header("Authorization") String token, @Path("orgName") String orgName); @GET("orgs/{orgName}/members") // get members by org Call> getMembersByOrg(@Header("Authorization") String token, @Path("orgName") String orgName); @GET("teams/{teamIndex}/members") // get team members by org Call> getTeamMembersByOrg(@Header("Authorization") String token, @Path("teamIndex") int teamIndex); @POST("orgs/{orgName}/teams") // create new team Call createTeamsByOrg(@Header("Authorization") String token, @Path("orgName") String orgName, @Body Teams jsonStr); @GET("users/search") // search users Call getUserBySearch(@Header("Authorization") String token, @Query("q") String searchKeyword, @Query("limit") int limit); @GET("repos/{owner}/{repo}/collaborators/{collaborator}") // check collaborator in repo Call checkRepoCollaborator(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("collaborator") String repoCollaborator); @DELETE("repos/{owner}/{repo}/collaborators/{username}") // delete a collaborator from repository Call deleteCollaborator(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("username") String username); @PUT("repos/{owner}/{repo}/collaborators/{username}") // add a collaborator to repository Call addCollaborator(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("username") String username, @Body Permission jsonStr); @PATCH("repos/{owner}/{repo}/issues/comments/{commentId}") // edit a comment Call patchIssueComment(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("commentId") int commentId, @Body IssueComments jsonStr); @GET("user/followers") // get user followers Call> getFollowers(@Header("Authorization") String token); @GET("user/following") // get following Call> getFollowing(@Header("Authorization") String token); @POST("user/emails") // add new email Call addNewEmail(@Header("Authorization") String token, @Body AddEmail jsonStr); @GET("user/emails") // get user emails Call> getUserEmails(@Header("Authorization") String token); @GET("repos/{owner}/{repo}/issues/{index}/labels") // get issue labels Call> getIssueLabels(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("index") int issueIndex); @PUT("repos/{owner}/{repo}/issues/{index}/labels") // replace an issue's labels Call updateIssueLabels(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("index") int issueIndex, @Body Labels jsonStr); @GET("repos/{owner}/{repo}/raw/{filename}") // get file contents Call getFileContents(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("filename") String filename); @POST("admin/users") // create new user Call createNewUser(@Header("Authorization") String token, @Body UserInfo jsonStr); @PATCH("repos/{owner}/{repo}/issues/{issueIndex}") // patch issue data Call patchIssue(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("issueIndex") int issueIndex, @Body CreateIssue jsonStr); @GET("orgs/{orgName}") // get an organization Call getOrganization(@Header("Authorization") String token, @Path("orgName") String orgName); @PATCH("repos/{owner}/{repo}/issues/{issueIndex}") // close / reopen issue Call closeReopenIssue(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("issueIndex") int issueIndex, @Body UpdateIssueState jsonStr); @POST("repos/{owner}/{repo}/releases") // create new release Call createNewRelease(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Body Releases jsonStr); @PATCH("repos/{owner}/{repo}/issues/{issueIndex}") // patch issue assignees Call patchIssueAssignees(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("issueIndex") int issueIndex, @Body UpdateIssueAssignees jsonStr); @GET("admin/users") // get all users Call> adminGetUsers(@Header("Authorization") String token); @GET("repos/{owner}/{repo}/stargazers") // get all repo stars Call> getRepoStargazers(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName); @GET("repos/{owner}/{repo}/subscribers") // get all repo watchers Call> getRepoWatchers(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName); @GET("repos/search") // get all the repos which match the query string Call queryRepos(@Header("Authorization") String token, @Query("q") String searchKeyword, @Query("private") Boolean repoTypeInclude, @Query("sort") String sort, @Query("order") String order, @Query("limit") int limit); @POST("repos/{owner}/{repo}/contents/{file}") // create new file Call createNewFile(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("file") String fileName, @Body NewFile jsonStr); @GET("repos/{owner}/{repo}/contents") // get all the files and dirs of a repository Call> getFiles(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Query("ref") String ref); @GET("repos/{owner}/{repo}/contents/{file}") // get single file contents Call getSingleFileContents(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("file") String file, @Query("ref") String ref); @GET("repos/{owner}/{repo}/contents/{fileDir}") // get all the sub files and dirs of a repository Call> getDirFiles(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("fileDir") String fileDir, @Query("ref") String ref); @GET("user/starred/{owner}/{repo}") // check star status of a repository Call checkRepoStarStatus(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName); @PUT("user/starred/{owner}/{repo}") // star a repository Call starRepository(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName); @DELETE("user/starred/{owner}/{repo}") // un star a repository Call unStarRepository(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName); @GET("repos/{owner}/{repo}/subscription") // check watch status of a repository Call checkRepoWatchStatus(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName); @PUT("repos/{owner}/{repo}/subscription") // watch a repository Call watchRepository(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName); @DELETE("repos/{owner}/{repo}/subscription") // un watch a repository Call unWatchRepository(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName); @GET("repos/{owner}/{repo}/issues/{index}/subscriptions/check") Call checkIssueWatchStatus(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("index") int issueIndex); @PUT("repos/{owner}/{repo}/issues/{index}/subscriptions/{user}") // subscribe user to issue Call addIssueSubscriber(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("index") int issueIndex, @Path("user") String issueSubscriber); @DELETE("repos/{owner}/{repo}/issues/{index}/subscriptions/{user}") // unsubscribe user to issue Call delIssueSubscriber(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("index") int issueIndex, @Path("user") String issueSubscriber); @GET("repos/{owner}/{repo}/pulls") // get repository pull requests Call> getPullRequests(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("page") int page, @Query("state") String state, @Query("limit") int limit); @GET("repos/{owner}/{repo}/pulls/{index}.diff") // get pull diff file contents Call getPullDiffContent(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Path("index") String pullIndex); @POST("repos/{owner}/{repo}/pulls/{index}/merge") // merge a pull request Call mergePullRequest(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("index") int index, @Body MergePullRequest jsonStr); @GET("repos/{owner}/{repo}/commits") // get all commits Call> getRepositoryCommits(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("page") int page, @Query("sha") String branchName, @Query("limit") int limit); @PATCH("repos/{owner}/{repo}/milestones/{index}") // close / reopen milestone Call closeReopenMilestone(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("index") int index, @Body Milestones jsonStr); @DELETE("repos/{owner}/{repo}/issues/comments/{id}") // delete own comment from issue Call deleteComment(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("id") int commentIndex); @GET("teams/{teamId}/members/{username}") // check team member Call checkTeamMember(@Header("Authorization") String token, @Path("teamId") int teamId, @Path("username") String username); @PUT("teams/{teamId}/members/{username}") // add new team member Call addTeamMember(@Header("Authorization") String token, @Path("teamId") int teamId, @Path("username") String username); @DELETE("teams/{teamId}/members/{username}") // remove team member Call removeTeamMember(@Header("Authorization") String token, @Path("teamId") int teamId, @Path("username") String username); @DELETE("repos/{owner}/{repo}/branches/{branch}") // delete branch Call deleteBranch(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("branch") String branchName); }