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
8c85a4e0
Commit
8c85a4e0
authored
Aug 11, 2015
by
Tim Olshansky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #60 from openwide-java/add-new-api-stuff
Added various API calls:
parents
d9f4c407
5cf40640
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
0 deletions
+73
-0
GitlabAPI.java
src/main/java/org/gitlab/api/GitlabAPI.java
+71
-0
GitlabUser.java
src/main/java/org/gitlab/api/models/GitlabUser.java
+2
-0
No files found.
src/main/java/org/gitlab/api/GitlabAPI.java
View file @
8c85a4e0
...
...
@@ -211,6 +211,32 @@ public class GitlabAPI {
return
retrieve
().
method
(
"PUT"
).
to
(
tailUrl
,
GitlabUser
.
class
);
}
/**
* Block a user
*
* @param targetUserId The id of the Gitlab user
* @throws IOException on gitlab api call error
*/
public
void
blockUser
(
Integer
targetUserId
)
throws
IOException
{
String
tailUrl
=
GitlabUser
.
USERS_URL
+
"/"
+
targetUserId
+
GitlabUser
.
BLOCK_URL
;
retrieve
().
method
(
"PUT"
).
to
(
tailUrl
,
Void
.
class
);
}
/**
* Unblock a user
*
* @param targetUserId The id of the Gitlab user
* @throws IOException on gitlab api call error
*/
public
void
unblockUser
(
Integer
targetUserId
)
throws
IOException
{
String
tailUrl
=
GitlabUser
.
USERS_URL
+
"/"
+
targetUserId
+
GitlabUser
.
UNBLOCK_URL
;
retrieve
().
method
(
"PUT"
).
to
(
tailUrl
,
Void
.
class
);
}
/**
* Create a new ssh key for the user
*
...
...
@@ -522,6 +548,39 @@ public class GitlabAPI {
return
dispatch
().
to
(
tailUrl
,
GitlabProject
.
class
);
}
/**
* Updates a Project
*
* @param projectId The id of the project to update
* @param name The name of the project
* @param description A description for the project, null otherwise
* @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 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 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 visibilityLevel The visibility level of the project, otherwise null indicates to use GitLab default
* @return the Gitlab Project
* @throws IOException on gitlab api call error
*/
public
GitlabProject
updateProject
(
Integer
projectId
,
String
name
,
String
description
,
Boolean
issuesEnabled
,
Boolean
wallEnabled
,
Boolean
mergeRequestsEnabled
,
Boolean
wikiEnabled
,
Boolean
snippetsEnabled
,
Boolean
publik
,
Integer
visibilityLevel
)
throws
IOException
{
Query
query
=
new
Query
()
.
appendIf
(
"name"
,
name
)
.
appendIf
(
"description"
,
description
)
.
appendIf
(
"issues_enabled"
,
issuesEnabled
)
.
appendIf
(
"wall_enabled"
,
wallEnabled
)
.
appendIf
(
"merge_requests_enabled"
,
mergeRequestsEnabled
)
.
appendIf
(
"wiki_enabled"
,
wikiEnabled
)
.
appendIf
(
"snippets_enabled"
,
snippetsEnabled
)
.
appendIf
(
"public"
,
publik
)
.
appendIf
(
"visibility_level"
,
visibilityLevel
);
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
query
.
toString
();
return
retrieve
().
method
(
"PUT"
).
to
(
tailUrl
,
GitlabProject
.
class
);
}
/**
* Delete a Project.
*
...
...
@@ -880,6 +939,18 @@ public class GitlabAPI {
return
Arrays
.
asList
(
retrieve
().
to
(
tailUrl
,
GitlabProjectMember
[].
class
));
}
/**
* Transfer a project to the given namespace
*
* @param namespaceId Namespace ID
* @param projectId Project ID
* @throws IOException on gitlab api call error
*/
public
void
transfer
(
Integer
namespaceId
,
Integer
projectId
)
throws
IOException
{
String
tailUrl
=
GitlabNamespace
.
URL
+
"/"
+
namespaceId
+
GitlabProject
.
URL
+
"/"
+
projectId
;
dispatch
().
to
(
tailUrl
,
Void
.
class
);
}
public
GitlabSession
getCurrentSession
()
throws
IOException
{
String
tailUrl
=
"/user"
;
return
retrieve
().
to
(
tailUrl
,
GitlabSession
.
class
);
...
...
src/main/java/org/gitlab/api/models/GitlabUser.java
View file @
8c85a4e0
...
...
@@ -8,6 +8,8 @@ public class GitlabUser {
public
static
String
URL
=
"/users"
;
public
static
String
USERS_URL
=
"/users"
;
public
static
String
USER_URL
=
"/user"
;
// for sudo based ops
public
static
String
BLOCK_URL
=
"/block"
;
public
static
String
UNBLOCK_URL
=
"/unblock"
;
private
Integer
_id
;
private
String
_username
;
...
...
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