Class WikisApi

All Implemented Interfaces:
Constants

public class WikisApi
extends AbstractApi
This class implements the client side API for the GitLab Wikis API. See Wikis API at GitLab for more information.
  • Constructor Details

    • WikisApi

      public WikisApi​(GitLabApi gitLabApi)
  • Method Details

    • getPages

      public List<WikiPage> getPages​(Object projectIdOrPath) throws GitLabApiException
      Get a list of pages in project wiki.
      GitLab Endpoint: GET /projects/:id/wikis
      Parameters:
      projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
      Returns:
      a list of pages in the project's wiki
      Throws:
      GitLabApiException - if any exception occurs
    • getPages

      public Pager<WikiPage> getPages​(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException
      Get a Pager of pages in project wiki.
      GitLab Endpoint: GET /projects/:id/wikis
      Parameters:
      projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
      itemsPerPage - the number of WikiPage instances that will be fetched per page
      Returns:
      a Pager of pages in project's wiki for the specified range
      Throws:
      GitLabApiException - if any exception occurs
    • getPagesStream

      public Stream<WikiPage> getPagesStream​(Object projectIdOrPath) throws GitLabApiException
      Get a Stream of pages in project wiki.
      GitLab Endpoint: GET /projects/:id/wikis
      Parameters:
      projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
      Returns:
      a Pager of pages in project's wiki for the specified range
      Throws:
      GitLabApiException - if any exception occurs
    • getPages

      public List<WikiPage> getPages​(Object projectIdOrPath, int page, int perPage) throws GitLabApiException
      Deprecated.
      Will be removed in a future release, use getPages(Object, boolean, int)
      Get a list of pages in project wiki for the specified page.
      GitLab Endpoint: GET /projects/:id/wikis
      Parameters:
      projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
      page - the page to get
      perPage - the number of wiki-pages per page
      Returns:
      a list of pages in project's wiki for the specified range
      Throws:
      GitLabApiException - if any exception occurs
    • getPages

      public List<WikiPage> getPages​(Object projectIdOrPath, boolean withContent) throws GitLabApiException
      Get a List of pages in project wiki.
      GitLab Endpoint: GET /projects/:id/wikis
      Parameters:
      projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
      withContent - if true the results will include the pages content
      Returns:
      a List of pages in project's wiki for the specified range
      Throws:
      GitLabApiException - if any exception occurs
    • getPages

      public Pager<WikiPage> getPages​(Object projectIdOrPath, boolean withContent, int itemsPerPage) throws GitLabApiException
      Get a Pager of pages in project wiki.
      GitLab Endpoint: GET /projects/:id/wikis
      Parameters:
      projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
      withContent - if true the results will include the pages content
      itemsPerPage - the number of WikiPage instances that will be fetched per page
      Returns:
      a Pager of pages in project's wiki for the specified range
      Throws:
      GitLabApiException - if any exception occurs
    • getPagesStream

      public Stream<WikiPage> getPagesStream​(Object projectIdOrPath, boolean withContent) throws GitLabApiException
      Get a Stream of pages in project wiki.
      GitLab Endpoint: GET /projects/:id/wikis
      Parameters:
      projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
      withContent - if true the results will include the pages content
      Returns:
      a Stream of pages in project's wiki for the specified range
      Throws:
      GitLabApiException - if any exception occurs
    • getPage

      public WikiPage getPage​(Object projectIdOrPath, String slug) throws GitLabApiException
      Get a single page of project wiki.
      GitLab Endpoint: GET /projects/:id/wikis/:slug
      Parameters:
      projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
      slug - the slug of the project's wiki page
      Returns:
      the specified project Snippet
      Throws:
      GitLabApiException - if any exception occurs
    • getOptionalPage

      public Optional<WikiPage> getOptionalPage​(Object projectIdOrPath, String slug)
      Get a single page of project wiki as an Optional instance.
      GitLab Endpoint: GET /projects/:id/wikis/:slug
      Parameters:
      projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
      slug - the slug of the project's wiki page
      Returns:
      the specified project Snippet as an Optional instance
    • createPage

      public WikiPage createPage​(Object projectIdOrPath, String title, String content) throws GitLabApiException
      Creates a new project wiki page. The user must have permission to create new wiki page.
      GitLab Endpoint: POST /projects/:id/wikis
      Parameters:
      projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
      title - the title of a snippet, required
      content - the content of a wiki page, required
      Returns:
      a WikiPage instance with info on the created page
      Throws:
      GitLabApiException - if any exception occurs
    • updatePage

      public WikiPage updatePage​(Object projectIdOrPath, String slug, String title, String content) throws GitLabApiException
      Updates an existing project wiki page. The user must have permission to change an existing wiki page.
      GitLab Endpoint: PUT /projects/:id/wikis/:slug
      Parameters:
      projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
      slug - the slug of the project's wiki page, required
      title - the title of a snippet, optional
      content - the content of a page, optional. Either title or content must be supplied.
      Returns:
      a WikiPage instance with info on the updated page
      Throws:
      GitLabApiException - if any exception occurs
    • deletePage

      public void deletePage​(Object projectIdOrPath, String slug) throws GitLabApiException
      Deletes an existing project wiki page. This is an idempotent function and deleting a non-existent page does not cause an error.
      GitLab Endpoint: DELETE /projects/:id/wikis/:slug
      Parameters:
      projectIdOrPath - the project in the form of an Integer(ID), String(path), or Project instance
      slug - the slug of the project's wiki page
      Throws:
      GitLabApiException - if any exception occurs
    • uploadAttachment

      public WikiAttachment uploadAttachment​(Object projectIdOrPath, File fileToUpload) throws GitLabApiException
      Uploads a file to the attachment folder inside the wiki’s repository. The attachment folder is the uploads folder.
      POST /projects/:id/wikis/attachments
      Parameters:
      projectIdOrPath - projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
      fileToUpload - the File instance of the file to upload, required
      Returns:
      a FileUpload instance with information on the just uploaded file
      Throws:
      GitLabApiException - if any exception occurs
    • uploadAttachment

      public WikiAttachment uploadAttachment​(Object projectIdOrPath, File fileToUpload, String branch) throws GitLabApiException
      Uploads a file to the attachment folder inside the wiki’s repository. The attachment folder is the uploads folder.
      POST /projects/:id/wikis/attachments
      Parameters:
      projectIdOrPath - projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
      fileToUpload - the File instance of the file to upload, required
      branch - the name of the branch, defaults to the wiki repository default branch, optional
      Returns:
      a FileUpload instance with information on the just uploaded file
      Throws:
      GitLabApiException - if any exception occurs