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
482588be
Commit
482588be
authored
Jan 17, 2020
by
Greg Messner
Browse files
Added getPages method that takes a withContent param (#499)
parent
d63b0aa0
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/WikisApi.java
View file @
482588be
...
@@ -28,6 +28,7 @@ import java.io.IOException;
...
@@ -28,6 +28,7 @@ import java.io.IOException;
import
java.net.URL
;
import
java.net.URL
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Optional
;
import
java.util.stream.Stream
;
import
javax.ws.rs.core.GenericType
;
import
javax.ws.rs.core.GenericType
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response
;
...
@@ -41,7 +42,6 @@ import org.gitlab4j.api.models.WikiPage;
...
@@ -41,7 +42,6 @@ import org.gitlab4j.api.models.WikiPage;
*/
*/
public
class
WikisApi
extends
AbstractApi
{
public
class
WikisApi
extends
AbstractApi
{
public
WikisApi
(
GitLabApi
gitLabApi
)
{
public
WikisApi
(
GitLabApi
gitLabApi
)
{
super
(
gitLabApi
);
super
(
gitLabApi
);
}
}
...
@@ -56,7 +56,34 @@ public class WikisApi extends AbstractApi {
...
@@ -56,7 +56,34 @@ public class WikisApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
WikiPage
>
getPages
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
public
List
<
WikiPage
>
getPages
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
return
(
getPages
(
projectIdOrPath
,
1
,
getDefaultPerPage
()));
return
(
getPages
(
projectIdOrPath
,
false
,
getDefaultPerPage
()).
all
());
}
/**
* Get a Pager of pages in project wiki.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/wikis</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param itemsPerPage the number of WikiPage instances that will be fetched per page
* @return a Pager of pages in project's wiki for the specified range
* @throws GitLabApiException if any exception occurs
*/
public
Pager
<
WikiPage
>
getPages
(
Object
projectIdOrPath
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
(
getPages
(
projectIdOrPath
,
false
,
itemsPerPage
));
}
/**
* Get a Stream of pages in project wiki.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/wikis</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @return a Pager of pages in project's wiki for the specified range
* @throws GitLabApiException if any exception occurs
*/
public
Stream
<
WikiPage
>
getPagesStream
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
return
(
getPages
(
projectIdOrPath
,
false
,
getDefaultPerPage
()).
stream
());
}
}
/**
/**
...
@@ -69,6 +96,7 @@ public class WikisApi extends AbstractApi {
...
@@ -69,6 +96,7 @@ public class WikisApi extends AbstractApi {
* @param perPage the number of wiki-pages per page
* @param perPage the number of wiki-pages per page
* @return a list of pages in project's wiki for the specified range
* @return a list of pages in project's wiki for the specified range
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
* @deprecated Will be removed in a future release, use {@link #getPages(Object, boolean, int)}
*/
*/
public
List
<
WikiPage
>
getPages
(
Object
projectIdOrPath
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
public
List
<
WikiPage
>
getPages
(
Object
projectIdOrPath
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
Response
response
=
get
(
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
...
@@ -76,6 +104,51 @@ public class WikisApi extends AbstractApi {
...
@@ -76,6 +104,51 @@ public class WikisApi extends AbstractApi {
return
response
.
readEntity
(
new
GenericType
<
List
<
WikiPage
>>()
{});
return
response
.
readEntity
(
new
GenericType
<
List
<
WikiPage
>>()
{});
}
}
/**
* Get a List of pages in project wiki.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/wikis</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param withContent if true the results will include the pages content
* @return a List of pages in project's wiki for the specified range
* @throws GitLabApiException if any exception occurs
*/
public
List
<
WikiPage
>
getPages
(
Object
projectIdOrPath
,
boolean
withContent
)
throws
GitLabApiException
{
return
(
getPages
(
projectIdOrPath
,
withContent
,
getDefaultPerPage
()).
all
());
}
/**
* Get a Pager of pages in project wiki.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/wikis</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param withContent if true the results will include the pages content
* @param itemsPerPage the number of WikiPage instances that will be fetched per page
* @return a Pager of pages in project's wiki for the specified range
* @throws GitLabApiException if any exception occurs
*/
public
Pager
<
WikiPage
>
getPages
(
Object
projectIdOrPath
,
boolean
withContent
,
int
itemsPerPage
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
().
withParam
(
"with_content"
,
(
withContent
?
1
:
0
));
return
(
new
Pager
<
WikiPage
>(
this
,
WikiPage
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"wikis"
));
}
/**
* Get a Stream of pages in project wiki.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/wikis</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param withContent if true the results will include the pages content
* @return a Stream of pages in project's wiki for the specified range
* @throws GitLabApiException if any exception occurs
*/
public
Stream
<
WikiPage
>
getPagesStream
(
Object
projectIdOrPath
,
boolean
withContent
)
throws
GitLabApiException
{
return
(
getPages
(
projectIdOrPath
,
withContent
,
getDefaultPerPage
()).
stream
());
}
/**
/**
* Get a single page of project wiki.
* Get a single page of project wiki.
*
*
...
...
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