Skip to content

Support for "link_type" in issue links #847

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

Closed
jmini opened this issue Jun 1, 2022 · 0 comments · Fixed by #964
Closed

Support for "link_type" in issue links #847

jmini opened this issue Jun 1, 2022 · 0 comments · Fixed by #964

Comments

@jmini
Copy link
Collaborator

jmini commented Jun 1, 2022

According to https://docs.gitlab.com/ee/api/issue_links.html

Endpoint:

POST /projects/:id/issues/:issue_iid/links

Supports a link_type query parameter:

Type: string
Required: no
Description: The type of the relation (“relates_to”, “blocks”, “is_blocked_by”), defaults to “relates_to”).

So this would needs to be reflected here:

/**
* Creates a two-way relation between two issues. User must be allowed to update both issues in order to succeed.
*
* <p>NOTE: Only available in GitLab Starter, GitLab Bronze, and higher tiers.</p>
*
* <pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/links</code></pre>
*
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
* @param issueIid the internal ID of a project's issue
* @param targetProjectIdOrPath the project in the form of an Long(ID), String(path), or Project instance of the target project
* @param targetIssueIid the internal ID of a target project’s issue
* @return an instance of IssueLink holding the link relationship
* @throws GitLabApiException if any exception occurs
*/
public IssueLink createIssueLink(Object projectIdOrPath, Long issueIid,
Object targetProjectIdOrPath, Long targetIssueIid) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm()
.withParam("target_project_id", getProjectIdOrPath(targetProjectIdOrPath), true)
.withParam("target_issue_iid", targetIssueIid, true);
Response response = post(Response.Status.OK, formData.asMap(),
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "links");
return (response.readEntity(IssueLink.class));
}

Maybe as enum?

And it needs to be present in IssueLink class (link_type attribute), when the response is parsed:

[
  {
    "id" : 84,
    "iid" : 14,
    "issue_link_id": 1,
    "project_id" : 4,
    "created_at" : "2016-01-07T12:44:33.959Z",
    "title" : "Issues with auth",
    "state" : "opened",
    "assignees" : [],
    "assignee" : null,
    "labels" : [
      "bug"
    ],
    "author" : {
      "name" : "Alexandra Bashirian",
      "avatar_url" : null,
      "state" : "active",
      "web_url" : "https://gitlab.example.com/eileen.lowe",
      "id" : 18,
      "username" : "eileen.lowe"
    },
    "description" : null,
    "updated_at" : "2016-01-07T12:44:33.959Z",
    "milestone" : null,
    "user_notes_count": 0,
    "due_date": null,
    "web_url": "http://example.com/example/example/issues/14",
    "confidential": false,
    "weight": null,
    "link_type": "relates_to",
    "link_created_at": "2016-01-07T12:44:33.959Z",
    "link_updated_at": "2016-01-07T12:44:33.959Z"
  }
]

Also the method reading the issue links GET /projects/:id/issues/:issue_iid/links should be reworked:

  • getIssueLinks(Object projectIdOrPath, Long issueIid)
  • getIssueLinks(Object projectIdOrPath, Long issueIid, int itemsPerPage)
  • getIssueLinksStream(Object projectIdOrPath, Long issueIid)

But there I am not sure to understand why the return type is not from type IssueLink

jmini added a commit to jmini/gitlab4j-api that referenced this issue Apr 24, 2023
jabby pushed a commit that referenced this issue Apr 26, 2023
* Add support for link type between issues

Fixes #847

* Create AbstractIssue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant