๐Ÿ“ˆ
Dashboards
This resource represents dashboards. Use it to obtain the details of dashboards as well as add and remove item properties from dashboards.
.gif created using the video https://www.youtube.com/watch?v=VswPTqLQzqA
โ€‹

Get all dashboards

Returns a list of dashboards owned by or shared with the user. The list may be filtered to include only favorite or owned dashboards.
  • ๐Ÿ”’ Permissions required: Anonymously
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/jira/v2"
"log"
"os"
)
โ€‹
func main() {
โ€‹
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
โ€‹
jiraCloud, err := v2.New(nil, host)
if err != nil {
return
}
โ€‹
jiraCloud.Auth.SetBasicAuth(mail, token)
jiraCloud.Auth.SetUserAgent("curl/7.54.0")
โ€‹
dashboards, response, err := jiraCloud.Dashboard.Gets(context.Background(), 0, 50, "")
โ€‹
if err != nil {
log.Fatal(err)
}
โ€‹
log.Println("HTTP Endpoint Used", response.Endpoint)
โ€‹
for _, dashboard := range dashboards.Dashboards {
log.Println(dashboard.ID, dashboard.Name)
}
}
๐Ÿงšโ€โ™€๏ธ Tips: You can extract the following struct tags
type DashboardPageScheme struct {
StartAt int `json:"startAt,omitempty"`
MaxResults int `json:"maxResults,omitempty"`
Total int `json:"total,omitempty"`
Dashboards []*DashboardScheme `json:"dashboards,omitempty"`
}
โ€‹
type DashboardScheme struct {
ID string `json:"id,omitempty"`
IsFavourite bool `json:"isFavourite,omitempty"`
Name string `json:"name,omitempty"`
Owner *UserScheme `json:"owner,omitempty"`
Popularity int `json:"popularity,omitempty"`
Rank int `json:"rank,omitempty"`
Self string `json:"self,omitempty"`
SharePermissions []*SharePermissionScheme `json:"sharePermissions,omitempty"`
EditPermission []*SharePermissionScheme `json:"editPermissions,omitempty"`
View string `json:"view,omitempty"`
}
โ€‹
type SharePermissionScheme struct {
ID int `json:"id,omitempty"`
Type string `json:"type,omitempty"`
Project *ProjectScheme `json:"project,omitempty"`
Role *ProjectRoleScheme `json:"role,omitempty"`
Group *GroupScheme `json:"group,omitempty"`
}
โ€‹
type DashboardSearchPageScheme struct {
Self string `json:"self,omitempty"`
MaxResults int `json:"maxResults,omitempty"`
StartAt int `json:"startAt,omitempty"`
Total int `json:"total,omitempty"`
IsLast bool `json:"isLast,omitempty"`
Values []*DashboardScheme `json:"values,omitempty"`
}

Create dashboard

This method creates a dashboard on Jira Cloud.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/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")
)
โ€‹
jiraCloud, err := v2.New(nil, host)
if err != nil {
return
}
โ€‹
jiraCloud.Auth.SetBasicAuth(mail, token)
jiraCloud.Auth.SetUserAgent("curl/7.54.0")
โ€‹
var payload = &models.DashboardPayloadScheme{
Name: "Team Tracking 4",
Description: "description sample",
SharePermissions: []*models.SharePermissionScheme{
{
Type: "project",
Project: &models.ProjectScheme{
ID: "10000",
},
Role: nil,
Group: nil,
},
{
Type: "group",
Group: &models.GroupScheme{Name: "jira-administrators"},
},
},
}
โ€‹
dashboard, response, err := jiraCloud.Dashboard.Create(context.Background(), payload)
if err != nil {
log.Fatal(err)
}
โ€‹
log.Println("Response HTTP Code", response.Code)
log.Println("HTTP Endpoint Used", response.Endpoint)
โ€‹
log.Printf("Dashboard Name: %v", dashboard.Name)
log.Printf("Dashboard ID: %v", dashboard.ID)
log.Printf("Dashboard View: %v", dashboard.View)
}
๐Ÿงšโ€โ™€๏ธ Tips: You can extract the following struct tags
type DashboardScheme struct {
ID string `json:"id,omitempty"`
IsFavourite bool `json:"isFavourite,omitempty"`
Name string `json:"name,omitempty"`
Owner *UserScheme `json:"owner,omitempty"`
Popularity int `json:"popularity,omitempty"`
Rank int `json:"rank,omitempty"`
Self string `json:"self,omitempty"`
SharePermissions []*SharePermissionScheme `json:"sharePermissions,omitempty"`
EditPermission []*SharePermissionScheme `json:"editPermissions,omitempty"`
View string `json:"view,omitempty"`
}

