org.gitlab4j.api.MarkdownApi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gitlab4j-api Show documentation
Show all versions of gitlab4j-api Show documentation
GitLab4J-API (gitlab4j-api) provides a full featured Java client library for working with GitLab repositories and servers via the GitLab REST API.
package org.gitlab4j.api;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.Response;
import org.gitlab4j.api.GitLabApi.ApiVersion;
import org.gitlab4j.api.models.Markdown;
/**
* This class provides an entry point to all the GitLab API markdown calls.
*/
public class MarkdownApi extends AbstractApi {
public MarkdownApi(GitLabApi gitLabApi) {
super(gitLabApi);
}
/**
* Render an arbitrary Markdown document.
*
* GitLab Endpoint: POST /api/v4/markdown
*
* @param text text to be transformed
* @return a Markdown instance with transformed info
* @throws GitLabApiException if any exception occurs
* @since GitLab 11.0
*/
public Markdown getMarkdown(String text) throws GitLabApiException {
if (!isApiVersion(ApiVersion.V4)) {
throw new GitLabApiException("Api version must be v4");
}
Form formData = new GitLabApiForm().withParam("text", text, true);
Response response = post(Response.Status.OK, formData.asMap(), "markdown");
return (response.readEntity(Markdown.class));
}
}