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
894e031d
Commit
894e031d
authored
Oct 10, 2019
by
Schoaf
Committed by
Greg Messner
Oct 09, 2019
Browse files
Add Badge API support to project (#447)
parent
8ff38545
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/ProjectApi.java
View file @
894e031d
...
@@ -40,6 +40,7 @@ import javax.ws.rs.core.Response;
...
@@ -40,6 +40,7 @@ import javax.ws.rs.core.Response;
import
org.gitlab4j.api.GitLabApi.ApiVersion
;
import
org.gitlab4j.api.GitLabApi.ApiVersion
;
import
org.gitlab4j.api.models.AccessLevel
;
import
org.gitlab4j.api.models.AccessLevel
;
import
org.gitlab4j.api.models.AccessRequest
;
import
org.gitlab4j.api.models.AccessRequest
;
import
org.gitlab4j.api.models.Badge
;
import
org.gitlab4j.api.models.Event
;
import
org.gitlab4j.api.models.Event
;
import
org.gitlab4j.api.models.FileUpload
;
import
org.gitlab4j.api.models.FileUpload
;
import
org.gitlab4j.api.models.Issue
;
import
org.gitlab4j.api.models.Issue
;
...
@@ -57,10 +58,12 @@ import org.gitlab4j.api.models.Visibility;
...
@@ -57,10 +58,12 @@ import org.gitlab4j.api.models.Visibility;
/**
/**
* This class provides an entry point to all the GitLab API project calls.
* This class provides an entry point to all the GitLab API project calls.
*
* @see <a href="https://docs.gitlab.com/ce/api/projects.html">Projects API at GitLab</a>
* @see <a href="https://docs.gitlab.com/ce/api/projects.html">Projects API at GitLab</a>
* @see <a href="https://docs.gitlab.com/ce/api/project_statistics.html">Project statistics API</a>
* @see <a href="https://docs.gitlab.com/ce/api/project_statistics.html">Project statistics API</a>
* @see <a href="https://docs.gitlab.com/ce/api/members.html">Group and project members API at GitLab</a>
* @see <a href="https://docs.gitlab.com/ce/api/members.html">Group and project members API at GitLab</a>
* @see <a href="https://docs.gitlab.com/ce/api/access_requests.html#group-and-project-access-requests-api">Group and project access requests API</a>
* @see <a href="https://docs.gitlab.com/ce/api/access_requests.html#group-and-project-access-requests-api">Group and project access requests API</a>
* @see <a href="https://docs.gitlab.com/ee/api/project_badges.html">Project badges API</a>
*/
*/
public
class
ProjectApi
extends
AbstractApi
implements
Constants
{
public
class
ProjectApi
extends
AbstractApi
implements
Constants
{
...
@@ -2942,5 +2945,44 @@ public class ProjectApi extends AbstractApi implements Constants {
...
@@ -2942,5 +2945,44 @@ public class ProjectApi extends AbstractApi implements Constants {
*/
*/
public
void
triggerHousekeeping
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
public
void
triggerHousekeeping
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
post
(
Response
.
Status
.
OK
,
(
Form
)
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"housekeeping"
);
post
(
Response
.
Status
.
OK
,
(
Form
)
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"housekeeping"
);
}
/**
* Add a badge to a project.
*
* <pre>
* <code>GitLab Endpoint: POST /projects/:id/badges</code>
* </pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param badge the badge to add
* @throws GitLabApiException if any exception occurs
*/
public
void
addBadge
(
Object
projectIdOrPath
,
Badge
badge
)
throws
GitLabApiException
{
Form
formData
=
new
Form
();
formData
.
param
(
"id"
,
String
.
valueOf
(
getProjectIdOrPath
(
projectIdOrPath
)));
formData
.
param
(
"link_url"
,
badge
.
getLinkUrl
());
formData
.
param
(
"image_url"
,
badge
.
getImageUrl
());
post
(
Response
.
Status
.
OK
,
formData
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"badges"
);
}
/**
* List all badges of a project <br>
* Gets a list of a project’s badges and its group badges..
*
* <pre>
* <code>GitLab Endpoint: GET /projects/:id/badges</code>
* </pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @throws GitLabApiException if any exception occurs
*/
public
List
<
Badge
>
getAllBadges
(
Object
projectIdOrPath
)
throws
GitLabApiException
{
try
(
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"badges"
))
{
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Badge
>>()
{
}));
}
}
}
}
}
src/main/java/org/gitlab4j/api/models/Badge.java
0 → 100644
View file @
894e031d
package
org.gitlab4j.api.models
;
import
org.gitlab4j.api.utils.JacksonJson
;
public
class
Badge
{
private
Integer
id
;
private
String
linkUrl
;
private
String
imageUrl
;
private
String
renderedLinkUrl
;
private
String
renderedImageUrl
;
private
String
kind
;
/**
* @return The ID or URL-encoded path of the project owned by the authenticated user
*/
public
Integer
getId
()
{
return
id
;
}
/**
* @param id The ID or URL-encoded path of the project owned by the authenticated user
*/
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
/**
* @return URL of the badge link
*/
public
String
getLinkUrl
()
{
return
linkUrl
;
}
/**
* @param linkUrl URL of the badge link
*/
public
void
setLinkUrl
(
String
linkUrl
)
{
this
.
linkUrl
=
linkUrl
;
}
/**
* @return URL of the badge image
*/
public
String
getImageUrl
()
{
return
imageUrl
;
}
/**
* @param imageUrl URL of the badge image
*/
public
void
setImageUrl
(
String
imageUrl
)
{
this
.
imageUrl
=
imageUrl
;
}
public
String
getRenderedImageUrl
()
{
return
renderedImageUrl
;
}
public
void
setRenderedImageUrl
(
String
renderedImageUrl
)
{
this
.
renderedImageUrl
=
renderedImageUrl
;
}
public
String
getRenderedLinkUrl
()
{
return
renderedLinkUrl
;
}
public
void
setRenderedLinkUrl
(
String
renderedLinkUrl
)
{
this
.
renderedLinkUrl
=
renderedLinkUrl
;
}
public
String
getKind
()
{
return
kind
;
}
public
void
setKind
(
String
kind
)
{
this
.
kind
=
kind
;
}
@Override
public
String
toString
()
{
return
(
JacksonJson
.
toJsonString
(
this
));
}
}
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