atlassian-api / atlassian-python-api

Atlassian Python REST API wrapper
https://atlassian-python-api.readthedocs.io
Apache License 2.0
1.34k stars 662 forks source link

[Jira] In version 3.14.1 assign_user does not work for cloud version #864

Open sebastianberm opened 2 years ago

sebastianberm commented 2 years ago

It seems like the PR's https://github.com/atlassian-api/atlassian-python-api/pull/821 fixed everything for Jira Server users. However, I had to change this back for our Jira cloud instance with GDPR strict settings enabled.

Jira Server docs: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2/issue-assign Jira Cloud docs: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-assignee-put

So this could be fixed by using the cloud boolean to figure out what you're connecting to.

It seems to be working if I refactor the assign_issue function like so:

    def assign_issue(self, issue, account_id=None):
        """Assign an issue to a user. None will set it to unassigned. -1 will set it to Automatic.
        :param issue: the issue ID or key to assign
        :type issue: int or str
        :param account_id: the account ID of the user to assign the issue to
        :type account_id: str
        :rtype: bool
        """
        base_url = self.resource_url("issue")
        url = "{base_url}/{issue}/assignee".format(base_url=base_url, issue=issue)
        if self.cloud:
            data = {"accountId": account_id}
        else:
            data = {"name": account_id}
        return self.put(url, data=data)
isaac-philip commented 2 years ago

this is great as you tested it works for cloud and very much required too. Whats holding you back to place this in the repository ? any issues please post here or connect on this project discord chat.

sebastianberm commented 2 years ago

Mostly the amount of time I had left for that particular project. Will try to create a PR for it later today, furthermore, I don't have time to create tests for this, so if it can be merged without tests, I'll file it later this week 👍

isaac-philip commented 2 years ago

I see similar issue #774 filed long back. maybe we need a better solution which can reflect at all cloud dependent functions.

setting this at the class level object would be better so can be used at other dependencies as well. this is what i am theoretically saying and would need to inspect it, but feel free to go in that direction.

gonchik commented 1 year ago

@isaac-philip is this actual ?