Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
java-gitlab-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
沈俊林
java-gitlab-api
Commits
2b10303a
Commit
2b10303a
authored
Aug 27, 2014
by
Chode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added addGroupMemeber, deleteGroupMember, addProjectMember, deleteProjectMember
parent
b7f901b7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
112 additions
and
4 deletions
+112
-4
GitlabAPI.java
src/main/java/org/gitlab/api/GitlabAPI.java
+112
-4
No files found.
src/main/java/org/gitlab/api/GitlabAPI.java
View file @
2b10303a
...
...
@@ -124,7 +124,7 @@ public class GitlabAPI {
* @param password
* @param username
* @param fullName
* @param skype
* @param skype
Id
* @param linkedIn
* @param twitter
* @param website_url
...
...
@@ -315,6 +315,60 @@ public class GitlabAPI {
return
dispatch
().
to
(
tailUrl
,
GitlabGroup
.
class
);
}
/**
* Add a group member.
*
* @param group the GitlabGroup
* @param user the GitlabUser
* @param accessLevel the GitlabAccessLevel
* @return the GitlabGroupMember
* @throws IOException on gitlab api call error
*/
public
GitlabGroupMember
addGroupMember
(
GitlabGroup
group
,
GitlabUser
user
,
GitlabAccessLevel
accessLevel
)
throws
IOException
{
return
addGroupMember
(
group
.
getId
(),
user
.
getId
(),
accessLevel
);
}
/**
* Add a group member.
*
* @param groupId the group id
* @param userId the user id
* @param accessLevel the GitlabAccessLevel
* @return the GitlabGroupMember
* @throws IOException on gitlab api call error
*/
public
GitlabGroupMember
addGroupMember
(
Integer
groupId
,
Integer
userId
,
GitlabAccessLevel
accessLevel
)
throws
IOException
{
Query
query
=
new
Query
()
.
appendIf
(
"id"
,
groupId
)
.
appendIf
(
"user_id"
,
userId
)
.
appendIf
(
"access_level"
,
accessLevel
);
String
tailUrl
=
GitlabGroup
.
URL
+
"/"
+
groupId
+
GitlabProjectMember
.
URL
+
query
.
toString
();
return
dispatch
().
to
(
tailUrl
,
GitlabGroupMember
.
class
);
}
/**
* Delete a group member.
*
* @param group the GitlabGroup
* @param user the GitlabUser
* @throws IOException on gitlab api call error
*/
public
void
deleteGroupMember
(
GitlabGroup
group
,
GitlabUser
user
)
throws
IOException
{
deleteGroupMember
(
group
.
getId
(),
user
.
getId
());
}
/**
* Delete a group member.
*
* @param groupId the group id
* @param userId the user id
* @throws IOException on gitlab api call error
*/
public
void
deleteGroupMember
(
Integer
groupId
,
Integer
userId
)
throws
IOException
{
String
tailUrl
=
GitlabGroup
.
URL
+
"/"
+
groupId
+
"/"
+
GitlabGroupMember
.
URL
+
"/"
+
userId
;
retrieve
().
method
(
"DELETE"
).
to
(
tailUrl
,
Void
.
class
);
}
public
GitlabProject
getProject
(
String
projectId
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
sanitizeProjectId
(
projectId
);
return
retrieve
().
to
(
tailUrl
,
GitlabProject
.
class
);
...
...
@@ -673,16 +727,70 @@ public class GitlabAPI {
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
sanitizeProjectId
(
projectId
)
+
GitlabMilestone
.
URL
;
return
Arrays
.
asList
(
retrieve
().
to
(
tailUrl
,
GitlabMilestone
[].
class
));
}
/**
* Add a project member.
*
* @param project the GitlabProject
* @param user the GitlabUser
* @param accessLevel the GitlabAccessLevel
* @return the GitlabProjectMember
* @throws IOException on gitlab api call error
*/
public
GitlabProjectMember
addProjectMember
(
GitlabProject
project
,
GitlabUser
user
,
GitlabAccessLevel
accessLevel
)
throws
IOException
{
return
addProjectMember
(
project
.
getId
(),
user
.
getId
(),
accessLevel
);
}
/**
* Add a project member.
*
* @param projectId the project id
* @param userId the user id
* @param accessLevel the GitlabAccessLevel
* @return the GitlabProjectMember
* @throws IOException on gitlab api call error
*/
public
GitlabProjectMember
addProjectMember
(
Integer
projectId
,
Integer
userId
,
GitlabAccessLevel
accessLevel
)
throws
IOException
{
Query
query
=
new
Query
()
.
appendIf
(
"id"
,
projectId
)
.
appendIf
(
"user_id"
,
userId
)
.
appendIf
(
"access_level"
,
accessLevel
);
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
GitlabProjectMember
.
URL
+
query
.
toString
();
return
dispatch
().
to
(
tailUrl
,
GitlabProjectMember
.
class
);
}
/**
* Delete a project team member.
*
* @param project the GitlabProject
* @param user the GitlabUser
* @throws IOException on gitlab api call error
*/
public
void
deleteProjectMember
(
GitlabProject
project
,
GitlabUser
user
)
throws
IOException
{
deleteProjectMember
(
project
.
getId
(),
user
.
getId
());
}
/**
* Delete a project team member.
*
* @param projectId the project id
* @param userId the user id
* @throws IOException on gitlab api call error
*/
public
void
deleteProjectMember
(
Integer
projectId
,
Integer
userId
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
"/"
+
GitlabProjectMember
.
URL
+
"/"
+
userId
;
retrieve
().
method
(
"DELETE"
).
to
(
tailUrl
,
Void
.
class
);
}
public
List
<
GitlabProjectMember
>
getProjectMembers
(
GitlabProject
project
)
throws
IOException
{
return
getProjectMembers
(
String
.
valueOf
(
project
.
getId
()));
}
public
List
<
GitlabProjectMember
>
getProjectMembers
(
String
projectId
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
sanitizeProjectId
(
projectId
)
+
GitlabProjectMember
.
URL
;
return
Arrays
.
asList
(
retrieve
().
to
(
tailUrl
,
GitlabProjectMember
[].
class
));
}
/**
* This will fail, if the given namespace is a user and not a group
* @param namespace
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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