Search for dashboards

Returns a paginated list of dashboards. This operation is similar to Get dashboards except that the results can be refined to include dashboards that have specific attributes. For example, dashboards with a particular name. When multiple attributes are specified only filters matching all attributes are returned.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/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")
)
โ€‹
jiraCloud, err := v2.New(nil, host)
if err != nil {
return
}
โ€‹
jiraCloud.Auth.SetBasicAuth(mail, token)
jiraCloud.Auth.SetUserAgent("curl/7.54.0")
โ€‹
searchOptions := models.DashboardSearchOptionsScheme{
DashboardName: "Bug",
GroupPermissionName: "administrators",
OrderBy: "description",
Expand: []string{"description", "favourite", "sharePermissions"},
}
โ€‹
dashboards, response, err := jiraCloud.Dashboard.Search(context.Background(), &searchOptions, 0, 50)
if err != nil {
log.Fatal(err)
}
โ€‹
log.Println("HTTP Endpoint Used", response.Endpoint)
โ€‹
for _, dashboard := range dashboards.Values {
log.Printf("Dashboard Name: %v", dashboard.Name)
log.Printf("Dashboard ID: %v", dashboard.ID)
log.Printf("Dashboard View: %v", dashboard.View)
โ€‹
if dashboard.SharePermissions != nil {
for _, permission := range dashboard.SharePermissions {
log.Println(permission)
}
}
}
โ€‹
}

Get dashboard

Returns a dashboard using the dashboard-id
  • ๐Ÿ”’ Permissions required: Access to the application
However, to get a dashboard, the dashboard must be shared with the user or the user must own it. Note, users with Administer Jira global permission are considered owners of the System dashboard. The System dashboard is considered to be shared with all other users.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/jira/v2"
"log"
"os"
)
โ€‹
func main() {
โ€‹
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
โ€‹
jiraCloud, err := v2.New(nil, host)
if err != nil {
return
}
โ€‹
jiraCloud.Auth.SetBasicAuth(mail, token)
jiraCloud.Auth.SetUserAgent("curl/7.54.0")
โ€‹
dashboard, response, err := jiraCloud.Dashboard.Get(context.Background(), "10001")
if err != nil {
log.Fatal(err)
}
โ€‹
log.Println("HTTP Endpoint Used", response.Endpoint)
โ€‹
log.Printf("Dashboard Name: %v", dashboard.Name)
log.Printf("Dashboard ID: %v", dashboard.ID)
log.Printf("Dashboard View: %v", dashboard.View)
}
๐Ÿงšโ€โ™€๏ธ Tips: You can extract the following struct tags
type DashboardScheme struct {
ID string `json:"id,omitempty"`
IsFavourite bool `json:"isFavourite,omitempty"`
Name string `json:"name,omitempty"`
Owner *UserScheme `json:"owner,omitempty"`
Popularity int `json:"popularity,omitempty"`
Rank int `json:"rank,omitempty"`
Self string `json:"self,omitempty"`
SharePermissions []*SharePermissionScheme `json:"sharePermissions,omitempty"`
EditPermission []*SharePermissionScheme `json:"editPermissions,omitempty"`
View string `json:"view,omitempty"`
}
โ€‹
type SharePermissionScheme struct {
ID int `json:"id,omitempty"`
Type string `json:"type,omitempty"`
Project *ProjectScheme `json:"project,omitempty"`
Role *ProjectRoleScheme `json:"role,omitempty"`
Group *GroupScheme `json:"group,omitempty"`
}

