Deprecation of search enpoints
As declared in https://developer.atlassian.com/changelog/#CHANGE-2046
the /search endpoints will be removed as of may 1st Is there any plan for an update?
The endpoints to use now are GET or POST of /rest/api/3/search/jql. I only just became aware of this so I'm scrambling for a replacement if this library doesn't yet support it.
I created a PR which works for my use case: https://github.com/lesstif/php-JiraCloud-RESTAPI/pull/97. It works with a simple JQL.
Might be useful to also implement the new bulk fetch: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-bulkfetch-post and the count api: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-approximate-count-post
I ended up including the bulk fetch and count. It's working for me.
In my testing using bulkFetch() has a significant performance improvement over get(), so I hope that it also gets merged in since the new search API won't return all the necessary fields (for our use case).
bulkFetch(): 0.04s per issue; get(): 0.4s per issue. So a ten times improvement.
@lesstif can you take a look at this PR? Does it look good or need some improvement?
The old search API was shut down today and the library therefore broken.
Any chance we can get this PR merged sooner rather than later?
It did not work for me. Using POST gave me wrong payload so I needed to use GET like in docs https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-jql-get
I ended up extending the IssueService with added functions
public function searchJql(
string $jql,
?string $nextPageToken = null,
int $maxResults = 15,
array $fields = ['*all'],
array $expand = [],
array $properties = [],
bool $fieldsByKeys = false,
bool $failFast = true,
array $reconcileIssues = [],
): IssueSearchJqlResult {
$payload = [
'jql' => $jql,
'nextPageToken' => $nextPageToken,
'maxResults' => $maxResults,
'fields' => implode(',', $fields),
'expand' => $expand,
'properties' => $properties,
'fieldsByKeys' => $fieldsByKeys,
'failFast' => $failFast,
'reconcileIssues' => $reconcileIssues,
];
$ret = $this->execGet('/search/jql', $payload);
$json = json_decode($ret);
return $this->json_mapper->map(
$json,
new IssueSearchJqlResult()
);
}
public function execGet(string $context, ?array $post_data = null): string|bool
{
$context .= '/?' . http_build_query($post_data);
return $this->exec($context, null, 'GET');
}
Created this new DTO to use with it
<?php
declare(strict_types=1);
namespace App\Component\JiraDto;
class IssueSearchJqlResult
{
private ?string $nextPageToken = null;
/** @var \JiraCloud\Issue\Issue[] */
private array $issues = [];
public function getNextPageToken(): ?string
{
return $this->nextPageToken;
}
public function setNextPageToken(?string $nextPageToken): void
{
$this->nextPageToken = $nextPageToken;
}
/** @return \JiraCloud\Issue\Issue[] */
public function getIssues(): array
{
return $this->issues;
}
/** @param \JiraCloud\Issue\Issue[] $issues */
public function setIssues(array $issues): void
{
$this->issues = $issues;
}
public function getIssue(int $index): \JiraCloud\Issue\Issue
{
return $this->issues[$index];
}
}
Still relevant!
Idd!
Works for me. Please merge this.
This worked for me too, I also went with the composer patch method for now.
I feel like hoping for any activity on this project from the maintainer is probably useless though. @herbdool you could probably create a new fork if you feel like maintaining it.
Thanks for merging the changes, @lesstif! We will give it a try.