๐Ÿ“š
Projects
This resource represents projects. Use this resource to get, create, update, and delete projects. Also get statuses available to a project, a project's notification schemes, and update a project's typ

Create project

Creates a project based on a project type template
1
const (
2
BusinessContentManagement = "com.atlassian.jira-core-project-templates:jira-core-simplified-content-management"
3
BusinessDocumentApproval = "com.atlassian.jira-core-project-templates:jira-core-simplified-document-approval"
4
BusinessLeadTracking = "com.atlassian.jira-core-project-templates:jira-core-simplified-lead-tracking"
5
BusinessProcessControl = "com.atlassian.jira-core-project-templates:jira-core-simplified-process-control"
6
BusinessProcurement = "com.atlassian.jira-core-project-templates:jira-core-simplified-procurement"
7
BusinessProjectManagement = "com.atlassian.jira-core-project-templates:jira-core-simplified-project-management"
8
BusinessRecruitment = "com.atlassian.jira-core-project-templates:jira-core-simplified-recruitment"
9
BusinessTaskTracking = "com.atlassian.jira-core-project-templates:jira-core-simplified-task-tracking"
10
ITSMServiceDesk = "com.atlassian.servicedesk:simplified-it-service-desk"
11
ITSMInternalServiceDesk = "com.atlassian.servicedesk:simplified-internal-service-desk"
12
ITSMExternalServiceDesk = "com.atlassian.servicedesk:simplified-external-service-desk"
13
SoftwareTeamManagedKanban = "com.pyxis.greenhopper.jira:gh-simplified-agility-kanban"
14
SoftwareTeamManagedScrum = "com.pyxis.greenhopper.jira:gh-simplified-agility-scrum"
15
SoftwareCompanyManagedKanban = "com.pyxis.greenhopper.jira:gh-simplified-kanban-classic"
16
SoftwareCompanyManagedScrum = "com.pyxis.greenhopper.jira:gh-simplified-scrum-classic"
17
)
Copied!
1
package main
2
โ€‹
3
import (
4
"context"
5
"github.com/ctreminiom/go-atlassian/jira/v2"
6
"github.com/ctreminiom/go-atlassian/pkg/infra/models"
7
"log"
8
"os"
9
)
10
โ€‹
11
func main() {
12
โ€‹
13
/*
14
----------- Set an environment variable in git bash -----------
15
export HOST="https://ctreminiom.atlassian.net/"
16
export MAIL="MAIL_ADDRESS"
17
export TOKEN="TOKEN_API"
18
โ€‹
19
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
20
*/
21
โ€‹
22
var (
23
host = os.Getenv("HOST")
24
mail = os.Getenv("MAIL")
25
token = os.Getenv("TOKEN")
26
)
27
โ€‹
28
atlassian, err := v2.New(nil, host)
29
if err != nil {
30
log.Fatal(err)
31
}
32
โ€‹
33
atlassian.Auth.SetBasicAuth(mail, token)
34
โ€‹
35
payload := &models.ProjectPayloadScheme{
36
NotificationScheme: 10021,
37
Description: "Example Project description",
38
LeadAccountID: "5b86be50b8e3cb5895860d6d",
39
URL: "https://atlassian.com",
40
ProjectTemplateKey: "com.pyxis.greenhopper.jira:gh-simplified-agility-kanban",
41
AvatarID: 10200,
42
IssueSecurityScheme: 10001,
43
Name: "Project DUMMY #3",
44
PermissionScheme: 10011,
45
AssigneeType: "PROJECT_LEAD",
46
ProjectTypeKey: "software",
47
Key: "DUMMY3",
48
CategoryID: 10120,
49
}
50
โ€‹
51
newProject, response, err := atlassian.Project.Create(context.Background(), payload)
52
if err != nil {
53
log.Fatal(err)
54
}
55
โ€‹
56
log.Println("HTTP Endpoint Used", response.Endpoint)
57
โ€‹
58
log.Println("-------------------")
59
log.Println(newProject.ID)
60
log.Println(newProject.Self)
61
log.Println(newProject.Key)
62
log.Println("-------------------")
63
}
Copied!

Get projects paginated

