🧱
Application Roles
This resource represents application roles. Use it to get details of an application role or all application roles.
​
​

Get all application roles

Returns all application roles. In Jira, application roles are managed using the Application access configuration page.
1
package main
2
​
3
import (
4
"context"
5
"github.com/ctreminiom/go-atlassian/jira/v3"
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 := v3.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
applicationRole, response, err := jiraCloud.Role.Get(context.Background(), "jira-software")
27
if err != nil {
28
if response != nil {
29
log.Println("Response HTTP Response", response.Bytes.String())
30
}
31
log.Fatal(err)
32
}
33
​
34
log.Println("Response HTTP Code", response.Code)
35
log.Println("HTTP Endpoint Used", response.Endpoint)
36
​
37
log.Printf("Application Role Name: %v", applicationRole.Name)
38
log.Printf("Application Role Key: %v", applicationRole.Key)
39
log.Printf("Application Role User Count: %v", applicationRole.UserCount)
40
​
41
return
42
​
43
}e
Copied!
πŸ§šβ€β™€οΈ Tips: You can extract the following struct tags
1
type ApplicationRoleScheme struct {
2
Key string `json:"key,omitempty"`
3
Groups []string `json:"groups,omitempty"`
4
Name string `json:"name,omitempty"`
5
DefaultGroups []string `json:"defaultGroups,omitempty"`
6
SelectedByDefault bool `json:"selectedByDefault,omitempty"`
7
Defined bool `json:"defined,omitempty"`
8
NumberOfSeats int `json:"numberOfSeats,omitempty"`
9
RemainingSeats int `json:"remainingSeats,omitempty"`
10
UserCount int `json:"userCount,omitempty"`
11
UserCountDescription string `json:"userCountDescription,omitempty"`
12
HasUnlimitedSeats bool `json:"hasUnlimitedSeats,omitempty"`
13
Platform bool `json:"platform,omitempty"`
14
}
Copied!

Get application role

This method returns an existing application role using the key as a parameter
1
package main
2
​
3
import (
4
"context"
5
"github.com/ctreminiom/go-atlassian/jira/v3"
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 := v3.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
applicationRoles, response, err := jiraCloud.Role.Gets(context.Background())
27
if err != nil {
28
if response != nil {
29
log.Println("Response HTTP Response", response.Bytes.String())
30
}
31
log.Fatal(err)
32
}
33
​
34
log.Println("Response HTTP Code", response.Code)
35
log.Println("HTTP Endpoint Used", response.Endpoint)
36
​
37
for _, applicationRole := range applicationRoles {
38
log.Printf("Application Role Name: %v", applicationRole.Name)
39
log.Printf("Application Role Key: %v", applicationRole.Key)
40
log.Printf("Application Role User Count: %v", applicationRole.UserCount)
41
}
42
}
43
​
Copied!
Export as PDF
Copy link