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
8ebcd09a
Commit
8ebcd09a
authored
Jan 30, 2017
by
Greg Messner
Browse files
Fixed createBranch() and added deleteBranch().
parent
1255c23a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/messners/gitlab/api/ProjectApi.java
View file @
8ebcd09a
...
@@ -15,458 +15,446 @@ import java.util.List;
...
@@ -15,458 +15,446 @@ import java.util.List;
public
class
ProjectApi
extends
AbstractApi
{
public
class
ProjectApi
extends
AbstractApi
{
ProjectApi
(
GitLabApi
gitLabApi
)
{
ProjectApi
(
GitLabApi
gitLabApi
)
{
super
(
gitLabApi
);
super
(
gitLabApi
);
}
}
/**
/**
* Get a list of projects accessible by the authenticated user.
* Get a list of projects accessible by the authenticated user.
*
*
* GET /projects
* GET /projects
*
*
* @return a list of projects accessible by the authenticated user
* @return a list of projects accessible by the authenticated user
* @throws GitLabApiException
* @throws GitLabApiException
*/
*/
public
List
<
Project
>
getProjects
()
throws
GitLabApiException
{
public
List
<
Project
>
getProjects
()
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
);
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Project
>>()
{
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Project
>>(){}));
}));
}
}
/**
/**
* Get a list of all GitLab projects (admin only).
* Get a list of all GitLab projects (admin only).
*
*
* GET /projects/all
* GET /projects/all
*
*
* @return a list of all GitLab projects
* @return a list of all GitLab projects
* @throws GitLabApiException
* @throws GitLabApiException
*/
*/
public
List
<
Project
>
getAllProjects
()
throws
GitLabApiException
{
public
List
<
Project
>
getAllProjects
()
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
UriComponent
.
decodeQuery
(
"per_page=9999"
,
true
),
"projects"
,
"all"
);
Response
response
=
get
(
Response
.
Status
.
OK
,
UriComponent
.
decodeQuery
(
"per_page=9999"
,
true
),
"projects"
,
"all"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Project
>>()
{
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Project
>>(){}));
}));
}
}
/**
/**
* Get a list of projects owned by the authenticated user.
* Get a list of projects owned by the authenticated user.
*
*
* GET /projects/owned
* GET /projects/owned
*
*
* @return a list of projects owned by the authenticated user
* @return a list of projects owned by the authenticated user
* @throws GitLabApiException
* @throws GitLabApiException
*/
*/
public
List
<
Project
>
getOwnedProjects
()
throws
GitLabApiException
{
public
List
<
Project
>
getOwnedProjects
()
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
"owned"
);
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
"owned"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Project
>>()
{
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Project
>>(){}));
}));
}
}
/**
/**
* Get a specific project, which is owned by the authentication user.
* Get a specific project, which is owned by the authentication user.
*
*
* GET /projects/:id
* GET /projects/:id
*
*
* @param projectId
* @param projectId
* @return the specified project
* @return the specified project
* @throws GitLabApiException
* @throws GitLabApiException
*/
*/
public
Project
getProject
(
Integer
projectId
)
throws
GitLabApiException
{
public
Project
getProject
(
Integer
projectId
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
);
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
);
return
(
response
.
readEntity
(
Project
.
class
));
return
(
response
.
readEntity
(
Project
.
class
));
}
}
/**
* Get a specific project, which is owned by the authentication user.
/**
*
* Get a specific project, which is owned by the authentication user.
* GET /projects/:id
*
*
* GET /projects/:id
* @param namespace the name of the project namespace or group
*
* @param project
* @param group
* @return the specified project
* @param project
* @throws GitLabApiException
* @return the specified project
*/
* @throws GitLabApiException
public
Project
getProject
(
String
namespace
,
String
project
)
throws
GitLabApiException
{
*/
public
Project
getProject
(
String
group
,
String
project
)
throws
GitLabApiException
{
if
(
namespace
==
null
)
{
throw
new
RuntimeException
(
"namespace cannot be null"
);
String
pid
=
null
;
}
try
{
pid
=
URLEncoder
.
encode
(
group
+
"/"
+
project
,
"UTF-8"
);
if
(
project
==
null
)
{
}
catch
(
UnsupportedEncodingException
uee
)
{
throw
new
RuntimeException
(
"project cannot be null"
);
throw
(
new
GitLabApiException
(
uee
));
}
}
String
pid
=
null
;
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
pid
);
try
{
return
(
response
.
readEntity
(
Project
.
class
));
pid
=
URLEncoder
.
encode
(
namespace
+
"/"
+
project
,
"UTF-8"
);
}
}
catch
(
UnsupportedEncodingException
uee
)
{
throw
(
new
GitLabApiException
(
uee
));
}
/**
* Create a new project in the specified group.
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
pid
);
*
return
(
response
.
readEntity
(
Project
.
class
));
* @param groupId
}
* @param projectName
* @return the created project
/**
* @throws GitLabApiException
* Create a new project in the specified group.
*/
*
public
Project
createProject
(
Integer
groupId
,
String
projectName
)
throws
GitLabApiException
{
* @param groupId
* @param projectName
Form
formData
=
new
Form
();
* @return the created project
addFormParam
(
formData
,
"namespace_id"
,
groupId
);
* @throws GitLabApiException
addFormParam
(
formData
,
"name"
,
projectName
,
true
);
*/
public
Project
createProject
(
Integer
groupId
,
String
projectName
)
throws
GitLabApiException
{
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
);
return
(
response
.
readEntity
(
Project
.
class
));
Form
formData
=
new
Form
();
}
addFormParam
(
formData
,
"namespace_id"
,
groupId
);
addFormParam
(
formData
,
"name"
,
projectName
,
true
);
/**
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
);
* Creates new project owned by the current user.
return
(
response
.
readEntity
(
Project
.
class
));
*
}
* @param project the Project instance with the configuration for the new project
* @return a Project instance with the newly created project info
/**
* @throws GitLabApiException
* Creates new project owned by the current user.
*/
*
public
Project
createProject
(
Project
project
)
throws
GitLabApiException
{
* @param project the Project instance with the configuration for the new project
return
(
createProject
(
project
,
null
));
* @return a Project instance with the newly created project info
}
* @throws GitLabApiException
*/
public
Project
createProject
(
Project
project
)
throws
GitLabApiException
{
/**
return
(
createProject
(
project
,
null
));
* Creates new project owned by the current user. The following properties on the Project instance
}
* are utilized in the creation of the project:
*
/**
* name (required) - new project name
* Creates new project owned by the current user. The following properties on the Project instance
* description (optional) - short project description
* are utilized in the creation of the project:
* issuesEnabled (optional)
*
* wallEnabled (optional)
* name (required) - new project name
* mergeRequestsEnabled (optional)
* description (optional) - short project description
* wikiEnabled (optional)
* issuesEnabled (optional)
* snippetsEnabled (optional)
* wallEnabled (optional)
* isPublic (optional) - if true same as setting visibility_level = 20
* mergeRequestsEnabled (optional)
* visibilityLevel (optional)
* wikiEnabled (optional)
*
* snippetsEnabled (optional)
* @param project the Project instance with the configuration for the new project
* isPublic (optional) - if true same as setting visibility_level = 20
* @param importUrl
* visibilityLevel (optional)
* @return a Project instance with the newly created project info
*
* @throws GitLabApiException
* @param project the Project instance with the configuration for the new project
*/
* @param importUrl
public
Project
createProject
(
Project
project
,
String
importUrl
)
throws
GitLabApiException
{
* @return a Project instance with the newly created project info
* @throws GitLabApiException
if
(
project
==
null
)
{
*/
return
(
null
);
public
Project
createProject
(
Project
project
,
String
importUrl
)
throws
GitLabApiException
{
}
if
(
project
==
null
)
{
String
name
=
project
.
getName
();
return
(
null
);
if
(
name
==
null
||
name
.
trim
().
length
()
==
0
)
{
}
return
(
null
);
}
String
name
=
project
.
getName
();
if
(
name
==
null
||
name
.
trim
().
length
()
==
0
)
{
Form
formData
=
new
Form
();
return
(
null
);
if
(
project
.
getNamespace
()
!=
null
)
{
}
addFormParam
(
formData
,
"namespace_id"
,
project
.
getNamespace
().
getId
());
}
Form
formData
=
new
Form
();
if
(
project
.
getNamespace
()
!=
null
)
{
addFormParam
(
formData
,
"name"
,
name
,
true
);
addFormParam
(
formData
,
"namespace_id"
,
project
.
getNamespace
().
getId
());
addFormParam
(
formData
,
"description"
,
project
.
getDescription
());
}
addFormParam
(
formData
,
"issues_enabled"
,
project
.
getIssuesEnabled
());
addFormParam
(
formData
,
"wall_enabled"
,
project
.
getWallEnabled
());
addFormParam
(
formData
,
"name"
,
name
,
true
);
addFormParam
(
formData
,
"merge_requests_enabled"
,
project
.
getMergeRequestsEnabled
());
addFormParam
(
formData
,
"description"
,
project
.
getDescription
());
addFormParam
(
formData
,
"wiki_enabled"
,
project
.
getWikiEnabled
());
addFormParam
(
formData
,
"issues_enabled"
,
project
.
getIssuesEnabled
());
addFormParam
(
formData
,
"snippets_enabled"
,
project
.
getSnippetsEnabled
());
addFormParam
(
formData
,
"wall_enabled"
,
project
.
getWallEnabled
());
addFormParam
(
formData
,
"public"
,
project
.
getPublic
());
addFormParam
(
formData
,
"merge_requests_enabled"
,
project
.
getMergeRequestsEnabled
());
addFormParam
(
formData
,
"visibility_level"
,
project
.
getVisibilityLevel
());
addFormParam
(
formData
,
"wiki_enabled"
,
project
.
getWikiEnabled
());
addFormParam
(
formData
,
"import_url"
,
importUrl
);
addFormParam
(
formData
,
"snippets_enabled"
,
project
.
getSnippetsEnabled
());
addFormParam
(
formData
,
"public"
,
project
.
getPublic
());
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
);
addFormParam
(
formData
,
"visibility_level"
,
project
.
getVisibilityLevel
());
return
(
response
.
readEntity
(
Project
.
class
));
addFormParam
(
formData
,
"import_url"
,
importUrl
);
}
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
);
return
(
response
.
readEntity
(
Project
.
class
));
/**
}
/**
* Creates a Project
* Creates a Project
*
*
* @param name
The name of the project
* @param name The name of the project
* @param namespaceId
The Namespace for the new project, otherwise null indicates to use the GitLab default (user)
* @param namespaceId The Namespace for the new project, otherwise null indicates to use the GitLab default (user)
* @param description
A description for the project, null otherwise
* @param description A description for the project, null otherwise
* @param issuesEnabled
Whether Issues should be enabled, otherwise null indicates to use GitLab default
* @param issuesEnabled Whether Issues should be enabled, otherwise null indicates to use GitLab default
* @param wallEnabled
Whether The Wall should be enabled, otherwise null indicates to use GitLab default
* @param wallEnabled Whether The Wall should be enabled, otherwise null indicates to use GitLab default
* @param mergeRequestsEnabled Whether Merge Requests should be enabled, otherwise null indicates to use GitLab default
* @param mergeRequestsEnabled Whether Merge Requests should be enabled, otherwise null indicates to use GitLab default
* @param wikiEnabled
Whether a Wiki should be enabled, otherwise null indicates to use GitLab default
* @param wikiEnabled Whether a Wiki should be enabled, otherwise null indicates to use GitLab default
* @param snippetsEnabled
Whether Snippets should be enabled, otherwise null indicates to use GitLab default
* @param snippetsEnabled Whether Snippets should be enabled, otherwise null indicates to use GitLab default
* @param publik
Whether the project is public or private, if true same as setting visibilityLevel = 20, otherwise null indicates to use GitLab default
* @param publik Whether the project is public or private, if true same as setting visibilityLevel = 20, otherwise null indicates to use GitLab default
* @param visibilityLevel
The visibility level of the project, otherwise null indicates to use GitLab default
* @param visibilityLevel The visibility level of the project, otherwise null indicates to use GitLab default
* @param importUrl
The Import URL for the project, otherwise null
* @param importUrl The Import URL for the project, otherwise null
* @return the Gitlab Project
* @return the Gitlab Project
* @throws GitLabApiException
* @throws GitLabApiException
*/
*/
public
Project
createProject
(
String
name
,
Integer
namespaceId
,
String
description
,
Boolean
issuesEnabled
,
Boolean
wallEnabled
,
Boolean
mergeRequestsEnabled
,
Boolean
wikiEnabled
,
Boolean
snippetsEnabled
,
Boolean
publik
,
Integer
visibilityLevel
,
String
importUrl
)
throws
GitLabApiException
{
public
Project
createProject
(
String
name
,
Integer
namespaceId
,
String
description
,
Boolean
issuesEnabled
,
Boolean
wallEnabled
,
Boolean
mergeRequestsEnabled
,
Boolean
wikiEnabled
,
Boolean
snippetsEnabled
,
Boolean
publik
,
Integer
visibilityLevel
,
String
importUrl
)
throws
GitLabApiException
{
if
(
name
==
null
||
name
.
trim
().
length
()
==
0
)
{
return
(
null
);
if
(
name
==
null
||
name
.
trim
().
length
()
==
0
)
{
}
return
(
null
);
}
Form
formData
=
new
Form
();
addFormParam
(
formData
,
"name"
,
name
,
true
);
Form
formData
=
new
Form
();
addFormParam
(
formData
,
"namespace_id"
,
namespaceId
);
addFormParam
(
formData
,
"name"
,
name
,
true
);
addFormParam
(
formData
,
"description"
,
description
);
addFormParam
(
formData
,
"namespace_id"
,
namespaceId
);
addFormParam
(
formData
,
"issues_enabled"
,
issuesEnabled
);
addFormParam
(
formData
,
"description"
,
description
);
addFormParam
(
formData
,
"wall_enabled"
,
wallEnabled
);
addFormParam
(
formData
,
"issues_enabled"
,
issuesEnabled
);
addFormParam
(
formData
,
"merge_requests_enabled"
,
mergeRequestsEnabled
);
addFormParam
(
formData
,
"wall_enabled"
,
wallEnabled
);
addFormParam
(
formData
,
"wiki_enabled"
,
wikiEnabled
);
addFormParam
(
formData
,
"merge_requests_enabled"
,
mergeRequestsEnabled
);
addFormParam
(
formData
,
"snippets_enabled"
,
snippetsEnabled
);
addFormParam
(
formData
,
"wiki_enabled"
,
wikiEnabled
);
addFormParam
(
formData
,
"public"
,
publik
);
addFormParam
(
formData
,
"snippets_enabled"
,
snippetsEnabled
);
addFormParam
(
formData
,
"visibility_level"
,
visibilityLevel
);
addFormParam
(
formData
,
"public"
,
publik
);
addFormParam
(
formData
,
"import_url"
,
importUrl
);
addFormParam
(
formData
,
"visibility_level"
,
visibilityLevel
);
addFormParam
(
formData
,
"import_url"
,
importUrl
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
);
return
(
response
.
readEntity
(
Project
.
class
));
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
);
return
(
response
.
readEntity
(
Project
.
class
));
}
}
/**
* Removes project with all resources(issues, merge requests etc).
*
* DELETE /projects/:id
*
* @param projectId
* @throws GitLabApiException
*/
public
void
deleteProject
(
Integer
projectId
)
throws
GitLabApiException
{
/**
if
(
projectId
==
null
)
{
* Removes project with all resources(issues, merge requests etc).
throw
new
RuntimeException
(
"projectId cannot be null"
);
*
}
* DELETE /projects/:id
*
delete
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
);
* @param projectId
}
* @throws GitLabApiException
*/
/**
public
void
deleteProject
(
Integer
projectId
)
throws
GitLabApiException
{
* Removes project with all resources(issues, merge requests etc).
*
if
(
projectId
==
null
)
{
* DELETE /projects/:id
throw
new
RuntimeException
(
"projectId cannot be null"
);
*
}
* @param project
* @throws GitLabApiException
delete
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
);
*/
}
public
void
deleteProject
(
Project
project
)
throws
GitLabApiException
{
deleteProject
(
project
.
getId
());
}
/**
* Removes project with all resources(issues, merge requests etc).
/**
*
* Get a list of project team members.
* DELETE /projects/:id
*
*
* GET /projects/:id/members
* @param project
*
* @throws GitLabApiException
* @param projectId
*/
* @return the members belonging to the specified project
public
void
deleteProject
(
Project
project
)
throws
GitLabApiException
{
* @throws GitLabApiException
deleteProject
(
project
.
getId
());
*/
}
public
List
<
Member
>
getMembers
(
Integer
projectId
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"members"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Member
>>()
{
/**
}));
* Get a list of project team members.
}
*
* GET /projects/:id/members
/**
*
* Gets a project team member.
* @param projectId
*
* @return the members belonging to the specified project
* GET /projects/:id/members/:user_id
* @throws GitLabApiException
*
*/
* @param projectId
public
List
<
Member
>
getMembers
(
Integer
projectId
)
throws
GitLabApiException
{
* @param userId
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"members"
);
* @return the member specified by the project ID/user ID pair
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Member
>>()
{}));
* @throws GitLabApiException
}
*/
public
Member
getMember
(
Integer
projectId
,
Integer
userId
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"members"
,
userId
);
/**
return
(
response
.
readEntity
(
Member
.
class
));
* Gets a project team member.
}
*
* GET /projects/:id/members/:user_id
/**
*
* Adds a user to a project team. This is an idempotent method and can be called multiple times
* @param projectId
* with the same parameters. Adding team membership to a user that is already a member does not
* @param userId
* affect the existing membership.
* @return the member specified by the project ID/user ID pair
*
* @throws GitLabApiException
* POST /projects/:id/members
*/
*
public
Member
getMember
(
Integer
projectId
,
Integer
userId
)
throws
GitLabApiException
{
* @param projectId
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"members"
,
userId
);
* @param userId
return
(
response
.
readEntity
(
Member
.
class
));
* @param accessLevel
}
* @return the added member
* @throws GitLabApiException
*/
/**
public
Member
addMember
(
Integer
projectId
,
Integer
userId
,
Integer
accessLevel
)
throws
GitLabApiException
{
* Adds a user to a project team. This is an idempotent method and can be called multiple times
* with the same parameters. Adding team membership to a user that is already a member does not
Form
formData
=
new
Form
();
* affect the existing membership.
formData
.
param
(
"user_id"
,
userId
.
toString
());
*
formData
.
param
(
"access_level"
,
accessLevel
.
toString
());
* POST /projects/:id/members
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
,
projectId
,
"members"
);
*
return
(
response
.
readEntity
(
Member
.
class
));
* @param projectId
}
* @param userId
* @param accessLevel
/**
* @return the added member
* Removes user from project team.
* @throws GitLabApiException
*
*/
* DELETE /projects/:id/members/:user_id
public
Member
addMember
(
Integer
projectId
,
Integer
userId
,
Integer
accessLevel
)
throws
GitLabApiException
{
*
* @param projectId
Form
formData
=
new
Form
();
* @param userId
formData
.
param
(
"user_id"
,
userId
.
toString
());
* @throws GitLabApiException
formData
.
param
(
"access_level"
,
accessLevel
.
toString
());
*/
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
,
projectId
,
"members"
);
public
void
removeMember
(
Integer
projectId
,
Integer
userId
)
throws
GitLabApiException
{
return
(
response
.
readEntity
(
Member
.
class
));
delete
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"members"
,
userId
);
}
}
/**
/**
* Get a project events for specific project. Sorted from newest to latest.
* Removes user from project team.
*
*
* GET /projects/:id/events
* DELETE /projects/:id/members/:user_id
*
*
* @param projectId
* @param projectId
* @return the project events for the specified project
* @param userId
* @throws GitLabApiException
* @throws GitLabApiException
*/
*/
public
List
<
Event
>
getProjectEvents
(
Integer
projectId
)
throws
GitLabApiException
{
public
void
removeMember
(
Integer
projectId
,
Integer
userId
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"events"
);
delete
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"members"
,
userId
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Event
>>()
{
}
}));
}
/**
/**
* Get a project events for specific project. Sorted from newest to latest.
* Get list of project hooks.
*
*
* GET /projects/:id/events
* GET /projects/:id/hooks
*
*
* @param projectId
* @param projectId
* @return the project events for the specified project
* @return a list of project hooks for the specified project
* @throws GitLabApiException
* @throws GitLabApiException
*/
*/
public
List
<
Event
>
getProjectEvents
(
Integer
projectId
)
throws
GitLabApiException
{
public
List
<
ProjectHook
>
getHooks
(
Integer
projectId
)
throws
GitLabApiException
{
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"events"
);
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"hooks"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
Event
>>()
{}));
return
(
response
.
readEntity
(
new
GenericType
<
List
<
ProjectHook
>>()
{
}
}));
}
/**
/**
* Get list of project hooks.
* Get a specific hook for project.
*
*
* GET /projects/:id/hooks
* GET /projects/:id/hooks/:hook_id
*
*
* @param projectId
* @param projectId
* @return a list of project hooks for the specified project
* @param hookId
* @throws GitLabApiException
* @return the project hook for the specified project ID/hook ID pair
*/
* @throws GitLabApiException
public
List
<
ProjectHook
>
getHooks
(
Integer
projectId
)
throws
GitLabApiException
{
*/
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"hooks"
);
public
ProjectHook
getHook
(
Integer
projectId
,
Integer
hookId
)
throws
GitLabApiException
{
return
(
response
.
readEntity
(
new
GenericType
<
List
<
ProjectHook
>>()
{}));
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"hooks"
,
hookId
);
}
return
(
response
.
readEntity
(
ProjectHook
.
class
));
}
/**
/**
* Get a specific hook for project.
* Adds a hook to project.
*
*
* GET /projects/:id/hooks/:hook_id
* POST /projects/:id/hooks
*
*
* @param projectId
* @param project
* @param hookId
* @param url
* @return the project hook for the specified project ID/hook ID pair
* @param doPushEvents
* @throws GitLabApiException
* @param doIssuesEvents
*/
* @param doMergeRequestsEvents
public
ProjectHook
getHook
(
Integer
projectId
,
Integer
hookId
)
throws
GitLabApiException
{
* @return the added project hook
Response
response
=
get
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"hooks"
,
hookId
);
* @throws GitLabApiException
return
(
response
.
readEntity
(
ProjectHook
.
class
));
*/
}
public
ProjectHook
addHook
(
Project
project
,
String
url
,
boolean
doPushEvents
,
boolean
doIssuesEvents
,
boolean
doMergeRequestsEvents
)
throws
GitLabApiException
{
if
(
project
==
null
)
{
/**
return
(
null
);
* Adds a hook to project.
}
*
* POST /projects/:id/hooks
return
(
addHook
(
project
.
getId
(),
url
,
doPushEvents
,
doIssuesEvents
,
doMergeRequestsEvents
));
*
}
* @param project
* @param url
/**
* @param doPushEvents
* Adds a hook to project.
* @param doIssuesEvents
*
* @param doMergeRequestsEvents
* POST /projects/:id/hooks
* @return the added project hook
*
* @throws GitLabApiException
* @param projectId
*/
* @param url
public
ProjectHook
addHook
(
Project
project
,
String
url
,
* @param doPushEvents
boolean
doPushEvents
,
boolean
doIssuesEvents
,
boolean
doMergeRequestsEvents
)
* @param doIssuesEvents
throws
GitLabApiException
{
* @param doMergeRequestsEvents
* @return the added project hook
if
(
project
==
null
)
{
* @throws GitLabApiException
return
(
null
);
*/
}
public
ProjectHook
addHook
(
Integer
projectId
,
String
url
,
boolean
doPushEvents
,
boolean
doIssuesEvents
,
boolean
doMergeRequestsEvents
)
throws
GitLabApiException
{
return
(
addHook
(
project
.
getId
(),
url
,
doPushEvents
,
doIssuesEvents
,
doMergeRequestsEvents
));
Form
formData
=
new
Form
();
}
formData
.
param
(
"url"
,
url
);
formData
.
param
(
"push_events"
,
Boolean
.
toString
(
doPushEvents
));
formData
.
param
(
"issues_enabled"
,
Boolean
.
toString
(
doIssuesEvents
));
/**
formData
.
param
(
"merge_requests_events"
,
Boolean
.
toString
(
doMergeRequestsEvents
));
* Adds a hook to project.
*
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
,
projectId
,
"hooks"
);
* POST /projects/:id/hooks
return
(
response
.
readEntity
(
ProjectHook
.
class
));
*
}
* @param projectId
* @param url
/**
* @param doPushEvents
* Deletes a hook from the project.
* @param doIssuesEvents
*
* @param doMergeRequestsEvents
* DELETE /projects/:id/hooks/:hook_id
* @return the added project hook
*
* @throws GitLabApiException
* @param projectId
*/
* @param hookId
public
ProjectHook
addHook
(
Integer
projectId
,
String
url
,
* @throws GitLabApiException
boolean
doPushEvents
,
boolean
doIssuesEvents
,
boolean
doMergeRequestsEvents
)
*/
throws
GitLabApiException
{
public
void
deleteHook
(
Integer
projectId
,
Integer
hookId
)
throws
GitLabApiException
{
delete
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"hooks"
,
hookId
);
Form
formData
=
new
Form
();
}
formData
.
param
(
"url"
,
url
);
formData
.
param
(
"push_events"
,
Boolean
.
toString
(
doPushEvents
));
/**
formData
.
param
(
"issues_enabled"
,
Boolean
.
toString
(
doIssuesEvents
));
* Deletes a hook from the project.
formData
.
param
(
"merge_requests_events"
,
Boolean
.
toString
(
doMergeRequestsEvents
));
*
* DELETE /projects/:id/hooks/:hook_id
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"projects"
,
projectId
,
"hooks"
);
*
return
(
response
.
readEntity
(
ProjectHook
.
class
));
* @param hook
}
* @throws GitLabApiException
*/
public
void
deleteHook
(
ProjectHook
hook
)
throws
GitLabApiException
{
/**
deleteHook
(
hook
.
getProjectId
(),
hook
.
getId
());
* Deletes a hook from the project.
}
*
* DELETE /projects/:id/hooks/:hook_id
/**
*
* Modifies a hook for project.
* @param projectId
*
* @param hookId
* PUT /projects/:id/hooks/:hook_id
* @throws GitLabApiException
*
*/
* @param hook
public
void
deleteHook
(
Integer
projectId
,
Integer
hookId
)
throws
GitLabApiException
{
* @return the modified project hook
delete
(
Response
.
Status
.
OK
,
null
,
"projects"
,
projectId
,
"hooks"
,
hookId
);
* @throws GitLabApiException
}
*/
public
ProjectHook
modifyHook
(
ProjectHook
hook
)
throws
GitLabApiException
{
/**
Form
formData
=
new
Form
();
* Deletes a hook from the project.
formData
.
param
(
"url"
,
hook
.
getUrl
());
*
formData
.
param
(
"push_events"
,
hook
.
getPushEvents
().
toString
());
* DELETE /projects/:id/hooks/:hook_id
formData
.
param
(
"issues_enabled"
,
hook
.
getIssuesEvents
().
toString
());
*
formData
.
param
(
"merge_requests_events"
,
hook
.
getMergeRequestsEvents
().
toString
());
* @param hook
* @throws GitLabApiException
Response
response
=
put
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
hook
.
getProjectId
(),
"hooks"
,
hook
.
getId
());
*/
return
(
response
.
readEntity
(
ProjectHook
.
class
));
public
void
deleteHook
(
ProjectHook
hook
)
throws
GitLabApiException
{
}
deleteHook
(
hook
.
getProjectId
(),
hook
.
getId
());
}
/**
* Modifies a hook for project.
*
* PUT /projects/:id/hooks/:hook_id
*
* @param hook
* @return the modified project hook
* @throws GitLabApiException
*/
public
ProjectHook
modifyHook
(
ProjectHook
hook
)
throws
GitLabApiException
{
Form
formData
=
new
Form
();
formData
.
param
(
"url"
,
hook
.
getUrl
());
formData
.
param
(
"push_events"
,
hook
.
getPushEvents
().
toString
());
formData
.
param
(
"issues_enabled"
,
hook
.
getIssuesEvents
().
toString
());
formData
.
param
(
"merge_requests_events"
,
hook
.
getMergeRequestsEvents
().
toString
());
Response
response
=
put
(
Response
.
Status
.
OK
,
formData
.
asMap
(),
"projects"
,
hook
.
getProjectId
(),
"hooks"
,
hook
.
getId
());
return
(
response
.
readEntity
(
ProjectHook
.
class
));
}
}
}
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