Comment on page
🗄
Filters
In Jira, a filter is a saved search query that you can use to retrieve a specific set of issues from your Jira instance. A filter can be based on various criteria such as issue type, priority, status, assignee, labels, and more.
Filters can be saved and shared with other users, allowing you to easily collaborate and work together on a specific set of issues. You can also use filters to create custom dashboards and reports to monitor the progress of your team's work.

POST /rest/api/{2-3}/filter
This method creates a new filter. The filter is shared according to the default share scope. The filter is not selected as a favorite, the method returns the following information:
package main
import (
"context"
"fmt"
"github.com/ctreminiom/go-atlassian/jira/v2"
"github.com/ctreminiom/go-atlassian/pkg/infra/models"
"github.com/google/uuid"
"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)
newFilterBody := models.FilterPayloadScheme{
Name: fmt.Sprintf("Filter #%v", uuid.New().String()),
Description: "Filter's description",
JQL: "issuetype = Bug",
Favorite: false,
SharePermissions: []*models.SharePermissionScheme{
{
Type: "project",
Project: &models.ProjectScheme{
ID: "10000",
},
Role: nil,
Group: nil,
},
{
Type: "group",
Group: &models.GroupScheme{Name: "jira-administrators"},
},
},
}
filter, response, err := atlassian.Filter.Create(context.Background(), &newFilterBody)
if err != nil {
log.Fatal(err)
}
log.Println("HTTP Endpoint Used", response.Endpoint)
log.Printf("The filter has been created: %v - %v", filter.ID, filter.Name)
}

Filter permissions on the UI interface
GET /rest/api/3/filter/favourite
This method returns the visible favorite filters of the user, the method returns the following information:
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 {
return
}
atlassian.Auth.SetBasicAuth(mail, token)
filters, response, err := atlassian.Filter.Favorite(context.Background())
if err != nil {
return
}
log.Println("HTTP Endpoint Used", response.Endpoint)
log.Println("favorite filters", len(filters))
for _, filter := range filters {
log.Println(filter)
}
GET /rest/api/{2-3}/filter/my
Returns the filters owned by the user. If
includeFavourites
is true
, the user's visible favorite filters are also returned, the method returns the following information:package main
import (
"context"
"github.com/ctreminiom/go-atlassian/jira/v2"
"log"
"os"
)