Returns a paginated list of projects visible to the user.
1
package main
2
โ€‹
3
import (
4
"context"
5
"github.com/ctreminiom/go-atlassian/jira/v2"
6
"github.com/ctreminiom/go-atlassian/pkg/infra/models"
7
"log"
8
"os"
9
)
10
โ€‹
11
func main() {
12
โ€‹
13
/*
14
----------- Set an environment variable in git bash -----------
15
export HOST="https://ctreminiom.atlassian.net/"
16
export MAIL="MAIL_ADDRESS"
17
export TOKEN="TOKEN_API"
18
โ€‹
19
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
20
*/
21
โ€‹
22
var (
23
host = os.Getenv("HOST")
24
mail = os.Getenv("MAIL")
25
token = os.Getenv("TOKEN")
26
)
27
โ€‹
28
atlassian, err := v2.New(nil, host)
29
if err != nil {
30
log.Fatal(err)
31
}
32
โ€‹
33
atlassian.Auth.SetBasicAuth(mail, token)
34
โ€‹
35
options := &models.ProjectSearchOptionsScheme{
36
OrderBy: "issueCount",
37
Action: "browse",
38
Expand: []string{"insight", "lead", "issueTypes", "projectKeys", "description"},
39
}
40
โ€‹
41
var (
42
startAt = 0
43
maxResults = 50
44
)
45
โ€‹
46
projects, response, err := atlassian.Project.Search(context.Background(), options, startAt, maxResults)
47
if err != nil {
48
log.Fatal(err)
49
}
50
โ€‹
51
log.Println("HTTP Endpoint Used", response.Endpoint)
52
โ€‹
53
for _, project := range projects.Values {
54
log.Println(project)
55
}
56
}
Copied!
๐Ÿงšโ€โ™€๏ธ Tips: You can extract the following struct tags
1
type ProjectSearchScheme struct {
2
Self string `json:"self,omitempty"`
3
NextPage string `json:"nextPage,omitempty"`
4
MaxResults int `json:"maxResults,omitempty"`
5
StartAt int `json:"startAt,omitempty"`
6
Total int `json:"total,omitempty"`
7
IsLast bool `json:"isLast,omitempty"`
8
Values []*ProjectScheme `json:"values,omitempty"`
9
}
Copied!

Get project

Returns the project detailsโ€‹
1
package main
2
โ€‹
3
import (
4
"context"
5
"github.com/ctreminiom/go-atlassian/jira/v2"
6
"log"
7
"os"
8
)
9
โ€‹
10
func main() {
11
โ€‹
12
/*
13
----------- Set an environment variable in git bash -----------
14
export HOST="https://ctreminiom.atlassian.net/"
15
export MAIL="MAIL_ADDRESS"
16
export TOKEN="TOKEN_API"
17
โ€‹
18
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
19
*/
20
โ€‹
21
var (
22
host = os.Getenv("HOST")
23
mail = os.Getenv("MAIL")
24
token = os.Getenv("TOKEN")
25
)
26
โ€‹
27
atlassian, err := v2.New(nil, host)
28
if err != nil {
29
log.Fatal(err)
30
}
31
โ€‹
32
atlassian.Auth.SetBasicAuth(mail, token)
33
โ€‹
34
project, response, err := atlassian.Project.Get(context.Background(), "KP", []string{"issueTypes"})
35
if err != nil {
36
log.Fatal(err)
37
}
38
โ€‹
39
log.Println("HTTP Endpoint Used", response.Endpoint)
40
log.Println(project)
41
โ€‹
42
for _, issueType := range project.IssueTypes {
43
log.Println(issueType.Name)
44
}
45
}
Copied!
๐Ÿงšโ€โ™€๏ธ Tips: You can extract the following struct tags
1
type ProjectScheme struct {
2
Expand string `json:"expand,omitempty"`
3
Self string `json:"self,omitempty"`
4
ID string `json:"id,omitempty"`
5
Key string `json:"key,omitempty"`
6
Description string `json:"description,omitempty"`
7
URL string `json:"url,omitempty"`
8
Email string `json:"email,omitempty"`
9
AssigneeType string `json:"assigneeType,omitempty"`
10
Name string `json:"name,omitempty"`
11
ProjectTypeKey string `json:"projectTypeKey,omitempty"`
12
Simplified bool `json:"simplified,omitempty"`
13
Style string `json:"style,omitempty"`
14
Favourite bool `json:"favourite,omitempty"`
15
IsPrivate bool `json:"isPrivate,omitempty"`
16
UUID string `json:"uuid,omitempty"`
17
Lead *UserScheme `json:"lead,omitempty"`
18
Components []*ComponentScheme `json:"components,omitempty"`
19
IssueTypes []*IssueTypeScheme `json:"issueTypes,omitempty"`
20
Versions []*VersionScheme `json:"versions,omitempty"`
21
Roles *ProjectRolesScheme `json:"roles,omitempty"`
22
AvatarUrls *AvatarURLScheme `json:"avatarUrls,omitempty"`
23
ProjectKeys []string `json:"projectKeys,omitempty"`
24
Insight *ProjectInsightScheme `json:"insight,omitempty"`
25
Category *ProjectCategoryScheme `json:"projectCategory,omitempty"`
26
Deleted bool `json:"deleted,omitempty"`
27
RetentionTillDate string `json:"retentionTillDate,omitempty"`
28
DeletedDate string `json:"deletedDate,omitempty"`
29
DeletedBy *UserScheme `json:"deletedBy,omitempty"`
30
Archived bool `json:"archived,omitempty"`
31
ArchivedDate string `json:"archivedDate,omitempty"`
32
ArchivedBy *UserScheme `json:"archivedBy,omitempty"`
33
}
Copied!

