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
f140bc20
Commit
f140bc20
authored
Dec 16, 2018
by
Greg Messner
Browse files
Added getXxxxxStream() methods that return Java 8 Streams.
parent
87991488
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/CommitsApi.java
View file @
f140bc20
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/DeployKeysApi.java
View file @
f140bc20
...
@@ -2,6 +2,7 @@ package org.gitlab4j.api;
...
@@ -2,6 +2,7 @@ package org.gitlab4j.api;
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.Form
;
import
javax.ws.rs.core.Form
;
import
javax.ws.rs.core.GenericType
;
import
javax.ws.rs.core.GenericType
;
...
@@ -20,22 +21,21 @@ public class DeployKeysApi extends AbstractApi {
...
@@ -20,22 +21,21 @@ public class DeployKeysApi extends AbstractApi {
/**
/**
* Get a list of all deploy keys across all projects of the GitLab instance. This method requires admin access.
* Get a list of all deploy keys across all projects of the GitLab instance. This method requires admin access.
* Only returns the first page.
*
*
* GET /deploy_keys
*
<pre><code>GitLab Endpoint:
GET /deploy_keys
</code></pre>
*
*
* @return a list of DeployKey
* @return a list of DeployKey
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
DeployKey
>
getDeployKeys
()
throws
GitLabApiException
{
public
List
<
DeployKey
>
getDeployKeys
()
throws
GitLabApiException
{
return
(
getDeployKeys
(
1
,
getDefaultPerPage
()));
return
(
getDeployKeys
(
getDefaultPerPage
())
.
all
()
);
}
}
/**
/**
* Get a list of all deploy keys across all projects of the GitLab instance using the specified page and per page settings.
* Get a list of all deploy keys across all projects of the GitLab instance using the specified page and per page settings.
* This method requires admin access.
* This method requires admin access.
*
*
* GET /deploy_keys
*
<pre><code>GitLab Endpoint:
GET /deploy_keys
</code></pre>
*
*
* @param page the page to get
* @param page the page to get
* @param perPage the number of deploy keys per page
* @param perPage the number of deploy keys per page
...
@@ -50,7 +50,7 @@ public class DeployKeysApi extends AbstractApi {
...
@@ -50,7 +50,7 @@ public class DeployKeysApi extends AbstractApi {
/**
/**
* Get a Pager of all deploy keys across all projects of the GitLab instance. This method requires admin access.
* Get a Pager of all deploy keys across all projects of the GitLab instance. This method requires admin access.
*
*
* GET /deploy_keys
*
<pre><code>GitLab Endpoint:
GET /deploy_keys
</code></pre>
*
*
* @param itemsPerPage the number of DeployKey instances that will be fetched per page
* @param itemsPerPage the number of DeployKey instances that will be fetched per page
* @return a Pager of DeployKey
* @return a Pager of DeployKey
...
@@ -59,98 +59,111 @@ public class DeployKeysApi extends AbstractApi {
...
@@ -59,98 +59,111 @@ public class DeployKeysApi extends AbstractApi {
public
Pager
<
DeployKey
>
getDeployKeys
(
int
itemsPerPage
)
throws
GitLabApiException
{
public
Pager
<
DeployKey
>
getDeployKeys
(
int
itemsPerPage
)
throws
GitLabApiException
{
return
(
new
Pager
<
DeployKey
>(
this
,
DeployKey
.
class
,
itemsPerPage
,
null
,
"deploy_keys"
));
return
(
new
Pager
<
DeployKey
>(
this
,
DeployKey
.
class
,
itemsPerPage
,
null
,
"deploy_keys"
));
}
}
/**
* Get a Stream of all deploy keys across all projects of the GitLab instance. This method requires admin access.
*
* <pre><code>GitLab Endpoint: GET /deploy_keys</code></pre>
*
* @return a list of DeployKey
* @throws GitLabApiException if any exception occurs
*/
public
Stream
<
DeployKey
>
getDeployKeysStream
()
throws
GitLabApiException
{
return
(
getDeployKeys
(
getDefaultPerPage
()).
stream
());
}
/**
/**
* Get a list of the deploy keys for the specified project. This method requires admin access.
* Get a list of the deploy keys for the specified project. This method requires admin access.
* Only returns the first page.
*
*
* GET /projects/:id/deploy_keys
*
<pre><code>GitLab Endpoint:
GET /projects/:id/deploy_keys
</code></pre>
*
*
* @param projectId
the ID of the project
* @param projectId
OrPath the project in the form of an Integer(ID), String(path), or Project instance
* @return a list of DeployKey
* @return a list of DeployKey
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
DeployKey
>
getProjectDeployKeys
(
Integer
projectId
)
throws
GitLabApiException
{
public
List
<
DeployKey
>
getProjectDeployKeys
(
Object
projectId
OrPath
)
throws
GitLabApiException
{
return
(
getProjectDeployKeys
(
projectId
,
1
,
getDefaultPerPage
()));
return
(
getProjectDeployKeys
(
projectId
OrPath
,
getDefaultPerPage
())
.
all
()
);
}
}
/**
/**
* Get a list of the deploy keys for the specified project using the specified page and per page settings.
* Get a list of the deploy keys for the specified project using the specified page and per page settings.
* This method requires admin access.
* This method requires admin access.
*
*
* GET /projects/:id/deploy_keys
*
<pre><code>GitLab Endpoint:
GET /projects/:id/deploy_keys
</code></pre>
*
*
* @param projectId
the ID of the project
* @param projectId
OrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param page the page to get
* @param page the page to get
* @param perPage the number of deploy keys per page
* @param perPage the number of deploy keys per page
* @return the list of DeployKey in the specified range
* @return the list of DeployKey in the specified range
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
DeployKey
>
getProjectDeployKeys
(
Integer
projectId
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
public
List
<
DeployKey
>
getProjectDeployKeys
(
Object
projectIdOrPath
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
if
(
projectId
==
null
)
{
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"deploy_keys"
);
throw
new
RuntimeException
(
"projectId cannot be null"
);
}
Response
response
=
get
(
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
"projects"
,
projectId
,
"deploy_keys"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
DeployKey
>>()
{}));
return
(
response
.
readEntity
(
new
GenericType
<
List
<
DeployKey
>>()
{}));
}
}
/**
/**
* Get a Pager of the deploy keys for the specified project. This method requires admin access.
* Get a Pager of the deploy keys for the specified project. This method requires admin access.
*
*
* GET /projects/:id/deploy_keys
*
<pre><code>GitLab Endpoint:
GET /projects/:id/deploy_keys
</code></pre>
*
*
* @param projectId the ID of the project
* @param
projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance@param
projectId the ID of the project
* @param itemsPerPage the number of DeployKey instances that will be fetched per page
* @param itemsPerPage the number of DeployKey instances that will be fetched per page
* @return a Pager of DeployKey
* @return a Pager of DeployKey
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Pager
<
DeployKey
>
getProjectDeployKeys
(
Integer
projectId
,
Integer
itemsPerPage
)
throws
GitLabApiException
{
public
Pager
<
DeployKey
>
getProjectDeployKeys
(
Object
projectIdOrPath
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
(
new
Pager
<
DeployKey
>(
this
,
DeployKey
.
class
,
itemsPerPage
,
null
,
if
(
projectId
==
null
)
{
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"deploy_keys"
));
throw
new
RuntimeException
(
"projectId cannot be null"
);
}
}
return
(
new
Pager
<
DeployKey
>(
this
,
DeployKey
.
class
,
itemsPerPage
,
null
,
"projects"
,
projectId
,
"deploy_keys"
));
/**
* Get a list of the deploy keys for the specified project. This method requires admin access.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/deploy_keys</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @return a list of DeployKey
* @throws GitLabApiException if any exception occurs
*/
public
Stream
<
DeployKey
>
getProjectDeployKeysStream
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
return
(
getProjectDeployKeys
(
projectIdOrPath
,
getDefaultPerPage
()).
stream
());
}
}
/**
/**
* Get a single deploy key for the specified project.
* Get a single deploy key for the specified project.
*
*
* GET /projects/:id/deploy_keys/:key_id
*
<pre><code>GitLab Endpoint:
GET /projects/:id/deploy_keys/:key_id
</code></pre>
*
*
* @param projectId
the ID of the project
* @param projectId
OrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param keyId the ID of the deploy key to delete
* @param keyId the ID of the deploy key to delete
* @return the DeployKey instance for the specified project ID and key ID
* @return the DeployKey instance for the specified project ID and key ID
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
DeployKey
getDeployKey
(
Integer
projectId
,
Integer
keyId
)
throws
GitLabApiException
{
public
DeployKey
getDeployKey
(
Object
projectIdOrPath
,
Integer
keyId
)
throws
GitLabApiException
{
if
(
projectId
==
null
)
{
throw
new
RuntimeException
(
"projectId cannot be null"
);
}
if
(
keyId
==
null
)
{
if
(
keyId
==
null
)
{
throw
new
RuntimeException
(
"keyId cannot be null"
);
throw
new
RuntimeException
(
"keyId cannot be null"
);
}
}
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"deploy_keys"
,
keyId
);
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"deploy_keys"
,
keyId
);
return
(
response
.
readEntity
(
DeployKey
.
class
));
return
(
response
.
readEntity
(
DeployKey
.
class
));
}
}
/**
/**
* Get a single deploy key for the specified project as an Optional instance.
* Get a single deploy key for the specified project as an Optional instance.
*
*
* GET /projects/:id/deploy_keys/:key_id
*
<pre><code>GitLab Endpoint:
GET /projects/:id/deploy_keys/:key_id
</code></pre>
*
*
* @param projectId
the ID of the project
* @param projectId
OrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param keyId the ID of the deploy key to delete
* @param keyId the ID of the deploy key to delete
* @return the DeployKey for the specified project ID and key ID as an Optional instance
* @return the DeployKey for the specified project ID and key ID as an Optional instance
*/
*/
public
Optional
<
DeployKey
>
getOptionalDeployKey
(
Integer
projectId
,
Integer
keyId
)
{
public
Optional
<
DeployKey
>
getOptionalDeployKey
(
Object
projectId
OrPath
,
Integer
keyId
)
{
try
{
try
{
return
(
Optional
.
ofNullable
(
getDeployKey
(
projectId
,
keyId
)));
return
(
Optional
.
ofNullable
(
getDeployKey
(
projectId
OrPath
,
keyId
)));
}
catch
(
GitLabApiException
glae
)
{
}
catch
(
GitLabApiException
glae
)
{
return
(
GitLabApi
.
createOptionalFromException
(
glae
));
return
(
GitLabApi
.
createOptionalFromException
(
glae
));
}
}
...
@@ -159,72 +172,62 @@ public class DeployKeysApi extends AbstractApi {
...
@@ -159,72 +172,62 @@ public class DeployKeysApi extends AbstractApi {
/**
/**
* Creates a new deploy key for a project.
* Creates a new deploy key for a project.
*
*
* POST /projects/:id/deploy_keys
*
<pre><code>GitLab Endpoint:
POST /projects/:id/deploy_keys
</code></pre>
*
*
* @param projectId
the ID of
the project
owned by the authenticated user, required
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param title the new deploy key's title, required
* @param title the new deploy key's title, required
* @param key the new deploy key, required
* @param key the new deploy key, required
* @param canPush can deploy key push to the project's repository, optional
* @param canPush can deploy key push to the project's repository, optional
* @return an DeployKey instance with info on the added deploy key
* @return an DeployKey instance with info on the added deploy key
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
DeployKey
addDeployKey
(
Integer
projectId
,
String
title
,
String
key
,
Boolean
canPush
)
throws
GitLabApiException
{
public
DeployKey
addDeployKey
(
Object
projectIdOrPath
,
String
title
,
String
key
,
Boolean
canPush
)
throws
GitLabApiException
{
if
(
projectId
==
null
)
{
throw
new
RuntimeException
(
"projectId cannot be null"
);
}
GitLabApiForm
formData
=
new
GitLabApiForm
()
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"title"
,
title
,
true
)
.
withParam
(
"title"
,
title
,
true
)
.
withParam
(
"key"
,
key
,
true
)
.
withParam
(
"key"
,
key
,
true
)
.
withParam
(
"can_push"
,
canPush
);
.
withParam
(
"can_push"
,
canPush
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
,
projectId
,
"deploy_keys"
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"deploy_keys"
);
return
(
response
.
readEntity
(
DeployKey
.
class
));
return
(
response
.
readEntity
(
DeployKey
.
class
));
}
}
/**
/**
* Removes a deploy key from the project. If the deploy key is used only for this project,it will be deleted from the system.
* Removes a deploy key from the project. If the deploy key is used only for this project,it will be deleted from the system.
*
*
* DELETE /projects/:id/deploy_keys/:key_id
*
<pre><code>GitLab Endpoint:
DELETE /projects/:id/deploy_keys/:key_id
</code></pre>
*
*
* @param projectId
the ID of the project
* @param projectId
OrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param keyId the ID of the deploy key to delete
* @param keyId the ID of the deploy key to delete
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
void
deleteDeployKey
(
Integer
projectId
,
Integer
keyId
)
throws
GitLabApiException
{
public
void
deleteDeployKey
(
Object
projectIdOrPath
,
Integer
keyId
)
throws
GitLabApiException
{
if
(
projectId
==
null
)
{
throw
new
RuntimeException
(
"projectId cannot be null"
);
}
if
(
keyId
==
null
)
{
if
(
keyId
==
null
)
{
throw
new
RuntimeException
(
"keyId cannot be null"
);
throw
new
RuntimeException
(
"keyId cannot be null"
);
}
}
delete
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"deploy_keys"
,
keyId
);
delete
(
Response
.
Status
.
OK
,
null
,
"projects"
,
getProjectIdOrPath
(
projectId
OrPath
)
,
"deploy_keys"
,
keyId
);
}
}
/**
/**
* Enables a deploy key for a project so this can be used. Returns the enabled key when successful.
* Enables a deploy key for a project so this can be used. Returns the enabled key when successful.
*
*
* POST /projects/:id/deploy_keys/:key_id/enable
*
<pre><code>GitLab Endpoint:
POST /projects/:id/deploy_keys/:key_id/enable
</code></pre>
*
*
* @param projectId
the ID of the project
* @param projectId
OrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param keyId the ID of the deploy key to enable
* @param keyId the ID of the deploy key to enable
* @return an DeployKey instance with info on the enabled deploy key
* @return an DeployKey instance with info on the enabled deploy key
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
DeployKey
enableDeployKey
(
Integer
projectId
,
Integer
keyId
)
throws
GitLabApiException
{
public
DeployKey
enableDeployKey
(
Object
projectIdOrPath
,
Integer
keyId
)
throws
GitLabApiException
{
if
(
projectId
==
null
)
{
throw
new
RuntimeException
(
"projectId cannot be null"
);
}
if
(
keyId
==
null
)
{
if
(
keyId
==
null
)
{
throw
new
RuntimeException
(
"keyId cannot be null"
);
throw
new
RuntimeException
(
"keyId cannot be null"
);
}
}
Response
response
=
post
(
Response
.
Status
.
CREATED
,
(
Form
)
null
,
"projects"
,
projectId
,
"deploy_keys"
,
keyId
,
"enable"
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
(
Form
)
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"deploy_keys"
,
keyId
,
"enable"
);
return
(
response
.
readEntity
(
DeployKey
.
class
));
return
(
response
.
readEntity
(
DeployKey
.
class
));
}
}
}
}
src/main/java/org/gitlab4j/api/EventsApi.java
View file @
f140bc20
...
@@ -2,6 +2,7 @@ package org.gitlab4j.api;
...
@@ -2,6 +2,7 @@ package org.gitlab4j.api;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
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
;
...
@@ -32,7 +33,7 @@ public class EventsApi extends AbstractApi {
...
@@ -32,7 +33,7 @@ public class EventsApi extends AbstractApi {
*/
*/
public
List
<
Event
>
getAuthenticatedUserEvents
(
ActionType
action
,
TargetType
targetType
,
public
List
<
Event
>
getAuthenticatedUserEvents
(
ActionType
action
,
TargetType
targetType
,
Date
before
,
Date
after
,
SortOrder
sortOrder
)
throws
GitLabApiException
{
Date
before
,
Date
after
,
SortOrder
sortOrder
)
throws
GitLabApiException
{
return
(
getAuthenticatedUserEvents
(
action
,
targetType
,
before
,
after
,
sortOrder
,
1
,
getDefaultPerPage
()));
return
(
getAuthenticatedUserEvents
(
action
,
targetType
,
before
,
after
,
sortOrder
,
getDefaultPerPage
())
.
all
()
);
}
}
/**
/**
...
@@ -80,7 +81,7 @@ public class EventsApi extends AbstractApi {
...
@@ -80,7 +81,7 @@ public class EventsApi extends AbstractApi {
* @return a Pager of events for the authenticated user and matching the supplied parameters
* @return a Pager of events for the authenticated user and matching the supplied parameters
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Pager
<
Event
>
getAuthenticatedUserEvents
(
ActionType
action
,
TargetType
targetType
,
Date
before
,
Date
after
,
public
Pager
<
Event
>
getAuthenticatedUserEvents
(
ActionType
action
,
TargetType
targetType
,
Date
before
,
Date
after
,
SortOrder
sortOrder
,
int
itemsPerPage
)
throws
GitLabApiException
{
SortOrder
sortOrder
,
int
itemsPerPage
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
()
GitLabApiForm
formData
=
new
GitLabApiForm
()
...
@@ -93,12 +94,30 @@ public class EventsApi extends AbstractApi {
...
@@ -93,12 +94,30 @@ public class EventsApi extends AbstractApi {
return
(
new
Pager
<
Event
>(
this
,
Event
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"events"
));
return
(
new
Pager
<
Event
>(
this
,
Event
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"events"
));
}
}
/**
* Get a Stream of events for the authenticated user.
*
* GET /events
*
* @param action include only events of a particular action type, optional
* @param targetType include only events of a particular target type, optional
* @param before include only events created before a particular date, optional
* @param after include only events created after a particular date, optional
* @param sortOrder sort events in ASC or DESC order by created_at. Default is DESC, optional
* @return a Stream of events for the authenticated user and matching the supplied parameters
* @throws GitLabApiException if any exception occurs
*/
public
Stream
<
Event
>
getAuthenticatedUserEventsStream
(
ActionType
action
,
TargetType
targetType
,
Date
before
,
Date
after
,
SortOrder
sortOrder
)
throws
GitLabApiException
{
return
(
getAuthenticatedUserEvents
(
action
,
targetType
,
before
,
after
,
sortOrder
,
getDefaultPerPage
()).
stream
());
}
/**
/**
* Get a list of events for the specified user.
* Get a list of events for the specified user.
*
*
* GET /users/:userId/events
* GET /users/:userId/events
*
*
* @param userId the user ID
to get the events for, required
* @param userId
OrUsername
the user ID
, username of the user, or a User instance holding the user ID or username
* @param action include only events of a particular action type, optional
* @param action include only events of a particular action type, optional
* @param targetType include only events of a particular target type, optional
* @param targetType include only events of a particular target type, optional
* @param before include only events created before a particular date, optional
* @param before include only events created before a particular date, optional
...
@@ -107,9 +126,9 @@ public class EventsApi extends AbstractApi {
...
@@ -107,9 +126,9 @@ public class EventsApi extends AbstractApi {
* @return a list of events for the specified user and matching the supplied parameters
* @return a list of events for the specified user and matching the supplied parameters
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
Event
>
getUserEvents
(
Integer
userId
,
ActionType
action
,
TargetType
targetType
,
public
List
<
Event
>
getUserEvents
(
Object
userIdOrUsername
,
ActionType
action
,
TargetType
targetType
,
Date
before
,
Date
after
,
SortOrder
sortOrder
)
throws
GitLabApiException
{
Date
before
,
Date
after
,
SortOrder
sortOrder
)
throws
GitLabApiException
{
return
(
getUserEvents
(
userId
,
action
,
targetType
,
before
,
after
,
sortOrder
,
1
,
getDefaultPerPage
()));
return
(
getUserEvents
(
userId
OrUsername
,
action
,
targetType
,
before
,
after
,
sortOrder
,
getDefaultPerPage
())
.
all
()
);
}
}
/**
/**
...
@@ -117,7 +136,7 @@ public class EventsApi extends AbstractApi {
...
@@ -117,7 +136,7 @@ public class EventsApi extends AbstractApi {
*
*
* GET /users/:userId/events
* GET /users/:userId/events
*
*
* @param userId the user ID
to get the events for, required
* @param userId
OrUsername
the user ID
, username of the user, or a User instance holding the user ID or username
* @param action include only events of a particular action type, optional
* @param action include only events of a particular action type, optional
* @param targetType include only events of a particular target type, optional
* @param targetType include only events of a particular target type, optional
* @param before include only events created before a particular date, optional
* @param before include only events created before a particular date, optional
...
@@ -128,12 +147,8 @@ public class EventsApi extends AbstractApi {
...
@@ -128,12 +147,8 @@ public class EventsApi extends AbstractApi {
* @return a list of events for the specified user and matching the supplied parameters
* @return a list of events for the specified user and matching the supplied parameters
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
Event
>
getUserEvents
(
Integer
userId
,
ActionType
action
,
TargetType
targetType
,
public
List
<
Event
>
getUserEvents
(
Object
userIdOrUsername
,
ActionType
action
,
TargetType
targetType
,
Date
before
,
Date
after
,
SortOrder
sortOrder
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
Date
before
,
Date
after
,
SortOrder
sortOrder
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
if
(
userId
==
null
)
{
throw
new
RuntimeException
(
"user ID cannot be null"
);
}
GitLabApiForm
formData
=
new
GitLabApiForm
()
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"action"
,
action
)
.
withParam
(
"action"
,
action
)
...
@@ -144,7 +159,8 @@ public class EventsApi extends AbstractApi {
...
@@ -144,7 +159,8 @@ public class EventsApi extends AbstractApi {
.
withParam
(
PAGE_PARAM
,
page
)
.
withParam
(
PAGE_PARAM
,
page
)
.
withParam
(
PER_PAGE_PARAM
,
perPage
);
.
withParam
(
PER_PAGE_PARAM
,
perPage
);
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"users"
,
userId
,
"events"
);
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"users"
,
getUserIdOrUsername
(
userIdOrUsername
),
"events"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Event
>>()
{}));
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Event
>>()
{}));
}
}
...
@@ -153,7 +169,7 @@ public class EventsApi extends AbstractApi {
...
@@ -153,7 +169,7 @@ public class EventsApi extends AbstractApi {
*
*
* GET /users/:userId/events
* GET /users/:userId/events
*
*
* @param userId the user ID
to get the events for, required
* @param userId
OrUsername
the user ID
, username of the user, or a User instance holding the user ID or username
* @param action include only events of a particular action type, optional
* @param action include only events of a particular action type, optional
* @param targetType include only events of a particular target type, optional
* @param targetType include only events of a particular target type, optional
* @param before include only events created before a particular date, optional
* @param before include only events created before a particular date, optional
...
@@ -163,13 +179,9 @@ public class EventsApi extends AbstractApi {
...
@@ -163,13 +179,9 @@ public class EventsApi extends AbstractApi {
* @return a Pager of events for the specified user and matching the supplied parameters
* @return a Pager of events for the specified user and matching the supplied parameters
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Pager
<
Event
>
getUserEvents
(
Integer
userId
,
ActionType
action
,
TargetType
targetType
,
Date
before
,
Date
after
,
public
Pager
<
Event
>
getUserEvents
(
Object
userIdOrUsername
,
ActionType
action
,
TargetType
targetType
,
Date
before
,
Date
after
,
SortOrder
sortOrder
,
int
itemsPerPage
)
throws
GitLabApiException
{
SortOrder
sortOrder
,
int
itemsPerPage
)
throws
GitLabApiException
{
if
(
userId
==
null
)
{
throw
new
RuntimeException
(
"user ID cannot be null"
);
}
GitLabApiForm
formData
=
new
GitLabApiForm
()
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"action"
,
action
)
.
withParam
(
"action"
,
action
)
.
withParam
(
"target_type"
,
targetType
!=
null
?
targetType
.
toValue
().
toLowerCase
()
:
null
)
.
withParam
(
"target_type"
,
targetType
!=
null
?
targetType
.
toValue
().
toLowerCase
()
:
null
)
...
@@ -177,7 +189,27 @@ public class EventsApi extends AbstractApi {
...
@@ -177,7 +189,27 @@ public class EventsApi extends AbstractApi {
.
withParam
(
"after"
,
after
)
.
withParam
(
"after"
,
after
)
.
withParam
(
"sort"
,
sortOrder
);
.
withParam
(
"sort"
,
sortOrder
);
return
(
new
Pager
<
Event
>(
this
,
Event
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"users"
,
userId
,
"events"
));
return
(
new
Pager
<
Event
>(
this
,
Event
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"users"
,
getUserIdOrUsername
(
userIdOrUsername
),
"events"
));
}
/**
* Get a Stream of events for the specified user.
*
* GET /users/:userId/events
*
* @param userIdOrUsername the user ID, username of the user, or a User instance holding the user ID or username
* @param action include only events of a particular action type, optional
* @param targetType include only events of a particular target type, optional
* @param before include only events created before a particular date, optional
* @param after include only events created after a particular date, optional
* @param sortOrder sort events in ASC or DESC order by created_at. Default is DESC, optional
* @return a Stream of events for the specified user and matching the supplied parameters
* @throws GitLabApiException if any exception occurs
*/
public
Stream
<
Event
>
getUserEventsStream
(
Object
userIdOrUsername
,
ActionType
action
,
TargetType
targetType
,
Date
before
,
Date
after
,
SortOrder
sortOrder
)
throws
GitLabApiException
{
return
(
getUserEvents
(
userIdOrUsername
,
action
,
targetType
,
before
,
after
,
sortOrder
,
getDefaultPerPage
()).
stream
());
}
}
/**
/**
...
@@ -185,7 +217,7 @@ public class EventsApi extends AbstractApi {
...
@@ -185,7 +217,7 @@ public class EventsApi extends AbstractApi {
*
*
* GET /:projectId/events
* GET /:projectId/events
*
*
* @param projectId the project
ID to get the events for, required
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param action include only events of a particular action type, optional
* @param action include only events of a particular action type, optional
* @param targetType include only events of a particular target type, optional
* @param targetType include only events of a particular target type, optional
* @param before include only events created before a particular date, optional
* @param before include only events created before a particular date, optional
...
@@ -194,9 +226,9 @@ public class EventsApi extends AbstractApi {
...
@@ -194,9 +226,9 @@ public class EventsApi extends AbstractApi {
* @return a list of events for the specified project and matching the supplied parameters
* @return a list of events for the specified project and matching the supplied parameters
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
Event
>
getProjectEvents
(
Integer
projectId
,
ActionType
action
,
TargetType
targetType
,
public
List
<
Event
>
getProjectEvents
(
Object
projectId
OrPath
,
ActionType
action
,
TargetType
targetType
,
Date
before
,
Date
after
,
SortOrder
sortOrder
)
throws
GitLabApiException
{
Date
before
,
Date
after
,
SortOrder
sortOrder
)
throws
GitLabApiException
{
return
(
getProjectEvents
(
projectId
,
action
,
targetType
,
before
,
after
,
sortOrder
,
1
,
getDefaultPerPage
()));
return
(
getProjectEvents
(
projectId
OrPath
,
action
,
targetType
,
before
,
after
,
sortOrder
,
getDefaultPerPage
())
.
all
()
);
}
}
/**
/**
...
@@ -204,7 +236,7 @@ public class EventsApi extends AbstractApi {
...
@@ -204,7 +236,7 @@ public class EventsApi extends AbstractApi {
*
*
* GET /projects/:projectId/events
* GET /projects/:projectId/events
*
*
* @param projectId the project
ID to get the events for, required
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param action include only events of a particular action type, optional
* @param action include only events of a particular action type, optional
* @param targetType include only events of a particular target type, optional
* @param targetType include only events of a particular target type, optional
* @param before include only events created before a particular date, optional
* @param before include only events created before a particular date, optional
...
@@ -215,13 +247,9 @@ public class EventsApi extends AbstractApi {
...
@@ -215,13 +247,9 @@ public class EventsApi extends AbstractApi {
* @return a list of events for the specified project and matching the supplied parameters
* @return a list of events for the specified project and matching the supplied parameters
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
Event
>
getProjectEvents
(
Integer
projectId
,
ActionType
action
,
TargetType
targetType
,
public
List
<
Event
>
getProjectEvents
(
Integer
projectId
OrPath
,
ActionType
action
,
TargetType
targetType
,
Date
before
,
Date
after
,
SortOrder
sortOrder
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
Date
before
,
Date
after
,
SortOrder
sortOrder
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
if
(
projectId
==
null
)
{
throw
new
RuntimeException
(
"project ID cannot be null"
);
}
GitLabApiForm
formData
=
new
GitLabApiForm
()
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"action"
,
action
)
.
withParam
(
"action"
,
action
)
.
withParam
(
"target_type"
,
targetType
!=
null
?
targetType
.
toValue
().
toLowerCase
()
:
null
)
.
withParam
(
"target_type"
,
targetType
!=
null
?
targetType
.
toValue
().
toLowerCase
()
:
null
)
...
@@ -231,7 +259,8 @@ public class EventsApi extends AbstractApi {
...
@@ -231,7 +259,8 @@ public class EventsApi extends AbstractApi {
.
withParam
(
PAGE_PARAM
,
page
)
.
withParam
(
PAGE_PARAM
,
page
)
.
withParam
(
PER_PAGE_PARAM
,
perPage
);
.
withParam
(
PER_PAGE_PARAM
,
perPage
);
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
projectId
,
"events"
);
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"events"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Event
>>()
{}));
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Event
>>()
{}));
}
}
...
@@ -240,7 +269,7 @@ public class EventsApi extends AbstractApi {
...
@@ -240,7 +269,7 @@ public class EventsApi extends AbstractApi {
*
*
* GET /projects/:projectId/events
* GET /projects/:projectId/events
*
*
* @param projectId the project
ID to get the events for, required
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param action include only events of a particular action type, optional
* @param action include only events of a particular action type, optional
* @param targetType include only events of a particular target type, optional
* @param targetType include only events of a particular target type, optional
* @param before include only events created before a particular date, optional
* @param before include only events created before a particular date, optional
...
@@ -250,13 +279,9 @@ public class EventsApi extends AbstractApi {
...
@@ -250,13 +279,9 @@ public class EventsApi extends AbstractApi {
* @return a Pager of events for the specified project and matching the supplied parameters
* @return a Pager of events for the specified project and matching the supplied parameters
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Pager
<
Event
>
getProjectEvents
(
Integer
projectId
,
ActionType
action
,
TargetType
targetType
,
Date
before
,
Date
after
,
public
Pager
<
Event
>
getProjectEvents
(
Object
projectId
OrPath
,
ActionType
action
,
TargetType
targetType
,
Date
before
,
Date
after
,
SortOrder
sortOrder
,
int
itemsPerPage
)
throws
GitLabApiException
{
SortOrder
sortOrder
,
int
itemsPerPage
)
throws
GitLabApiException
{
if
(
projectId
==
null
)
{
throw
new
RuntimeException
(
"project ID cannot be null"
);
}
GitLabApiForm
formData
=
new
GitLabApiForm
()
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"action"
,
action
)
.
withParam
(
"action"
,
action
)
.
withParam
(
"target_type"
,
targetType
!=
null
?
targetType
.
toValue
().
toLowerCase
()
:
null
)
.
withParam
(
"target_type"
,
targetType
!=
null
?
targetType
.
toValue
().
toLowerCase
()
:
null
)
...
@@ -264,6 +289,26 @@ public class EventsApi extends AbstractApi {
...
@@ -264,6 +289,26 @@ public class EventsApi extends AbstractApi {
.
withParam
(
"after"
,
after
)
.
withParam
(
"after"
,
after
)
.
withParam
(
"sort"
,
sortOrder
);
.
withParam
(
"sort"
,
sortOrder
);
return
(
new
Pager
<
Event
>(
this
,
Event
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"projects"
,
projectId
,
"events"
));
return
(
new
Pager
<
Event
>(
this
,
Event
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"events"
));
}
/**
* Get a Stream of events for the specified project.
*
* GET /:projectId/events
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param action include only events of a particular action type, optional
* @param targetType include only events of a particular target type, optional
* @param before include only events created before a particular date, optional
* @param after include only events created after a particular date, optional
* @param sortOrder sort events in ASC or DESC order by created_at. Default is DESC, optional
* @return a Stream of events for the specified project and matching the supplied parameters
* @throws GitLabApiException if any exception occurs
*/
public
Stream
<
Event
>
getProjectEventsStream
(
Object
projectIdOrPath
,
ActionType
action
,
TargetType
targetType
,
Date
before
,
Date
after
,
SortOrder
sortOrder
)
throws
GitLabApiException
{
return
(
getProjectEvents
(
projectIdOrPath
,
action
,
targetType
,
before
,
after
,
sortOrder
,
getDefaultPerPage
()).
stream
());
}
}
}
}
src/main/java/org/gitlab4j/api/JobApi.java
View file @
f140bc20
...
@@ -8,6 +8,7 @@ import java.nio.file.Path;
...
@@ -8,6 +8,7 @@ import java.nio.file.Path;
import
java.nio.file.StandardCopyOption
;
import
java.nio.file.StandardCopyOption
;
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.Form
;
import
javax.ws.rs.core.Form
;
import
javax.ws.rs.core.GenericType
;
import
javax.ws.rs.core.GenericType
;
...
@@ -30,23 +31,20 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -30,23 +31,20 @@ public class JobApi extends AbstractApi implements Constants {
/**
/**
* Get a list of jobs in a project.
* Get a list of jobs in a project.
*
*
* GET /projects/:id/jobs
*
<pre><code>GitLab Endpoint:
GET /projects/:id/jobs
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @return a list containing the jobs for the specified project ID
* @return a list containing the jobs for the specified project ID
* @throws GitLabApiException if any exception occurs during execution
* @throws GitLabApiException if any exception occurs during execution
*/
*/
public
List
<
Job
>
getJobs
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
public
List
<
Job
>
getJobs
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
getDefaultPerPageParam
(),
return
(
getJobs
(
projectIdOrPath
,
getDefaultPerPage
()).
all
());
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"jobs"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Job
>>()
{
}));
}
}
/**
/**
* Get a list of jobs in a project in the specified page range.
* Get a list of jobs in a project in the specified page range.
*
*
* GET /projects/:id/jobs
*
<pre><code>GitLab Endpoint:
GET /projects/:id/jobs
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the jobs for
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the jobs for
* @param page the page to get
* @param page the page to get
...
@@ -56,14 +54,13 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -56,14 +54,13 @@ public class JobApi extends AbstractApi implements Constants {
*/
*/
public
List
<
Job
>
getJobs
(
Object
projectIdOrPath
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
public
List
<
Job
>
getJobs
(
Object
projectIdOrPath
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"jobs"
);
Response
response
=
get
(
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"jobs"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Job
>>()
{
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Job
>>()
{}));
}));
}
}
/**
/**
* Get a Pager of jobs in a project.
* Get a Pager of jobs in a project.
*
*
* GET /projects/:id/jobs
*
<pre><code>GitLab Endpoint:
GET /projects/:id/jobs
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the jobs for
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the jobs for
* @param itemsPerPage the number of Job instances that will be fetched per page
* @param itemsPerPage the number of Job instances that will be fetched per page
...
@@ -74,10 +71,23 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -74,10 +71,23 @@ public class JobApi extends AbstractApi implements Constants {
return
(
new
Pager
<
Job
>(
this
,
Job
.
class
,
itemsPerPage
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"jobs"
));
return
(
new
Pager
<
Job
>(
this
,
Job
.
class
,
itemsPerPage
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"jobs"
));
}
}
/**
* Get a Stream of jobs in a project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/jobs</code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @return a Stream containing the jobs for the specified project ID
* @throws GitLabApiException if any exception occurs during execution
*/
public
Stream
<
Job
>
getJobsStream
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
return
(
getJobs
(
projectIdOrPath
,
getDefaultPerPage
()).
stream
());
}
/**
/**
* Get a list of jobs in a project.
* Get a list of jobs in a project.
*
*
* GET /projects/:id/jobs
*
<pre><code>GitLab Endpoint:
GET /projects/:id/jobs
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the jobs for
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the jobs for
* @param scope the scope of jobs, one of: CREATED, PENDING, RUNNING, FAILED, SUCCESS, CANCELED, SKIPPED, MANUAL
* @param scope the scope of jobs, one of: CREATED, PENDING, RUNNING, FAILED, SUCCESS, CANCELED, SKIPPED, MANUAL
...
@@ -85,15 +95,44 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -85,15 +95,44 @@ public class JobApi extends AbstractApi implements Constants {
* @throws GitLabApiException if any exception occurs during execution
* @throws GitLabApiException if any exception occurs during execution
*/
*/
public
List
<
Job
>
getJobs
(
Object
projectIdOrPath
,
JobScope
scope
)
throws
GitLabApiException
{
public
List
<
Job
>
getJobs
(
Object
projectIdOrPath
,
JobScope
scope
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
().
withParam
(
"scope"
,
scope
).
withParam
(
PER_PAGE_PARAM
,
getDefaultPerPage
());
return
(
getJobs
(
projectIdOrPath
,
scope
,
getDefaultPerPage
()).
all
());
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"jobs"
);
}
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Job
>>()
{}));
/**
* Get a list of jobs in a project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/jobs</code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the jobs for
* @param scope the scope of jobs, one of: CREATED, PENDING, RUNNING, FAILED, SUCCESS, CANCELED, SKIPPED, MANUAL
* @param itemsPerPage the number of Job instances that will be fetched per page
* @return a list containing the jobs for the specified project ID
* @throws GitLabApiException if any exception occurs during execution
*/
public
Pager
<
Job
>
getJobs
(
Object
projectIdOrPath
,
JobScope
scope
,
int
itemsPerPage
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
().
withParam
(
"scope"
,
scope
);
return
(
new
Pager
<
Job
>(
this
,
Job
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"jobs"
));
}
/**
* Get a Stream of jobs in a project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/jobs</code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the jobs for
* @param scope the scope of jobs, one of: CREATED, PENDING, RUNNING, FAILED, SUCCESS, CANCELED, SKIPPED, MANUAL
* @return a Stream containing the jobs for the specified project ID
* @throws GitLabApiException if any exception occurs during execution
*/
public
Stream
<
Job
>
getJobsStream
(
Object
projectIdOrPath
,
JobScope
scope
)
throws
GitLabApiException
{
return
(
getJobs
(
projectIdOrPath
,
scope
,
getDefaultPerPage
()).
stream
());
}
}
/**
/**
* Get a list of jobs in a pipeline.
* Get a list of jobs in a pipeline.
*
*
* GET /projects/:id/pipelines/:pipeline_id/jobs
*
<pre><code>GitLab Endpoint:
GET /projects/:id/pipelines/:pipeline_id/jobs
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the pipelines for
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the pipelines for
* @param pipelineId the pipeline ID to get the list of jobs for
* @param pipelineId the pipeline ID to get the list of jobs for
...
@@ -109,7 +148,7 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -109,7 +148,7 @@ public class JobApi extends AbstractApi implements Constants {
/**
/**
* Get a list of jobs in a pipeline.
* Get a list of jobs in a pipeline.
*
*
* GET /projects/:id/pipelines/:pipeline_id/jobs
*
<pre><code>GitLab Endpoint:
GET /projects/:id/pipelines/:pipeline_id/jobs
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the pipelines for
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the pipelines for
* @param pipelineId the pipeline ID to get the list of jobs for
* @param pipelineId the pipeline ID to get the list of jobs for
...
@@ -126,7 +165,7 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -126,7 +165,7 @@ public class JobApi extends AbstractApi implements Constants {
/**
/**
* Get single job in a project.
* Get single job in a project.
*
*
* GET /projects/:id/jobs/:job_id
*
<pre><code>GitLab Endpoint:
GET /projects/:id/jobs/:job_id
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the job for
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the job for
* @param jobId the job ID to get
* @param jobId the job ID to get
...
@@ -141,7 +180,7 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -141,7 +180,7 @@ public class JobApi extends AbstractApi implements Constants {
/**
/**
* Get single job in a project as an Optional instance.
* Get single job in a project as an Optional instance.
*
*
* GET /projects/:id/jobs/:job_id
*
<pre><code>GitLab Endpoint:
GET /projects/:id/jobs/:job_id
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the job for
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the job for
* @param jobId the job ID to get
* @param jobId the job ID to get
...
@@ -160,7 +199,7 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -160,7 +199,7 @@ public class JobApi extends AbstractApi implements Constants {
* The file will be saved to the specified directory. If the file already exists in the directory it will
* The file will be saved to the specified directory. If the file already exists in the directory it will
* be overwritten.
* be overwritten.
*
*
* GET /projects/:id/jobs/artifacts/:ref_name/download?job=name
*
<pre><code>GitLab Endpoint:
GET /projects/:id/jobs/artifacts/:ref_name/download?job=name
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param ref the ref from a repository
* @param ref the ref from a repository
...
@@ -197,7 +236,7 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -197,7 +236,7 @@ public class JobApi extends AbstractApi implements Constants {
* provided the job finished successfully. The file will be saved to the specified directory.
* provided the job finished successfully. The file will be saved to the specified directory.
* If the file already exists in the directory it will be overwritten.
* If the file already exists in the directory it will be overwritten.
*
*
* GET /projects/:id/jobs/artifacts/:ref_name/download?job=name
*
<pre><code>GitLab Endpoint:
GET /projects/:id/jobs/artifacts/:ref_name/download?job=name
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param ref the ref from a repository
* @param ref the ref from a repository
...
@@ -217,7 +256,7 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -217,7 +256,7 @@ public class JobApi extends AbstractApi implements Constants {
* specified directory with the following name pattern: job-{jobid}-artifacts.zip. If the file already
* specified directory with the following name pattern: job-{jobid}-artifacts.zip. If the file already
* exists in the directory it will be overwritten.
* exists in the directory it will be overwritten.
*
*
* GET /projects/:id/jobs/:job_id/artifacts
*
<pre><code>GitLab Endpoint:
GET /projects/:id/jobs/:job_id/artifacts
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param jobId the job ID to get the artifacts for
* @param jobId the job ID to get the artifacts for
...
@@ -249,7 +288,7 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -249,7 +288,7 @@ public class JobApi extends AbstractApi implements Constants {
/**
/**
* Get an InputStream pointing to the job artifacts file for the specified job ID.
* Get an InputStream pointing to the job artifacts file for the specified job ID.
*
*
* GET /projects/:id/jobs/:job_id/artifacts
*
<pre><code>GitLab Endpoint:
GET /projects/:id/jobs/:job_id/artifacts
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param jobId the job ID to get the artifacts for
* @param jobId the job ID to get the artifacts for
...
@@ -267,7 +306,7 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -267,7 +306,7 @@ public class JobApi extends AbstractApi implements Constants {
*
*
* Only a single file is going to be extracted from the archive and streamed to a client.
* Only a single file is going to be extracted from the archive and streamed to a client.
*
*
* GET /projects/:id/jobs/:job_id/artifacts/*artifact_path
*
<pre><code>GitLab Endpoint:
GET /projects/:id/jobs/:job_id/artifacts/*artifact_path
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param jobId the unique job identifier
* @param jobId the unique job identifier
...
@@ -302,7 +341,7 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -302,7 +341,7 @@ public class JobApi extends AbstractApi implements Constants {
*
*
* Only a single file is going to be extracted from the archive and streamed to a client.
* Only a single file is going to be extracted from the archive and streamed to a client.
*
*
* GET /projects/:id/jobs/:job_id/artifacts/*artifact_path
*
<pre><code>GitLab Endpoint:
GET /projects/:id/jobs/:job_id/artifacts/*artifact_path
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param jobId the unique job identifier
* @param jobId the unique job identifier
...
@@ -321,7 +360,7 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -321,7 +360,7 @@ public class JobApi extends AbstractApi implements Constants {
*
*
* Only a single file is going to be extracted from the archive and streamed to a client.
* Only a single file is going to be extracted from the archive and streamed to a client.
*
*
* GET /projects/:id/jobs/:job_id/artifacts/*artifact_path
*
<pre><code>GitLab Endpoint:
GET /projects/:id/jobs/:job_id/artifacts/*artifact_path
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param jobId the unique job identifier
* @param jobId the unique job identifier
...
@@ -357,7 +396,7 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -357,7 +396,7 @@ public class JobApi extends AbstractApi implements Constants {
*
*
* Only a single file is going to be extracted from the archive and streamed to a client.
* Only a single file is going to be extracted from the archive and streamed to a client.
*
*
* GET /projects/:id/jobs/:job_id/artifacts/*artifact_path
*
<pre><code>GitLab Endpoint:
GET /projects/:id/jobs/:job_id/artifacts/*artifact_path
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param jobId the unique job identifier
* @param jobId the unique job identifier
...
@@ -375,7 +414,7 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -375,7 +414,7 @@ public class JobApi extends AbstractApi implements Constants {
/**
/**
* Get a trace of a specific job of a project
* Get a trace of a specific job of a project
*
*
* GET /projects/:id/jobs/:id/trace
*
<pre><code>GitLab Endpoint:
GET /projects/:id/jobs/:id/trace
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* to get the specified job's trace for
* to get the specified job's trace for
...
@@ -392,7 +431,7 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -392,7 +431,7 @@ public class JobApi extends AbstractApi implements Constants {
/**
/**
* Cancel specified job in a project.
* Cancel specified job in a project.
*
*
* POST /projects/:id/jobs/:job_id/cancel
*
<pre><code>GitLab Endpoint:
POST /projects/:id/jobs/:job_id/cancel
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param jobId the ID to cancel job
* @param jobId the ID to cancel job
...
@@ -408,7 +447,7 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -408,7 +447,7 @@ public class JobApi extends AbstractApi implements Constants {
/**
/**
* Retry specified job in a project.
* Retry specified job in a project.
*
*
* POST /projects/:id/jobs/:job_id/retry
*
<pre><code>GitLab Endpoint:
POST /projects/:id/jobs/:job_id/retry
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param jobId the ID to retry job
* @param jobId the ID to retry job
...
@@ -424,7 +463,7 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -424,7 +463,7 @@ public class JobApi extends AbstractApi implements Constants {
/**
/**
* Erase specified job in a project.
* Erase specified job in a project.
*
*
* POST /projects/:id/jobs/:job_id/erase
*
<pre><code>GitLab Endpoint:
POST /projects/:id/jobs/:job_id/erase
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param jobId the ID to erase job
* @param jobId the ID to erase job
...
@@ -440,7 +479,7 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -440,7 +479,7 @@ public class JobApi extends AbstractApi implements Constants {
/**
/**
* Play specified job in a project.
* Play specified job in a project.
*
*
* POST /projects/:id/jobs/:job_id/play
*
<pre><code>GitLab Endpoint:
POST /projects/:id/jobs/:job_id/play
</code></pre>
*
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param jobId the ID to play job
* @param jobId the ID to play job
...
...
src/main/java/org/gitlab4j/api/LabelsApi.java
View file @
f140bc20
...
@@ -14,80 +14,89 @@ public class LabelsApi extends AbstractApi {
...
@@ -14,80 +14,89 @@ public class LabelsApi extends AbstractApi {
}
}
/**
/**
* Get all labels of the specified project.
Only returns the first page
* Get all labels of the specified project.
*
*
* @param projectId the project
ID to get the labels for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @return a list of project's labels
* @return a list of project's labels
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
Label
>
getLabels
(
Integer
projectId
)
throws
GitLabApiException
{
public
List
<
Label
>
getLabels
(
Object
projectId
OrPath
)
throws
GitLabApiException
{
return
(
getLabels
(
projectId
,
1
,
getDefaultPerPage
()));
return
(
getLabels
(
projectId
OrPath
,
getDefaultPerPage
())
.
all
()
);
}
}
/**
/**
* Get all labels of the specified project to using the specified page and per page setting
* Get all labels of the specified project to using the specified page and per page setting
*
*
* @param projectId the project
ID to get the labels for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param page
the page to get
* @param page the page to get
* @param perPage
the number of i
ssue
s per page
* @param perPage the number of i
tem
s per page
* @return a list of project's labels in the specified range
* @return a list of project's labels in the specified range
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
Label
>
getLabels
(
Integer
projectId
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
public
List
<
Label
>
getLabels
(
Object
projectIdOrPath
,
int
page
,
int
perPage
)
throws
GitLabApiException
{
Response
response
=
get
(
javax
.
ws
.
rs
.
core
.
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
if
(
projectId
==
null
)
{
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"labels"
);
throw
new
RuntimeException
(
"projectId cannot be null"
);
}
Response
response
=
get
(
javax
.
ws
.
rs
.
core
.
Response
.
Status
.
OK
,
getPageQueryParams
(
page
,
perPage
),
"projects"
,
projectId
,
"labels"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Label
>>()
{}));
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Label
>>()
{}));
}
}
/**
* Get a Pager of all labels of the specified project.
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param itemsPerPage the number of items per page
* @return a list of project's labels in the specified range
* @throws GitLabApiException if any exception occurs
*/
public
Pager
<
Label
>
getLabels
(
Object
projectIdOrPath
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
(
new
Pager
<
Label
>(
this
,
Label
.
class
,
itemsPerPage
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"labels"
));
}
/**
/**
* Create a label
* Create a label
*
*
* @param projectId
the project
ID to create a label for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param name the name for the label
* @param name the name for the label
* @param color the color for the label
* @param color the color for the label
* @param description the description for the label
* @param description the description for the label
* @return the created Label instance
* @return the created Label instance
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Label
createLabel
(
Integer
projectId
,
String
name
,
String
color
,
String
description
)
throws
GitLabApiException
{
public
Label
createLabel
(
Object
projectId
OrPath
,
String
name
,
String
color
,
String
description
)
throws
GitLabApiException
{
return
(
createLabel
(
projectId
,
name
,
color
,
description
,
null
));
return
(
createLabel
(
projectId
OrPath
,
name
,
color
,
description
,
null
));
}
}
/**
/**
* Create a label
* Create a label
*
*
* @param projectId the project
ID to create a label for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param name
the name for the label
* @param name the name for the label
* @param color
the color for the label
* @param color the color for the label
* @return the created Label instance
* @return the created Label instance
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Label
createLabel
(
Integer
projectId
,
String
name
,
String
color
)
throws
GitLabApiException
{
public
Label
createLabel
(
Object
projectId
OrPath
,
String
name
,
String
color
)
throws
GitLabApiException
{
return
(
createLabel
(
projectId
,
name
,
color
,
null
,
null
));
return
(
createLabel
(
projectId
OrPath
,
name
,
color
,
null
,
null
));
}
}
/**
/**
* Create a label
* Create a label
*
*
* @param projectId the project
ID to create a label for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param name
the name for the label
* @param name the name for the label
* @param color
the color for the label
* @param color the color for the label
* @param priority
the priority for the label
* @param priority the priority for the label
* @return the created Label instance
* @return the created Label instance
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Label
createLabel
(
Integer
projectId
,
String
name
,
String
color
,
Integer
priority
)
throws
GitLabApiException
{
public
Label
createLabel
(
Object
projectId
OrPath
,
String
name
,
String
color
,
Integer
priority
)
throws
GitLabApiException
{
return
(
createLabel
(
projectId
,
name
,
color
,
null
,
priority
));
return
(
createLabel
(
projectId
OrPath
,
name
,
color
,
null
,
priority
));
}
}
/**
/**
* Create a label
* Create a label
*
*
* @param projectId the project
ID to create a label for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param name the name for the label
* @param name the name for the label
* @param color the color for the label
* @param color the color for the label
* @param description the description for the label
* @param description the description for the label
...
@@ -95,18 +104,14 @@ public class LabelsApi extends AbstractApi {
...
@@ -95,18 +104,14 @@ public class LabelsApi extends AbstractApi {
* @return the created Label instance
* @return the created Label instance
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Label
createLabel
(
Integer
projectId
,
String
name
,
String
color
,
String
description
,
Integer
priority
)
throws
GitLabApiException
{
public
Label
createLabel
(
Object
projectIdOrPath
,
String
name
,
String
color
,
String
description
,
Integer
priority
)
throws
GitLabApiException
{
if
(
projectId
==
null
)
{
throw
new
RuntimeException
(
"projectId cannot be null"
);
}
GitLabApiForm
formData
=
new
GitLabApiForm
()
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"name"
,
name
,
true
)
.
withParam
(
"name"
,
name
,
true
)
.
withParam
(
"color"
,
color
,
true
)
.
withParam
(
"color"
,
color
,
true
)
.
withParam
(
"description"
,
description
)
.
withParam
(
"description"
,
description
)
.
withParam
(
"priority"
,
priority
);
.
withParam
(
"priority"
,
priority
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
,
projectId
,
"labels"
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
,
getProjectIdOrPath
(
projectId
OrPath
)
,
"labels"
);
return
(
response
.
readEntity
(
Label
.
class
));
return
(
response
.
readEntity
(
Label
.
class
));
}
}
...
@@ -114,7 +119,7 @@ public class LabelsApi extends AbstractApi {
...
@@ -114,7 +119,7 @@ public class LabelsApi extends AbstractApi {
/**
/**
* Update the specified label
* Update the specified label
*
*
* @param projectId the project
ID to update a label for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param name the name for the label
* @param name the name for the label
* @param newName the new name for the label
* @param newName the new name for the label
* @param description the description for the label
* @param description the description for the label
...
@@ -122,15 +127,15 @@ public class LabelsApi extends AbstractApi {
...
@@ -122,15 +127,15 @@ public class LabelsApi extends AbstractApi {
* @return the modified Label instance
* @return the modified Label instance
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Label
updateLabelName
(
Integer
projectId
,
String
name
,
String
newName
,
String
description
,
Integer
priority
)
throws
GitLabApiException
{
public
Label
updateLabelName
(
Object
projectId
OrPath
,
String
name
,
String
newName
,
String
description
,
Integer
priority
)
throws
GitLabApiException
{
return
(
updateLabel
(
projectId
,
name
,
newName
,
null
,
description
,
priority
));
return
(
updateLabel
(
projectId
OrPath
,
name
,
newName
,
null
,
description
,
priority
));
}
}
/**
/**
* Update the specified label
* Update the specified label
*
*
* @param projectId the project
ID to update a label for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param name the name for the label
* @param name the name for the label
* @param color the color for the label
* @param color the color for the label
* @param description the description for the label
* @param description the description for the label
...
@@ -138,14 +143,14 @@ public class LabelsApi extends AbstractApi {
...
@@ -138,14 +143,14 @@ public class LabelsApi extends AbstractApi {
* @return the modified Label instance
* @return the modified Label instance
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Label
updateLabelColor
(
Integer
projectId
,
String
name
,
String
color
,
String
description
,
Integer
priority
)
throws
GitLabApiException
{
public
Label
updateLabelColor
(
Object
projectId
OrPath
,
String
name
,
String
color
,
String
description
,
Integer
priority
)
throws
GitLabApiException
{
return
(
updateLabel
(
projectId
,
name
,
null
,
color
,
description
,
priority
));
return
(
updateLabel
(
projectId
OrPath
,
name
,
null
,
color
,
description
,
priority
));
}
}
/**
/**
* Update the specified label
* Update the specified label
*
*
* @param projectId the project
ID to update a label for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param name the name for the label
* @param name the name for the label
* @param newName the new name for the label
* @param newName the new name for the label
* @param color the color for the label
* @param color the color for the label
...
@@ -154,11 +159,7 @@ public class LabelsApi extends AbstractApi {
...
@@ -154,11 +159,7 @@ public class LabelsApi extends AbstractApi {
* @return the modified Label instance
* @return the modified Label instance
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Label
updateLabel
(
Integer
projectId
,
String
name
,
String
newName
,
String
color
,
String
description
,
Integer
priority
)
throws
GitLabApiException
{
public
Label
updateLabel
(
Object
projectIdOrPath
,
String
name
,
String
newName
,
String
color
,
String
description
,
Integer
priority
)
throws
GitLabApiException
{
if
(
projectId
==
null
)
{
throw
new
RuntimeException
(
"projectId cannot be null"
);
}
GitLabApiForm
formData
=
new
GitLabApiForm
()
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"name"
,
name
,
true
)
.
withParam
(
"name"
,
name
,
true
)
...
@@ -166,53 +167,50 @@ public class LabelsApi extends AbstractApi {
...
@@ -166,53 +167,50 @@ public class LabelsApi extends AbstractApi {
.
withParam
(
"color"
,
color
)
.
withParam
(
"color"
,
color
)
.
withParam
(
"description"
,
description
)
.
withParam
(
"description"
,
description
)
.
withParam
(
"priority"
,
priority
);
.
withParam
(
"priority"
,
priority
);
Response
response
=
put
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
projectId
,
"labels"
);
Response
response
=
put
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"labels"
);
return
(
response
.
readEntity
(
Label
.
class
));
return
(
response
.
readEntity
(
Label
.
class
));
}
}
/**
/**
* Delete the specified label
* Delete the specified label
*
*
* @param projectId the project
ID to delete a label for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param name the name for the label
* @param name the name for the label
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
void
deleteLabel
(
Integer
projectId
,
String
name
)
throws
GitLabApiException
{
public
void
deleteLabel
(
Object
projectIdOrPath
,
String
name
)
throws
GitLabApiException
{
if
(
projectId
==
null
)
{
throw
new
RuntimeException
(
"projectId cannot be null"
);
}
GitLabApiForm
formData
=
new
GitLabApiForm
()
GitLabApiForm
formData
=
new
GitLabApiForm
().
withParam
(
"name"
,
name
,
true
);
.
withParam
(
"name"
,
name
,
true
);
Response
.
Status
expectedStatus
=
(
isApiVersion
(
GitLabApi
.
ApiVersion
.
V3
)
?
Response
.
Status
.
OK
:
Response
.
Status
.
NO_CONTENT
);
Response
.
Status
expectedStatus
=
(
isApiVersion
(
GitLabApi
.
ApiVersion
.
V3
)
?
Response
.
Status
.
OK
:
Response
.
Status
.
NO_CONTENT
);
delete
(
expectedStatus
,
formData
.
asMap
(),
"projects"
,
projectId
,
"labels"
);
delete
(
expectedStatus
,
formData
.
asMap
(),
"projects"
,
getProjectIdOrPath
(
projectId
OrPath
)
,
"labels"
);
}
}
/**
/**
* Subscribe a specified label
* Subscribe a specified label
*
*
* @param projectId the project
ID to subscribe a label for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param labelId the lab
l
e ID
* @param labelId the labe
l
ID
* @return HttpStatusCode 503
* @return HttpStatusCode 503
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Label
subscribeLabel
(
Integer
projectId
,
Integer
labelId
)
throws
GitLabApiException
{
public
Label
subscribeLabel
(
Object
projectIdOrPath
,
Integer
labelId
)
throws
GitLabApiException
{
Response
response
=
post
(
Response
.
Status
.
NOT_MODIFIED
,
getDefaultPerPageParam
(),
"projects"
,
projectId
,
"labels"
,
labelId
,
"subscribe"
);
Response
response
=
post
(
Response
.
Status
.
NOT_MODIFIED
,
getDefaultPerPageParam
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"labels"
,
labelId
,
"subscribe"
);
return
(
response
.
readEntity
(
Label
.
class
));
return
(
response
.
readEntity
(
Label
.
class
));
}
}
/**
/**
* Unsubscribe a specified label
* Unsubscribe a specified label
*
*
* @param projectId the project
ID to unsubscribe a label for
* @param projectId
OrPath
the project
in the form of an Integer(ID), String(path), or Project instance
* @param labelId the lab
l
e ID
* @param labelId the labe
l
ID
* @return HttpStatusCode 503
* @return HttpStatusCode 503
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
Label
unsubscribeLabel
(
Integer
projectId
,
Integer
labelId
)
throws
GitLabApiException
{
public
Label
unsubscribeLabel
(
Object
projectIdOrPath
,
Integer
labelId
)
throws
GitLabApiException
{
Response
response
=
post
(
Response
.
Status
.
NOT_MODIFIED
,
getDefaultPerPageParam
(),
"projects"
,
projectId
,
"labels"
,
labelId
,
"unsubscribe"
);
Response
response
=
post
(
Response
.
Status
.
NOT_MODIFIED
,
getDefaultPerPageParam
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"labels"
,
labelId
,
"unsubscribe"
);
return
(
response
.
readEntity
(
Label
.
class
));
return
(
response
.
readEntity
(
Label
.
class
));
}
}
}
}
src/main/java/org/gitlab4j/api/MergeRequestApi.java
View file @
f140bc20
This diff is collapsed.
Click to expand it.
src/main/java/org/gitlab4j/api/NamespaceApi.java
View file @
f140bc20
package
org.gitlab4j.api
;
package
org.gitlab4j.api
;
import
java.util.List
;
import
java.util.List
;
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
;
...
@@ -20,21 +21,20 @@ public class NamespaceApi extends AbstractApi {
...
@@ -20,21 +21,20 @@ public class NamespaceApi extends AbstractApi {
* Get a list of the namespaces of the authenticated user. If the user is an administrator,
* Get a list of the namespaces of the authenticated user. If the user is an administrator,
* a list of all namespaces in the GitLab instance is created.
* a list of all namespaces in the GitLab instance is created.
*
*
* GET /namespaces
*
<pre><code>GitLab Endpoint:
GET /namespaces
</code></pre>
*
*
* @return a List of Namespace instances
* @return a List of Namespace instances
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
Namespace
>
getNamespaces
()
throws
GitLabApiException
{
public
List
<
Namespace
>
getNamespaces
()
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
getDefaultPerPageParam
(),
"namespaces"
);
return
(
getNamespaces
(
getDefaultPerPage
()).
all
());
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Namespace
>>()
{}));
}
}
/**
/**
* Get a list of the namespaces of the authenticated user. If the user is an administrator,
* Get a list of the namespaces of the authenticated user. If the user is an administrator,
* a list of all namespaces in the GitLab instance is
c
re
a
ted.
* a list of all namespaces in the GitLab instance is ret
urn
ed.
*
*
* GET /namespaces
*
<pre><code>GitLab Endpoint:
GET /namespaces
</code></pre>
*
*
* @param page the page to get
* @param page the page to get
* @param perPage the number of Namespace instances per page
* @param perPage the number of Namespace instances per page
...
@@ -48,9 +48,9 @@ public class NamespaceApi extends AbstractApi {
...
@@ -48,9 +48,9 @@ public class NamespaceApi extends AbstractApi {
/**
/**
* Get a Pager of the namespaces of the authenticated user. If the user is an administrator,
* Get a Pager of the namespaces of the authenticated user. If the user is an administrator,
* a Pager of all namespaces in the GitLab instance is
c
re
a
ted.
* a Pager of all namespaces in the GitLab instance is ret
urn
ed.
*
*
* GET /namespaces
*
<pre><code>GitLab Endpoint:
GET /namespaces
</code></pre>
*
*
* @param itemsPerPage the number of Project instances that will be fetched per page
* @param itemsPerPage the number of Project instances that will be fetched per page
* @return a Pager of Namespace instances
* @return a Pager of Namespace instances
...
@@ -60,25 +60,36 @@ public class NamespaceApi extends AbstractApi {
...
@@ -60,25 +60,36 @@ public class NamespaceApi extends AbstractApi {
return
(
new
Pager
<
Namespace
>(
this
,
Namespace
.
class
,
itemsPerPage
,
null
,
"namespaces"
));
return
(
new
Pager
<
Namespace
>(
this
,
Namespace
.
class
,
itemsPerPage
,
null
,
"namespaces"
));
}
}
/**
* Get a Stream of the namespaces of the authenticated user. If the user is an administrator,
* a Stream of all namespaces in the GitLab instance is returned.
*
* <pre><code>GitLab Endpoint: GET /namespaces</code></pre>
*
* @return a Stream of Namespace instances
* @throws GitLabApiException if any exception occurs
*/
public
Stream
<
Namespace
>
getNamespacesStream
()
throws
GitLabApiException
{
return
(
getNamespaces
(
getDefaultPerPage
()).
stream
());
}
/**
/**
* Get all namespaces that match a string in their name or path.
* Get all namespaces that match a string in their name or path.
*
*
* GET /namespaces?search=:query
*
<pre><code>GitLab Endpoint:
GET /namespaces?search=:query
</code></pre>
*
*
* @param query the search string
* @param query the search string
* @return the Namespace List with the matching namespaces
* @return the Namespace List with the matching namespaces
* @throws GitLabApiException if any exception occurs
* @throws GitLabApiException if any exception occurs
*/
*/
public
List
<
Namespace
>
findNamespaces
(
String
query
)
throws
GitLabApiException
{
public
List
<
Namespace
>
findNamespaces
(
String
query
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
().
withParam
(
"search"
,
query
,
true
).
withParam
(
PER_PAGE_PARAM
,
getDefaultPerPage
());
return
(
findNamespaces
(
query
,
getDefaultPerPage
()).
all
());
Response
response
=
get
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"namespaces"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Namespace
>>()
{}));
}
}
/**
/**
* Get all namespaces that match a string in their name or path in the specified page range.
* Get all namespaces that match a string in their name or path in the specified page range.
*
*
* GET /namespaces?search=:query
*
<pre><code>GitLab Endpoint:
GET /namespaces?search=:query
</code></pre>
*
*
* @param query the search string
* @param query the search string
* @param page the page to get
* @param page the page to get
...
@@ -95,7 +106,7 @@ public class NamespaceApi extends AbstractApi {
...
@@ -95,7 +106,7 @@ public class NamespaceApi extends AbstractApi {
/**
/**
* Get a Pager of all namespaces that match a string in their name or path.
* Get a Pager of all namespaces that match a string in their name or path.
*
*
* GET /namespaces?search=:query
*
<pre><code>GitLab Endpoint:
GET /namespaces?search=:query
</code></pre>
*
*
* @param query the search string
* @param query the search string
* @param itemsPerPage the number of Project instances that will be fetched per page
* @param itemsPerPage the number of Project instances that will be fetched per page
...
@@ -106,4 +117,17 @@ public class NamespaceApi extends AbstractApi {
...
@@ -106,4 +117,17 @@ public class NamespaceApi extends AbstractApi {
GitLabApiForm
formData
=
new
GitLabApiForm
().
withParam
(
"search"
,
query
,
true
);
GitLabApiForm
formData
=
new
GitLabApiForm
().
withParam
(
"search"
,
query
,
true
);
return
(
new
Pager
<
Namespace
>(
this
,
Namespace
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"namespaces"
));
return
(
new
Pager
<
Namespace
>(
this
,
Namespace
.
class
,
itemsPerPage
,
formData
.
asMap
(),
"namespaces"
));
}
}
/**
* Get all namespaces that match a string in their name or path as a Stream.
*
* <pre><code>GitLab Endpoint: GET /namespaces?search=:query</code></pre>
*
* @param query the search string
* @return a Stream with the matching namespaces
* @throws GitLabApiException if any exception occurs
*/
public
Stream
<
Namespace
>
findNamespacesStream
(
String
query
)
throws
GitLabApiException
{
return
(
findNamespaces
(
query
,
getDefaultPerPage
()).
stream
());
}
}
}
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