Updates a workflow scheme, including the name, default workflow, issue type to project mappings, and more. If the workflow scheme is active (that is, being used by at least one project), then a draft workflow scheme is created or updated instead, provided that updateDraftIfNeeded is set to true.
package main
import (
"context"
"fmt"
v3 "github.com/ctreminiom/go-atlassian/jira/v3"
"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")
)
instance, err := v3.New(nil, host)
if err != nil {
log.Fatal(err)
}
instance.Auth.SetBasicAuth(mail, token)
instance.Auth.SetUserAgent("curl/7.54.0")
payload := &models.WorkflowSchemePayloadScheme{
Name: "Example workflow scheme - UPDATED",
Description: "The description of the example workflow scheme.",
IssueTypeMappings: map[string]interface{}{
"10002": "PV: Project Management Workflow",
"10005": "Software Simplified Workflow for Project K2",
},
UpdateDraftIfNeeded: true,
}
workflowSchemeUpdated, response, err := instance.Workflow.Scheme.Update(context.Background(), 10003, payload)
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println(response.Code)
}
log.Fatal(err)
}
fmt.Println(workflowSchemeUpdated.Name)
fmt.Println(workflowSchemeUpdated.Description)
fmt.Println(workflowSchemeUpdated.ID)
fmt.Println(workflowSchemeUpdated.Self)
fmt.Println(workflowSchemeUpdated.DefaultWorkflow)
}
Delete Workflow Scheme
DELETE /rest/api/{2-3}/workflowscheme/{id}
Delete deletes a workflow scheme. Please note that a workflow scheme cannot be deleted if it is active (that is, being used by at least one project).
Associations returns a list of the workflow schemes associated with a list of projects.
Each returned workflow scheme includes a list of the requested projects associated with it.
Any team-managed or non-existent projects in the request are ignored and no errors are returned.
If the project is associated with the Default Workflow Scheme no ID is returned. This is because the way the Default Workflow Scheme is stored means it has no ID.
package main
import (
"context"
"fmt"
v3 "github.com/ctreminiom/go-atlassian/jira/v3"
"log"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
instance, err := v3.New(nil, host)
if err != nil {
log.Fatal(err)
}
instance.Auth.SetBasicAuth(mail, token)
instance.Auth.SetUserAgent("curl/7.54.0")
schemesByProject, response, err := instance.Workflow.Scheme.Associations(context.Background(), []int{10001})
if err != nil {
if response != nil {
log.Println(response.Bytes.String())
log.Println(response.Code)
}
log.Fatal(err)
}
for _, mapping := range schemesByProject.Values {
fmt.Println(mapping.WorkflowScheme.Name, mapping.WorkflowScheme.ID)
fmt.Println(mapping.ProjectIds)
}
}
Assign Workflow Scheme
PUT /rest/api/{2-3}/workflowscheme/project
Assign assigns a workflow scheme to a project. This operation is performed only when there are no issues in the project. The workflow schemes can only be assigned to classic projects.