Returns the share permissions for a filter. A filter can be shared with groups, projects, all logged-in users, or the public. Sharing with all logged-in users or the public is known as global share permission, the method returns the following information:
package main
import (
"context"
_ "github.com/ctreminiom/go-atlassian/jira/v3"
"github.com/ctreminiom/go-atlassian/jira/v2"
"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)
permissions, response, err := atlassian.Filter.Share.Gets(context.Background(), 1)
if err != nil {
log.Fatal(err)
}
log.Println("HTTP Endpoint Used", response.Endpoint)
for index, permission := range permissions {
log.Println(index, permission.Type, permission.Type)
}
}
Add share permission
POST /rest/api/3/filter/{id}/permission
Add a share permissions to a filter. If you add global share permission (one for all logged-in users or the public) it will overwrite all share permissions for the filter, the method returns the following information:
package main
import (
"context"
_ "github.com/ctreminiom/go-atlassian/jira/v3"
"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")
)
atlassian, err := v2.New(nil, host)
if err != nil {
return
}
atlassian.Auth.SetBasicAuth(mail, token)
/*
We can add different share permissions, for example:
---- Project ID only
payload := jira.PermissionFilterBodyScheme{
Type: "project",
ProjectID: "10000",
}
---- Project ID and role ID
payload := jira.PermissionFilterBodyScheme{
Type: "project",
ProjectID: "10000",
ProjectRoleID: "222222",
}
==== Group Name
payload := jira.PermissionFilterBodyScheme{
Type: "group",
GroupName: "jira-users",
}
*/
payload := models.PermissionFilterPayloadScheme{
Type: "project",
ProjectID: "10000",
}
permissions, response, err := atlassian.Filter.Share.Add(context.Background(), 1001, &payload)
if err != nil {
return
}
log.Println("HTTP Endpoint Used", response.Endpoint)
for index, permission := range permissions {
log.Println(index, permission.ID, permission.Type)
}
}
Get share permission
GET /rest/api/3/filter/{id}/permission
Returns share permission for a filter. A filter can be shared with groups, projects, all logged-in users, or the public.
Sharing with all logged-in users or the public is known as global share permission, the method returns the following information: