getDefaultPerPageParam(boolean customAttributesEnabled) {
-
- GitLabApiForm form = new GitLabApiForm().withParam(PER_PAGE_PARAM, getDefaultPerPage());
- if (customAttributesEnabled)
- return (form.withParam("with_custom_attributes", true).asMap());
-
- return (form.asMap());
- }
+ protected final GitLabApi gitLabApi;
+
+ public AbstractApi(final GitLabApi gitLabApi) {
+ this.gitLabApi = gitLabApi;
+ }
+
+ /**
+ * Returns the project ID or path from the provided Integer, String, or Project instance.
+ *
+ * @param obj the object to determine the ID or path from
+ * @return the project ID or path from the provided Long, String, or Project instance
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ public Object getProjectIdOrPath(final Object obj) throws GitLabApiException {
+
+ if (obj == null) {
+ throw (new RuntimeException("Cannot determine ID or path from null object"));
+ } else if (obj instanceof Long) {
+ return (obj);
+ } else if (obj instanceof String) {
+ return (urlEncode(((String) obj).trim()));
+ } else if (obj instanceof Project) {
+
+ final Long id = ((Project) obj).getId();
+ if (id != null && id.longValue() > 0) {
+ return (id);
+ }
+
+ final String path = ((Project) obj).getPathWithNamespace();
+ if (path != null && path.trim().length() > 0) {
+ return (urlEncode(path.trim()));
+ }
+
+ throw (new RuntimeException("Cannot determine ID or path from provided Project instance"));
+
+ } else {
+ throw (new RuntimeException(
+ "Cannot determine ID or path from provided "
+ + obj.getClass().getSimpleName()
+ + " instance, must be Long, String, or a Project instance"));
+ }
+ }
+
+ /**
+ * Returns the group ID or path from the provided Integer, String, or Group instance.
+ *
+ * @param obj the object to determine the ID or path from
+ * @return the group ID or path from the provided Long, String, or Group instance
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ public Object getGroupIdOrPath(final Object obj) throws GitLabApiException {
+
+ if (obj == null) {
+ throw (new RuntimeException("Cannot determine ID or path from null object"));
+ } else if (obj instanceof Long) {
+ return (obj);
+ } else if (obj instanceof String) {
+ return (urlEncode(((String) obj).trim()));
+ } else if (obj instanceof Group) {
+
+ final Long id = ((Group) obj).getId();
+ if (id != null && id.longValue() > 0) {
+ return (id);
+ }
+
+ final String path = ((Group) obj).getFullPath();
+ if (path != null && path.trim().length() > 0) {
+ return (urlEncode(path.trim()));
+ }
+
+ throw (new RuntimeException("Cannot determine ID or path from provided Group instance"));
+
+ } else {
+ throw (new RuntimeException(
+ "Cannot determine ID or path from provided "
+ + obj.getClass().getSimpleName()
+ + " instance, must be Long, String, or a Group instance"));
+ }
+ }
+
+ /**
+ * Returns the user ID or path from the provided Integer, String, or User instance.
+ *
+ * @param obj the object to determine the ID or username from
+ * @return the user ID or username from the provided Integer, String, or User instance
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ public Object getUserIdOrUsername(final Object obj) throws GitLabApiException {
+
+ if (obj == null) {
+ throw (new RuntimeException("Cannot determine ID or username from null object"));
+ } else if (obj instanceof Long) {
+ return (obj);
+ } else if (obj instanceof String) {
+ return (urlEncode(((String) obj).trim()));
+ } else if (obj instanceof User) {
+
+ final Long id = ((User) obj).getId();
+ if (id != null && id.longValue() > 0) {
+ return (id);
+ }
+
+ final String username = ((User) obj).getUsername();
+ if (username != null && username.trim().length() > 0) {
+ return (urlEncode(username.trim()));
+ }
+
+ throw (new RuntimeException("Cannot determine ID or username from provided User instance"));
+
+ } else {
+ throw (new RuntimeException(
+ "Cannot determine ID or username from provided "
+ + obj.getClass().getSimpleName()
+ + " instance, must be Integer, String, or a User instance"));
+ }
+ }
+
+ /**
+ * Returns the label ID or name from the provided Integer, String, or Label instance.
+ *
+ * @param obj the object to determine the ID or name from
+ * @return the user ID or name from the provided Integer, String, or Label instance
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ public Object getLabelIdOrName(final Object obj) throws GitLabApiException {
+
+ if (obj == null) {
+ throw (new RuntimeException("Cannot determine ID or name from null object"));
+ } else if (obj instanceof Long) {
+ return (obj);
+ } else if (obj instanceof String) {
+ return (urlEncode(((String) obj).trim()));
+ } else if (obj instanceof Label) {
+
+ final Long id = ((Label) obj).getId();
+ if (id != null && id.longValue() > 0) {
+ return (id);
+ }
+
+ final String name = ((Label) obj).getName();
+ if (name != null && name.trim().length() > 0) {
+ return (urlEncode(name.trim()));
+ }
+
+ throw (new RuntimeException("Cannot determine ID or name from provided Label instance"));
+
+ } else {
+ throw (new RuntimeException(
+ "Cannot determine ID or name from provided "
+ + obj.getClass().getSimpleName()
+ + " instance, must be Integer, String, or a Label instance"));
+ }
+ }
+
+ protected ApiVersion getApiVersion() {
+ return (gitLabApi.getApiVersion());
+ }
+
+ protected boolean isApiVersion(final ApiVersion apiVersion) {
+ return (gitLabApi.getApiVersion() == apiVersion);
+ }
+
+ protected int getDefaultPerPage() {
+ return (gitLabApi.getDefaultPerPage());
+ }
+
+ protected GitLabApiClient getApiClient() {
+ return (gitLabApi.getApiClient());
+ }
+
+ /**
+ * Encode a string to be used as in-path argument for a gitlab api request.
+ *
+ * Standard URL encoding changes spaces to plus signs, but for arguments that are part of the
+ * path, like the :file_path in a "Get raw file" request, gitlab expects spaces to be encoded with
+ * %20.
+ *
+ * @param s the string to encode
+ * @return encoded version of s with spaces encoded as %2F
+ * @throws GitLabApiException if encoding throws an exception
+ */
+ protected String urlEncode(final String s) throws GitLabApiException {
+ return (UrlEncoder.urlEncode(s));
+ }
+
+ /**
+ * Perform an HTTP GET call with the specified query parameters and path objects, returning a
+ * ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param queryParams multivalue map of request parameters
+ * @param pathArgs variable list of arguments used to build the URI
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response get(
+ final Response.Status expectedStatus,
+ final MultivaluedMap queryParams,
+ final Object... pathArgs)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().get(queryParams, pathArgs), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform an HTTP GET call with the specified query parameters and path objects, returning a
+ * ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param queryParams multivalue map of request parameters
+ * @param accepts if non-empty will set the Accepts header to this value
+ * @param pathArgs variable list of arguments used to build the URI
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response getWithAccepts(
+ final Response.Status expectedStatus,
+ final MultivaluedMap queryParams,
+ final String accepts,
+ final Object... pathArgs)
+ throws GitLabApiException {
+ try {
+ return validate(
+ getApiClient().getWithAccepts(queryParams, accepts, pathArgs), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform an HTTP GET call with the specified query parameters and URL, returning a
+ * ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param queryParams multivalue map of request parameters
+ * @param url the fully formed path to the GitLab API endpoint
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response get(
+ final Response.Status expectedStatus,
+ final MultivaluedMap queryParams,
+ final URL url)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().get(queryParams, url), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform an HTTP HEAD call with the specified query parameters and path objects, returning a
+ * ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param queryParams multivalue map of request parameters
+ * @param pathArgs variable list of arguments used to build the URI
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response head(
+ final Response.Status expectedStatus,
+ final MultivaluedMap queryParams,
+ final Object... pathArgs)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().head(queryParams, pathArgs), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform an HTTP PATCH call with the specified query parameters and path objects, returning a
+ * ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param queryParams multivalue map of request parameters
+ * @param pathArgs variable list of arguments used to build the URI
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response patch(
+ final Response.Status expectedStatus,
+ final MultivaluedMap queryParams,
+ final Object... pathArgs)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().patch(queryParams, pathArgs), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform an HTTP PATCH call with the specified query parameters and URL, returning a
+ * ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param queryParams multivalue map of request parameters
+ * @param url the fully formed path to the GitLab API endpoint
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response patch(
+ final Response.Status expectedStatus,
+ final MultivaluedMap queryParams,
+ final URL url)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().patch(queryParams, url), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform an HTTP POST call with the specified form data and path objects, returning a
+ * ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param formData the Form containing the name/value pairs for the POST data
+ * @param pathArgs variable list of arguments used to build the URI
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response post(
+ final Response.Status expectedStatus, final Form formData, final Object... pathArgs)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().post(formData, pathArgs), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform an HTTP POST call with the specified payload object and path objects, returning a
+ * ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param payload the object instance that will be serialized to JSON and used as the POST data
+ * @param pathArgs variable list of arguments used to build the URI
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response post(
+ final Response.Status expectedStatus, final Object payload, final Object... pathArgs)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().post(payload, pathArgs), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform an HTTP POST call with the specified payload object and path objects, returning a
+ * ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param stream the StreamingOutput that will be used for the POST data
+ * @param mediaType the content-type for the streamed data
+ * @param pathArgs variable list of arguments used to build the URI
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response post(
+ final Response.Status expectedStatus,
+ final StreamingOutput stream,
+ final String mediaType,
+ final Object... pathArgs)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().post(stream, mediaType, pathArgs), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform an HTTP POST call with the specified form data and path objects, returning a
+ * ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param queryParams multivalue map of request parameters
+ * @param pathArgs variable list of arguments used to build the URI
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response post(
+ final Response.Status expectedStatus,
+ final MultivaluedMap queryParams,
+ final Object... pathArgs)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().post(queryParams, pathArgs), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform an HTTP POST call with the specified form data and URL, returning a ClientResponse
+ * instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param formData the Form containing the name/value pairs for the POST data
+ * @param url the fully formed path to the GitLab API endpoint
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response post(final Response.Status expectedStatus, final Form formData, final URL url)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().post(formData, url), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform a file upload with the specified File instance and path objects, returning a
+ * ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param name the name for the form field that contains the file name
+ * @param fileToUpload a File instance pointing to the file to upload
+ * @param mediaType unused; will be removed in the next major version
+ * @param pathArgs variable list of arguments used to build the URI
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response upload(
+ final Response.Status expectedStatus,
+ final String name,
+ final File fileToUpload,
+ final String mediaType,
+ final Object... pathArgs)
+ throws GitLabApiException {
+ try {
+ return validate(
+ getApiClient().upload(name, fileToUpload, mediaType, pathArgs), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ protected Response upload(
+ final Response.Status expectedStatus,
+ final String name,
+ final InputStream inputStream,
+ final String filename,
+ final String mediaType,
+ final Object... pathArgs)
+ throws GitLabApiException {
+ try {
+ return validate(
+ getApiClient().upload(name, inputStream, filename, mediaType, pathArgs), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform a file upload with the specified File instance and path objects, returning a
+ * ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param name the name for the form field that contains the file name
+ * @param fileToUpload a File instance pointing to the file to upload
+ * @param mediaType unused; will be removed in the next major version
+ * @param url the fully formed path to the GitLab API endpoint
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response upload(
+ final Response.Status expectedStatus,
+ final String name,
+ final File fileToUpload,
+ final String mediaType,
+ final URL url)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().upload(name, fileToUpload, mediaType, url), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform a file upload with the specified File instance and path objects, returning a
+ * ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param name the name for the form field that contains the file name
+ * @param fileToUpload a File instance pointing to the file to upload
+ * @param mediaType unused; will be removed in the next major version
+ * @param formData the Form containing the name/value pairs
+ * @param url the fully formed path to the GitLab API endpoint
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response upload(
+ final Response.Status expectedStatus,
+ final String name,
+ final File fileToUpload,
+ final String mediaType,
+ final Form formData,
+ final URL url)
+ throws GitLabApiException {
+
+ try {
+ return validate(
+ getApiClient().upload(name, fileToUpload, mediaType, formData, url), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform an HTTP PUT call with the specified form data and path objects, returning a
+ * ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param queryParams multivalue map of request parameters
+ * @param pathArgs variable list of arguments used to build the URI
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response put(
+ final Response.Status expectedStatus,
+ final MultivaluedMap queryParams,
+ final Object... pathArgs)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().put(queryParams, pathArgs), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform an HTTP PUT call with the specified form data and URL, returning a ClientResponse
+ * instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param queryParams multivalue map of request parameters
+ * @param url the fully formed path to the GitLab API endpoint
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response put(
+ final Response.Status expectedStatus,
+ final MultivaluedMap queryParams,
+ final URL url)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().put(queryParams, url), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform an HTTP PUT call with the specified payload object and path objects, returning a
+ * ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param payload the object instance that will be serialized to JSON and used as the PUT data
+ * @param pathArgs variable list of arguments used to build the URI
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response put(
+ final Response.Status expectedStatus, final Object payload, final Object... pathArgs)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().put(payload, pathArgs), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform an HTTP PUT call with the specified form data and path objects, returning a
+ * ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param formData the Form containing the name/value pairs for the POST data
+ * @param pathArgs variable list of arguments used to build the URI
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response putWithFormData(
+ final Response.Status expectedStatus, final Form formData, final Object... pathArgs)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().put(formData, pathArgs), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform a file upload using the HTTP PUT method with the specified File instance and path
+ * objects, returning a ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param name the name for the form field that contains the file name
+ * @param fileToUpload a File instance pointing to the file to upload
+ * @param pathArgs variable list of arguments used to build the URI
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response putUpload(
+ final Response.Status expectedStatus,
+ final String name,
+ final File fileToUpload,
+ final Object... pathArgs)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().putUpload(name, fileToUpload, pathArgs), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform a file upload using the HTTP PUT method with the specified File instance and path
+ * objects, returning a ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param name the name for the form field that contains the file name
+ * @param fileToUpload a File instance pointing to the file to upload
+ * @param url the fully formed path to the GitLab API endpoint
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response putUpload(
+ final Response.Status expectedStatus,
+ final String name,
+ final File fileToUpload,
+ final URL url)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().putUpload(name, fileToUpload, url), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform an HTTP DELETE call with the specified form data and path objects, returning a
+ * ClientResponse instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param queryParams multivalue map of request parameters
+ * @param pathArgs variable list of arguments used to build the URI
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response delete(
+ final Response.Status expectedStatus,
+ final MultivaluedMap queryParams,
+ final Object... pathArgs)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().delete(queryParams, pathArgs), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Perform an HTTP DELETE call with the specified form data and URL, returning a ClientResponse
+ * instance with the data returned from the endpoint.
+ *
+ * @param expectedStatus the HTTP status that should be returned from the server
+ * @param queryParams multivalue map of request parameters
+ * @param url the fully formed path to the GitLab API endpoint
+ * @return a ClientResponse instance with the data returned from the endpoint
+ * @throws GitLabApiException if any exception occurs during execution
+ */
+ protected Response delete(
+ final Response.Status expectedStatus,
+ final MultivaluedMap queryParams,
+ final URL url)
+ throws GitLabApiException {
+ try {
+ return validate(getApiClient().delete(queryParams, url), expectedStatus);
+ } catch (final Exception e) {
+ throw handle(e);
+ }
+ }
+
+ /**
+ * Convenience method for adding query and form parameters to a get() or post() call.
+ *
+ * @param formData the Form containing the name/value pairs
+ * @param name the name of the field/attribute to add
+ * @param value the value of the field/attribute to add
+ */
+ protected void addFormParam(final Form formData, final String name, final Object value)
+ throws IllegalArgumentException {
+ addFormParam(formData, name, value, false);
+ }
+
+ /**
+ * Convenience method for adding query and form parameters to a get() or post() call. If required
+ * is true and value is null, will throw an IllegalArgumentException.
+ *
+ * @param formData the Form containing the name/value pairs
+ * @param name the name of the field/attribute to add
+ * @param value the value of the field/attribute to add
+ * @param required the field is required flag
+ * @throws IllegalArgumentException if a required parameter is null or empty
+ */
+ protected void addFormParam(
+ final Form formData, final String name, final Object value, final boolean required)
+ throws IllegalArgumentException {
+
+ if (value == null) {
+
+ if (required) {
+ throw new IllegalArgumentException(name + " cannot be empty or null");
+ }
+
+ return;
+ }
+
+ final String stringValue = value.toString();
+ if (required && stringValue.trim().length() == 0) {
+ throw new IllegalArgumentException(name + " cannot be empty or null");
+ }
+
+ formData.param(name, stringValue);
+ }
+
+ /**
+ * Validates response the response from the server against the expected HTTP status and the
+ * returned secret token, if either is not correct will throw a GitLabApiException.
+ *
+ * @param response response
+ * @param expected expected response status
+ * @return original response if the response status is expected
+ * @throws GitLabApiException if HTTP status is not as expected, or the secret token doesn't match
+ */
+ protected Response validate(final Response response, final Response.Status expected)
+ throws GitLabApiException {
+
+ final int responseCode = response.getStatus();
+ final int expectedResponseCode = expected.getStatusCode();
+
+ if (responseCode != expectedResponseCode) {
+
+ // If the expected code is 200-204 and the response code is 200-204 it is OK. We do this
+ // because
+ // GitLab is constantly changing the expected code in the 200 to 204 range
+ if (expectedResponseCode > 204
+ || responseCode > 204
+ || expectedResponseCode < 200
+ || responseCode < 200) throw new GitLabApiException(response);
+ }
+
+ if (!getApiClient().validateSecretToken(response)) {
+ throw new GitLabApiException(new NotAuthorizedException("Invalid secret token in response."));
+ }
+
+ return (response);
+ }
+
+ /**
+ * Wraps an exception in a GitLabApiException if needed.
+ *
+ * @param thrown the exception that should be wrapped
+ * @return either the untouched GitLabApiException or a new GitLabApiExceptin wrapping a
+ * non-GitLabApiException
+ */
+ protected GitLabApiException handle(final Exception thrown) {
+
+ if (thrown instanceof GitLabApiException) {
+ return ((GitLabApiException) thrown);
+ }
+
+ return (new GitLabApiException(thrown));
+ }
+
+ /**
+ * Creates a MultivaluedMap instance containing the "per_page" param.
+ *
+ * @param perPage the number of projects per page
+ * @return a MultivaluedMap instance containing the "per_page" param
+ */
+ protected MultivaluedMap getPerPageQueryParam(final int perPage) {
+ return (new GitLabApiForm().withParam(PER_PAGE_PARAM, perPage).asMap());
+ }
+
+ /**
+ * Creates a MultivaluedMap instance containing "page" and "per_page" params.
+ *
+ * @param page the page to get
+ * @param perPage the number of projects per page
+ * @return a MultivaluedMap instance containing "page" and "per_page" params
+ */
+ protected MultivaluedMap getPageQueryParams(final int page, final int perPage) {
+ return (new GitLabApiForm()
+ .withParam(PAGE_PARAM, page)
+ .withParam(PER_PAGE_PARAM, perPage)
+ .asMap());
+ }
+
+ /**
+ * Creates a MultivaluedMap instance containing "page" and "per_page" params.
+ *
+ * @param page the page to get
+ * @param perPage the number of projects per page
+ * @param customAttributesEnabled enables customAttributes for this query
+ * @return a MultivaluedMap instance containing "page" and "per_page" params
+ */
+ protected MultivaluedMap getPageQueryParams(
+ final int page, final int perPage, final boolean customAttributesEnabled) {
+
+ final GitLabApiForm form =
+ new GitLabApiForm().withParam(PAGE_PARAM, page).withParam(PER_PAGE_PARAM, perPage);
+ if (customAttributesEnabled) return (form.withParam("with_custom_attributes", true).asMap());
+
+ return (form.asMap());
+ }
+
+ /**
+ * Creates a MultivaluedMap instance containing the "per_page" param with the default value.
+ *
+ * @return a MultivaluedMap instance containing the "per_page" param with the default value
+ */
+ protected MultivaluedMap getDefaultPerPageParam() {
+ return (new GitLabApiForm().withParam(PER_PAGE_PARAM, getDefaultPerPage()).asMap());
+ }
+
+ /**
+ * Creates a MultivaluedMap instance containing the "per_page" param with the default value.
+ *
+ * @param customAttributesEnabled enables customAttributes for this query
+ * @return a MultivaluedMap instance containing the "per_page" param with the default value
+ */
+ protected MultivaluedMap getDefaultPerPageParam(
+ final boolean customAttributesEnabled) {
+
+ final GitLabApiForm form = new GitLabApiForm().withParam(PER_PAGE_PARAM, getDefaultPerPage());
+ if (customAttributesEnabled) return (form.withParam("with_custom_attributes", true).asMap());
+
+ return (form.asMap());
+ }
}
diff --git a/src/main/java/org/gitlab4j/api/ApplicationSettingsApi.java b/src/main/java/org/gitlab4j/api/ApplicationSettingsApi.java
index 28ff1d716..88b28afc5 100644
--- a/src/main/java/org/gitlab4j/api/ApplicationSettingsApi.java
+++ b/src/main/java/org/gitlab4j/api/ApplicationSettingsApi.java
@@ -1,23 +1,20 @@
package org.gitlab4j.api;
+import com.fasterxml.jackson.databind.JsonNode;
+import jakarta.ws.rs.core.Response;
import java.text.ParseException;
import java.util.Iterator;
-
-import javax.ws.rs.core.Response;
-
-import org.gitlab4j.api.models.Setting;
import org.gitlab4j.api.models.ApplicationSettings;
+import org.gitlab4j.api.models.Setting;
import org.gitlab4j.api.utils.ISO8601;
-import com.fasterxml.jackson.databind.JsonNode;
-
/**
* This class implements the client side API for the GitLab Application Settings API.
* See Application Settings API at GitLab for more information.
*/
public class ApplicationSettingsApi extends AbstractApi {
- public ApplicationSettingsApi(GitLabApi gitLabApi) {
+ public ApplicationSettingsApi(final GitLabApi gitLabApi) {
super(gitLabApi);
}
@@ -31,8 +28,8 @@ public ApplicationSettingsApi(GitLabApi gitLabApi) {
*/
public ApplicationSettings getApplicationSettings() throws GitLabApiException {
- Response response = get(Response.Status.OK, null, "application", "settings");
- JsonNode root = response.readEntity(JsonNode.class);
+ final Response response = get(Response.Status.OK, null, "application", "settings");
+ final JsonNode root = response.readEntity(JsonNode.class);
return (parseApplicationSettings(root));
}
@@ -46,7 +43,7 @@ public ApplicationSettings getApplicationSettings() throws GitLabApiException {
* @return the updated application settings in an ApplicationSettings instance
* @throws GitLabApiException if any exception occurs
*/
- public ApplicationSettings updateApplicationSettings(ApplicationSettings appSettings) throws GitLabApiException {
+ public ApplicationSettings updateApplicationSettings(final ApplicationSettings appSettings) throws GitLabApiException {
if (appSettings == null || appSettings.getSettings().isEmpty()) {
throw new GitLabApiException("ApplicationSettings cannot be null or empty.");
@@ -54,8 +51,8 @@ public ApplicationSettings updateApplicationSettings(ApplicationSettings appSett
final GitLabApiForm form = new GitLabApiForm();
appSettings.getSettings().forEach((s, v) -> form.withParam(s, v));
- Response response = put(Response.Status.OK, form.asMap(), "application", "settings");
- JsonNode root = response.readEntity(JsonNode.class);
+ final Response response = put(Response.Status.OK, form.asMap(), "application", "settings");
+ final JsonNode root = response.readEntity(JsonNode.class);
return (parseApplicationSettings(root));
}
@@ -69,7 +66,7 @@ public ApplicationSettings updateApplicationSettings(ApplicationSettings appSett
* @return the updated application settings in an ApplicationSettings instance
* @throws GitLabApiException if any exception occurs
*/
- public ApplicationSettings updateApplicationSetting(Setting setting, Object value) throws GitLabApiException {
+ public ApplicationSettings updateApplicationSetting(final Setting setting, final Object value) throws GitLabApiException {
if (setting == null) {
throw new GitLabApiException("setting cannot be null.");
@@ -88,15 +85,15 @@ public ApplicationSettings updateApplicationSetting(Setting setting, Object valu
* @return the updated application settings in an ApplicationSettings instance
* @throws GitLabApiException if any exception occurs
*/
- public ApplicationSettings updateApplicationSetting(String setting, Object value) throws GitLabApiException {
+ public ApplicationSettings updateApplicationSetting(final String setting, final Object value) throws GitLabApiException {
if (setting == null || setting.trim().isEmpty()) {
throw new GitLabApiException("setting cannot be null or empty.");
}
- GitLabApiForm form = new GitLabApiForm().withParam(setting, value);
- Response response = put(Response.Status.OK, form.asMap(), "application", "settings");
- JsonNode root = response.readEntity(JsonNode.class);
+ final GitLabApiForm form = new GitLabApiForm().withParam(setting, value);
+ final Response response = put(Response.Status.OK, form.asMap(), "application", "settings");
+ final JsonNode root = response.readEntity(JsonNode.class);
return (parseApplicationSettings(root));
}
@@ -107,14 +104,14 @@ public ApplicationSettings updateApplicationSetting(String setting, Object value
* @return the populated ApplicationSettings instance
* @throws GitLabApiException if any error occurs
*/
- public static final ApplicationSettings parseApplicationSettings(JsonNode root) throws GitLabApiException {
+ public static final ApplicationSettings parseApplicationSettings(final JsonNode root) throws GitLabApiException {
- ApplicationSettings appSettings = new ApplicationSettings();
+ final ApplicationSettings appSettings = new ApplicationSettings();
- Iterator fieldNames = root.fieldNames();
+ final Iterator fieldNames = root.fieldNames();
while (fieldNames.hasNext()) {
- String fieldName = fieldNames.next();
+ final String fieldName = fieldNames.next();
switch (fieldName) {
case "id":
appSettings.setId(root.path(fieldName).asLong());
@@ -122,25 +119,25 @@ public static final ApplicationSettings parseApplicationSettings(JsonNode root)
case "created_at":
try {
- String value = root.path(fieldName).asText();
+ final String value = root.path(fieldName).asText();
appSettings.setCreatedAt(ISO8601.toDate(value));
- } catch (ParseException pe) {
+ } catch (final ParseException pe) {
throw new GitLabApiException(pe);
}
break;
case "updated_at":
try {
- String value = root.path(fieldName).asText();
+ final String value = root.path(fieldName).asText();
appSettings.setUpdatedAt(ISO8601.toDate(value));
- } catch (ParseException pe) {
+ } catch (final ParseException pe) {
throw new GitLabApiException(pe);
}
break;
default:
- Setting setting = Setting.forValue(fieldName);
+ final Setting setting = Setting.forValue(fieldName);
if (setting != null) {
appSettings.addSetting(setting, root.path(fieldName));
} else {
diff --git a/src/main/java/org/gitlab4j/api/ApplicationsApi.java b/src/main/java/org/gitlab4j/api/ApplicationsApi.java
index b5c793702..1bfe21748 100644
--- a/src/main/java/org/gitlab4j/api/ApplicationsApi.java
+++ b/src/main/java/org/gitlab4j/api/ApplicationsApi.java
@@ -1,132 +1,144 @@
package org.gitlab4j.api;
+import jakarta.ws.rs.core.GenericType;
+import jakarta.ws.rs.core.Response;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.Response;
-
import org.gitlab4j.api.models.Application;
/**
- * This class implements the client side API for the GitLab Applications API.
- * See Applications API at GitLab for more information.
+ * This class implements the client side API for the GitLab Applications API. See Applications API at GitLab for more
+ * information.
*/
public class ApplicationsApi extends AbstractApi {
- public ApplicationsApi(GitLabApi gitLabApi) {
- super(gitLabApi);
+ public ApplicationsApi(final GitLabApi gitLabApi) {
+ super(gitLabApi);
+ }
+
+ /**
+ * Get all OATH applications.
+ *
+ * GitLab Endpoint: GET /api/v4/applications
+ *
+ * @return a List of OAUTH Application instances
+ * @throws GitLabApiException if any exception occurs
+ */
+ public List getApplications() throws GitLabApiException {
+ return (getApplications(getDefaultPerPage()).all());
+ }
+
+ /**
+ * Get all OAUTH applications using the specified page and per page setting
+ *
+ * GitLab Endpoint: GET /api/v4/applications
+ *
+ * @param page the page to get
+ * @param perPage the number of items per page
+ * @return a list of OAUTH Applications in the specified range
+ * @throws GitLabApiException if any exception occurs
+ */
+ public List getApplications(final int page, final int perPage)
+ throws GitLabApiException {
+ final Response response =
+ get(
+ jakarta.ws.rs.core.Response.Status.OK,
+ getPageQueryParams(page, perPage),
+ "applications");
+ return (response.readEntity(new GenericType>() {}));
+ }
+
+ /**
+ * Get a Pager of all OAUTH applications.
+ *
+ * GitLab Endpoint: GET /api/v4/applications
+ *
+ * @param itemsPerPage the number of items per page
+ * @return a Pager of Application instances in the specified range
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Pager getApplications(final int itemsPerPage) throws GitLabApiException {
+ return (new Pager(this, Application.class, itemsPerPage, null, "applications"));
+ }
+
+ /**
+ * Get a Stream of all OAUTH Application instances.
+ *
+ * GitLab Endpoint: GET /api/v4/applications
+ *
+ * @return a Stream of OAUTH Application instances
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Stream getApplicationsStream() throws GitLabApiException {
+ return (getApplications(getDefaultPerPage()).stream());
+ }
+
+ /**
+ * Create an OAUTH Application.
+ *
+ * GitLab Endpoint: POST /api/v4/applications
+ *
+ * @param name the name for the OAUTH Application
+ * @param redirectUri the redirect URI for the OAUTH Application
+ * @param scopes the scopes of the application (api, read_user, sudo, read_repository, openid,
+ * profile, email)
+ * @return the created Application instance
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Application createApplication(
+ final String name, final String redirectUri, final ApplicationScope[] scopes)
+ throws GitLabApiException {
+
+ if (scopes == null || scopes.length == 0) {
+ throw new GitLabApiException("scopes cannot be null or empty");
}
- /**
- * Get all OATH applications.
- *
- * GitLab Endpoint: GET /api/v4/applications
- *
- * @return a List of OAUTH Application instances
- * @throws GitLabApiException if any exception occurs
- */
- public List getApplications() throws GitLabApiException {
- return (getApplications(getDefaultPerPage()).all());
+ return (createApplication(name, redirectUri, Arrays.asList(scopes)));
+ }
+
+ /**
+ * Create an OAUTH Application.
+ *
+ * GitLab Endpoint: POST /api/v4/applications
+ *
+ * @param name the name for the OAUTH Application
+ * @param redirectUri the redirect URI for the OAUTH Application
+ * @param scopes the scopes of the application (api, read_user, sudo, read_repository, openid,
+ * profile, email)
+ * @return the created Application instance
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Application createApplication(
+ final String name, final String redirectUri, final List scopes)
+ throws GitLabApiException {
+
+ if (scopes == null || scopes.isEmpty()) {
+ throw new GitLabApiException("scopes cannot be null or empty");
}
- /**
- * Get all OAUTH applications using the specified page and per page setting
- *
- * GitLab Endpoint: GET /api/v4/applications
- *
- * @param page the page to get
- * @param perPage the number of items per page
- * @return a list of OAUTH Applications in the specified range
- * @throws GitLabApiException if any exception occurs
- */
- public List getApplications(int page, int perPage) throws GitLabApiException {
- Response response = get(javax.ws.rs.core.Response.Status.OK, getPageQueryParams(page, perPage), "applications");
- return (response.readEntity(new GenericType>() {}));
- }
-
- /**
- * Get a Pager of all OAUTH applications.
- *
- * GitLab Endpoint: GET /api/v4/applications
- *
- * @param itemsPerPage the number of items per page
- * @return a Pager of Application instances in the specified range
- * @throws GitLabApiException if any exception occurs
- */
- public Pager getApplications(int itemsPerPage) throws GitLabApiException {
- return (new Pager(this, Application.class, itemsPerPage, null, "applications"));
- }
-
- /**
- * Get a Stream of all OAUTH Application instances.
- *
- * GitLab Endpoint: GET /api/v4/applications
- *
- * @return a Stream of OAUTH Application instances
- * @throws GitLabApiException if any exception occurs
- */
- public Stream getApplicationsStream() throws GitLabApiException {
- return (getApplications(getDefaultPerPage()).stream());
- }
-
- /**
- * Create an OAUTH Application.
- *
- * GitLab Endpoint: POST /api/v4/applications
- *
- * @param name the name for the OAUTH Application
- * @param redirectUri the redirect URI for the OAUTH Application
- * @param scopes the scopes of the application (api, read_user, sudo, read_repository, openid, profile, email)
- * @return the created Application instance
- * @throws GitLabApiException if any exception occurs
- */
- public Application createApplication(String name, String redirectUri, ApplicationScope[] scopes) throws GitLabApiException {
-
- if (scopes == null || scopes.length == 0) {
- throw new GitLabApiException("scopes cannot be null or empty");
- }
-
- return (createApplication(name, redirectUri, Arrays.asList(scopes)));
- }
-
- /**
- * Create an OAUTH Application.
- *
- * GitLab Endpoint: POST /api/v4/applications
- *
- * @param name the name for the OAUTH Application
- * @param redirectUri the redirect URI for the OAUTH Application
- * @param scopes the scopes of the application (api, read_user, sudo, read_repository, openid, profile, email)
- * @return the created Application instance
- * @throws GitLabApiException if any exception occurs
- */
- public Application createApplication(String name, String redirectUri, List scopes) throws GitLabApiException {
-
- if (scopes == null || scopes.isEmpty()) {
- throw new GitLabApiException("scopes cannot be null or empty");
- }
-
- String scopesString = scopes.stream().map(ApplicationScope::toString).collect(Collectors.joining(","));
- GitLabApiForm formData = new GitLabApiForm()
- .withParam("name", name, true)
- .withParam("redirect_uri", redirectUri, true)
- .withParam("scopes", scopesString, true);
- Response response = post(Response.Status.CREATED, formData, "applications");
- return (response.readEntity(Application.class));
- }
-
- /**
- * Delete the specified OAUTH Application.
- *
- * GitLab Endpoint: DELETE /api/v4/applications/:applicationId
- *
- * @param applicationId the ID of the OUAUTH Application to delete
- * @throws GitLabApiException if any exception occurs
- */
- public void deleteApplication(Long applicationId) throws GitLabApiException {
- delete(Response.Status.NO_CONTENT, null, "applications", applicationId);
- }
+ final String scopesString =
+ scopes.stream().map(ApplicationScope::toString).collect(Collectors.joining(","));
+ final GitLabApiForm formData =
+ new GitLabApiForm()
+ .withParam("name", name, true)
+ .withParam("redirect_uri", redirectUri, true)
+ .withParam("scopes", scopesString, true);
+ final Response response = post(Response.Status.CREATED, formData, "applications");
+ return (response.readEntity(Application.class));
+ }
+
+ /**
+ * Delete the specified OAUTH Application.
+ *
+ * GitLab Endpoint: DELETE /api/v4/applications/:applicationId
+ *
+ * @param applicationId the ID of the OUAUTH Application to delete
+ * @throws GitLabApiException if any exception occurs
+ */
+ public void deleteApplication(final Long applicationId) throws GitLabApiException {
+ delete(Response.Status.NO_CONTENT, null, "applications", applicationId);
+ }
}
diff --git a/src/main/java/org/gitlab4j/api/AuditEventApi.java b/src/main/java/org/gitlab4j/api/AuditEventApi.java
index eebfb6173..9404696e2 100644
--- a/src/main/java/org/gitlab4j/api/AuditEventApi.java
+++ b/src/main/java/org/gitlab4j/api/AuditEventApi.java
@@ -1,12 +1,10 @@
package org.gitlab4j.api;
+import jakarta.ws.rs.core.Form;
+import jakarta.ws.rs.core.Response;
import java.util.Date;
import java.util.List;
import java.util.stream.Stream;
-
-import javax.ws.rs.core.Form;
-import javax.ws.rs.core.Response;
-
import org.gitlab4j.api.models.AuditEvent;
import org.gitlab4j.api.utils.ISO8601;
@@ -16,7 +14,7 @@
*/
public class AuditEventApi extends AbstractApi {
- public AuditEventApi(GitLabApi gitLabApi) {
+ public AuditEventApi(final GitLabApi gitLabApi) {
super(gitLabApi);
}
@@ -32,7 +30,7 @@ public AuditEventApi(GitLabApi gitLabApi) {
* @return a List of group Audit events
* @throws GitLabApiException if any exception occurs
*/
- public List getAuditEvents(Date created_after, Date created_before, String entityType, Long entityId) throws GitLabApiException {
+ public List getAuditEvents(final Date created_after, final Date created_before, final String entityType, final Long entityId) throws GitLabApiException {
return (getAuditEvents(created_after, created_before, entityType, entityId, getDefaultPerPage()).all());
}
@@ -49,8 +47,8 @@ public List getAuditEvents(Date created_after, Date created_before,
* @return a Pager of group Audit events
* @throws GitLabApiException if any exception occurs
*/
- public Pager getAuditEvents(Date created_after, Date created_before, String entityType, Long entityId, int itemsPerPage) throws GitLabApiException {
- Form form = new GitLabApiForm()
+ public Pager getAuditEvents(final Date created_after, final Date created_before, final String entityType, final Long entityId, final int itemsPerPage) throws GitLabApiException {
+ final Form form = new GitLabApiForm()
.withParam("created_before", ISO8601.toString(created_before, false))
.withParam("created_after", ISO8601.toString(created_after, false))
.withParam("entity_type", entityType)
@@ -70,7 +68,7 @@ public Pager getAuditEvents(Date created_after, Date created_before,
* @return a Stream of group Audit events
* @throws GitLabApiException if any exception occurs
*/
- public Stream getAuditEventsStream(Date created_after, Date created_before, String entityType, Long entityId) throws GitLabApiException {
+ public Stream getAuditEventsStream(final Date created_after, final Date created_before, final String entityType, final Long entityId) throws GitLabApiException {
return (getAuditEvents(created_after, created_before, entityType, entityId, getDefaultPerPage()).stream());
}
@@ -83,8 +81,8 @@ public Stream getAuditEventsStream(Date created_after, Date created_
* @return the group Audit event
* @throws GitLabApiException if any exception occurs
*/
- public AuditEvent getAuditEvent(Long auditEventId) throws GitLabApiException {
- Response response = get(Response.Status.OK, null, "audit_events", auditEventId);
+ public AuditEvent getAuditEvent(final Long auditEventId) throws GitLabApiException {
+ final Response response = get(Response.Status.OK, null, "audit_events", auditEventId);
return (response.readEntity(AuditEvent.class));
}
}
diff --git a/src/main/java/org/gitlab4j/api/AwardEmojiApi.java b/src/main/java/org/gitlab4j/api/AwardEmojiApi.java
index dce6a1306..53a7f9db1 100644
--- a/src/main/java/org/gitlab4j/api/AwardEmojiApi.java
+++ b/src/main/java/org/gitlab4j/api/AwardEmojiApi.java
@@ -1,427 +1,702 @@
package org.gitlab4j.api;
+import jakarta.ws.rs.core.GenericType;
+import jakarta.ws.rs.core.Response;
import java.util.List;
-
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.Response;
-
import org.gitlab4j.api.models.AwardEmoji;
/**
* This class implements the client side API for the GitLab Award Emoji API calls.
*
- * @see GitLab Award Emoji API Documentaion
+ * @see GitLab Award Emoji API
+ * Documentaion
* @since v4.8.31
*/
public class AwardEmojiApi extends AbstractApi {
- public AwardEmojiApi(GitLabApi gitLabApi) {
- super(gitLabApi);
- }
+ public AwardEmojiApi(final GitLabApi gitLabApi) {
+ super(gitLabApi);
+ }
- /**
- * Get a list of award emoji for the specified issue.
- *
- * GitLab Endpoint: GET /projects/:id/issues/:issue_iid/award_emoji
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param issueIid the issue IID to get the award emojis for
- * @return a list of AwardEmoji for the specified issue
- * @throws GitLabApiException if any exception occurs
- */
- public List getIssueAwardEmojis(Object projectIdOrPath, Long issueIid) throws GitLabApiException {
- Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
- "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "award_emoji");
- return response.readEntity(new GenericType>() {});
- }
+ /**
+ * Get a list of award emoji for the specified issue.
+ *
+ * GitLab Endpoint: GET /projects/:id/issues/:issue_iid/award_emoji
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param issueIid the issue IID to get the award emojis for
+ * @return a list of AwardEmoji for the specified issue
+ * @throws GitLabApiException if any exception occurs
+ */
+ public List getIssueAwardEmojis(final Object projectIdOrPath, final Long issueIid)
+ throws GitLabApiException {
+ final Response response =
+ get(
+ Response.Status.OK,
+ getPageQueryParams(1, getDefaultPerPage()),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "issues",
+ issueIid,
+ "award_emoji");
+ return response.readEntity(new GenericType>() {});
+ }
- /**
- * Get a list of award emoji for the specified merge request.
- *
- * GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/award_emoji
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param mergeRequestIid the merge request IID to get the award emojis for
- * @return a list of AwardEmoji for the specified merge request
- * @throws GitLabApiException if any exception occurs
- */
- public List getMergeRequestAwardEmojis(Object projectIdOrPath, Long mergeRequestIid) throws GitLabApiException {
- Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
- "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "award_emoji");
- return response.readEntity(new GenericType>() {});
- }
+ /**
+ * Get a list of award emoji for the specified merge request.
+ *
+ *
+ * GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/award_emoji
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param mergeRequestIid the merge request IID to get the award emojis for
+ * @return a list of AwardEmoji for the specified merge request
+ * @throws GitLabApiException if any exception occurs
+ */
+ public List getMergeRequestAwardEmojis(
+ final Object projectIdOrPath, final Long mergeRequestIid) throws GitLabApiException {
+ final Response response =
+ get(
+ Response.Status.OK,
+ getPageQueryParams(1, getDefaultPerPage()),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "merge_requests",
+ mergeRequestIid,
+ "award_emoji");
+ return response.readEntity(new GenericType>() {});
+ }
- /**
- * Get a list of award emoji for the specified snippet.
- *
- * GitLab Endpoint: GET /projects/:id/snippets/:snippet_id/award_emoji
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param snippetId the snippet ID to get the award emojis for
- * @return a list of AwardEmoji for the specified snippet
- * @throws GitLabApiException if any exception occurs
- */
- public List getSnippetAwardEmojis(Object projectIdOrPath, Long snippetId) throws GitLabApiException {
- Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
- "projects", getProjectIdOrPath(projectIdOrPath), "snippets", snippetId, "award_emoji");
- return response.readEntity(new GenericType>() {});
- }
+ /**
+ * Get a list of award emoji for the specified snippet.
+ *
+ * GitLab Endpoint: GET /projects/:id/snippets/:snippet_id/award_emoji
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param snippetId the snippet ID to get the award emojis for
+ * @return a list of AwardEmoji for the specified snippet
+ * @throws GitLabApiException if any exception occurs
+ */
+ public List getSnippetAwardEmojis(final Object projectIdOrPath, final Long snippetId)
+ throws GitLabApiException {
+ final Response response =
+ get(
+ Response.Status.OK,
+ getPageQueryParams(1, getDefaultPerPage()),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "snippets",
+ snippetId,
+ "award_emoji");
+ return response.readEntity(new GenericType>() {});
+ }
- /**
- * Get a list of award emoji for the specified issue note.
- *
- * GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param issueIid the issue IID of the issue that owns the note
- * @param noteId the note ID to get the award emojis for
- * @return a list of AwardEmoji for the specified note
- * @throws GitLabApiException if any exception occurs
- */
- public List getIssueNoteAwardEmojis(Object projectIdOrPath, Long issueIid, Long noteId) throws GitLabApiException {
- Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
- "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji");
- return response.readEntity(new GenericType>() {});
- }
+ /**
+ * Get a list of award emoji for the specified issue note.
+ *
+ *
+ * GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param issueIid the issue IID of the issue that owns the note
+ * @param noteId the note ID to get the award emojis for
+ * @return a list of AwardEmoji for the specified note
+ * @throws GitLabApiException if any exception occurs
+ */
+ public List getIssueNoteAwardEmojis(
+ final Object projectIdOrPath, final Long issueIid, final Long noteId)
+ throws GitLabApiException {
+ final Response response =
+ get(
+ Response.Status.OK,
+ getPageQueryParams(1, getDefaultPerPage()),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "issues",
+ issueIid,
+ "notes",
+ noteId,
+ "award_emoji");
+ return response.readEntity(new GenericType>() {});
+ }
- /**
- * Get a list of award emoji for the specified issue note.
- *
- * GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param issueIid the issue IID of the issue that owns the note
- * @param noteId the note ID to get the award emojis for
- * @return a list of AwardEmoji for the specified note
- * @throws GitLabApiException if any exception occurs
- */
- public List getNoteAwardEmojis(Object projectIdOrPath, Long issueIid, Long noteId) throws GitLabApiException {
- return getIssueNoteAwardEmojis(projectIdOrPath, issueIid, noteId);
- }
+ /**
+ * Get a list of award emoji for the specified issue note.
+ *
+ *
+ * GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param issueIid the issue IID of the issue that owns the note
+ * @param noteId the note ID to get the award emojis for
+ * @return a list of AwardEmoji for the specified note
+ * @throws GitLabApiException if any exception occurs
+ */
+ public List getNoteAwardEmojis(
+ final Object projectIdOrPath, final Long issueIid, final Long noteId)
+ throws GitLabApiException {
+ return getIssueNoteAwardEmojis(projectIdOrPath, issueIid, noteId);
+ }
- /**
- * Get a list of award emoji for the specified merge request note.
- *
- * GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/notes/:note_id/award_emoji
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param mergeRequestIid the merge request IID of the merge request that owns the note
- * @param noteId the note ID to get the award emojis for
- * @return a list of AwardEmoji for the specified note
- * @throws GitLabApiException if any exception occurs
- */
- public List getMergeRequestNoteAwardEmojis(Object projectIdOrPath, Long mergeRequestIid, Long noteId) throws GitLabApiException {
- Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
- "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji");
- return response.readEntity(new GenericType>() {});
- }
+ /**
+ * Get a list of award emoji for the specified merge request note.
+ *
+ *
+ * GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/notes/:note_id/award_emoji
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param mergeRequestIid the merge request IID of the merge request that owns the note
+ * @param noteId the note ID to get the award emojis for
+ * @return a list of AwardEmoji for the specified note
+ * @throws GitLabApiException if any exception occurs
+ */
+ public List getMergeRequestNoteAwardEmojis(
+ final Object projectIdOrPath, final Long mergeRequestIid, final Long noteId)
+ throws GitLabApiException {
+ final Response response =
+ get(
+ Response.Status.OK,
+ getPageQueryParams(1, getDefaultPerPage()),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "merge_requests",
+ mergeRequestIid,
+ "notes",
+ noteId,
+ "award_emoji");
+ return response.readEntity(new GenericType>() {});
+ }
- /**
- * Get the specified award emoji for the specified issue.
- *
- * GitLab Endpoint: GET /projects/:id/issues/:issue_iid/award_emoji/:award_id
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param issueIid the issue IID to get the award emoji for
- * @param awardId the ID of the award emoji to get
- * @return an AwardEmoji instance for the specified award emoji
- * @throws GitLabApiException if any exception occurs
- */
- public AwardEmoji getIssueAwardEmoji(Object projectIdOrPath, Long issueIid, Long awardId) throws GitLabApiException {
- Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
- "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "award_emoji", awardId);
- return (response.readEntity(AwardEmoji.class));
- }
+ /**
+ * Get the specified award emoji for the specified issue.
+ *
+ * GitLab Endpoint: GET /projects/:id/issues/:issue_iid/award_emoji/:award_id
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param issueIid the issue IID to get the award emoji for
+ * @param awardId the ID of the award emoji to get
+ * @return an AwardEmoji instance for the specified award emoji
+ * @throws GitLabApiException if any exception occurs
+ */
+ public AwardEmoji getIssueAwardEmoji(
+ final Object projectIdOrPath, final Long issueIid, final Long awardId)
+ throws GitLabApiException {
+ final Response response =
+ get(
+ Response.Status.OK,
+ getPageQueryParams(1, getDefaultPerPage()),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "issues",
+ issueIid,
+ "award_emoji",
+ awardId);
+ return (response.readEntity(AwardEmoji.class));
+ }
- /**
- * Get the specified award emoji for the specified merge request.
- *
- * GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/award_emoji/:award_id
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param mergeRequestIid the merge request IID to get the award emoji for
- * @param awardId the ID of the award emoji to get
- * @return an AwardEmoji instance for the specified award emoji
- * @throws GitLabApiException if any exception occurs
- */
- public AwardEmoji getMergeRequestAwardEmoji(Object projectIdOrPath, Long mergeRequestIid, Long awardId) throws GitLabApiException {
- Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
- "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "award_emoji", awardId);
- return (response.readEntity(AwardEmoji.class));
- }
+ /**
+ * Get the specified award emoji for the specified merge request.
+ *
+ *
+ * GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/award_emoji/:award_id
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param mergeRequestIid the merge request IID to get the award emoji for
+ * @param awardId the ID of the award emoji to get
+ * @return an AwardEmoji instance for the specified award emoji
+ * @throws GitLabApiException if any exception occurs
+ */
+ public AwardEmoji getMergeRequestAwardEmoji(
+ final Object projectIdOrPath, final Long mergeRequestIid, final Long awardId)
+ throws GitLabApiException {
+ final Response response =
+ get(
+ Response.Status.OK,
+ getPageQueryParams(1, getDefaultPerPage()),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "merge_requests",
+ mergeRequestIid,
+ "award_emoji",
+ awardId);
+ return (response.readEntity(AwardEmoji.class));
+ }
- /**
- * Get the specified award emoji for the specified snippet.
- *
- * GitLab Endpoint: GET /projects/:id/snippets/:snippet_id/award_emoji/:award_id
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param snippetId the snippet ID to get the award emoji for
- * @param awardId the ID of the award emoji to get
- * @return an AwardEmoji instance for the specified award emoji
- * @throws GitLabApiException if any exception occurs
- */
- public AwardEmoji getSnippetAwardEmoji(Object projectIdOrPath, Long snippetId, Long awardId) throws GitLabApiException {
- Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
- "projects", getProjectIdOrPath(projectIdOrPath), "snippets", snippetId, "award_emoji", awardId);
- return (response.readEntity(AwardEmoji.class));
- }
+ /**
+ * Get the specified award emoji for the specified snippet.
+ *
+ * GitLab Endpoint: GET /projects/:id/snippets/:snippet_id/award_emoji/:award_id
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param snippetId the snippet ID to get the award emoji for
+ * @param awardId the ID of the award emoji to get
+ * @return an AwardEmoji instance for the specified award emoji
+ * @throws GitLabApiException if any exception occurs
+ */
+ public AwardEmoji getSnippetAwardEmoji(
+ final Object projectIdOrPath, final Long snippetId, final Long awardId)
+ throws GitLabApiException {
+ final Response response =
+ get(
+ Response.Status.OK,
+ getPageQueryParams(1, getDefaultPerPage()),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "snippets",
+ snippetId,
+ "award_emoji",
+ awardId);
+ return (response.readEntity(AwardEmoji.class));
+ }
- /**
- * Get the specified award emoji for the specified issue note.
- *
- * GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param issueIid the issue IID of the issue that owns the note
- * @param noteId the note ID to get the award emoji from
- * @param awardId the ID of the award emoji to get
- * @return an AwardEmoji instance for the specified award emoji
- * @throws GitLabApiException if any exception occurs
- */
- public AwardEmoji getIssueNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long noteId, Long awardId) throws GitLabApiException {
- Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
- "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji", awardId);
- return (response.readEntity(AwardEmoji.class));
- }
+ /**
+ * Get the specified award emoji for the specified issue note.
+ *
+ *
+ * GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param issueIid the issue IID of the issue that owns the note
+ * @param noteId the note ID to get the award emoji from
+ * @param awardId the ID of the award emoji to get
+ * @return an AwardEmoji instance for the specified award emoji
+ * @throws GitLabApiException if any exception occurs
+ */
+ public AwardEmoji getIssueNoteAwardEmoji(
+ final Object projectIdOrPath, final Long issueIid, final Long noteId, final Long awardId)
+ throws GitLabApiException {
+ final Response response =
+ get(
+ Response.Status.OK,
+ getPageQueryParams(1, getDefaultPerPage()),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "issues",
+ issueIid,
+ "notes",
+ noteId,
+ "award_emoji",
+ awardId);
+ return (response.readEntity(AwardEmoji.class));
+ }
- /**
- * Get the specified award emoji for the specified issue note.
- *
- * GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param issueIid the issue IID of the issue that owns the note
- * @param noteId the note ID to get the award emoji from
- * @param awardId the ID of the award emoji to get
- * @return an AwardEmoji instance for the specified award emoji
- * @throws GitLabApiException if any exception occurs
- * @deprecated use {@link #getIssueNoteAwardEmoji(Object, Long, Long, Long)} instead
- */
- @Deprecated
- public AwardEmoji getNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long noteId, Long awardId) throws GitLabApiException {
- return getIssueNoteAwardEmoji(projectIdOrPath, issueIid, noteId, awardId);
- }
+ /**
+ * Get the specified award emoji for the specified issue note.
+ *
+ *
+ * GitLab Endpoint: GET /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param issueIid the issue IID of the issue that owns the note
+ * @param noteId the note ID to get the award emoji from
+ * @param awardId the ID of the award emoji to get
+ * @return an AwardEmoji instance for the specified award emoji
+ * @throws GitLabApiException if any exception occurs
+ * @deprecated use {@link #getIssueNoteAwardEmoji(Object, Long, Long, Long)} instead
+ */
+ @Deprecated
+ public AwardEmoji getNoteAwardEmoji(
+ final Object projectIdOrPath, final Long issueIid, final Long noteId, final Long awardId)
+ throws GitLabApiException {
+ return getIssueNoteAwardEmoji(projectIdOrPath, issueIid, noteId, awardId);
+ }
- /**
- * Get the specified award emoji for the specified merge request note.
- *
- * GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/notes/:note_id/award_emoji/:award_id
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param mergeRequestIid the merge request IID of the merge request that owns the note
- * @param noteId the note ID to get the award emoji from
- * @param awardId the ID of the award emoji to get
- * @return an AwardEmoji instance for the specified award emoji
- * @throws GitLabApiException if any exception occurs
- */
- public AwardEmoji getMergeRequestNoteAwardEmoji(Object projectIdOrPath, Long mergeRequestIid, Long noteId, Long awardId) throws GitLabApiException {
- Response response = get(Response.Status.OK, getPageQueryParams(1, getDefaultPerPage()),
- "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji", awardId);
- return (response.readEntity(AwardEmoji.class));
- }
+ /**
+ * Get the specified award emoji for the specified merge request note.
+ *
+ *
+ * GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/notes/:note_id/award_emoji/:award_id
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param mergeRequestIid the merge request IID of the merge request that owns the note
+ * @param noteId the note ID to get the award emoji from
+ * @param awardId the ID of the award emoji to get
+ * @return an AwardEmoji instance for the specified award emoji
+ * @throws GitLabApiException if any exception occurs
+ */
+ public AwardEmoji getMergeRequestNoteAwardEmoji(
+ final Object projectIdOrPath,
+ final Long mergeRequestIid,
+ final Long noteId,
+ final Long awardId)
+ throws GitLabApiException {
+ final Response response =
+ get(
+ Response.Status.OK,
+ getPageQueryParams(1, getDefaultPerPage()),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "merge_requests",
+ mergeRequestIid,
+ "notes",
+ noteId,
+ "award_emoji",
+ awardId);
+ return (response.readEntity(AwardEmoji.class));
+ }
- /**
- * Add an award emoji for the specified issue.
- *
- * GitLab Endpoint: POST /projects/:id/issues/:issue_iid/award_emoji
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param issueIid the issue IID to add the award emoji to
- * @param name the name of the award emoji to add
- * @return an AwardEmoji instance for the added award emoji
- * @throws GitLabApiException if any exception occurs
- */
- public AwardEmoji addIssueAwardEmoji(Object projectIdOrPath, Long issueIid, String name) throws GitLabApiException {
- GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
- Response response = post(Response.Status.CREATED, form.asMap(),
- "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "award_emoji");
- return (response.readEntity(AwardEmoji.class));
- }
+ /**
+ * Add an award emoji for the specified issue.
+ *
+ * GitLab Endpoint: POST /projects/:id/issues/:issue_iid/award_emoji
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param issueIid the issue IID to add the award emoji to
+ * @param name the name of the award emoji to add
+ * @return an AwardEmoji instance for the added award emoji
+ * @throws GitLabApiException if any exception occurs
+ */
+ public AwardEmoji addIssueAwardEmoji(
+ final Object projectIdOrPath, final Long issueIid, final String name)
+ throws GitLabApiException {
+ final GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
+ final Response response =
+ post(
+ Response.Status.CREATED,
+ form.asMap(),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "issues",
+ issueIid,
+ "award_emoji");
+ return (response.readEntity(AwardEmoji.class));
+ }
- /**
- * Add an award emoji to the specified merge request.
- *
- * GitLab Endpoint: POST /projects/:id/merge_requests/:merge_request_iid/award_emoji
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param mergeRequestIid the merge request IID to add the award emoji to
- * @param name the name of the award emoji to add
- * @return an AwardEmoji instance for the added award emoji
- * @throws GitLabApiException if any exception occurs
- */
- public AwardEmoji addMergeRequestAwardEmoji(Object projectIdOrPath, Long mergeRequestIid, String name) throws GitLabApiException {
- GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
- Response response = post(Response.Status.CREATED, form.asMap(),
- "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "award_emoji");
- return (response.readEntity(AwardEmoji.class));
- }
+ /**
+ * Add an award emoji to the specified merge request.
+ *
+ *
+ * GitLab Endpoint: POST /projects/:id/merge_requests/:merge_request_iid/award_emoji
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param mergeRequestIid the merge request IID to add the award emoji to
+ * @param name the name of the award emoji to add
+ * @return an AwardEmoji instance for the added award emoji
+ * @throws GitLabApiException if any exception occurs
+ */
+ public AwardEmoji addMergeRequestAwardEmoji(
+ final Object projectIdOrPath, final Long mergeRequestIid, final String name)
+ throws GitLabApiException {
+ final GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
+ final Response response =
+ post(
+ Response.Status.CREATED,
+ form.asMap(),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "merge_requests",
+ mergeRequestIid,
+ "award_emoji");
+ return (response.readEntity(AwardEmoji.class));
+ }
- /**
- * Add an award emoji to the specified snippet.
- *
- * GitLab Endpoint: POST /projects/:id/snippets/:snippet_id/award_emoji
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param snippetId the snippet ID to add the award emoji to
- * @param name the name of the award emoji to add
- * @return an AwardEmoji instance for the added award emoji
- * @throws GitLabApiException if any exception occurs
- */
- public AwardEmoji addSnippetAwardEmoji(Object projectIdOrPath, Long snippetId, String name) throws GitLabApiException {
- GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
- Response response = post(Response.Status.CREATED, form.asMap(),
- "projects", getProjectIdOrPath(projectIdOrPath), "snippets", snippetId, "award_emoji");
- return (response.readEntity(AwardEmoji.class));
- }
+ /**
+ * Add an award emoji to the specified snippet.
+ *
+ * GitLab Endpoint: POST /projects/:id/snippets/:snippet_id/award_emoji
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param snippetId the snippet ID to add the award emoji to
+ * @param name the name of the award emoji to add
+ * @return an AwardEmoji instance for the added award emoji
+ * @throws GitLabApiException if any exception occurs
+ */
+ public AwardEmoji addSnippetAwardEmoji(
+ final Object projectIdOrPath, final Long snippetId, final String name)
+ throws GitLabApiException {
+ final GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
+ final Response response =
+ post(
+ Response.Status.CREATED,
+ form.asMap(),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "snippets",
+ snippetId,
+ "award_emoji");
+ return (response.readEntity(AwardEmoji.class));
+ }
- /**
- * Add an award emoji for the specified issue note.
- *
- * GitLab Endpoint: POST /projects/:id/issues/:issue_iid/notes/:noteId/award_emoji
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param issueIid the issue IID of the issue that owns the note
- * @param noteId the note ID to add the award emoji to
- * @param name the name of the award emoji to add
- * @return an AwardEmoji instance for the added award emoji
- * @throws GitLabApiException if any exception occurs
- */
- public AwardEmoji addIssueNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long noteId, String name) throws GitLabApiException {
- GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
- Response response = post(Response.Status.CREATED, form.asMap(),
- "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji");
- return (response.readEntity(AwardEmoji.class));
- }
+ /**
+ * Add an award emoji for the specified issue note.
+ *
+ *
+ * GitLab Endpoint: POST /projects/:id/issues/:issue_iid/notes/:noteId/award_emoji
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param issueIid the issue IID of the issue that owns the note
+ * @param noteId the note ID to add the award emoji to
+ * @param name the name of the award emoji to add
+ * @return an AwardEmoji instance for the added award emoji
+ * @throws GitLabApiException if any exception occurs
+ */
+ public AwardEmoji addIssueNoteAwardEmoji(
+ final Object projectIdOrPath, final Long issueIid, final Long noteId, final String name)
+ throws GitLabApiException {
+ final GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
+ final Response response =
+ post(
+ Response.Status.CREATED,
+ form.asMap(),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "issues",
+ issueIid,
+ "notes",
+ noteId,
+ "award_emoji");
+ return (response.readEntity(AwardEmoji.class));
+ }
- /**
- * Add an award emoji for the specified issue note.
- *
- * GitLab Endpoint: POST /projects/:id/issues/:issue_iid/notes/:noteId/award_emoji
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param issueIid the issue IID of the issue that owns the note
- * @param noteId the note ID to add the award emoji to
- * @param name the name of the award emoji to add
- * @return an AwardEmoji instance for the added award emoji
- * @throws GitLabApiException if any exception occurs
- * @deprecated use {@link #addIssueNoteAwardEmoji(Object, Long, Long, String)}
- */
- @Deprecated
- public AwardEmoji addNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long noteId, String name) throws GitLabApiException {
- return addIssueNoteAwardEmoji(projectIdOrPath, issueIid, noteId, name);
- }
+ /**
+ * Add an award emoji for the specified issue note.
+ *
+ *
+ * GitLab Endpoint: POST /projects/:id/issues/:issue_iid/notes/:noteId/award_emoji
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param issueIid the issue IID of the issue that owns the note
+ * @param noteId the note ID to add the award emoji to
+ * @param name the name of the award emoji to add
+ * @return an AwardEmoji instance for the added award emoji
+ * @throws GitLabApiException if any exception occurs
+ * @deprecated use {@link #addIssueNoteAwardEmoji(Object, Long, Long, String)}
+ */
+ @Deprecated
+ public AwardEmoji addNoteAwardEmoji(
+ final Object projectIdOrPath, final Long issueIid, final Long noteId, final String name)
+ throws GitLabApiException {
+ return addIssueNoteAwardEmoji(projectIdOrPath, issueIid, noteId, name);
+ }
- /**
- * Add an award emoji for the specified merge request note.
- *
- * GitLab Endpoint: POST /projects/:id/merge_requests/:merge_request_iid/notes/:noteId/award_emoji
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param mergeRequestIid the merge request IID of the merge request that owns the note
- * @param noteId the note ID to add the award emoji to
- * @param name the name of the award emoji to add
- * @return an AwardEmoji instance for the added award emoji
- * @throws GitLabApiException if any exception occurs
- */
- public AwardEmoji addMergeRequestAwardEmoji(Object projectIdOrPath, Integer mergeRequestIid, Integer noteId, String name) throws GitLabApiException {
- GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
- Response response = post(Response.Status.CREATED, form.asMap(),
- "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji");
- return (response.readEntity(AwardEmoji.class));
- }
+ /**
+ * Add an award emoji for the specified merge request note.
+ *
+ *
+ * GitLab Endpoint: POST /projects/:id/merge_requests/:merge_request_iid/notes/:noteId/award_emoji
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param mergeRequestIid the merge request IID of the merge request that owns the note
+ * @param noteId the note ID to add the award emoji to
+ * @param name the name of the award emoji to add
+ * @return an AwardEmoji instance for the added award emoji
+ * @throws GitLabApiException if any exception occurs
+ */
+ public AwardEmoji addMergeRequestAwardEmoji(
+ final Object projectIdOrPath,
+ final Integer mergeRequestIid,
+ final Integer noteId,
+ final String name)
+ throws GitLabApiException {
+ final GitLabApiForm form = new GitLabApiForm().withParam("name", name, true);
+ final Response response =
+ post(
+ Response.Status.CREATED,
+ form.asMap(),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "merge_requests",
+ mergeRequestIid,
+ "notes",
+ noteId,
+ "award_emoji");
+ return (response.readEntity(AwardEmoji.class));
+ }
- /**
- * Delete an award emoji from the specified issue.
- *
- * GitLab Endpoint: DELETE /projects/:id/issues/:issue_iid/award_emoji/:award_id
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param issueIid the issue IID to delete the award emoji from
- * @param awardId the ID of the award emoji to delete
- * @throws GitLabApiException if any exception occurs
- */
- public void deleteIssueAwardEmoji(Object projectIdOrPath, Long issueIid, Long awardId) throws GitLabApiException {
- delete(Response.Status.NO_CONTENT, null,
- "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "award_emoji", awardId);
- }
+ /**
+ * Delete an award emoji from the specified issue.
+ *
+ * GitLab Endpoint: DELETE /projects/:id/issues/:issue_iid/award_emoji/:award_id
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param issueIid the issue IID to delete the award emoji from
+ * @param awardId the ID of the award emoji to delete
+ * @throws GitLabApiException if any exception occurs
+ */
+ public void deleteIssueAwardEmoji(
+ final Object projectIdOrPath, final Long issueIid, final Long awardId)
+ throws GitLabApiException {
+ delete(
+ Response.Status.NO_CONTENT,
+ null,
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "issues",
+ issueIid,
+ "award_emoji",
+ awardId);
+ }
- /**
- * Delete an award emoji from the specified merge request.
- *
- * GitLab Endpoint: DELETE /projects/:id/merge_requests/:merge_request_iid/award_emoji/:award_id
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param mergeRequestIid the merge request IID to delete the award emoji from
- * @param awardId the ID of the award emoji to delete
- * @throws GitLabApiException if any exception occurs
- */
- public void deleteMergeRequestAwardEmoji(Object projectIdOrPath, Long mergeRequestIid, Long awardId) throws GitLabApiException {
- delete(Response.Status.NO_CONTENT, null,
- "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "award_emoji", awardId);
- }
+ /**
+ * Delete an award emoji from the specified merge request.
+ *
+ *
+ * GitLab Endpoint: DELETE /projects/:id/merge_requests/:merge_request_iid/award_emoji/:award_id
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param mergeRequestIid the merge request IID to delete the award emoji from
+ * @param awardId the ID of the award emoji to delete
+ * @throws GitLabApiException if any exception occurs
+ */
+ public void deleteMergeRequestAwardEmoji(
+ final Object projectIdOrPath, final Long mergeRequestIid, final Long awardId)
+ throws GitLabApiException {
+ delete(
+ Response.Status.NO_CONTENT,
+ null,
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "merge_requests",
+ mergeRequestIid,
+ "award_emoji",
+ awardId);
+ }
- /**
- * Delete an award emoji from the specified snippet.
- *
- * GitLab Endpoint: DELETE /projects/:id/snippets/:snippet_id/award_emoji/:award_id
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param snippetId the snippet ID to delete the award emoji from
- * @param awardId the ID of the award emoji to delete
- * @throws GitLabApiException if any exception occurs
- */
- public void deleteSnippetAwardEmoji(Object projectIdOrPath, Long snippetId, Long awardId) throws GitLabApiException {
- delete(Response.Status.NO_CONTENT, null,
- "projects", getProjectIdOrPath(projectIdOrPath), "snippets", snippetId, "award_emoji", awardId);
- }
+ /**
+ * Delete an award emoji from the specified snippet.
+ *
+ *
+ * GitLab Endpoint: DELETE /projects/:id/snippets/:snippet_id/award_emoji/:award_id
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param snippetId the snippet ID to delete the award emoji from
+ * @param awardId the ID of the award emoji to delete
+ * @throws GitLabApiException if any exception occurs
+ */
+ public void deleteSnippetAwardEmoji(
+ final Object projectIdOrPath, final Long snippetId, final Long awardId)
+ throws GitLabApiException {
+ delete(
+ Response.Status.NO_CONTENT,
+ null,
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "snippets",
+ snippetId,
+ "award_emoji",
+ awardId);
+ }
- /**
- * Delete an award emoji from the specified issue note.
- *
- * GitLab Endpoint: DELETE /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param issueIid the issue IID that owns the note
- * @param noteId the note ID of the note to delete the award emoji from
- * @param awardId the ID of the award emoji to delete
- * @throws GitLabApiException if any exception occurs
- */
- public void deleteIssueNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long noteId, Long awardId) throws GitLabApiException {
- delete(Response.Status.NO_CONTENT, null,
- "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes", noteId, "award_emoji", awardId);
- }
+ /**
+ * Delete an award emoji from the specified issue note.
+ *
+ *
+ * GitLab Endpoint: DELETE /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param issueIid the issue IID that owns the note
+ * @param noteId the note ID of the note to delete the award emoji from
+ * @param awardId the ID of the award emoji to delete
+ * @throws GitLabApiException if any exception occurs
+ */
+ public void deleteIssueNoteAwardEmoji(
+ final Object projectIdOrPath, final Long issueIid, final Long noteId, final Long awardId)
+ throws GitLabApiException {
+ delete(
+ Response.Status.NO_CONTENT,
+ null,
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "issues",
+ issueIid,
+ "notes",
+ noteId,
+ "award_emoji",
+ awardId);
+ }
- /**
- * Delete an award emoji from the specified issue note.
- *
- * GitLab Endpoint: DELETE /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param issueIid the issue IID that owns the note
- * @param noteId the note ID of the note to delete the award emoji from
- * @param awardId the ID of the award emoji to delete
- * @throws GitLabApiException if any exception occurs
- * @deprecated use {@link #deleteIssueNoteAwardEmoji(Object, Long, Long, Long)} instead
- */
- @Deprecated
- public void deleteNoteAwardEmoji(Object projectIdOrPath, Long issueIid, Long noteId, Long awardId) throws GitLabApiException {
- deleteIssueNoteAwardEmoji(projectIdOrPath, issueIid, noteId, awardId);
- }
+ /**
+ * Delete an award emoji from the specified issue note.
+ *
+ *
+ * GitLab Endpoint: DELETE /projects/:id/issues/:issue_iid/notes/:note_id/award_emoji/:award_id
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param issueIid the issue IID that owns the note
+ * @param noteId the note ID of the note to delete the award emoji from
+ * @param awardId the ID of the award emoji to delete
+ * @throws GitLabApiException if any exception occurs
+ * @deprecated use {@link #deleteIssueNoteAwardEmoji(Object, Long, Long, Long)} instead
+ */
+ @Deprecated
+ public void deleteNoteAwardEmoji(
+ final Object projectIdOrPath, final Long issueIid, final Long noteId, final Long awardId)
+ throws GitLabApiException {
+ deleteIssueNoteAwardEmoji(projectIdOrPath, issueIid, noteId, awardId);
+ }
- /**
- * Delete an award emoji from the specified merge request note.
- *
- * GitLab Endpoint: DELETE /projects/:id/merge_requests/:merge_request_iid/notes/:note_id/award_emoji/:award_id
- *
- * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
- * @param mergeRequestIid the merge request IID of the merge request that owns the note
- * @param noteId the note ID of the note to delete the award emoji from
- * @param awardId the ID of the award emoji to delete
- * @throws GitLabApiException if any exception occurs
- */
- public void deleteMergeRequestNoteAwardEmoji(Object projectIdOrPath, Long mergeRequestIid, Long noteId, Long awardId) throws GitLabApiException {
- delete(Response.Status.NO_CONTENT, null,
- "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "notes", noteId, "award_emoji", awardId);
- }
+ /**
+ * Delete an award emoji from the specified merge request note.
+ *
+ *
+ * GitLab Endpoint: DELETE /projects/:id/merge_requests/:merge_request_iid/notes/:note_id/award_emoji/:award_id
+ *
+ *
+ * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or
+ * path
+ * @param mergeRequestIid the merge request IID of the merge request that owns the note
+ * @param noteId the note ID of the note to delete the award emoji from
+ * @param awardId the ID of the award emoji to delete
+ * @throws GitLabApiException if any exception occurs
+ */
+ public void deleteMergeRequestNoteAwardEmoji(
+ final Object projectIdOrPath,
+ final Long mergeRequestIid,
+ final Long noteId,
+ final Long awardId)
+ throws GitLabApiException {
+ delete(
+ Response.Status.NO_CONTENT,
+ null,
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "merge_requests",
+ mergeRequestIid,
+ "notes",
+ noteId,
+ "award_emoji",
+ awardId);
+ }
}
diff --git a/src/main/java/org/gitlab4j/api/BoardsApi.java b/src/main/java/org/gitlab4j/api/BoardsApi.java
index 975cba5e4..ff04152da 100644
--- a/src/main/java/org/gitlab4j/api/BoardsApi.java
+++ b/src/main/java/org/gitlab4j/api/BoardsApi.java
@@ -3,327 +3,453 @@
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
-
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.Response;
-
+import jakarta.ws.rs.core.GenericType;
+import jakarta.ws.rs.core.Response;
import org.gitlab4j.api.models.Board;
import org.gitlab4j.api.models.BoardList;
/**
* This class implements the client side API for the GitLab Issue Boards API calls.
*
- * NOTE: If a user is not a member of a group and the group is private,
- * a GET request on that group will result to a 404 status code.
+ * NOTE: If a user is not a member of a group and the group is private, a GET request on that
+ * group will result to a 404 status code.
*
- * @see GitLab Issue Boards API Documentaion
+ * @see GitLab Issue Boards API
+ * Documentaion
*/
public class BoardsApi extends AbstractApi {
- public BoardsApi(GitLabApi gitLabApi) {
- super(gitLabApi);
- }
+ public BoardsApi(final GitLabApi gitLabApi) {
+ super(gitLabApi);
+ }
- /**
- * Lists Issue Boards in the given project.
- *
- *
GitLab Endpoint: GET /projects/:id/boards
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @return a list of project's issue boards
- * @throws GitLabApiException if any exception occurs
- */
- public List getBoards(Object projectIdOrPath) throws GitLabApiException {
- return (getBoards(projectIdOrPath, getDefaultPerPage()).all());
- }
+ /**
+ * Lists Issue Boards in the given project.
+ *
+ * GitLab Endpoint: GET /projects/:id/boards
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @return a list of project's issue boards
+ * @throws GitLabApiException if any exception occurs
+ */
+ public List getBoards(final Object projectIdOrPath) throws GitLabApiException {
+ return (getBoards(projectIdOrPath, getDefaultPerPage()).all());
+ }
- /**
- * Get all issue boards for the specified project using the specified page and per page setting
- *
- * GitLab Endpoint: GET /projects/:id/boards
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param page the page to get
- * @param perPage the number of items per page
- * @return a list of project's Boards in the specified range
- * @throws GitLabApiException if any exception occurs
- */
- public List getBoards(Object projectIdOrPath, int page, int perPage) throws GitLabApiException {
- Response response = get(javax.ws.rs.core.Response.Status.OK, getPageQueryParams(page, perPage),
- "projects", getProjectIdOrPath(projectIdOrPath), "boards");
- return (response.readEntity(new GenericType>() {}));
- }
+ /**
+ * Get all issue boards for the specified project using the specified page and per page setting
+ *
+ * GitLab Endpoint: GET /projects/:id/boards
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param page the page to get
+ * @param perPage the number of items per page
+ * @return a list of project's Boards in the specified range
+ * @throws GitLabApiException if any exception occurs
+ */
+ public List getBoards(final Object projectIdOrPath, final int page, final int perPage)
+ throws GitLabApiException {
+ final Response response =
+ get(
+ jakarta.ws.rs.core.Response.Status.OK,
+ getPageQueryParams(page, perPage),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "boards");
+ return (response.readEntity(new GenericType>() {}));
+ }
- /**
- * Get a Pager of all issue boards for the specified project.
- *
- * GitLab Endpoint: GET /projects/:id/boards
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param itemsPerPage the number of items per page
- * @return a Pager of project's issue boards
- * @throws GitLabApiException if any exception occurs
- */
- public Pager getBoards(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException {
- return (new Pager(this, Board.class, itemsPerPage, null,
- "projects", getProjectIdOrPath(projectIdOrPath), "boards"));
- }
+ /**
+ * Get a Pager of all issue boards for the specified project.
+ *
+ * GitLab Endpoint: GET /projects/:id/boards
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param itemsPerPage the number of items per page
+ * @return a Pager of project's issue boards
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Pager getBoards(final Object projectIdOrPath, final int itemsPerPage)
+ throws GitLabApiException {
+ return (new Pager(
+ this,
+ Board.class,
+ itemsPerPage,
+ null,
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "boards"));
+ }
- /**
- * Get a Stream of all issue boards for the specified project.
- *
- * GitLab Endpoint: GET /projects/:id/boards
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @return a Stream of project's issue boards
- * @throws GitLabApiException if any exception occurs
- */
- public Stream getBoardsStream(Object projectIdOrPath) throws GitLabApiException {
- return (getBoards(projectIdOrPath, getDefaultPerPage()).stream());
- }
+ /**
+ * Get a Stream of all issue boards for the specified project.
+ *
+ * GitLab Endpoint: GET /projects/:id/boards
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @return a Stream of project's issue boards
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Stream getBoardsStream(final Object projectIdOrPath) throws GitLabApiException {
+ return (getBoards(projectIdOrPath, getDefaultPerPage()).stream());
+ }
- /**
- * Get a single issue board.
- *
- * GitLab Endpoint: GET /projects/:id/boards/:board_id
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param boardId the ID of the board
- * @return a Board instance for the specified board ID
- * @throws GitLabApiException if any exception occurs
- */
- public Board getBoard(Object projectIdOrPath, Long boardId) throws GitLabApiException {
- Response response = get(Response.Status.OK, null,
- "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId);
- return (response.readEntity(Board.class));
- }
+ /**
+ * Get a single issue board.
+ *
+ * GitLab Endpoint: GET /projects/:id/boards/:board_id
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param boardId the ID of the board
+ * @return a Board instance for the specified board ID
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Board getBoard(final Object projectIdOrPath, final Long boardId)
+ throws GitLabApiException {
+ final Response response =
+ get(
+ Response.Status.OK,
+ null,
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "boards",
+ boardId);
+ return (response.readEntity(Board.class));
+ }
- /**
- * Get an issue board as an Optional instance.
- *
- * GitLab Endpoint: GET /projects/:id/boards/:board_id
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param boardId the ID of the board
- * @return the Board instance for the specified board ID as an Optional instance
- */
- public Optional getOptionalBoard(Object projectIdOrPath, Long boardId) {
- try {
- return (Optional.ofNullable(getBoard(projectIdOrPath, boardId)));
- } catch (GitLabApiException glae) {
- return (GitLabApi.createOptionalFromException(glae));
- }
+ /**
+ * Get an issue board as an Optional instance.
+ *
+ * GitLab Endpoint: GET /projects/:id/boards/:board_id
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param boardId the ID of the board
+ * @return the Board instance for the specified board ID as an Optional instance
+ */
+ public Optional getOptionalBoard(final Object projectIdOrPath, final Long boardId) {
+ try {
+ return (Optional.ofNullable(getBoard(projectIdOrPath, boardId)));
+ } catch (final GitLabApiException glae) {
+ return (GitLabApi.createOptionalFromException(glae));
}
+ }
- /**
- * Creates a new Issue Board.
- *
- * NOTE: This is only available in GitLab EE
- *
- * GitLab Endpoint: POST /projects/:id/boards
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param name the name for the new board
- * @return the created Board instance
- * @throws GitLabApiException if any exception occurs
- */
- public Board createBoard(Object projectIdOrPath, String name) throws GitLabApiException {
- GitLabApiForm formData = new GitLabApiForm().withParam("name", name, true);
- Response response = post(Response.Status.CREATED, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "boards");
- return (response.readEntity(Board.class));
- }
+ /**
+ * Creates a new Issue Board.
+ *
+ * NOTE: This is only available in GitLab EE
+ *
+ *
GitLab Endpoint: POST /projects/:id/boards
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param name the name for the new board
+ * @return the created Board instance
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Board createBoard(final Object projectIdOrPath, final String name)
+ throws GitLabApiException {
+ final GitLabApiForm formData = new GitLabApiForm().withParam("name", name, true);
+ final Response response =
+ post(
+ Response.Status.CREATED,
+ formData.asMap(),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "boards");
+ return (response.readEntity(Board.class));
+ }
- /**
- * Updates an existing Issue Board.
- *
- * NOTE: This is only available in GitLab EE
- *
- * GitLab Endpoint: PUT /projects/:id/boards/:board_id
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance, required
- * @param boardId the ID of the board, required
- * @param name the new name of the board, optional (can be null)
- * @param assigneeId the assignee the board should be scoped to, optional (can be null)
- * @param milestoneId the milestone the board should be scoped to, optional (can be null)
- * @param labels a comma-separated list of label names which the board should be scoped to, optional (can be null)
- * @param weight the weight range from 0 to 9, to which the board should be scoped to, optional (can be null)
- * @return the updated Board instance
- * @throws GitLabApiException if any exception occurs
- */
- public BoardList updateBoard(Object projectIdOrPath, Long boardId, String name,
- Long assigneeId, Long milestoneId, String labels, Integer weight) throws GitLabApiException {
- GitLabApiForm formData = new GitLabApiForm()
- .withParam("name", name)
- .withParam("assignee_id", assigneeId)
- .withParam("milestone_id", milestoneId)
- .withParam("labels", labels)
- .withParam("weight", weight);
- Response response = put(Response.Status.OK, formData.asMap(),
- "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId);
- return (response.readEntity(BoardList.class));
- }
+ /**
+ * Updates an existing Issue Board.
+ *
+ * NOTE: This is only available in GitLab EE
+ *
+ *
GitLab Endpoint: PUT /projects/:id/boards/:board_id
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance, required
+ * @param boardId the ID of the board, required
+ * @param name the new name of the board, optional (can be null)
+ * @param assigneeId the assignee the board should be scoped to, optional (can be null)
+ * @param milestoneId the milestone the board should be scoped to, optional (can be null)
+ * @param labels a comma-separated list of label names which the board should be scoped to,
+ * optional (can be null)
+ * @param weight the weight range from 0 to 9, to which the board should be scoped to, optional
+ * (can be null)
+ * @return the updated Board instance
+ * @throws GitLabApiException if any exception occurs
+ */
+ public BoardList updateBoard(
+ final Object projectIdOrPath,
+ final Long boardId,
+ final String name,
+ final Long assigneeId,
+ final Long milestoneId,
+ final String labels,
+ final Integer weight)
+ throws GitLabApiException {
+ final GitLabApiForm formData =
+ new GitLabApiForm()
+ .withParam("name", name)
+ .withParam("assignee_id", assigneeId)
+ .withParam("milestone_id", milestoneId)
+ .withParam("labels", labels)
+ .withParam("weight", weight);
+ final Response response =
+ put(
+ Response.Status.OK,
+ formData.asMap(),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "boards",
+ boardId);
+ return (response.readEntity(BoardList.class));
+ }
- /**
- * Soft deletes an existing Issue Board.
- *
- * NOTE: This is only available in GitLab EE
- *
- * GitLab Endpoint: DELETE /projects/:id/boards/:board_id
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param boardId the ID of the board
- * @throws GitLabApiException if any exception occurs
- */
- public void deleteBoard(Object projectIdOrPath, Long boardId) throws GitLabApiException {
- delete(Response.Status.NO_CONTENT, null, "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId);
- }
+ /**
+ * Soft deletes an existing Issue Board.
+ *
+ * NOTE: This is only available in GitLab EE
+ *
+ *
GitLab Endpoint: DELETE /projects/:id/boards/:board_id
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param boardId the ID of the board
+ * @throws GitLabApiException if any exception occurs
+ */
+ public void deleteBoard(final Object projectIdOrPath, final Long boardId)
+ throws GitLabApiException {
+ delete(
+ Response.Status.NO_CONTENT,
+ null,
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "boards",
+ boardId);
+ }
- /**
- * Get a list of the board’s lists. Does not include open and closed lists.
- *
- * GitLab Endpoint: GET /projects/:id/boards/:board_id/lists
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param boardId the ID of the board
- * @return a list of the issue board's lists
- * @throws GitLabApiException if any exception occurs
- */
- public List getBoardLists(Object projectIdOrPath, Long boardId) throws GitLabApiException {
- return (getBoardLists(projectIdOrPath, boardId, getDefaultPerPage()).all());
- }
+ /**
+ * Get a list of the board’s lists. Does not include open and closed lists.
+ *
+ * GitLab Endpoint: GET /projects/:id/boards/:board_id/lists
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param boardId the ID of the board
+ * @return a list of the issue board's lists
+ * @throws GitLabApiException if any exception occurs
+ */
+ public List getBoardLists(final Object projectIdOrPath, final Long boardId)
+ throws GitLabApiException {
+ return (getBoardLists(projectIdOrPath, boardId, getDefaultPerPage()).all());
+ }
- /**
- * Get a list of the board’s lists for the specified project to using the specified page and per page setting.
- * Does not include open and closed lists.
- *
- * GitLab Endpoint: GET /projects/:id/boards/:board_id/lists
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param boardId the ID of the board
- * @param page the page to get
- * @param perPage the number of Boards per page
- * @return a list of the issue board's lists in the specified range
- * @throws GitLabApiException if any exception occurs
- */
- public List getBoardLists(Object projectIdOrPath, Long boardId, int page, int perPage) throws GitLabApiException {
- Response response = get(javax.ws.rs.core.Response.Status.OK, getPageQueryParams(page, perPage),
- "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId, "lists");
- return (response.readEntity(new GenericType>() {}));
- }
+ /**
+ * Get a list of the board’s lists for the specified project to using the specified page and per
+ * page setting. Does not include open and closed lists.
+ *
+ * GitLab Endpoint: GET /projects/:id/boards/:board_id/lists
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param boardId the ID of the board
+ * @param page the page to get
+ * @param perPage the number of Boards per page
+ * @return a list of the issue board's lists in the specified range
+ * @throws GitLabApiException if any exception occurs
+ */
+ public List getBoardLists(
+ final Object projectIdOrPath, final Long boardId, final int page, final int perPage)
+ throws GitLabApiException {
+ final Response response =
+ get(
+ jakarta.ws.rs.core.Response.Status.OK,
+ getPageQueryParams(page, perPage),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "boards",
+ boardId,
+ "lists");
+ return (response.readEntity(new GenericType>() {}));
+ }
- /**
- * Get a Pager of the board’s lists. Does not include open and closed lists.
- *
- * GitLab Endpoint: GET /projects/:id/boards/:board_id/lists
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param boardId the ID of the board
- * @param itemsPerPage the number of Board instances that will be fetched per page
- * @return a Pager of the issue board's lists
- * @throws GitLabApiException if any exception occurs
- */
- public Pager getBoardLists(Object projectIdOrPath, Long boardId, int itemsPerPage) throws GitLabApiException {
- return (new Pager(this, BoardList.class, itemsPerPage, null,
- "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId, "lists"));
- }
+ /**
+ * Get a Pager of the board’s lists. Does not include open and closed lists.
+ *
+ * GitLab Endpoint: GET /projects/:id/boards/:board_id/lists
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param boardId the ID of the board
+ * @param itemsPerPage the number of Board instances that will be fetched per page
+ * @return a Pager of the issue board's lists
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Pager getBoardLists(
+ final Object projectIdOrPath, final Long boardId, final int itemsPerPage)
+ throws GitLabApiException {
+ return (new Pager(
+ this,
+ BoardList.class,
+ itemsPerPage,
+ null,
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "boards",
+ boardId,
+ "lists"));
+ }
- /**
- * Get a Stream of the board’s lists. Does not include open and closed lists.
- *
- * GitLab Endpoint: GET /projects/:id/boards/:board_id/lists
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param boardId the ID of the board
- * @return a Stream of the issue board's lists
- * @throws GitLabApiException if any exception occurs
- */
- public Stream getBoardsListsStream(Object projectIdOrPath, Long boardId) throws GitLabApiException {
- return (getBoardLists(projectIdOrPath, boardId, getDefaultPerPage()).stream());
- }
+ /**
+ * Get a Stream of the board’s lists. Does not include open and closed lists.
+ *
+ * GitLab Endpoint: GET /projects/:id/boards/:board_id/lists
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param boardId the ID of the board
+ * @return a Stream of the issue board's lists
+ * @throws GitLabApiException if any exception occurs
+ */
+ public Stream getBoardsListsStream(final Object projectIdOrPath, final Long boardId)
+ throws GitLabApiException {
+ return (getBoardLists(projectIdOrPath, boardId, getDefaultPerPage()).stream());
+ }
- /**
- * Get a single issue board list.
- *
- * GitLab Endpoint: GET /projects/:id/boards/:board_id/lists/:list_id
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param boardId the ID of the board
- * @param listId the ID of the board lists to get
- * @return a BoardList instance for the specified board ID and list ID
- * @throws GitLabApiException if any exception occurs
- */
- public BoardList getBoardList(Object projectIdOrPath, Long boardId, Long listId) throws GitLabApiException {
- Response response = get(Response.Status.OK, null,
- "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId, "lists", listId);
- return (response.readEntity(BoardList.class));
- }
+ /**
+ * Get a single issue board list.
+ *
+ * GitLab Endpoint: GET /projects/:id/boards/:board_id/lists/:list_id
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param boardId the ID of the board
+ * @param listId the ID of the board lists to get
+ * @return a BoardList instance for the specified board ID and list ID
+ * @throws GitLabApiException if any exception occurs
+ */
+ public BoardList getBoardList(final Object projectIdOrPath, final Long boardId, final Long listId)
+ throws GitLabApiException {
+ final Response response =
+ get(
+ Response.Status.OK,
+ null,
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "boards",
+ boardId,
+ "lists",
+ listId);
+ return (response.readEntity(BoardList.class));
+ }
- /**
- * Get a single issue board list as an Optional instance.
- *
- * GitLab Endpoint: GET /projects/:id/boards/:board_id/lists/:list_id
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param boardId the ID of the board
- * @param listId the ID of the board lists to get
- * @return a BoardList instance for the specified board ID and list ID as an Optional instance
- */
- public Optional getOptionalBoardList(Object projectIdOrPath, Long boardId, Long listId) {
- try {
- return (Optional.ofNullable(getBoardList(projectIdOrPath, boardId, listId)));
- } catch (GitLabApiException glae) {
- return (GitLabApi.createOptionalFromException(glae));
- }
+ /**
+ * Get a single issue board list as an Optional instance.
+ *
+ * GitLab Endpoint: GET /projects/:id/boards/:board_id/lists/:list_id
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param boardId the ID of the board
+ * @param listId the ID of the board lists to get
+ * @return a BoardList instance for the specified board ID and list ID as an Optional instance
+ */
+ public Optional getOptionalBoardList(
+ final Object projectIdOrPath, final Long boardId, final Long listId) {
+ try {
+ return (Optional.ofNullable(getBoardList(projectIdOrPath, boardId, listId)));
+ } catch (final GitLabApiException glae) {
+ return (GitLabApi.createOptionalFromException(glae));
}
+ }
- /**
- * Creates a new Issue Board list.
- *
- * GitLab Endpoint: POST /projects/:id/boards/:board_id/lists
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param boardId the ID of the board
- * @param labelId the ID of the label
- * @return the created BoardList instance
- * @throws GitLabApiException if any exception occurs
- */
- public BoardList createBoardList(Object projectIdOrPath, Long boardId, Long labelId) throws GitLabApiException {
- GitLabApiForm formData = new GitLabApiForm()
- .withParam("label_id", labelId, true);
- Response response = post(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId, "lists");
- return (response.readEntity(BoardList.class));
- }
+ /**
+ * Creates a new Issue Board list.
+ *
+ * GitLab Endpoint: POST /projects/:id/boards/:board_id/lists
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param boardId the ID of the board
+ * @param labelId the ID of the label
+ * @return the created BoardList instance
+ * @throws GitLabApiException if any exception occurs
+ */
+ public BoardList createBoardList(
+ final Object projectIdOrPath, final Long boardId, final Long labelId)
+ throws GitLabApiException {
+ final GitLabApiForm formData = new GitLabApiForm().withParam("label_id", labelId, true);
+ final Response response =
+ post(
+ Response.Status.CREATED,
+ formData,
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "boards",
+ boardId,
+ "lists");
+ return (response.readEntity(BoardList.class));
+ }
- /**
- * Updates an existing Issue Board list. This call is used to change list position.
- *
- * GitLab Endpoint: PUT /projects/:id/boards/:board_id/lists/:list_id
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param boardId the ID of the board
- * @param listId the ID of the list
- * @param position the new position for the list
- * @return the updated BoardList instance
- * @throws GitLabApiException if any exception occurs
- */
- public BoardList updateBoardList(Object projectIdOrPath, Long boardId, Long listId, Integer position) throws GitLabApiException {
- GitLabApiForm formData = new GitLabApiForm().withParam("position", position, true);
- Response response = putWithFormData(Response.Status.OK, formData,
- "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId, "lists", listId);
- return (response.readEntity(BoardList.class));
- }
+ /**
+ * Updates an existing Issue Board list. This call is used to change list position.
+ *
+ * GitLab Endpoint: PUT /projects/:id/boards/:board_id/lists/:list_id
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param boardId the ID of the board
+ * @param listId the ID of the list
+ * @param position the new position for the list
+ * @return the updated BoardList instance
+ * @throws GitLabApiException if any exception occurs
+ */
+ public BoardList updateBoardList(
+ final Object projectIdOrPath, final Long boardId, final Long listId, final Integer position)
+ throws GitLabApiException {
+ final GitLabApiForm formData = new GitLabApiForm().withParam("position", position, true);
+ final Response response =
+ putWithFormData(
+ Response.Status.OK,
+ formData,
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "boards",
+ boardId,
+ "lists",
+ listId);
+ return (response.readEntity(BoardList.class));
+ }
- /**
- * Soft deletes an existing Issue Board list. Only for admins and project owners.
- *
- * GitLab Endpoint: DELETE /projects/:id/boards/:board_id/lists/:list_id
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param boardId the ID of the board
- * @param listId the ID of the list
- * @throws GitLabApiException if any exception occurs
- */
- public void deleteBoardList(Object projectIdOrPath, Long boardId, Long listId) throws GitLabApiException {
- delete(Response.Status.NO_CONTENT, null, "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId, "lists", listId);
- }
+ /**
+ * Soft deletes an existing Issue Board list. Only for admins and project owners.
+ *
+ * GitLab Endpoint: DELETE /projects/:id/boards/:board_id/lists/:list_id
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param boardId the ID of the board
+ * @param listId the ID of the list
+ * @throws GitLabApiException if any exception occurs
+ */
+ public void deleteBoardList(final Object projectIdOrPath, final Long boardId, final Long listId)
+ throws GitLabApiException {
+ delete(
+ Response.Status.NO_CONTENT,
+ null,
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "boards",
+ boardId,
+ "lists",
+ listId);
+ }
}
diff --git a/src/main/java/org/gitlab4j/api/CommitsApi.java b/src/main/java/org/gitlab4j/api/CommitsApi.java
index c6cffde7d..0ae4308d2 100644
--- a/src/main/java/org/gitlab4j/api/CommitsApi.java
+++ b/src/main/java/org/gitlab4j/api/CommitsApi.java
@@ -1,16 +1,14 @@
package org.gitlab4j.api;
+import jakarta.ws.rs.core.Form;
+import jakarta.ws.rs.core.GenericType;
+import jakarta.ws.rs.core.MultivaluedMap;
+import jakarta.ws.rs.core.Response;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
-
-import javax.ws.rs.core.Form;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-
import org.gitlab4j.api.models.Comment;
import org.gitlab4j.api.models.Commit;
import org.gitlab4j.api.models.CommitAction;
@@ -26,940 +24,1324 @@
import org.gitlab4j.api.utils.ISO8601;
/**
- * This class implements the client side API for the GitLab commits calls.
- * See Commits API at GitLab for more information.
+ * This class implements the client side API for the GitLab commits calls. See Commits API at GitLab for more
+ * information.
*/
public class CommitsApi extends AbstractApi {
- public CommitsApi(GitLabApi gitLabApi) {
- super(gitLabApi);
- }
-
- /**
- * Get a list of all repository commits in a project.
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @return a list containing the commits for the specified project ID
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- */
- public List getCommits(Object projectIdOrPath) throws GitLabApiException {
- return (getCommits(projectIdOrPath, null, null, null, null, true, null, null, getDefaultPerPage()).all());
- }
-
- /**
- * Get a list of repository commits in a project.
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param page the page to get
- * @param perPage the number of commits per page
- * @return a list containing the commits for the specified project ID
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- * @deprecated
- */
- @Deprecated
- public List getCommits(Object projectIdOrPath, int page, int perPage) throws GitLabApiException {
- return (getCommits(projectIdOrPath, null, null, null, page, perPage));
- }
-
- /**
- * Get a Pager of all repository commits in a project.
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param itemsPerPage the number of Commit instances that will be fetched per page
- * @return a Pager containing the commits for the specified project ID
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- */
- public Pager getCommits(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException {
- return (getCommits(projectIdOrPath, null, null, null, null, true, null, null, itemsPerPage));
- }
-
- /**
- * Get a Stream of all repository commits in a project.
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @return a Stream containing the commits for the specified project ID
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- */
- public Stream getCommitStream(Object projectIdOrPath) throws GitLabApiException {
- return (getCommits(projectIdOrPath, null, null, null,null, true, null, null, getDefaultPerPage()).stream());
- }
-
- /**
- * Get a list of repository commits in a project.
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param ref the name of a repository branch or tag or if not given the default branch
- * @param since only commits after or on this date will be returned
- * @param until only commits before or on this date will be returned
- * @param path the path to file of a project
- * @return a list containing the commits for the specified project ID
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- */
- public List getCommits(Object projectIdOrPath, String ref, Date since, Date until, String path) throws GitLabApiException {
- return (getCommits(projectIdOrPath, ref, since, until, path, null, null, null, getDefaultPerPage()).all());
- }
-
- /**
- * Get a list of file commits in a project
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits?path=:file_path
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param ref the name of a repository branch or tag or if not given the default branch
- * @param path the path to file of a project
- * @return a list containing the commits for the specified project ID and file
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- */
- public List getCommits(Object projectIdOrPath, String ref, String path) throws GitLabApiException {
- return (getCommits(projectIdOrPath, ref, null, null, path, null, null, null, getDefaultPerPage()).all());
- }
-
- /**
- * Get a list of repository commits in a project.
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param ref the name of a repository branch or tag or if not given the default branch
- * @param since only commits after or on this date will be returned
- * @param until only commits before or on this date will be returned
- * @return a list containing the commits for the specified project ID
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- */
- public List getCommits(Object projectIdOrPath, String ref, Date since, Date until) throws GitLabApiException {
- return (getCommits(projectIdOrPath, ref, since, until, null, null, null, null, getDefaultPerPage()).all());
- }
-
- /**
- * Get a list of repository commits in a project.
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param ref the name of a repository branch or tag or if not given the default branch
- * @param since only commits after or on this date will be returned
- * @param until only commits before or on this date will be returned
- * @param page the page to get
- * @param perPage the number of commits per page
- * @return a list containing the commits for the specified project ID
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- * @deprecated
- */
- @Deprecated
- public List getCommits(Object projectIdOrPath, String ref, Date since, Date until, int page, int perPage) throws GitLabApiException {
- return (getCommits(projectIdOrPath, ref, since, until, null, page, perPage));
- }
-
- /**
- * Get a Stream of repository commits in a project.
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param ref the name of a repository branch or tag or if not given the default branch
- * @param since only commits after or on this date will be returned
- * @param until only commits before or on this date will be returned
- * @return a Stream containing the commits for the specified project ID
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- */
- public Stream getCommitsStream(Object projectIdOrPath, String ref, Date since, Date until) throws GitLabApiException {
- return (getCommits(projectIdOrPath, ref, since, until, null, null, null, null, getDefaultPerPage()).stream());
- }
-
- /**
- * Get a Stream of repository commits in a project.
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param ref the name of a repository branch or tag or if not given the default branch
- * @param since only commits after or on this date will be returned
- * @param until only commits before or on this date will be returned
- * @param path the path to file of a project
- * @return a Stream containing the commits for the specified project ID
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- */
- public Stream getCommitsStream(Object projectIdOrPath, String ref, Date since, Date until, String path) throws GitLabApiException {
- return (getCommits(projectIdOrPath, ref, since, until, path, null, null, null, getDefaultPerPage()).stream());
- }
-
- /**
- * Get a list of repository commits in a project.
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param ref the name of a repository branch or tag or if not given the default branch
- * @param since only commits after or on this date will be returned
- * @param until only commits before or on this date will be returned
- * @param path the path to file of a project
- * @param page the page to get
- * @param perPage the number of commits per page
- * @return a list containing the commits for the specified project ID
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- * @deprecated
- */
- @Deprecated
- public List getCommits(Object projectIdOrPath, String ref, Date since, Date until, String path, int page, int perPage) throws GitLabApiException {
- Form formData = new GitLabApiForm()
- .withParam("ref_name", ref)
- .withParam("since", ISO8601.toString(since, false))
- .withParam("until", ISO8601.toString(until, false))
- .withParam("path", (path == null ? null : urlEncode(path)))
- .withParam(PAGE_PARAM, page)
- .withParam(PER_PAGE_PARAM, perPage);
- Response response = get(Response.Status.OK, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits");
- return (response.readEntity(new GenericType>() {}));
- }
-
- /**
- * Get a Pager of repository commits in a project.
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param ref the name of a repository branch or tag or if not given the default branch
- * @param since only commits after or on this date will be returned
- * @param until only commits before or on this date will be returned
- * @param itemsPerPage the number of Commit instances that will be fetched per page
- * @return a Pager containing the commits for the specified project ID
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- */
- public Pager getCommits(Object projectIdOrPath, String ref, Date since, Date until, int itemsPerPage) throws GitLabApiException {
- return getCommits(projectIdOrPath, ref, since, until, null, null, null, null, itemsPerPage);
- }
-
- /**
- * Get a Pager of repository commits in a project
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param ref the name of a repository branch or tag or if not given the default branch
- * @param since only commits after or on this date will be returned
- * @param until only commits before or on this date will be returned
- * @param itemsPerPage the number of Commit instances that will be fetched per page
- * @param path the path to file of a project
- * @return a Pager containing the commits for the specified project ID
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- */
- public Pager getCommits(Object projectIdOrPath, String ref, Date since, Date until, String path, int itemsPerPage) throws GitLabApiException {
- return (getCommits(projectIdOrPath, ref, since, until, path, null, null, null, itemsPerPage));
- }
-
- /**
- * Get a List of the specified repository commits in a project
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param ref the name of a repository branch or tag or if not given the default branch
- * @param since only commits after or on this date will be returned
- * @param until only commits before or on this date will be returned
- * @param path the path to file of a project
- * @param all retrieve every commit from the repository
- * @param withStats stats about each commit will be added to the response
- * @param firstParent follow only the first parent commit upon seeing a merge commit
- * @return a Pager containing the commits for the specified project ID
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- */
- public List getCommits(Object projectIdOrPath, String ref, Date since, Date until,
- String path, Boolean all, Boolean withStats, Boolean firstParent) throws GitLabApiException {
- return (getCommits(projectIdOrPath, ref, since, until, path, all, withStats, firstParent, getDefaultPerPage()).all());
- }
-
- /**
- * Get a Pager of the specified repository commits in a project
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param ref the name of a repository branch or tag or if not given the default branch
- * @param since only commits after or on this date will be returned
- * @param until only commits before or on this date will be returned
- * @param path the path to file of a project
- * @param all retrieve every commit from the repository
- * @param withStats stats about each commit will be added to the response
- * @param firstParent follow only the first parent commit upon seeing a merge commit
- * @param itemsPerPage the number of Commit instances that will be fetched per page
- * @return a Pager containing the commits for the specified project ID
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- */
- public Pager getCommits(Object projectIdOrPath, String ref, Date since, Date until,
- String path, Boolean all, Boolean withStats, Boolean firstParent, int itemsPerPage) throws GitLabApiException {
- Form formData = new GitLabApiForm()
- .withParam("ref_name", ref)
- .withParam("since", ISO8601.toString(since, false))
- .withParam("until", ISO8601.toString(until, false))
- .withParam("path", (path == null ? null : urlEncode(path)))
- .withParam("all", all)
- .withParam("with_stats", withStats)
- .withParam("first_parent", firstParent);
- return (new Pager(this, Commit.class, itemsPerPage, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits"));
- }
-
- /**
- * Get a Stream of the specified repository commits in a project
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param ref the name of a repository branch or tag or if not given the default branch
- * @param since only commits after or on this date will be returned
- * @param until only commits before or on this date will be returned
- * @param path the path to file of a project
- * @param all retrieve every commit from the repository
- * @param withStats stats about each commit will be added to the response
- * @param firstParent follow only the first parent commit upon seeing a merge commit
- * @return a Stream containing the commits for the specified project ID
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- */
- public Stream getCommitsStream(Object projectIdOrPath, String ref, Date since, Date until,
- String path, Boolean all, Boolean withStats, Boolean firstParent) throws GitLabApiException {
- return (getCommits(projectIdOrPath, ref, since, until, path, all, withStats, firstParent, getDefaultPerPage()).stream());
- }
-
- /**
- * Get a specific commit identified by the commit hash or name of a branch or tag.
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits/:sha
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param sha a commit hash or name of a branch or tag
- * @return the Commit instance for the specified project ID/sha pair
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- */
- public Commit getCommit(Object projectIdOrPath, String sha) throws GitLabApiException {
- Response response = get(Response.Status.OK, getDefaultPerPageParam(), "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", urlEncode(sha));
- return (response.readEntity(Commit.class));
- }
-
- /**
- * Get a specific commit identified by the commit hash or name of a branch or tag as an Optional instance
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits/:sha
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param sha a commit hash or name of a branch or tag
- * @return the Commit for the specified project ID/sha pair as an Optional instance
- */
- public Optional getOptionalCommit(Object projectIdOrPath, String sha) {
- try {
- return (Optional.ofNullable(getCommit(projectIdOrPath, sha)));
- } catch (GitLabApiException glae) {
- return (GitLabApi.createOptionalFromException(glae));
- }
- }
-
- /**
- * Get a List of all references (from branches or tags) a commit is pushed to.
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param sha a commit hash or name of a branch or tag
- * @return a List of all references (from branches or tags) a commit is pushed to
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- * @since Gitlab 10.6
- */
- public List getCommitRefs(Object projectIdOrPath, String sha) throws GitLabApiException {
- return (getCommitRefs(projectIdOrPath, sha, RefType.ALL, getDefaultPerPage()).all());
- }
-
- /**
- * Get a Pager of references (from branches or tags) a commit is pushed to.
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs?type=:refType
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param sha a commit hash or name of a branch or tag
- * @param itemsPerPage the number of Commit instances that will be fetched per page
- * @return a Pager of references (from branches or tags) a commit is pushed to
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- * @since Gitlab 10.6
- */
- public Pager getCommitRefs(Object projectIdOrPath, String sha, int itemsPerPage) throws GitLabApiException {
- return (getCommitRefs(projectIdOrPath, sha, RefType.ALL, itemsPerPage));
- }
-
- /**
- * Get a Stream of all references (from branches or tags) a commit is pushed to.
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param sha a commit hash or name of a branch or tag
- * @return a Stream of all references (from branches or tags) a commit is pushed to
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- * @since Gitlab 10.6
- */
- public Stream getCommitRefsStream(Object projectIdOrPath, String sha) throws GitLabApiException {
- return (getCommitRefs(projectIdOrPath, sha, RefType.ALL, getDefaultPerPage()).stream());
- }
-
- /**
- * Get a List of all references (from branches or tags) a commit is pushed to.
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs?type=:refType
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param sha a commit hash or name of a branch or tag
- * @param refType the scope of commits. Possible values branch, tag, all. Default is all.
- * @return a List of all references (from branches or tags) a commit is pushed to
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- * @since Gitlab 10.6
- */
- public List getCommitRefs(Object projectIdOrPath, String sha, RefType refType) throws GitLabApiException {
- return (getCommitRefs(projectIdOrPath, sha, refType, getDefaultPerPage()).all());
- }
-
- /**
- * Get a Pager of references (from branches or tags) a commit is pushed to.
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs?type=:refType
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param sha a commit hash or name of a branch or tag
- * @param refType the scope of commits. Possible values branch, tag, all. Default is all.
- * @param itemsPerPage the number of Commit instances that will be fetched per page
- * @return a Pager of references (from branches or tags) a commit is pushed to
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- * @since Gitlab 10.6
- */
- public Pager getCommitRefs(Object projectIdOrPath, String sha, CommitRef.RefType refType, int itemsPerPage) throws GitLabApiException {
- Form form = new GitLabApiForm().withParam("type", refType);
- return (new Pager(this, CommitRef.class, itemsPerPage, form.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "repository", "commits", urlEncode(sha), "refs"));
+ public CommitsApi(final GitLabApi gitLabApi) {
+ super(gitLabApi);
+ }
+
+ /**
+ * Get a list of all repository commits in a project.
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @return a list containing the commits for the specified project ID
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ */
+ public List getCommits(final Object projectIdOrPath) throws GitLabApiException {
+ return (getCommits(
+ projectIdOrPath, null, null, null, null, true, null, null, getDefaultPerPage())
+ .all());
+ }
+
+ /**
+ * Get a list of repository commits in a project.
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param page the page to get
+ * @param perPage the number of commits per page
+ * @return a list containing the commits for the specified project ID
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ * @deprecated
+ */
+ @Deprecated
+ public List getCommits(final Object projectIdOrPath, final int page, final int perPage)
+ throws GitLabApiException {
+ return (getCommits(projectIdOrPath, null, null, null, page, perPage));
+ }
+
+ /**
+ * Get a Pager of all repository commits in a project.
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param itemsPerPage the number of Commit instances that will be fetched per page
+ * @return a Pager containing the commits for the specified project ID
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ */
+ public Pager getCommits(final Object projectIdOrPath, final int itemsPerPage)
+ throws GitLabApiException {
+ return (getCommits(projectIdOrPath, null, null, null, null, true, null, null, itemsPerPage));
+ }
+
+ /**
+ * Get a Stream of all repository commits in a project.
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @return a Stream containing the commits for the specified project ID
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ */
+ public Stream getCommitStream(final Object projectIdOrPath) throws GitLabApiException {
+ return (getCommits(
+ projectIdOrPath, null, null, null, null, true, null, null, getDefaultPerPage())
+ .stream());
+ }
+
+ /**
+ * Get a list of repository commits in a project.
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param ref the name of a repository branch or tag or if not given the default branch
+ * @param since only commits after or on this date will be returned
+ * @param until only commits before or on this date will be returned
+ * @param path the path to file of a project
+ * @return a list containing the commits for the specified project ID
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ */
+ public List getCommits(
+ final Object projectIdOrPath,
+ final String ref,
+ final Date since,
+ final Date until,
+ final String path)
+ throws GitLabApiException {
+ return (getCommits(
+ projectIdOrPath, ref, since, until, path, null, null, null, getDefaultPerPage())
+ .all());
+ }
+
+ /**
+ * Get a list of file commits in a project
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits?path=:file_path
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param ref the name of a repository branch or tag or if not given the default branch
+ * @param path the path to file of a project
+ * @return a list containing the commits for the specified project ID and file
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ */
+ public List getCommits(final Object projectIdOrPath, final String ref, final String path)
+ throws GitLabApiException {
+ return (getCommits(
+ projectIdOrPath, ref, null, null, path, null, null, null, getDefaultPerPage())
+ .all());
+ }
+
+ /**
+ * Get a list of repository commits in a project.
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param ref the name of a repository branch or tag or if not given the default branch
+ * @param since only commits after or on this date will be returned
+ * @param until only commits before or on this date will be returned
+ * @return a list containing the commits for the specified project ID
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ */
+ public List getCommits(
+ final Object projectIdOrPath, final String ref, final Date since, final Date until)
+ throws GitLabApiException {
+ return (getCommits(
+ projectIdOrPath, ref, since, until, null, null, null, null, getDefaultPerPage())
+ .all());
+ }
+
+ /**
+ * Get a list of repository commits in a project.
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param ref the name of a repository branch or tag or if not given the default branch
+ * @param since only commits after or on this date will be returned
+ * @param until only commits before or on this date will be returned
+ * @param page the page to get
+ * @param perPage the number of commits per page
+ * @return a list containing the commits for the specified project ID
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ * @deprecated
+ */
+ @Deprecated
+ public List getCommits(
+ final Object projectIdOrPath,
+ final String ref,
+ final Date since,
+ final Date until,
+ final int page,
+ final int perPage)
+ throws GitLabApiException {
+ return (getCommits(projectIdOrPath, ref, since, until, null, page, perPage));
+ }
+
+ /**
+ * Get a Stream of repository commits in a project.
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param ref the name of a repository branch or tag or if not given the default branch
+ * @param since only commits after or on this date will be returned
+ * @param until only commits before or on this date will be returned
+ * @return a Stream containing the commits for the specified project ID
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ */
+ public Stream getCommitsStream(
+ final Object projectIdOrPath, final String ref, final Date since, final Date until)
+ throws GitLabApiException {
+ return (getCommits(
+ projectIdOrPath, ref, since, until, null, null, null, null, getDefaultPerPage())
+ .stream());
+ }
+
+ /**
+ * Get a Stream of repository commits in a project.
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param ref the name of a repository branch or tag or if not given the default branch
+ * @param since only commits after or on this date will be returned
+ * @param until only commits before or on this date will be returned
+ * @param path the path to file of a project
+ * @return a Stream containing the commits for the specified project ID
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ */
+ public Stream getCommitsStream(
+ final Object projectIdOrPath,
+ final String ref,
+ final Date since,
+ final Date until,
+ final String path)
+ throws GitLabApiException {
+ return (getCommits(
+ projectIdOrPath, ref, since, until, path, null, null, null, getDefaultPerPage())
+ .stream());
+ }
+
+ /**
+ * Get a list of repository commits in a project.
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param ref the name of a repository branch or tag or if not given the default branch
+ * @param since only commits after or on this date will be returned
+ * @param until only commits before or on this date will be returned
+ * @param path the path to file of a project
+ * @param page the page to get
+ * @param perPage the number of commits per page
+ * @return a list containing the commits for the specified project ID
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ * @deprecated
+ */
+ @Deprecated
+ public List getCommits(
+ final Object projectIdOrPath,
+ final String ref,
+ final Date since,
+ final Date until,
+ final String path,
+ final int page,
+ final int perPage)
+ throws GitLabApiException {
+ final Form formData =
+ new GitLabApiForm()
+ .withParam("ref_name", ref)
+ .withParam("since", ISO8601.toString(since, false))
+ .withParam("until", ISO8601.toString(until, false))
+ .withParam("path", (path == null ? null : urlEncode(path)))
+ .withParam(PAGE_PARAM, page)
+ .withParam(PER_PAGE_PARAM, perPage);
+ final Response response =
+ get(
+ Response.Status.OK,
+ formData.asMap(),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "repository",
+ "commits");
+ return (response.readEntity(new GenericType>() {}));
+ }
+
+ /**
+ * Get a Pager of repository commits in a project.
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param ref the name of a repository branch or tag or if not given the default branch
+ * @param since only commits after or on this date will be returned
+ * @param until only commits before or on this date will be returned
+ * @param itemsPerPage the number of Commit instances that will be fetched per page
+ * @return a Pager containing the commits for the specified project ID
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ */
+ public Pager getCommits(
+ final Object projectIdOrPath,
+ final String ref,
+ final Date since,
+ final Date until,
+ final int itemsPerPage)
+ throws GitLabApiException {
+ return getCommits(projectIdOrPath, ref, since, until, null, null, null, null, itemsPerPage);
+ }
+
+ /**
+ * Get a Pager of repository commits in a project
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param ref the name of a repository branch or tag or if not given the default branch
+ * @param since only commits after or on this date will be returned
+ * @param until only commits before or on this date will be returned
+ * @param itemsPerPage the number of Commit instances that will be fetched per page
+ * @param path the path to file of a project
+ * @return a Pager containing the commits for the specified project ID
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ */
+ public Pager getCommits(
+ final Object projectIdOrPath,
+ final String ref,
+ final Date since,
+ final Date until,
+ final String path,
+ final int itemsPerPage)
+ throws GitLabApiException {
+ return (getCommits(projectIdOrPath, ref, since, until, path, null, null, null, itemsPerPage));
+ }
+
+ /**
+ * Get a List of the specified repository commits in a project
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param ref the name of a repository branch or tag or if not given the default branch
+ * @param since only commits after or on this date will be returned
+ * @param until only commits before or on this date will be returned
+ * @param path the path to file of a project
+ * @param all retrieve every commit from the repository
+ * @param withStats stats about each commit will be added to the response
+ * @param firstParent follow only the first parent commit upon seeing a merge commit
+ * @return a Pager containing the commits for the specified project ID
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ */
+ public List getCommits(
+ final Object projectIdOrPath,
+ final String ref,
+ final Date since,
+ final Date until,
+ final String path,
+ final Boolean all,
+ final Boolean withStats,
+ final Boolean firstParent)
+ throws GitLabApiException {
+ return (getCommits(
+ projectIdOrPath,
+ ref,
+ since,
+ until,
+ path,
+ all,
+ withStats,
+ firstParent,
+ getDefaultPerPage())
+ .all());
+ }
+
+ /**
+ * Get a Pager of the specified repository commits in a project
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param ref the name of a repository branch or tag or if not given the default branch
+ * @param since only commits after or on this date will be returned
+ * @param until only commits before or on this date will be returned
+ * @param path the path to file of a project
+ * @param all retrieve every commit from the repository
+ * @param withStats stats about each commit will be added to the response
+ * @param firstParent follow only the first parent commit upon seeing a merge commit
+ * @param itemsPerPage the number of Commit instances that will be fetched per page
+ * @return a Pager containing the commits for the specified project ID
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ */
+ public Pager getCommits(
+ final Object projectIdOrPath,
+ final String ref,
+ final Date since,
+ final Date until,
+ final String path,
+ final Boolean all,
+ final Boolean withStats,
+ final Boolean firstParent,
+ final int itemsPerPage)
+ throws GitLabApiException {
+ final Form formData =
+ new GitLabApiForm()
+ .withParam("ref_name", ref)
+ .withParam("since", ISO8601.toString(since, false))
+ .withParam("until", ISO8601.toString(until, false))
+ .withParam("path", (path == null ? null : urlEncode(path)))
+ .withParam("all", all)
+ .withParam("with_stats", withStats)
+ .withParam("first_parent", firstParent);
+ return (new Pager(
+ this,
+ Commit.class,
+ itemsPerPage,
+ formData.asMap(),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "repository",
+ "commits"));
+ }
+
+ /**
+ * Get a Stream of the specified repository commits in a project
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param ref the name of a repository branch or tag or if not given the default branch
+ * @param since only commits after or on this date will be returned
+ * @param until only commits before or on this date will be returned
+ * @param path the path to file of a project
+ * @param all retrieve every commit from the repository
+ * @param withStats stats about each commit will be added to the response
+ * @param firstParent follow only the first parent commit upon seeing a merge commit
+ * @return a Stream containing the commits for the specified project ID
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ */
+ public Stream getCommitsStream(
+ final Object projectIdOrPath,
+ final String ref,
+ final Date since,
+ final Date until,
+ final String path,
+ final Boolean all,
+ final Boolean withStats,
+ final Boolean firstParent)
+ throws GitLabApiException {
+ return (getCommits(
+ projectIdOrPath, ref, since, until, path, all, withStats, firstParent, getDefaultPerPage())
+ .stream());
+ }
+
+ /**
+ * Get a specific commit identified by the commit hash or name of a branch or tag.
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits/:sha
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param sha a commit hash or name of a branch or tag
+ * @return the Commit instance for the specified project ID/sha pair
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ */
+ public Commit getCommit(final Object projectIdOrPath, final String sha)
+ throws GitLabApiException {
+ final Response response =
+ get(
+ Response.Status.OK,
+ getDefaultPerPageParam(),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "repository",
+ "commits",
+ urlEncode(sha));
+ return (response.readEntity(Commit.class));
+ }
+
+ /**
+ * Get a specific commit identified by the commit hash or name of a branch or tag as an Optional
+ * instance
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits/:sha
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param sha a commit hash or name of a branch or tag
+ * @return the Commit for the specified project ID/sha pair as an Optional instance
+ */
+ public Optional getOptionalCommit(final Object projectIdOrPath, final String sha) {
+ try {
+ return (Optional.ofNullable(getCommit(projectIdOrPath, sha)));
+ } catch (final GitLabApiException glae) {
+ return (GitLabApi.createOptionalFromException(glae));
}
-
- /**
- * Get a Stream of all references (from branches or tags) a commit is pushed to.
- *
- * GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs?type=:refType
- *
- * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
- * @param sha a commit hash or name of a branch or tag
- * @param refType the scope of commits. Possible values branch, tag, all. Default is all.
- * @return a Stream of all references (from branches or tags) a commit is pushed to
- * @throws GitLabApiException GitLabApiException if any exception occurs during execution
- * @since Gitlab 10.6
- */
- public Stream getCommitRefsStream(Object projectIdOrPath, String sha, RefType refType) throws GitLabApiException {
- return (getCommitRefs(projectIdOrPath, sha, refType, getDefaultPerPage()).stream());
+ }
+
+ /**
+ * Get a List of all references (from branches or tags) a commit is pushed to.
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param sha a commit hash or name of a branch or tag
+ * @return a List of all references (from branches or tags) a commit is pushed to
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ * @since Gitlab 10.6
+ */
+ public List getCommitRefs(final Object projectIdOrPath, final String sha)
+ throws GitLabApiException {
+ return (getCommitRefs(projectIdOrPath, sha, RefType.ALL, getDefaultPerPage()).all());
+ }
+
+ /**
+ * Get a Pager of references (from branches or tags) a commit is pushed to.
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs?type=:refType
+ *
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param sha a commit hash or name of a branch or tag
+ * @param itemsPerPage the number of Commit instances that will be fetched per page
+ * @return a Pager of references (from branches or tags) a commit is pushed to
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ * @since Gitlab 10.6
+ */
+ public Pager getCommitRefs(
+ final Object projectIdOrPath, final String sha, final int itemsPerPage)
+ throws GitLabApiException {
+ return (getCommitRefs(projectIdOrPath, sha, RefType.ALL, itemsPerPage));
+ }
+
+ /**
+ * Get a Stream of all references (from branches or tags) a commit is pushed to.
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param sha a commit hash or name of a branch or tag
+ * @return a Stream of all references (from branches or tags) a commit is pushed to
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ * @since Gitlab 10.6
+ */
+ public Stream getCommitRefsStream(final Object projectIdOrPath, final String sha)
+ throws GitLabApiException {
+ return (getCommitRefs(projectIdOrPath, sha, RefType.ALL, getDefaultPerPage()).stream());
+ }
+
+ /**
+ * Get a List of all references (from branches or tags) a commit is pushed to.
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs?type=:refType
+ *
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param sha a commit hash or name of a branch or tag
+ * @param refType the scope of commits. Possible values branch, tag, all. Default is all.
+ * @return a List of all references (from branches or tags) a commit is pushed to
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ * @since Gitlab 10.6
+ */
+ public List getCommitRefs(
+ final Object projectIdOrPath, final String sha, final RefType refType)
+ throws GitLabApiException {
+ return (getCommitRefs(projectIdOrPath, sha, refType, getDefaultPerPage()).all());
+ }
+
+ /**
+ * Get a Pager of references (from branches or tags) a commit is pushed to.
+ *
+ * GitLab Endpoint: GET /projects/:id/repository/commits/:sha/refs?type=:refType
+ *
+ *
+ * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project
+ * instance
+ * @param sha a commit hash or name of a branch or tag
+ * @param refType the scope of commits. Possible values branch, tag, all. Default is all.
+ * @param itemsPerPage the number of Commit instances that will be fetched per page
+ * @return a Pager of references (from branches or tags) a commit is pushed to
+ * @throws GitLabApiException GitLabApiException if any exception occurs during execution
+ * @since Gitlab 10.6
+ */
+ public Pager getCommitRefs(
+ final Object projectIdOrPath,
+ final String sha,
+ final CommitRef.RefType refType,
+ final int itemsPerPage)
+ throws GitLabApiException {
+ final Form form = new GitLabApiForm().withParam("type", refType);
+ return (new Pager(
+ this,
+ CommitRef.class,
+ itemsPerPage,
+ form.asMap(),
+ "projects",
+ getProjectIdOrPath(projectIdOrPath),
+ "repository",
+ "commits",
+ urlEncode(sha),
+ "refs"));
+ }
+
+ /**
+ * Get a Stream of all references (from branches or tags) a commit is pushed to.
+ *
+ *