Retrieve a list of all statuses

I hit a limit of the official REST API to list statuses (see JSWSERVER-15668). In order to have a list with all the statuses, I created the following REST endpoint.

import com.atlassian.jira.issue.status.Status
import com.atlassian.jira.config.StatusManager
import com.atlassian.jira.component.ComponentAccessor

import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.json.JsonBuilder
import groovy.transform.BaseScript

import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response

@BaseScript CustomEndpointDelegate delegate

allStatuses(httpMethod: "GET", groups: ["jira-system-administrators"]) { MultivaluedMap queryParams, String body ->
    StatusManager statusManager = ComponentAccessor.getComponentOfType(StatusManager.class)
    Collection<Status> statuses = statusManager.getStatuses()

    def s = []
    for (status in statuses) {
        s.add([
          'id': status.getId(),
          'name': status.getName(),
          'description': status.getDescription(),
          'statusCategory': status.getStatusCategory().getName(),
        ])
    }
    return Response.ok(new JsonBuilder(s).toString()).build();}
2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.