Update project

Updates the project details of a project.
1
package main
2
โ€‹
3
import (
4
"context"
5
"github.com/ctreminiom/go-atlassian/jira/v2"
6
"github.com/ctreminiom/go-atlassian/pkg/infra/models"
7
"log"
8
"os"
9
)
10
โ€‹
11
func main() {
12
โ€‹
13
/*
14
----------- Set an environment variable in git bash -----------
15
export HOST="https://ctreminiom.atlassian.net/"
16
export MAIL="MAIL_ADDRESS"
17
export TOKEN="TOKEN_API"
18
โ€‹
19
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
20
*/
21
โ€‹
22
var (
23
host = os.Getenv("HOST")
24
mail = os.Getenv("MAIL")
25
token = os.Getenv("TOKEN")
26
)
27
โ€‹
28
atlassian, err := v2.New(nil, host)
29
if err != nil {
30
log.Fatal(err)
31
}
32
โ€‹
33
atlassian.Auth.SetBasicAuth(mail, token)
34
โ€‹
35
payload := &models.ProjectUpdateScheme{
36
Description: "Example Project description",
37
}
38
โ€‹
39
projectUpdated, response, err := atlassian.Project.Update(context.Background(), "KP", payload)
40
if err != nil {
41
log.Fatal(err)
42
}
43
โ€‹
44
log.Println("HTTP Endpoint Used", response.Endpoint)
45
log.Println(projectUpdated)
46
}
Copied!

Delete project

Deletes a project.
1
package main
2
โ€‹
3
import (
4
"context"
5
"github.com/ctreminiom/go-atlassian/jira/v2"
6
"log"
7
"os"
8
)
9
โ€‹
10
func main() {
11
โ€‹
12
var (
13
host = os.Getenv("HOST")
14
mail = os.Getenv("MAIL")
15
token = os.Getenv("TOKEN")
16
)
17
โ€‹
18
jiraCloud, err := v2.New(nil, host)
19
if err != nil {
20
return
21
}
22
โ€‹
23
jiraCloud.Auth.SetBasicAuth(mail, token)
24
jiraCloud.Auth.SetUserAgent("curl/7.54.0")
25
โ€‹
26
response, err := jiraCloud.Project.Delete(context.Background(), "DUM", true)
27
if err != nil {
28
log.Fatal(err)
29
}
30
โ€‹
31
log.Println("HTTP Endpoint Used", response.Endpoint)
32
}
Copied!

Archive project

