๐Ÿงฑ
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.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/jira/v3"
"log"
"os"
)
โ€‹
func main() {
โ€‹
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
โ€‹
jiraCloud, err := v3.New(nil, host)
if err != nil {
return
}
โ€‹
jiraCloud.Auth.SetBasicAuth(mail, token)
jiraCloud.Auth.SetUserAgent("curl/7.54.0")
โ€‹
applicationRole, response, err := jiraCloud.Role.Get(context.Background(), "jira-software")
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("Application Role Name: %v", applicationRole.Name)
log.Printf("Application Role Key: %v", applicationRole.Key)
log.Printf("Application Role User Count: %v", applicationRole.UserCount)
โ€‹
return
โ€‹
}e
๐Ÿงšโ€โ™€๏ธ Tips: You can extract the following struct tags
type ApplicationRoleScheme struct {
Key string `json:"key,omitempty"`
Groups []string `json:"groups,omitempty"`
Name string `json:"name,omitempty"`
DefaultGroups []string `json:"defaultGroups,omitempty"`
SelectedByDefault bool `json:"selectedByDefault,omitempty"`
Defined bool `json:"defined,omitempty"`
NumberOfSeats int `json:"numberOfSeats,omitempty"`
RemainingSeats int `json:"remainingSeats,omitempty"`
UserCount int `json:"userCount,omitempty"`
UserCountDescription string `json:"userCountDescription,omitempty"`
HasUnlimitedSeats bool `json:"hasUnlimitedSeats,omitempty"`
Platform bool `json:"platform,omitempty"`
}

Get application role

This method returns an existing application role using the key as a parameter
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/jira/v3"
"log"
"os"
)
โ€‹
func main() {
โ€‹
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
โ€‹
jiraCloud, err := v3.New(nil, host)
if err != nil {
return
}
โ€‹
jiraCloud.Auth.SetBasicAuth(mail, token)
jiraCloud.Auth.SetUserAgent("curl/7.54.0")
โ€‹
applicationRoles, response, err := jiraCloud.Role.Gets(context.Background())
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)
โ€‹
for _, applicationRole := range applicationRoles {
log.Printf("Application Role Name: %v", applicationRole.Name)
log.Printf("Application Role Key: %v", applicationRole.Key)
log.Printf("Application Role User Count: %v", applicationRole.UserCount)
}
}
โ€‹
Export as PDF
Copy link
On this page
Get all application roles
Get application role