Page cover

๐Ÿ—บ๏ธStatus

Not found

Search Workflow Statuses

GET /rest/api/{2-3}/statuses/search

Search returns a paginated list of statuses that match a search on name or project.

package main

import (
	"context"
	"fmt"
	v2 "github.com/ctreminiom/go-atlassian/v2/jira/v2"
	"github.com/ctreminiom/go-atlassian/pkg/infra/models"
	"log"
	"os"
)

func main() {

	var (
		host  = os.Getenv("HOST")
		mail  = os.Getenv("MAIL")
		token = os.Getenv("TOKEN")
	)

	atlassian, err := v2.New(nil, host)
	if err != nil {
		return
	}

	atlassian.Auth.SetBasicAuth(mail, token)
	
	options := &models.WorkflowStatusSearchParams{
		ProjectID:      "10000",
		StatusCategory: "IN_PROGRESS",
		Expand:         []string{"usages"},
	}

	var projectStatuses []*models.WorkflowStatusDetailScheme
	var startAt int

	for {

		page, response, err := atlassian.Workflow.Status.Search(context.Background(), options, startAt, 50)
		if err != nil {
			log.Println(response.Code)
			log.Println(response.Endpoint)
			log.Fatal(err)
		}

		projectStatuses = append(projectStatuses, page.Values...)

		if page.IsLast {
			break
		}

		startAt = startAt + 50
	}

	for _, status := range projectStatuses {
		fmt.Println(status.Name, status.ID, status.StatusCategory)


		fmt.Println("--------------------------------")
		fmt.Println("Status Name:", status.Name)
		fmt.Println("Status ID:", status.ID)
		fmt.Println("Status Category:", status.StatusCategory)

		for index, project := range status.Usages {

			fmt.Println("--- Project Usage #", index)
			fmt.Println("----  Project ID:", project.Project.ID)
			fmt.Println("----  Project IssueTypes:", project.IssueTypes)
		}
		fmt.Println("--------------------------------")
	}
}

Gets Workflow Statuses

GET /rest/api/{2-3}/statuses

Get returns a list of the statuses specified by one or more status IDs.

Create Workflow Statuses

POST /rest/api/{2-3}/statuses

Create creates statuses for a global or project scope.

Update Workflow Statuses

PUT /rest/api/{2-3}/statuses

Update updates statuses by ID.

Delete Workflow Statuses

DELETE /rest/api/{2-3}/statuses

Delete deletes statuses by ID.

Bulk Workflow Statuses

GET /rest/api/{2-3}/status

Bulk returns a list of all statuses associated with active workflows.

Get Workflow Status

GET /rest/api/{2-3}/status/{idOrName}

Get returns a status.

  • The status must be associated with an active workflow to be returned.

  • If a name is used on more than one status, only the status found first is returned. Therefore, identifying the status by its ID may be preferable.

Last updated

Was this helpful?