Archives a project. Archived projects cannot be deleted. To delete an archived project, restore the project and then delete it. To restore a project, use the Jira UI.
1
package main
2
โ€‹
3
import (
4
"context"
5
"github.com/ctreminiom/go-atlassian/jira/v2"
6
"log"
7
"os"
8
)
9
โ€‹
10
func main() {
11
โ€‹
12
/*
13
----------- Set an environment variable in git bash -----------
14
export HOST="https://ctreminiom.atlassian.net/"
15
export MAIL="MAIL_ADDRESS"
16
export TOKEN="TOKEN_API"
17
โ€‹
18
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
19
*/
20
โ€‹
21
var (
22
host = os.Getenv("HOST")
23
mail = os.Getenv("MAIL")
24
token = os.Getenv("TOKEN")
25
)
26
โ€‹
27
atlassian, err := v2.New(nil, host)
28
if err != nil {
29
log.Fatal(err)
30
}
31
โ€‹
32
atlassian.Auth.SetBasicAuth(mail, token)
33
โ€‹
34
response, err := atlassian.Project.Archive(context.Background(), "PK")
35
if err != nil {
36
log.Fatal(err)
37
}
38
โ€‹
39
log.Println("HTTP Endpoint Used", response.Endpoint)
40
}
Copied!

Delete project asynchronously

Deletes a project asynchronously.
1
package main
2
โ€‹
3
import (
4
"context"
5
"github.com/ctreminiom/go-atlassian/jira/v2"
6
"log"
7
"os"
8
)
9
โ€‹
10
func main() {
11
โ€‹
12
var (
13
host = os.Getenv("HOST")
14
mail = os.Getenv("MAIL")
15
token = os.Getenv("TOKEN")
16
)
17
โ€‹
18
jiraCloud, err := v2.New(nil, host)
19
if err != nil {
20
return
21
}
22
โ€‹
23
jiraCloud.Auth.SetBasicAuth(mail, token)
24
jiraCloud.Auth.SetUserAgent("curl/7.54.0")
25
โ€‹
26
task, response, err := jiraCloud.Project.DeleteAsynchronously(context.Background(), "DUM")
27
if err != nil {
28
log.Fatal(err)
29
}
30
โ€‹
31
log.Println("HTTP Endpoint Used", response.Endpoint)
32
log.Println(task.ID)
33
log.Println(task)
34
}
Copied!
๐Ÿงšโ€โ™€๏ธ Tips: You can extract the following struct tags
1
type TaskScheme struct {
2
Self string `json:"self"`
3
ID string `json:"id"`
4
Description string `json:"description"`
5
Status string `json:"status"`
6
Result string `json:"result"`
7
SubmittedBy int `json:"submittedBy"`
8
Progress int `json:"progress"`
9
ElapsedRuntime int `json:"elapsedRuntime"`
10
Submitted int64 `json:"submitted"`
11
Started int64 `json:"started"`
12
Finished int64 `json:"finished"`
13
LastUpdate int64 `json:"lastUpdate"`
14
}
Copied!

Restore deleted project

Restores a project from the Jira recycle bin.
1
package main
2
โ€‹
3
import (
4
"context"
5
"github.com/ctreminiom/go-atlassian/jira/v2"
6
"log"
7
"os"
8
)
9
โ€‹
10
func main() {
11
โ€‹
12
var (
13
host = os.Getenv("HOST")
14
mail = os.Getenv("MAIL")
15
token = os.Getenv("TOKEN")
16
)
17
โ€‹
18
jiraCloud, err := v2.New(nil, host)
19
if err != nil {
20
return
21
}
22
โ€‹
23
jiraCloud.Auth.SetBasicAuth(mail, token)
24
jiraCloud.Auth.SetUserAgent("curl/7.54.0")
25
โ€‹
26
projectRestored, response, err := jiraCloud.Project.Restore(context.Background(), "DUM")
27
if err != nil {
28
log.Fatal(err)
29
}
30
โ€‹
31
log.Println("HTTP Endpoint Used", response.Endpoint)
32
log.Println(projectRestored)
33
โ€‹
34
}
Copied!

Get all statuses for project

