atlassian-api / atlassian-python-api

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

expand parameter missing in JIRA get_issue vs issue methid #1354

Closed gkowalc closed 3 months ago

gkowalc commented 3 months ago

I am trying to get details from the issue and to expand some of the fields (like changelog). Looking at the code I noticed we have a method named issue:

def issue(self, key, fields="*all", expand=None):
        base_url = self.resource_url("issue")
        url = "{base_url}/{key}?fields={fields}".format(base_url=base_url, key=key, fields=fields)
        params = {}
        if expand:
            params["expand"] = expand
        return self.get(url, params=params)

which takes expand params. I tested it and everything works well. But we also have method get_issue:

  def get_issue(
        self,
        issue_id_or_key,
        fields=None,
        properties=None,
        update_history=True,
    ):
        """
        Returns a full representation of the issue for the given issue key
        By default, all fields are returned in this get-issue resource

        :param issue_id_or_key: str
        :param fields: str
        :param properties: str
        :param update_history: bool
        :return: issue
        """
        base_url = self.resource_url("issue")
        url = "{base_url}/{issue_id_or_key}".format(base_url=base_url, issue_id_or_key=issue_id_or_key)
        params = {}

        if fields is not None:
            if isinstance(fields, (list, tuple, set)):
                fields = ",".join(fields)
            params["fields"] = fields
        if properties is not None:
            params["properties"] = properties
        if update_history is True:
            params["updateHistory"] = "true"
        if update_history is False:
            params["updateHistory"] = "false"

        return self.get(url, params=params)

which takes few other parameters fields=None, properties=None, update_history=True but not expand. Is there a good reason to have to methods which basically serve the same functionality which different set of accepted parameters? Im thinking about adding PR with:

       if expand:
            params["expand"] = expand `

condition to get_issue method and add a deprecated note to issue method (so that people relying on that method can re-write their code before removing duplicated issue method. What do you think?

gkowalc commented 3 months ago

I added PR that adds expand parameter to get_issue method - https://github.com/atlassian-api/atlassian-python-api/pull/1357