๐Ÿšง
Permission Schemes
This resource represents permission schemes for a project.

Get assigned permission scheme

Gets the permission scheme associated with the project.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/jira/v2"
"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)
โ€‹
scheme, response, err := atlassian.Project.Permission.Get(context.Background(), "KP", []string{"all"})
if err != nil {
log.Fatal(err)
}
โ€‹
log.Println("HTTP Endpoint Used", response.Endpoint)
log.Println(scheme)
}
๐Ÿงšโ€โ™€๏ธ Tips: You can extract the following struct tags
type PermissionSchemeScheme struct {
Expand string `json:"expand,omitempty"`
ID int `json:"id,omitempty"`
Self string `json:"self,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Permissions []*PermissionGrantScheme `json:"permissions,omitempty"`
Scope *TeamManagedProjectScopeScheme `json:"scope,omitempty"`
}
โ€‹
type PermissionScopeItemScheme struct {
Self string `json:"self,omitempty"`
ID string `json:"id,omitempty"`
Key string `json:"key,omitempty"`
Name string `json:"name,omitempty"`
ProjectTypeKey string `json:"projectTypeKey,omitempty"`
Simplified bool `json:"simplified,omitempty"`
ProjectCategory *ProjectCategoryScheme `json:"projectCategory,omitempty"`
}

Assign permission scheme

Assigns a permission scheme with a project
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/jira/v2"
"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)
โ€‹
var (
projectKeyOrID = "KP"
permissionSchemeID = 10000
)
โ€‹
scheme, response, err := atlassian.Project.Permission.Assign(context.Background(), projectKeyOrID, permissionSchemeID)
if err != nil {
log.Fatal(err)
}
โ€‹
log.Println("HTTP Endpoint Used", response.Endpoint)
log.Println(scheme)
}

Get project issue security levels

Returns all issue security levels for the project that the user has access to.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/jira/v2"
"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)
โ€‹
levels, response, err := atlassian.Project.Permission.SecurityLevels(context.Background(), "KP")
if err != nil {
log.Fatal(err)
}
โ€‹
log.Println("HTTP Endpoint Used", response.Endpoint)
โ€‹
for _, level := range levels.Levels {
log.Println(level)
}
}
Last modified 8mo ago