{
+
+ private DateFormat dateFormat;
+
+ public DateTypeAdapter() {}
+
+ public DateTypeAdapter(DateFormat dateFormat) {
+ this.dateFormat = dateFormat;
+ }
+
+ public void setFormat(DateFormat dateFormat) {
+ this.dateFormat = dateFormat;
+ }
+
+ @Override
+ public void write(JsonWriter out, Date date) throws IOException {
+ if (date == null) {
+ out.nullValue();
+ } else {
+ String value;
+ if (dateFormat != null) {
+ value = dateFormat.format(date);
+ } else {
+ value = ISO8601Utils.format(date, true);
+ }
+ out.value(value);
+ }
+ }
+
+ @Override
+ public Date read(JsonReader in) throws IOException {
+ try {
+ switch (in.peek()) {
+ case NULL:
+ in.nextNull();
+ return null;
+ default:
+ String date = in.nextString();
+ try {
+ if (dateFormat != null) {
+ return dateFormat.parse(date);
+ }
+ return ISO8601Utils.parse(date, new ParsePosition(0));
+ } catch (ParseException e) {
+ throw new JsonParseException(e);
+ }
+ }
+ } catch (IllegalArgumentException e) {
+ throw new JsonParseException(e);
+ }
+ }
+ }
+
+ public JSON setDateFormat(DateFormat dateFormat) {
+ dateTypeAdapter.setFormat(dateFormat);
+ return this;
+ }
+
+ public JSON setSqlDateFormat(DateFormat dateFormat) {
+ sqlDateTypeAdapter.setFormat(dateFormat);
+ return this;
+ }
+}
diff --git a/src/main/java/org/gitnex/tea4j/v2/StringUtil.java b/src/main/java/org/gitnex/tea4j/v2/StringUtil.java
new file mode 100644
index 0000000..ef928d2
--- /dev/null
+++ b/src/main/java/org/gitnex/tea4j/v2/StringUtil.java
@@ -0,0 +1,52 @@
+/*
+ * Gitea API.
+ * This documentation describes the Gitea API.
+ *
+ * OpenAPI spec version: {{AppVer | JSEscape | Safe}}
+ *
+ *
+ * NOTE: This class is auto generated by the swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen.git
+ * Do not edit the class manually.
+ */
+
+package org.gitnex.tea4j.v2;
+
+public class StringUtil {
+ /**
+ * Check if the given array contains the given value (with case-insensitive comparison).
+ *
+ * @param array The array
+ * @param value The value to search
+ * @return true if the array contains the value
+ */
+ public static boolean containsIgnoreCase(String[] array, String value) {
+ for (String str : array) {
+ if (value == null && str == null) return true;
+ if (value != null && value.equalsIgnoreCase(str)) return true;
+ }
+ return false;
+ }
+
+ /**
+ * Join an array of strings with the given separator.
+ *
+ * Note: This might be replaced by utility method from commons-lang or guava someday if one of
+ * those libraries is added as dependency.
+ *
+ * @param array The array of strings
+ * @param separator The separator
+ * @return the resulting string
+ */
+ public static String join(String[] array, String separator) {
+ int len = array.length;
+ if (len == 0) return "";
+
+ StringBuilder out = new StringBuilder();
+ out.append(array[0]);
+ for (int i = 1; i < len; i++) {
+ out.append(separator).append(array[i]);
+ }
+ return out.toString();
+ }
+}
diff --git a/src/main/java/org/gitnex/tea4j/v2/apis/AdminApi.java b/src/main/java/org/gitnex/tea4j/v2/apis/AdminApi.java
new file mode 100644
index 0000000..2e5d674
--- /dev/null
+++ b/src/main/java/org/gitnex/tea4j/v2/apis/AdminApi.java
@@ -0,0 +1,174 @@
+package org.gitnex.tea4j.v2.apis;
+
+import java.util.List;
+import org.gitnex.tea4j.v2.CollectionFormats.*;
+import org.gitnex.tea4j.v2.models.CreateKeyOption;
+import org.gitnex.tea4j.v2.models.CreateOrgOption;
+import org.gitnex.tea4j.v2.models.CreateRepoOption;
+import org.gitnex.tea4j.v2.models.CreateUserOption;
+import org.gitnex.tea4j.v2.models.Cron;
+import org.gitnex.tea4j.v2.models.EditUserOption;
+import org.gitnex.tea4j.v2.models.Organization;
+import org.gitnex.tea4j.v2.models.PublicKey;
+import org.gitnex.tea4j.v2.models.Repository;
+import org.gitnex.tea4j.v2.models.User;
+import retrofit2.Call;
+import retrofit2.http.*;
+
+public interface AdminApi {
+ /**
+ * Adopt unadopted files as a repository
+ *
+ * @param owner owner of the repo (required)
+ * @param repo name of the repo (required)
+ * @return Call<Void>
+ */
+ @POST("admin/unadopted/{owner}/{repo}")
+ Call adminAdoptRepository(
+ @retrofit2.http.Path("owner") String owner, @retrofit2.http.Path("repo") String repo);
+
+ /**
+ * Create an organization
+ *
+ * @param body (required)
+ * @param username username of the user that will own the created organization (required)
+ * @return Call<Organization>
+ */
+ @Headers({"Content-Type:application/json"})
+ @POST("admin/users/{username}/orgs")
+ Call adminCreateOrg(
+ @retrofit2.http.Body CreateOrgOption body, @retrofit2.http.Path("username") String username);
+
+ /**
+ * Add a public key on behalf of a user
+ *
+ * @param username username of the user (required)
+ * @param body (optional)
+ * @return Call<PublicKey>
+ */
+ @Headers({"Content-Type:application/json"})
+ @POST("admin/users/{username}/keys")
+ Call adminCreatePublicKey(
+ @retrofit2.http.Path("username") String username, @retrofit2.http.Body CreateKeyOption body);
+
+ /**
+ * Create a repository on behalf of a user
+ *
+ * @param body (required)
+ * @param username username of the user. This user will own the created repository (required)
+ * @return Call<Repository>
+ */
+ @Headers({"Content-Type:application/json"})
+ @POST("admin/users/{username}/repos")
+ Call adminCreateRepo(
+ @retrofit2.http.Body CreateRepoOption body, @retrofit2.http.Path("username") String username);
+
+ /**
+ * Create a user
+ *
+ * @param body (optional)
+ * @return Call<User>
+ */
+ @Headers({"Content-Type:application/json"})
+ @POST("admin/users")
+ Call adminCreateUser(@retrofit2.http.Body CreateUserOption body);
+
+ /**
+ * List cron tasks
+ *
+ * @param page page number of results to return (1-based) (optional)
+ * @param limit page size of results (optional)
+ * @return Call<List<Cron>>
+ */
+ @GET("admin/cron")
+ Call> adminCronList(
+ @retrofit2.http.Query("page") Integer page, @retrofit2.http.Query("limit") Integer limit);
+
+ /**
+ * Run cron task
+ *
+ * @param task task to run (required)
+ * @return Call<Void>
+ */
+ @POST("admin/cron/{task}")
+ Call adminCronRun(@retrofit2.http.Path("task") String task);
+
+ /**
+ * Delete unadopted files
+ *
+ * @param owner owner of the repo (required)
+ * @param repo name of the repo (required)
+ * @return Call<Void>
+ */
+ @DELETE("admin/unadopted/{owner}/{repo}")
+ Call adminDeleteUnadoptedRepository(
+ @retrofit2.http.Path("owner") String owner, @retrofit2.http.Path("repo") String repo);
+
+ /**
+ * Delete a user
+ *
+ * @param username username of user to delete (required)
+ * @return Call<Void>
+ */
+ @DELETE("admin/users/{username}")
+ Call adminDeleteUser(@retrofit2.http.Path("username") String username);
+
+ /**
+ * Delete a user's public key
+ *
+ * @param username username of user (required)
+ * @param id id of the key to delete (required)
+ * @return Call<Void>
+ */
+ @DELETE("admin/users/{username}/keys/{id}")
+ Call adminDeleteUserPublicKey(
+ @retrofit2.http.Path("username") String username, @retrofit2.http.Path("id") Long id);
+
+ /**
+ * Edit an existing user
+ *
+ * @param username username of user to edit (required)
+ * @param body (optional)
+ * @return Call<User>
+ */
+ @Headers({"Content-Type:application/json"})
+ @PATCH("admin/users/{username}")
+ Call adminEditUser(
+ @retrofit2.http.Path("username") String username, @retrofit2.http.Body EditUserOption body);
+
+ /**
+ * List all organizations
+ *
+ * @param page page number of results to return (1-based) (optional)
+ * @param limit page size of results (optional)
+ * @return Call<List<Organization>>
+ */
+ @GET("admin/orgs")
+ Call> adminGetAllOrgs(
+ @retrofit2.http.Query("page") Integer page, @retrofit2.http.Query("limit") Integer limit);
+
+ /**
+ * List all users
+ *
+ * @param page page number of results to return (1-based) (optional)
+ * @param limit page size of results (optional)
+ * @return Call<List<User>>
+ */
+ @GET("admin/users")
+ Call> adminGetAllUsers(
+ @retrofit2.http.Query("page") Integer page, @retrofit2.http.Query("limit") Integer limit);
+
+ /**
+ * List unadopted repositories
+ *
+ * @param page page number of results to return (1-based) (optional)
+ * @param limit page size of results (optional)
+ * @param pattern pattern of repositories to search for (optional)
+ * @return Call<List<String>>
+ */
+ @GET("admin/unadopted")
+ Call> adminUnadoptedList(
+ @retrofit2.http.Query("page") Integer page,
+ @retrofit2.http.Query("limit") Integer limit,
+ @retrofit2.http.Query("pattern") String pattern);
+}
diff --git a/src/main/java/org/gitnex/tea4j/v2/apis/IssueApi.java b/src/main/java/org/gitnex/tea4j/v2/apis/IssueApi.java
new file mode 100644
index 0000000..8ea8a15
--- /dev/null
+++ b/src/main/java/org/gitnex/tea4j/v2/apis/IssueApi.java
@@ -0,0 +1,873 @@
+package org.gitnex.tea4j.v2.apis;
+
+import java.util.Date;
+import java.util.List;
+import org.gitnex.tea4j.v2.CollectionFormats.*;
+import org.gitnex.tea4j.v2.models.AddTimeOption;
+import org.gitnex.tea4j.v2.models.Comment;
+import org.gitnex.tea4j.v2.models.CreateIssueCommentOption;
+import org.gitnex.tea4j.v2.models.CreateIssueOption;
+import org.gitnex.tea4j.v2.models.CreateLabelOption;
+import org.gitnex.tea4j.v2.models.CreateMilestoneOption;
+import org.gitnex.tea4j.v2.models.EditDeadlineOption;
+import org.gitnex.tea4j.v2.models.EditIssueCommentOption;
+import org.gitnex.tea4j.v2.models.EditIssueOption;
+import org.gitnex.tea4j.v2.models.EditLabelOption;
+import org.gitnex.tea4j.v2.models.EditMilestoneOption;
+import org.gitnex.tea4j.v2.models.EditReactionOption;
+import org.gitnex.tea4j.v2.models.Issue;
+import org.gitnex.tea4j.v2.models.IssueDeadline;
+import org.gitnex.tea4j.v2.models.IssueLabelsOption;
+import org.gitnex.tea4j.v2.models.Label;
+import org.gitnex.tea4j.v2.models.Milestone;
+import org.gitnex.tea4j.v2.models.Reaction;
+import org.gitnex.tea4j.v2.models.TimelineComment;
+import org.gitnex.tea4j.v2.models.TrackedTime;
+import org.gitnex.tea4j.v2.models.User;
+import org.gitnex.tea4j.v2.models.WatchInfo;
+import retrofit2.Call;
+import retrofit2.http.*;
+
+public interface IssueApi {
+ /**
+ * Add a label to an issue
+ *
+ * @param owner owner of the repo (required)
+ * @param repo name of the repo (required)
+ * @param index index of the issue (required)
+ * @param body (optional)
+ * @return Call<List<Label>>
+ */
+ @Headers({"Content-Type:application/json"})
+ @POST("repos/{owner}/{repo}/issues/{index}/labels")
+ Call> issueAddLabel(
+ @retrofit2.http.Path("owner") String owner,
+ @retrofit2.http.Path("repo") String repo,
+ @retrofit2.http.Path("index") Long index,
+ @retrofit2.http.Body IssueLabelsOption body);
+
+ /**
+ * Subscribe user to issue
+ *
+ * @param owner owner of the repo (required)
+ * @param repo name of the repo (required)
+ * @param index index of the issue (required)
+ * @param user user to subscribe (required)
+ * @return Call<Void>
+ */
+ @PUT("repos/{owner}/{repo}/issues/{index}/subscriptions/{user}")
+ Call issueAddSubscription(
+ @retrofit2.http.Path("owner") String owner,
+ @retrofit2.http.Path("repo") String repo,
+ @retrofit2.http.Path("index") Long index,
+ @retrofit2.http.Path("user") String user);
+
+ /**
+ * Add tracked time to a issue
+ *
+ * @param owner owner of the repo (required)
+ * @param repo name of the repo (required)
+ * @param index index of the issue (required)
+ * @param body (optional)
+ * @return Call<TrackedTime>
+ */
+ @Headers({"Content-Type:application/json"})
+ @POST("repos/{owner}/{repo}/issues/{index}/times")
+ Call issueAddTime(
+ @retrofit2.http.Path("owner") String owner,
+ @retrofit2.http.Path("repo") String repo,
+ @retrofit2.http.Path("index") Long index,
+ @retrofit2.http.Body AddTimeOption body);
+
+ /**
+ * Check if user is subscribed to an issue
+ *
+ * @param owner owner of the repo (required)
+ * @param repo name of the repo (required)
+ * @param index index of the issue (required)
+ * @return Call<WatchInfo>
+ */
+ @GET("repos/{owner}/{repo}/issues/{index}/subscriptions/check")
+ Call issueCheckSubscription(
+ @retrofit2.http.Path("owner") String owner,
+ @retrofit2.http.Path("repo") String repo,
+ @retrofit2.http.Path("index") Long index);
+
+ /**
+ * Remove all labels from an issue
+ *
+ * @param owner owner of the repo (required)
+ * @param repo name of the repo (required)
+ * @param index index of the issue (required)
+ * @return Call<Void>
+ */
+ @DELETE("repos/{owner}/{repo}/issues/{index}/labels")
+ Call issueClearLabels(
+ @retrofit2.http.Path("owner") String owner,
+ @retrofit2.http.Path("repo") String repo,
+ @retrofit2.http.Path("index") Long index);
+
+ /**
+ * Add a comment to an issue
+ *
+ * @param owner owner of the repo (required)
+ * @param repo name of the repo (required)
+ * @param index index of the issue (required)
+ * @param body (optional)
+ * @return Call<Comment>
+ */
+ @Headers({"Content-Type:application/json"})
+ @POST("repos/{owner}/{repo}/issues/{index}/comments")
+ Call issueCreateComment(
+ @retrofit2.http.Path("owner") String owner,
+ @retrofit2.http.Path("repo") String repo,
+ @retrofit2.http.Path("index") Long index,
+ @retrofit2.http.Body CreateIssueCommentOption body);
+
+ /**
+ * Create an issue. If using deadline only the date will be taken into account, and time of day
+ * ignored.
+ *
+ * @param owner owner of the repo (required)
+ * @param repo name of the repo (required)
+ * @param body (optional)
+ * @return Call<Issue>
+ */
+ @Headers({"Content-Type:application/json"})
+ @POST("repos/{owner}/{repo}/issues")
+ Call issueCreateIssue(
+ @retrofit2.http.Path("owner") String owner,
+ @retrofit2.http.Path("repo") String repo,
+ @retrofit2.http.Body CreateIssueOption body);
+
+ /**
+ * Create a label
+ *
+ * @param owner owner of the repo (required)
+ * @param repo name of the repo (required)
+ * @param body (optional)
+ * @return Call<Label>
+ */
+ @Headers({"Content-Type:application/json"})
+ @POST("repos/{owner}/{repo}/labels")
+ Call