Modifying filter access rights in Jira using Python

Hey everyone! I've been working with the Jira Python library and I'm stuck on something. I made a new filter using the `create_filter` function, but it's set to private by default. I want to share this filter with my team, but I can't figure out how to change the permissions.

I've looked through the docs and can't find any way to set or update the filter permissions. Has anyone done this before? Is there a trick I'm missing or maybe a different method I should be using?

Here's a quick example of what I've tried:

```python
from jira import JIRA

jira = JIRA(server='https://your-jira-instance.com', basic_auth=('username', 'password'))

new_filter = jira.create_filter(name='My Team Filter', jql='project = TEAM')
# How do I make this filter visible to others?

Any help would be super appreciated! Thanks in advance!

I’ve encountered this issue as well. While the Jira Python library doesn’t provide a straightforward method for modifying filter permissions, you can leverage the Jira REST API to achieve this. After creating your filter, use the jira.put() method to update the permissions. Here’s an example:

filter_id = new_filter.id
url = f'/rest/api/2/filter/{filter_id}'
payload = {
    'sharePermissions': [
        {'type': 'project', 'projectId': 'YOUR_PROJECT_ID'}
    ]
}
jira.put(url, json=payload)

This will share the filter with all users who have access to the specified project. Adjust the ‘type’ and other parameters based on your specific sharing requirements. Remember to handle potential exceptions when making API calls.

hey mate, i had the same problem. try using the REST API directly. after creating the filter, do something like this:

jira.put(f’/rest/api/2/filter/{new_filter.id}', json={‘sharePermissions’: [{‘type’: ‘group’, ‘groupname’: ‘your-team-group’}]})

this should share it with your team. good luck!

I’ve actually faced this exact issue before, and it can be a bit tricky. The Jira Python library doesn’t have a direct method to modify filter permissions, but there’s a workaround using the underlying REST API.

After creating your filter, you can use the jira.put() method to update the permissions. Here’s how I did it:

filter_id = new_filter.id
url = f'/rest/api/2/filter/{filter_id}'
payload = {
    'sharePermissions': [
        {'type': 'group', 'groupname': 'jira-users'}
    ]
}
jira.put(url, json=payload)

This will share the filter with all Jira users. You can adjust the ‘groupname’ or use different permission types like ‘project’ or ‘global’ depending on your needs.

Remember to handle potential exceptions, as this method involves direct API calls. It’s not as clean as a dedicated method, but it gets the job done. Hope this helps!