Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
b0083d56
Unverified
Commit
b0083d56
authored
Apr 02, 2020
by
Olivier Ribardière
Committed by
GitHub
Apr 02, 2020
Browse files
Adding ref parameter on SearchAPI on projects (#544) (#545)
parent
39c27683
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/SearchApi.java
View file @
b0083d56
...
@@ -208,9 +208,29 @@ public class SearchApi extends AbstractApi {
...
@@ -208,9 +208,29 @@ public class SearchApi extends AbstractApi {
* @since GitLab 10.5
* @since GitLab 10.5
*/
*/
public
List
<?>
projectSearch
(
Object
projectIdOrPath
,
ProjectSearchScope
scope
,
String
search
)
throws
GitLabApiException
{
public
List
<?>
projectSearch
(
Object
projectIdOrPath
,
ProjectSearchScope
scope
,
String
search
)
throws
GitLabApiException
{
return
(
projectSearch
(
projectIdOrPath
,
scope
,
search
,
this
.
getDefaultPerPage
()).
all
());
return
(
projectSearch
(
projectIdOrPath
,
scope
,
search
,
null
,
this
.
getDefaultPerPage
()).
all
());
}
}
/**
* Search within the specified project. If a user is not a member of a project and the project is private,
* a request on that project will result to a 404 status code.
*
* <pre><code>GitLab Endpoint: POST /projects/:projectId/search?scope=:scope&search=:search-query&ref=ref</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
* @param scope search the expression within the specified scope. Currently these scopes are supported:
* issues, merge_requests, milestones, notes, wiki_blobs, commits, blobs, users
* @param search the search query
* @param ref the name of a repository branch or tag to search on. The project’s default branch is used by
* default. This is only applicable for scopes: commits, blobs, and wiki_blobs.
* @return a List containing the object type specified by the scope
* @throws GitLabApiException if any exception occurs
* @since GitLab 10.5
*/
public
List
<?>
projectSearch
(
Object
projectIdOrPath
,
ProjectSearchScope
scope
,
String
search
,
String
ref
)
throws
GitLabApiException
{
return
(
projectSearch
(
projectIdOrPath
,
scope
,
search
,
ref
,
this
.
getDefaultPerPage
()).
all
());
}
/**
/**
* Search within the specified project. If a user is not a member of a project and the project is private,
* Search within the specified project. If a user is not a member of a project and the project is private,
* a request on that project will result to a 404 status code.
* a request on that project will result to a 404 status code.
...
@@ -226,9 +246,30 @@ public class SearchApi extends AbstractApi {
...
@@ -226,9 +246,30 @@ public class SearchApi extends AbstractApi {
* @since GitLab 10.5
* @since GitLab 10.5
*/
*/
public
Stream
<?>
projectSearchStream
(
Object
projectIdOrPath
,
ProjectSearchScope
scope
,
String
search
)
throws
GitLabApiException
{
public
Stream
<?>
projectSearchStream
(
Object
projectIdOrPath
,
ProjectSearchScope
scope
,
String
search
)
throws
GitLabApiException
{
return
(
projectSearch
(
projectIdOrPath
,
scope
,
search
,
getDefaultPerPage
()).
stream
());
return
(
projectSearch
(
projectIdOrPath
,
scope
,
search
,
null
,
getDefaultPerPage
()).
stream
());
}
/**
* Search within the specified project. If a user is not a member of a project and the project is private,
* a request on that project will result to a 404 status code.
*
* <pre><code>GitLab Endpoint: POST /projects/:projectId/search?scope=:scope&search=:search-query&ref=ref</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
* @param scope search the expression within the specified scope. Currently these scopes are supported:
* issues, merge_requests, milestones, notes, wiki_blobs, commits, blobs, users
* @param search the search query
* @param ref the name of a repository branch or tag to search on. The project’s default branch is used by
* default. This is only applicable for scopes: commits, blobs, and wiki_blobs.
* @return a Stream containing the object type specified by the scope
* @throws GitLabApiException if any exception occurs
* @since GitLab 10.5
*/
public
Stream
<?>
projectSearchStream
(
Object
projectIdOrPath
,
ProjectSearchScope
scope
,
String
search
,
String
ref
)
throws
GitLabApiException
{
return
(
projectSearch
(
projectIdOrPath
,
scope
,
search
,
ref
,
getDefaultPerPage
()).
stream
());
}
}
/**
/**
* Search within the specified project. If a user is not a member of a project and the project is private,
* Search within the specified project. If a user is not a member of a project and the project is private,
* a request on that project will result to a 404 status code.
* a request on that project will result to a 404 status code.
...
@@ -245,10 +286,39 @@ public class SearchApi extends AbstractApi {
...
@@ -245,10 +286,39 @@ public class SearchApi extends AbstractApi {
* @since GitLab 10.5
* @since GitLab 10.5
*/
*/
public
Pager
<?>
projectSearch
(
Object
projectIdOrPath
,
ProjectSearchScope
scope
,
String
search
,
int
itemsPerPage
)
throws
GitLabApiException
{
public
Pager
<?>
projectSearch
(
Object
projectIdOrPath
,
ProjectSearchScope
scope
,
String
search
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
projectSearch
(
projectIdOrPath
,
scope
,
search
,
null
,
itemsPerPage
);
}
/**
* Search within the specified project. If a user is not a member of a project and the project is private,
* a request on that project will result to a 404 status code.
*
* <pre><code>GitLab Endpoint: POST /project/:projectId/search?scope=:scope&search=:search-query&ref=ref</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
* @param scope search the expression within the specified scope. Currently these scopes are supported:
* issues, merge_requests, milestones, notes, wiki_blobs, commits, blobs, users
* @param search the search query
* @param ref the name of a repository branch or tag to search on. The project’s default branch is used by
* default. This is only applicable for scopes: commits, blobs, and wiki_blobs.
* @param itemsPerPage the number of items that will be fetched per page
* @return a Pager containing the object type specified by the scope
* @throws GitLabApiException if any exception occurs
* @since GitLab 10.5
*/
public
Pager
<?>
projectSearch
(
Object
projectIdOrPath
,
ProjectSearchScope
scope
,
String
search
,
String
ref
,
int
itemsPerPage
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
()
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"scope"
,
scope
,
true
)
.
withParam
(
"scope"
,
scope
,
true
)
.
withParam
(
"search"
,
search
,
true
);
.
withParam
(
"search"
,
search
,
true
)
.
withParam
(
"ref"
,
ref
,
false
);
if
(
ref
!=
null
)
{
if
(!
scope
.
equals
(
ProjectSearchScope
.
BLOBS
)
&&
!
scope
.
equals
(
ProjectSearchScope
.
WIKI_BLOBS
)
&&
!
scope
.
equals
(
ProjectSearchScope
.
COMMITS
))
{
throw
new
GitLabApiException
(
"Ref parameter is only applicable for scopes: commits, blobs, and wiki_blobs"
);
}
}
switch
(
scope
)
{
switch
(
scope
)
{
case
BLOBS:
case
BLOBS:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment