pycontribs / jira

Python Jira library. Development chat available on https://matrix.to/#/#pycontribs:matrix.org
https://jira.readthedocs.io
BSD 2-Clause "Simplified" License
1.92k stars 859 forks source link

Add new JIRA Teams API #1761

Open Maxim-Durand opened 8 months ago

Maxim-Durand commented 8 months ago

Problem trying to solve

I think it's currently not possible to fetch JIRA's team members using this client.

Possible solution(s)

Jira launched a new rest-api at https://developer.atlassian.com/platform/teams/rest/v1/api-group-teams-members-public-api/#api-group-teams-members-public-api to support this workflow. I think it's only about adding this into the current client for a new release.

Alternatives

Instead of using https://github.com/pycontribs/jira, the user can use the REST API For instance here is code snippet to fetch the members of a team (you'll need to fill the jira_.* variables with your own values).

from requests.auth import HTTPBasicAuth

url = f"{jira_server_url}/gateway/api/public/teams/v1/org/{jira_org_id}/teams/{jira_team_id}/members"
headers = {
    "Accept": "*/*",
    "Content-Type": "application/json"
}
payload = json.dumps({
    "first": 40
})
response = requests.request(
    "POST",
    url,
    auth=HTTPBasicAuth(jira_api_id, jira_api_token),
    data=payload,
    headers=headers
)
print(response.text)

Additional Context

No response

Maxim-Durand commented 8 months ago

I'll try to create a PR to add this feature.