Update dashboard

Updates a dashboard, replacing all the dashboard details with those provided. The dashboard to be updated must be owned by the user.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/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")
)
โ€‹
jiraCloud, err := v2.New(nil, host)
if err != nil {
return
}
โ€‹
jiraCloud.Auth.SetBasicAuth(mail, token)
jiraCloud.Auth.SetUserAgent("curl/7.54.0")
โ€‹
var payload = &models.DashboardPayloadScheme{
Name: "Team Tracking #1111",
Description: "",
SharePermissions: []*models.SharePermissionScheme{
{
Type: "project",
Project: &models.ProjectScheme{
ID: "10000",
},
Role: nil,
Group: nil,
},
{
Type: "group",
Group: &models.GroupScheme{Name: "jira-administrators"},
},
},
}
โ€‹
dashboard, response, err := jiraCloud.Dashboard.Update(context.Background(), "10001", payload)
if err != nil {
log.Fatal(err)
}
โ€‹
log.Println("HTTP Endpoint Used", response.Endpoint)
โ€‹
log.Printf("Dashboard Name: %v", dashboard.Name)
log.Printf("Dashboard ID: %v", dashboard.ID)
log.Printf("Dashboard View: %v", dashboard.View)
}
โ€‹

Delete dashboard

Deletes a dashboard, The dashboard to be deleted must be owned by the user.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/jira/v2"
"log"
"os"
)
โ€‹
func main() {
โ€‹
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
โ€‹
jiraCloud, err := v2.New(nil, host)
if err != nil {
return
}
โ€‹
jiraCloud.Auth.SetBasicAuth(mail, token)
jiraCloud.Auth.SetUserAgent("curl/7.54.0")
โ€‹
response, err := jiraCloud.Dashboard.Delete(context.Background(), "10003")
if err != nil {
log.Fatal(err)
}
โ€‹
log.Println("Response HTTP Code", response.Code)
log.Println("HTTP Endpoint Used", response.Endpoint)
}

Copy dashboard

Copies a dashboard. Any values provided in the dashboard parameter replace those in the copied dashboard.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/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")
)
โ€‹
jiraCloud, err := v2.New(nil, host)
if err != nil {
return
}
โ€‹
jiraCloud.Auth.SetBasicAuth(mail, token)
jiraCloud.Auth.SetUserAgent("curl/7.54.0")
โ€‹
var payload = &models.DashboardPayloadScheme{
Name: "Team Tracking #2 copy",
Description: "Description sample",
SharePermissions: []*models.SharePermissionScheme{
{
Type: "project",
Project: &models.ProjectScheme{
ID: "10000",
},
Role: nil,
Group: nil,
},
{
Type: "group",
Group: &models.GroupScheme{Name: "jira-administrators"},
},
},
}
โ€‹
dashboard, response, err := jiraCloud.Dashboard.Copy(context.Background(), "10001", payload)
if err != nil {
if response != nil {
log.Println("Response HTTP Response", response.Bytes.String())
}
log.Fatal(err)
}
โ€‹
log.Println("Response HTTP Code", response.Code)
log.Println("HTTP Endpoint Used", response.Endpoint)
โ€‹
log.Printf("Dashboard Name: %v", dashboard.Name)
log.Printf("Dashboard ID: %v", dashboard.ID)
log.Printf("Dashboard View: %v", dashboard.View)
}
Export as PDF
Copy link
On this page
Get all dashboards
Create dashboard
Search for dashboards
Get dashboard
Update dashboard
Delete dashboard
Copy dashboard