Returns the valid statuses for a project. The statuses are grouped by issue type, as each project has a set of valid issue types and each issue type has a set of valid statuses.
1
package main
2
โ€‹
3
import (
4
"context"
5
"github.com/ctreminiom/go-atlassian/jira/v2"
6
"log"
7
"os"
8
)
9
โ€‹
10
func main() {
11
โ€‹
12
/*
13
----------- Set an environment variable in git bash -----------
14
export HOST="https://ctreminiom.atlassian.net/"
15
export MAIL="MAIL_ADDRESS"
16
export TOKEN="TOKEN_API"
17
โ€‹
18
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
19
*/
20
โ€‹
21
var (
22
host = os.Getenv("HOST")
23
mail = os.Getenv("MAIL")
24
token = os.Getenv("TOKEN")
25
)
26
โ€‹
27
atlassian, err := v2.New(nil, host)
28
if err != nil {
29
log.Fatal(err)
30
}
31
โ€‹
32
atlassian.Auth.SetBasicAuth(mail, token)
33
โ€‹
34
statuses, response, err := atlassian.Project.Statuses(context.Background(), "KP")
35
if err != nil {
36
log.Fatal(err)
37
}
38
โ€‹
39
log.Println("HTTP Endpoint Used", response.Endpoint)
40
โ€‹
41
for _, status := range statuses {
42
log.Println(status)
43
}
44
}
Copied!

Get project notification scheme

Gets a notification scheme associated with the project.
1
package main
2
โ€‹
3
import (
4
"context"
5
"github.com/ctreminiom/go-atlassian/jira/v2"
6
"log"
7
"os"
8
)
9
โ€‹
10
func main() {
11
โ€‹
12
/*
13
----------- Set an environment variable in git bash -----------
14
export HOST="https://ctreminiom.atlassian.net/"
15
export MAIL="MAIL_ADDRESS"
16
export TOKEN="TOKEN_API"
17
โ€‹
18
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
19
*/
20
โ€‹
21
var (
22
host = os.Getenv("HOST")
23
mail = os.Getenv("MAIL")
24
token = os.Getenv("TOKEN")
25
)
26
โ€‹
27
atlassian, err := v2.New(nil, host)
28
if err != nil {
29
log.Fatal(err)
30
}
31
โ€‹
32
atlassian.Auth.SetBasicAuth(mail, token)
33
โ€‹
34
notificationScheme, response, err := atlassian.Project.NotificationScheme(context.Background(), "KP", []string{"all"})
35
if err != nil {
36
log.Fatal(err)
37
}
38
โ€‹
39
log.Println("HTTP Endpoint Used", response.Endpoint)
40
log.Println(notificationScheme)
41
โ€‹
42
log.Println(notificationScheme.Name, notificationScheme.ID)
43
โ€‹
44
for _, event := range notificationScheme.NotificationSchemeEvents {
45
โ€‹
46
log.Println(event.Event.ID, event.Event.Name)
47
โ€‹
48
for index, notification := range event.Notifications {
49
log.Println(index, event.Event.Name, notification.ID, notification.NotificationType, notification.Parameter)
50
}
51
}
52
}
Copied!
๐Ÿงšโ€โ™€๏ธ Tips: You can extract the following struct tags
1
type NotificationSchemeScheme struct {
2
Expand string `json:"expand,omitempty"`
3
ID int `json:"id,omitempty"`
4
Self string `json:"self,omitempty"`
5
Name string `json:"name,omitempty"`
6
Description string `json:"description,omitempty"`
7
NotificationSchemeEvents []*ProjectNotificationSchemeEventScheme `json:"notificationSchemeEvents,omitempty"`
8
Scope *TeamManagedProjectScopeScheme `json:"scope,omitempty"`
9
}
10
โ€‹
11
type ProjectNotificationSchemeEventScheme struct {
12
Event *NotificationEventScheme `json:"event,omitempty"`
13
Notifications []*EventNotificationScheme `json:"notifications,omitempty"`
14
}
15
โ€‹
16
type NotificationEventScheme struct {
17
ID int `json:"id,omitempty"`
18
Name string `json:"name,omitempty"`
19
Description string `json:"description,omitempty"`
20
TemplateEvent *NotificationEventScheme `json:"templateEvent,omitempty"`
21
}
22
โ€‹
23
type EventNotificationScheme struct {
24
Expand string `json:"expand,omitempty"`
25
ID int `json:"id,omitempty"`
26
NotificationType string `json:"notificationType,omitempty"`
27
Parameter string `json:"parameter,omitempty"`
28
EmailAddress string `json:"emailAddress,omitempty"`
29
Group *GroupScheme `json:"group,omitempty"`
30
Field *IssueFieldScheme `json:"field,omitempty"`
31
ProjectRole *ProjectRoleScheme `json:"projectRole,omitempty"`
32
User *UserScheme `json:"user,omitempty"`
33
}
Copied!
Last modified 6mo ago