๐Ÿ”“
Permissions
This resource represents permissions. Use it to obtain details of all permissions and determine whether the user has certain permissions.

Get my permissions

Returns a list of permissions indicating which permissions the user has. Details of the user's permissions can be obtained in a global, project, or issue context.
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")
)
โ€‹
atlassian, err := v2.New(nil, host)
if err != nil {
log.Fatal(err)
}
โ€‹
atlassian.Auth.SetBasicAuth(mail, token)
โ€‹
permissions, response, err := atlassian.Permission.Gets(context.Background())
if err != nil {
log.Fatal(err)
}
โ€‹
log.Println("HTTP Endpoint Used", response.Endpoint)
โ€‹
for _, permission := range permissions {
log.Println(permission)
}
}

Check permissions

  • for a list of global permissions, the global permissions are granted to a user.
  • for a list of project permissions and lists of projects and issues, for each project permission a list of the projects and issues a user can access or manipulate.
If no account ID is provided, the operation returns details for the logged-in user.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/jira/v2"
"github.com/ctreminiom/go-atlassian/pkg/infra/models"
"log"
"os"
)
โ€‹
func main() {
โ€‹
/*
----------- Set an environment variable in git bash -----------
export HOST="https://ctreminiom.atlassian.net/"
export MAIL="MAIL_ADDRESS"
export TOKEN="TOKEN_API"
โ€‹
Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
*/
โ€‹
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
โ€‹
atlassian, err := v2.New(nil, host)
if err != nil {
log.Fatal(err)
}
โ€‹
atlassian.Auth.SetBasicAuth(mail, token)
โ€‹
payload := &models.PermissionCheckPayload{
GlobalPermissions: []string{"ADMINISTER"},
AccountID: "", //
ProjectPermissions: []*models.BulkProjectPermissionsScheme{
{
Issues: nil,
Projects: []int{10000},
Permissions: []string{"EDIT_ISSUES"},
},
},
}
โ€‹
grants, response, err := atlassian.Permission.Check(context.Background(), payload)
if err != nil {
log.Fatal(err)
}
โ€‹
log.Println("HTTP Endpoint Used", response.Endpoint)
โ€‹
for _, permission := range grants.ProjectPermissions {
log.Println(permission.Permission, permission.Issues)
}
โ€‹
}
Export as PDF
Copy link
On this page
Get my permissions
Check permissions