Class LabelsApi

All Implemented Interfaces:
Constants

public class LabelsApi extends AbstractApi
This class provides an entry point to all the GitLab API project and group label calls.
See Also:
  • Constructor Details

    • LabelsApi

      public LabelsApi(GitLabApi gitLabApi)
  • Method Details

    • getProjectLabels

      public List<Label> getProjectLabels(Object projectIdOrPath) throws GitLabApiException
      Get all labels of the specified project.
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      Returns:
      a list of project's labels
      Throws:
      GitLabApiException - if any exception occurs
    • getProjectLabels

      public Pager<Label> getProjectLabels(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException
      Get a Pager of all labels of the specified project.
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      itemsPerPage - the number of items per page
      Returns:
      a list of project's labels in the specified range
      Throws:
      GitLabApiException - if any exception occurs
    • getProjectLabelsStream

      public Stream<Label> getProjectLabelsStream(Object projectIdOrPath) throws GitLabApiException
      Get a Stream of all labels of the specified project.
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      Returns:
      a Stream of project's labels
      Throws:
      GitLabApiException - if any exception occurs
    • getProjectLabel

      public Label getProjectLabel(Object projectIdOrPath, Object labelIdOrName) throws GitLabApiException
      Get a single project label.
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      labelIdOrName - the label in the form of an Long(ID), String(name), or Label instance
      Returns:
      a Label instance holding the information for the group label
      Throws:
      GitLabApiException - if any exception occurs
    • getOptionalProjectLabel

      public Optional<Label> getOptionalProjectLabel(Object projectIdOrPath, Object labelIdOrName) throws GitLabApiException
      Get a single project label as the value of an Optional.
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      labelIdOrName - the label in the form of an Long(ID), String(name), or Label instance
      Returns:
      a Optional instance with a Label instance as its value
      Throws:
      GitLabApiException - if any exception occurs
    • createProjectLabel

      public Label createProjectLabel(Object projectIdOrPath, Label labelProperties) throws GitLabApiException
      Create a project label. A Label instance is used to set the label properties. withXXX() methods are provided to set the properties of the label to create:
      
         // name and color properties are required
         Label labelProperties = new Label()
                .withName("a-pink-project-label")
                .withColor("pink")
                .withDescription("A new pink project label")
             .withPriority(10);
         gitLabApi.getLabelsApi().createProjectLabel(projectId, labelProperties);
       
      GitLab Endpoint: POST /groups/:id/labels
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      labelProperties - a Label instance holding the properties for the new group label
      Returns:
      the created Label instance
      Throws:
      GitLabApiException - if any exception occurs
    • updateProjectLabel

      public Label updateProjectLabel(Object projectIdOrPath, Object labelIdOrName, Label labelConfig) throws GitLabApiException
      Update the specified project label. The name, color, and description can be updated. A Label instance is used to set the properties of the label to update, withXXX() methods are provided to set the properties to update:
      
         Label labelUpdates = new Label()
              .withName("a-new-name")
              .withColor("red")
              .withDescription("A red group label");
         gitLabApi.getLabelsApi().updateGroupLabel(projectId, labelId, labelUpdates);
       
      GitLab Endpoint: PUT /projects/:id/labels/:label_id
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      labelIdOrName - the label in the form of an Long(ID), String(name), or Label instance
      labelConfig - a Label instance holding the label properties to update
      Returns:
      the updated Label instance
      Throws:
      GitLabApiException - if any exception occurs
    • deleteProjectLabel

      public void deleteProjectLabel(Object projectIdOrPath, Object labelIdOrName) throws GitLabApiException
      Delete the specified project label.
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      labelIdOrName - the label in the form of an Long(ID), String(name), or Label instance
      Throws:
      GitLabApiException - if any exception occurs
    • subscribeProjectLabel

      public Label subscribeProjectLabel(Object projectIdOrPath, Object labelIdOrName) throws GitLabApiException
      Subscribe a specified project label.
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      labelIdOrName - the label in the form of an Long(ID), String(name), or Label instance
      Returns:
      HttpStatusCode 503
      Throws:
      GitLabApiException - if any exception occurs
    • unsubscribeProjectLabel

      public Label unsubscribeProjectLabel(Object projectIdOrPath, Object labelIdOrName) throws GitLabApiException
      Unsubscribe a specified project label.
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      labelIdOrName - the label in the form of an Long(ID), String(name), or Label instance
      Returns:
      HttpStatusCode 503
      Throws:
      GitLabApiException - if any exception occurs
    • getGroupLabels

      public List<Label> getGroupLabels(Object groupIdOrPath) throws GitLabApiException
      Get all labels of the specified group.
      Parameters:
      groupIdOrPath - the group in the form of an Long(ID), String(path), or Group instance
      Returns:
      a list of group's labels
      Throws:
      GitLabApiException - if any exception occurs
    • getGroupLabels

      public Pager<Label> getGroupLabels(Object groupIdOrPath, int itemsPerPage) throws GitLabApiException
      Get a Pager of all labels of the specified group.
      Parameters:
      groupIdOrPath - the group in the form of an Long(ID), String(path), or Group instance
      itemsPerPage - the number of items per page
      Returns:
      a list of group's labels in the specified range
      Throws:
      GitLabApiException - if any exception occurs
    • getGroupLabelsStream

      public Stream<Label> getGroupLabelsStream(Object groupIdOrPath) throws GitLabApiException
      Get a Stream of all labels of the specified group.
      Parameters:
      groupIdOrPath - the group in the form of an Long(ID), String(path), or Group instance
      Returns:
      a Stream of group's labels
      Throws:
      GitLabApiException - if any exception occurs
    • getGroupLabel

      public Label getGroupLabel(Object groupIdOrPath, Object labelIdOrName) throws GitLabApiException
      Get a single group label.
      Parameters:
      groupIdOrPath - the group in the form of an Long(ID), String(path), or Group instance
      labelIdOrName - the label in the form of an Long(ID), String(name), or Label instance
      Returns:
      a Label instance holding the information for the group label
      Throws:
      GitLabApiException - if any exception occurs
    • getOptionalGroupLabel

      public Optional<Label> getOptionalGroupLabel(Object groupIdOrPath, Object labelIdOrName) throws GitLabApiException
      Get a single group label as the value of an Optional.
      Parameters:
      groupIdOrPath - the group in the form of an Long(ID), String(path), or Group instance
      labelIdOrName - the label in the form of an Long(ID), String(name), or Label instance
      Returns:
      a Optional instance with a Label instance as its value
      Throws:
      GitLabApiException - if any exception occurs
    • createGroupLabel

      public Label createGroupLabel(Object groupIdOrPath, Label labelProperties) throws GitLabApiException
      Create a group label. A Label instance is used to set the label properties. withXXX() methods are provided to set the properties of the label to create:
      
         Label labelProperties = new Label()
             .withName("a-name")
             .withColor("green")
             .withDescription("A new green group label");
         gitLabApi.getLabelsApi().createGroupLabel(projectId, labelProperties);
       
      GitLab Endpoint: POST /groups/:id/labels
      Parameters:
      groupIdOrPath - the group in the form of an Long(ID), String(path), or Group instance
      labelProperties - a Label instance holding the properties for the new group label
      Returns:
      the created Label instance
      Throws:
      GitLabApiException - if any exception occurs
    • updateGroupLabel

      public Label updateGroupLabel(Object groupIdOrPath, Object labelIdOrName, Label labelConfig) throws GitLabApiException
      Update the specified label. The name, color, and description can be updated. A Label instance is used to set the properties of the label to update, withXXX() methods are provided to set the properties to update:
      
         Label labelUpdates = new Label()
             .withName("a-new-name")
             .withColor("red")
             .withDescription("A red group label");
         gitLabApi.getLabelsApi().updateGroupLabel(projectId, labelId, labelUpdates);
       
      GitLab Endpoint: PUT /groups/:id/labels/:label_id
      Parameters:
      groupIdOrPath - the group in the form of an Long(ID), String(path), or Group instance
      labelIdOrName - the label in the form of an Long(ID), String(name), or Label instance
      labelConfig - a Label instance holding the label properties to update
      Returns:
      the updated Label instance
      Throws:
      GitLabApiException - if any exception occurs
    • deleteGroupLabel

      public void deleteGroupLabel(Object groupIdOrPath, Object labelIdOrName) throws GitLabApiException
      Delete the specified label
      Parameters:
      groupIdOrPath - the group in the form of an Long(ID), String(path), or Group instance
      labelIdOrName - the label in the form of an Long(ID), String(name), or Label instance
      Throws:
      GitLabApiException - if any exception occurs
    • subscribeGroupLabel

      public Label subscribeGroupLabel(Object groupIdOrPath, Object labelIdOrName) throws GitLabApiException
      Subscribe a specified group label.
      Parameters:
      groupIdOrPath - the group in the form of an Long(ID), String(path), or Group instance
      labelIdOrName - the label in the form of an Long(ID), String(name), or Label instance
      Returns:
      HttpStatusCode 503
      Throws:
      GitLabApiException - if any exception occurs
    • unsubscribeGroupLabel

      public Label unsubscribeGroupLabel(Object groupIdOrPath, Object labelIdOrName) throws GitLabApiException
      Unsubscribe a specified group label.
      Parameters:
      groupIdOrPath - the group in the form of an Long(ID), String(path), or Group instance
      labelIdOrName - the label in the form of an Long(ID), String(name), or Label instance
      Returns:
      HttpStatusCode 503
      Throws:
      GitLabApiException - if any exception occurs
    • getLabels

      @Deprecated public List<Label> getLabels(Object projectIdOrPath) throws GitLabApiException
      Deprecated.
      Replaced by the getProjectLabels(Object) method.
      Get all labels of the specified project.
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      Returns:
      a list of project's labels
      Throws:
      GitLabApiException - if any exception occurs
    • getLabels

      @Deprecated public List<Label> getLabels(Object projectIdOrPath, int page, int perPage) throws GitLabApiException
      Deprecated.
      Will be removed in the next major release (6.0.0)
      Get all labels of the specified project to using the specified page and per page setting
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      page - the page to get
      perPage - the number of items per page
      Returns:
      a list of project's labels in the specified range
      Throws:
      GitLabApiException - if any exception occurs
    • getLabels

      @Deprecated public Pager<Label> getLabels(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException
      Deprecated.
      Replaced by the getProjectLabels(Object, int) method.
      Get a Pager of all labels of the specified project.
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      itemsPerPage - the number of items per page
      Returns:
      a list of project's labels in the specified range
      Throws:
      GitLabApiException - if any exception occurs
    • getLabelsStream

      @Deprecated public Stream<Label> getLabelsStream(Object projectIdOrPath) throws GitLabApiException
      Deprecated.
      Replaced by the getProjectLabelsStream(Object) method.
      Get a Stream of all labels of the specified project.
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      Returns:
      a Stream of project's labels
      Throws:
      GitLabApiException - if any exception occurs
    • createLabel

      @Deprecated public Label createLabel(Object projectIdOrPath, String name, String color, String description) throws GitLabApiException
      Deprecated.
      Replaced by the createProjectLabel(Object, Label) method.
      Create a label
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      name - the name for the label
      color - the color for the label
      description - the description for the label
      Returns:
      the created Label instance
      Throws:
      GitLabApiException - if any exception occurs
    • createLabel

      @Deprecated public Label createLabel(Object projectIdOrPath, String name, String color) throws GitLabApiException
      Deprecated.
      Replaced by the createProjectLabel(Object, Label) method.
      Create a label
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      name - the name for the label
      color - the color for the label
      Returns:
      the created Label instance
      Throws:
      GitLabApiException - if any exception occurs
    • createLabel

      @Deprecated public Label createLabel(Object projectIdOrPath, String name, String color, Integer priority) throws GitLabApiException
      Deprecated.
      Replaced by the createProjectLabel(Object, Label) method.
      Create a label
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      name - the name for the label
      color - the color for the label
      priority - the priority for the label
      Returns:
      the created Label instance
      Throws:
      GitLabApiException - if any exception occurs
    • createLabel

      @Deprecated public Label createLabel(Object projectIdOrPath, String name, String color, String description, Integer priority) throws GitLabApiException
      Deprecated.
      Replaced by the createProjectLabel(Object, Label) method.
      Create a label
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      name - the name for the label
      color - the color for the label
      description - the description for the label
      priority - the priority for the label
      Returns:
      the created Label instance
      Throws:
      GitLabApiException - if any exception occurs
    • updateLabelName

      @Deprecated public Label updateLabelName(Object projectIdOrPath, String name, String newName, String description, Integer priority) throws GitLabApiException
      Deprecated.
      Update the specified label
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      name - the name for the label
      newName - the new name for the label
      description - the description for the label
      priority - the priority for the label
      Returns:
      the modified Label instance
      Throws:
      GitLabApiException - if any exception occurs
    • updateLabelColor

      @Deprecated public Label updateLabelColor(Object projectIdOrPath, String name, String color, String description, Integer priority) throws GitLabApiException
      Deprecated.
      Update the specified label
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      name - the name for the label
      color - the color for the label
      description - the description for the label
      priority - the priority for the label
      Returns:
      the modified Label instance
      Throws:
      GitLabApiException - if any exception occurs
    • updateLabel

      @Deprecated public Label updateLabel(Object projectIdOrPath, String name, String newName, String color, String description, Integer priority) throws GitLabApiException
      Deprecated.
      Update the specified label
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      name - the name for the label
      newName - the new name for the label
      color - the color for the label
      description - the description for the label
      priority - the priority for the label
      Returns:
      the modified Label instance
      Throws:
      GitLabApiException - if any exception occurs
    • deleteLabel

      @Deprecated public void deleteLabel(Object projectIdOrPath, String name) throws GitLabApiException
      Deprecated.
      Replaced by the deleteProjectLabel(Object, Object) method.
      Delete the specified label
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      name - the name for the label
      Throws:
      GitLabApiException - if any exception occurs
    • subscribeLabel

      @Deprecated public Label subscribeLabel(Object projectIdOrPath, Long labelId) throws GitLabApiException
      Deprecated.
      Subscribe a specified label
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      labelId - the label ID
      Returns:
      HttpStatusCode 503
      Throws:
      GitLabApiException - if any exception occurs
    • unsubscribeLabel

      @Deprecated public Label unsubscribeLabel(Object projectIdOrPath, Long labelId) throws GitLabApiException
      Deprecated.
      Unsubscribe a specified label
      Parameters:
      projectIdOrPath - the project in the form of an Long(ID), String(path), or Project instance
      labelId - the label ID
      Returns:
      HttpStatusCode 503
      Throws:
      GitLabApiException - if any exception occurs