Skip to content

Support for "link_type" in issue links #847

@jmini

Description

@jmini

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions