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 org.gitlab4j.api.GitLabApi.ApiVersion;
import org.gitlab4j.api.models.Markdown;
import org.gitlab4j.api.models.MarkdownRequest;
import javax.ws.rs.core.Response;
/**
* 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");
}
return getMarkdown(new MarkdownRequest(text, true));
}
/**
* Render an arbitrary Markdown document.
*
* GitLab Endpoint: POST /api/v4/markdown
*
* @param markdownRequest a request of markdown transformation
* @return a Markdown instance with transformed info
* @throws GitLabApiException if any exception occurs
* @since GitLab 11.0
*/
public Markdown getMarkdown(MarkdownRequest markdownRequest) throws GitLabApiException {
if (!isApiVersion(ApiVersion.V4)) {
throw new GitLabApiException("Api version must be v4");
}
Response response = post(Response.Status.OK, markdownRequest, "markdown");
return (response.readEntity(Markdown.class));
}
}