Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add api-method to delete remotelinks #1300

Closed
rynkk opened this issue Mar 2, 2022 · 2 comments · Fixed by #1395
Closed

Add api-method to delete remotelinks #1300

rynkk opened this issue Mar 2, 2022 · 2 comments · Fixed by #1395
Labels
feature good first issue New contributors welcome !

Comments

@rynkk
Copy link
Contributor

rynkk commented Mar 2, 2022

Problem trying to solve

It seems as if there was no method in the JIRA class to remove remotelinks (by globalId or internalId) from issues.
Is this in purpose/has there not been any demand for this, yet?

Possible solution(s)

Implement the DELETE remotelink routes (As described here:
https://docs.atlassian.com/software/jira/docs/api/REST/8.13.14/#issue-deleteRemoteIssueLinkByGlobalId
https://docs.atlassian.com/software/jira/docs/api/REST/8.13.14/#issue-deleteRemoteIssueLinkById
https://developer.atlassian.com/server/jira/platform/jira-rest-api-for-remote-issue-links/#deleting-a-remote-link-by-global-id )

import urllib.parse
@translate_resource_args
def delete_remotelink(self, issue: Union[str, Issue], *, internalid: Optional[str] = None, globalid: Optional[str] = None) -> Response:
    """Delete remotelink from issue by internalId or globalId.

    Args:
        issue (str): Key (or Issue) of Issue
        internalid (str): InternalID of the remotelink to delete
        globalid (str): GlobalID of the remotelink to delete

    Returns:
        Response
    """
    if not ((internalid is None) ^ (globalid is None)):
        raise ValueError("Must supply either 'internalid' XOR 'globalid'.")
    if internalid is not None:
        url = self._get_url("issue/" + str(issue) + "/remotelink/" + str(internalid))
    elif globalid is not None:
        # stop "&" and other special characters in globalid from messing around with the query
        globalid = urllib.parse.quote(globalid, safe="")
        url = self._get_url("issue/" + str(issue) + "/remotelink?globalId=" + globalid)
    return self._session.delete(url)
        

Alternatives

Splitting the above method into 2 (One for globalId one for internalId)

Additional Context

Pull request wanted?


Jannik Meinecke ([email protected]) on behalf of MBition GmbH.
Provider Information

@adehad adehad added feature good first issue New contributors welcome ! labels Mar 5, 2022
@adehad
Copy link
Contributor

adehad commented Mar 5, 2022

@rynkk I believe there is an implementation for the internal id at least at the resource level:

e.g. the RemoteLink class itself has a .delete() method inherited from the Resource class:

def delete(self, params: Optional[Dict[str, Any]] = None) -> Optional[Response]:

(also see the test case I've linked at the bottom of this message)

Now at the global ID level, I do not believe this exists.

It would be great if you are able to submit a pull request for your proposal, it looks good to me as a single method, some suggestions from me:

--internalid
++internal_id
--globalid
++global_id

Would also be great if you can use the "f-string" format, we have this running on our linter tox -e lint so it should just be applied for you, e.g.
self._get_url(f"issue/{issue}/remotelink?globalId={globalid}")

and it would be great if you can write a test case for this, perhaps very similar to this:

def test_delete_remote_link(self):

Thanks!

@rynkk
Copy link
Contributor Author

rynkk commented Mar 7, 2022

I will have to wait until I've had my employer's FOSS-workshop. Don't want to be in a pickle in the end. I will start working on this in approx. 1,5 months. If anyone else is craving this, feel free.


Jannik Meinecke ([email protected]) on behalf of MBition GmbH.
Provider Information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature good first issue New contributors welcome !
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants