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
2341a37b
Commit
2341a37b
authored
Oct 01, 2015
by
Lorenzo Caenazzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert format code
parent
37444213
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
370 additions
and
393 deletions
+370
-393
pom.xml
pom.xml
+135
-135
GitlabAPI.java
src/main/java/org/gitlab/api/GitlabAPI.java
+127
-153
TokenType.java
src/main/java/org/gitlab/api/TokenType.java
+10
-8
GitlabHTTPRequestor.java
src/main/java/org/gitlab/api/http/GitlabHTTPRequestor.java
+34
-33
Query.java
src/main/java/org/gitlab/api/http/Query.java
+24
-28
GitlabBranch.java
src/main/java/org/gitlab/api/models/GitlabBranch.java
+0
-1
GitlabBranchCommit.java
src/main/java/org/gitlab/api/models/GitlabBranchCommit.java
+0
-1
GitlabMergeRequest.java
src/main/java/org/gitlab/api/models/GitlabMergeRequest.java
+0
-1
GitlabNamespace.java
src/main/java/org/gitlab/api/models/GitlabNamespace.java
+0
-1
GitlabProjectAccessLevel.java
.../java/org/gitlab/api/models/GitlabProjectAccessLevel.java
+3
-0
GitlabRepositoryTree.java
...main/java/org/gitlab/api/models/GitlabRepositoryTree.java
+29
-30
GitlabSSHKey.java
src/main/java/org/gitlab/api/models/GitlabSSHKey.java
+1
-1
GitlabUser.java
src/main/java/org/gitlab/api/models/GitlabUser.java
+0
-1
GitlabAPIT.java
src/test/java/org/gitlab/api/GitlabAPIT.java
+6
-0
QueryTest.java
src/test/java/org/gitlab/api/http/QueryTest.java
+1
-0
No files found.
pom.xml
View file @
2341a37b
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
org.gitlab
</groupId>
<groupId>
org.gitlab
</groupId>
<artifactId>
java-gitlab-api
</artifactId>
<artifactId>
java-gitlab-api
</artifactId>
<version>
1.1.10-SNAPSHOT
</version>
<version>
1.1.10-SNAPSHOT
</version>
<name>
Gitlab Java API Wrapper
</name>
<name>
Gitlab Java API Wrapper
</name>
<description>
A Java wrapper for the Gitlab Git Hosting Server API
</description>
<description>
A Java wrapper for the Gitlab Git Hosting Server API
</description>
<parent>
<parent>
<groupId>
org.sonatype.oss
</groupId>
<groupId>
org.sonatype.oss
</groupId>
<artifactId>
oss-parent
</artifactId>
<artifactId>
oss-parent
</artifactId>
<version>
9
</version>
<version>
9
</version>
</parent>
</parent>
<developers>
<developers>
<developer>
<developer>
<id>
timols
</id>
<id>
timols
</id>
<name>
Tim Olshansky
</name>
<name>
Tim Olshansky
</name>
<email>
tim.olshansky@gmail.com
</email>
<email>
tim.olshansky@gmail.com
</email>
</developer>
</developer>
</developers>
</developers>
<contributors>
<contributors>
<contributor>
<contributor>
<name>
Adam Retter
</name>
<name>
Adam Retter
</name>
<email>
adam.retter@googlemail.com
</email>
<email>
adam.retter@googlemail.com
</email>
<organization>
Evolved Binary Ltd
</organization>
<organization>
Evolved Binary Ltd
</organization>
</contributor>
</contributor>
<contributor>
<contributor>
<name>
Cesar Aguilar
</name>
<name>
Cesar Aguilar
</name>
<email>
cesar@fuzzproductions.com
</email>
<email>
cesar@fuzzproductions.com
</email>
<organization>
Fuzz Productions
</organization>
<organization>
Fuzz Productions
</organization>
</contributor>
</contributor>
<contributor>
<contributor>
<name>
Chris Luu
</name>
<name>
Chris Luu
</name>
<email>
luu@fuzzproductions.com
</email>
<email>
luu@fuzzproductions.com
</email>
<organization>
Fuzz Productions
</organization>
<organization>
Fuzz Productions
</organization>
</contributor>
</contributor>
</contributors>
</contributors>
<licenses>
<licenses>
<license>
<license>
<name>
The Apache Software License, Version 2.0
</name>
<name>
The Apache Software License, Version 2.0
</name>
<url>
http://www.apache.org/licenses/LICENSE-2.0.txt
</url>
<url>
http://www.apache.org/licenses/LICENSE-2.0.txt
</url>
<distribution>
repo
</distribution>
<distribution>
repo
</distribution>
</license>
</license>
</licenses>
</licenses>
<scm>
<scm>
<connection>
scm:git:ssh://github.com/timols/java-gitlab-api.git
</connection>
<connection>
scm:git:ssh://github.com/timols/java-gitlab-api.git
</connection>
<developerConnection>
scm:git:ssh://git@github.com/timols/java-gitlab-api.git
</developerConnection>
<developerConnection>
scm:git:ssh://git@github.com/timols/java-gitlab-api.git
</developerConnection>
<url>
https://github.com/timols/java-gitlab-api
</url>
<url>
https://github.com/timols/java-gitlab-api
</url>
</scm>
</scm>
<issueManagement>
<issueManagement>
<system>
Github
</system>
<system>
Github
</system>
<url>
https://github.com/timols/java-gitlab-api/issues
</url>
<url>
https://github.com/timols/java-gitlab-api/issues
</url>
</issueManagement>
</issueManagement>
<properties>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
</properties>
</properties>
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-core
</artifactId>
<artifactId>
jackson-core
</artifactId>
<version>
2.5.3
</version>
<version>
2.5.3
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
<artifactId>
jackson-databind
</artifactId>
<version>
2.5.3
</version>
<version>
2.5.3
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
commons-io
</groupId>
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
<artifactId>
commons-io
</artifactId>
<version>
2.4
</version>
<version>
2.4
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.hamcrest
</groupId>
<groupId>
org.hamcrest
</groupId>
<artifactId>
hamcrest-all
</artifactId>
<artifactId>
hamcrest-all
</artifactId>
<version>
1.3
</version>
<version>
1.3
</version>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
junit
</groupId>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<artifactId>
junit
</artifactId>
<version>
4.12
</version>
<version>
4.12
</version>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
<plugins>
<plugins>
<plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
2.5.1
</version>
<version>
2.5.1
</version>
<configuration>
<configuration>
<source>
1.6
</source>
<source>
1.6
</source>
<target>
1.6
</target>
<target>
1.6
</target>
</configuration>
</configuration>
</plugin>
</plugin>
<plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-surefire-plugin
</artifactId>
<artifactId>
maven-surefire-plugin
</artifactId>
<version>
2.17
</version>
<version>
2.17
</version>
</plugin>
</plugin>
<plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-failsafe-plugin
</artifactId>
<artifactId>
maven-failsafe-plugin
</artifactId>
<version>
2.17
</version>
<version>
2.17
</version>
<executions>
<executions>
<execution>
<execution>
<id>
default-integration-test
</id>
<id>
default-integration-test
</id>
<goals>
<goals>
<goal>
integration-test
</goal>
<goal>
integration-test
</goal>
</goals>
</goals>
</execution>
</execution>
<execution>
<execution>
<id>
default-verify
</id>
<id>
default-verify
</id>
<goals>
<goals>
<goal>
verify
</goal>
<goal>
verify
</goal>
</goals>
</goals>
</execution>
</execution>
</executions>
</executions>
</plugin>
</plugin>
<plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-source-plugin
</artifactId>
<artifactId>
maven-source-plugin
</artifactId>
<version>
2.4
</version>
<version>
2.4
</version>
<executions>
<executions>
<execution>
<execution>
<id>
attach-sources
</id>
<id>
attach-sources
</id>
<phase>
verify
</phase>
<phase>
verify
</phase>
<goals>
<goals>
<goal>
jar-no-fork
</goal>
<goal>
jar-no-fork
</goal>
</goals>
</goals>
</execution>
</execution>
</executions>
</executions>
</plugin>
</plugin>
</plugins>
</plugins>
</build>
</build>
</project>
</project>
src/main/java/org/gitlab/api/GitlabAPI.java
View file @
2341a37b
...
@@ -14,6 +14,7 @@ import java.net.URLEncoder;
...
@@ -14,6 +14,7 @@ import java.net.URLEncoder;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
/**
/**
* Gitlab API Wrapper class
* Gitlab API Wrapper class
*
*
...
@@ -115,32 +116,31 @@ public class GitlabAPI {
...
@@ -115,32 +116,31 @@ public class GitlabAPI {
/**
/**
* Create a new User
* Create a new User
*
*
* @param email User email
* @param email
User email
* @param password Password
* @param password
Password
* @param username User name
* @param username
User name
* @param fullName Full name
* @param fullName
Full name
* @param skypeId Skype Id
* @param skypeId
Skype Id
* @param linkedIn LinkedIn
* @param linkedIn
LinkedIn
* @param twitter Twitter
* @param twitter
Twitter
* @param website_url Website URL
* @param website_url
Website URL
* @param projects_limit Projects limit
* @param projects_limit
Projects limit
* @param extern_uid External User ID
* @param extern_uid
External User ID
* @param extern_provider_name External Provider Name
* @param extern_provider_name External Provider Name
* @param bio Bio
* @param bio
Bio
* @param isAdmin Is Admin
* @param isAdmin
Is Admin
* @param can_create_group Can Create Group
* @param can_create_group
Can Create Group
* @param skip_confirmation Skip Confirmation
* @param skip_confirmation
Skip Confirmation
* @return A GitlabUser
* @return
A GitlabUser
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
* @see
* @see <a href="http://doc.gitlab.com/ce/api/users.html">http://doc.gitlab.com/ce/api/users.html</a>
* <a href="http://doc.gitlab.com/ce/api/users.html">http://doc.gitlab.com/ce/api/users.html</a>
*/
*/
public
GitlabUser
createUser
(
String
email
,
String
password
,
String
username
,
public
GitlabUser
createUser
(
String
email
,
String
password
,
String
username
,
String
fullName
,
String
skypeId
,
String
linkedIn
,
String
fullName
,
String
skypeId
,
String
linkedIn
,
String
twitter
,
String
website_url
,
Integer
projects_limit
,
String
twitter
,
String
website_url
,
Integer
projects_limit
,
String
extern_uid
,
String
extern_provider_name
,
String
extern_uid
,
String
extern_provider_name
,
String
bio
,
Boolean
isAdmin
,
Boolean
can_create_group
,
String
bio
,
Boolean
isAdmin
,
Boolean
can_create_group
,
Boolean
skip_confirmation
)
throws
IOException
{
Boolean
skip_confirmation
)
throws
IOException
{
Query
query
=
new
Query
()
Query
query
=
new
Query
()
.
append
(
"email"
,
email
)
.
append
(
"email"
,
email
)
...
@@ -164,33 +164,34 @@ public class GitlabAPI {
...
@@ -164,33 +164,34 @@ public class GitlabAPI {
return
dispatch
().
to
(
tailUrl
,
GitlabUser
.
class
);
return
dispatch
().
to
(
tailUrl
,
GitlabUser
.
class
);
}
}
/**
/**
* Update a user
* Update a user
*
*
* @param targetUserId User ID
* @param targetUserId
User ID
* @param email User email
* @param email
User email
* @param password Password
* @param password
Password
* @param username User name
* @param username
User name
* @param fullName Full name
* @param fullName
Full name
* @param skypeId Skype Id
* @param skypeId
Skype Id
* @param linkedIn LinkedIn
* @param linkedIn
LinkedIn
* @param twitter Twitter
* @param twitter
Twitter
* @param website_url Website URL
* @param website_url
Website URL
* @param projects_limit Projects limit
* @param projects_limit
Projects limit
* @param extern_uid External User ID
* @param extern_uid
External User ID
* @param extern_provider_name External Provider Name
* @param extern_provider_name External Provider Name
* @param bio Bio
* @param bio
Bio
* @param isAdmin Is Admin
* @param isAdmin
Is Admin
* @param can_create_group Can Create Group
* @param can_create_group
Can Create Group
* @return The Updated User
* @return The Updated User
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
public
GitlabUser
updateUser
(
Integer
targetUserId
,
public
GitlabUser
updateUser
(
Integer
targetUserId
,
String
email
,
String
password
,
String
username
,
String
email
,
String
password
,
String
username
,
String
fullName
,
String
skypeId
,
String
linkedIn
,
String
fullName
,
String
skypeId
,
String
linkedIn
,
String
twitter
,
String
website_url
,
Integer
projects_limit
,
String
twitter
,
String
website_url
,
Integer
projects_limit
,
String
extern_uid
,
String
extern_provider_name
,
String
extern_uid
,
String
extern_provider_name
,
String
bio
,
Boolean
isAdmin
,
Boolean
can_create_group
)
throws
IOException
{
String
bio
,
Boolean
isAdmin
,
Boolean
can_create_group
)
throws
IOException
{
Query
query
=
new
Query
()
Query
query
=
new
Query
()
.
append
(
"email"
,
email
)
.
append
(
"email"
,
email
)
...
@@ -243,8 +244,8 @@ public class GitlabAPI {
...
@@ -243,8 +244,8 @@ public class GitlabAPI {
* Create a new ssh key for the user
* Create a new ssh key for the user
*
*
* @param targetUserId The id of the Gitlab user
* @param targetUserId The id of the Gitlab user
* @param title The title of the ssh key
* @param title
The title of the ssh key
* @param key The public key
* @param key
The public key
* @return The new GitlabSSHKey
* @return The new GitlabSSHKey
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
...
@@ -263,7 +264,7 @@ public class GitlabAPI {
...
@@ -263,7 +264,7 @@ public class GitlabAPI {
* Delete user's ssh key
* Delete user's ssh key
*
*
* @param targetUserId The id of the Gitlab user
* @param targetUserId The id of the Gitlab user
* @param targetKeyId The id of the Gitlab ssh key
* @param targetKeyId
The id of the Gitlab ssh key
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
public
void
deleteSSHKey
(
Integer
targetUserId
,
Integer
targetKeyId
)
throws
IOException
{
public
void
deleteSSHKey
(
Integer
targetUserId
,
Integer
targetKeyId
)
throws
IOException
{
...
@@ -271,6 +272,7 @@ public class GitlabAPI {
...
@@ -271,6 +272,7 @@ public class GitlabAPI {
retrieve
().
method
(
"DELETE"
).
to
(
tailUrl
,
Void
.
class
);
retrieve
().
method
(
"DELETE"
).
to
(
tailUrl
,
Void
.
class
);
}
}
/**
/**
* Gets all ssh keys for a user
* Gets all ssh keys for a user
*
*
...
@@ -298,7 +300,7 @@ public class GitlabAPI {
...
@@ -298,7 +300,7 @@ public class GitlabAPI {
/**
/**
* Delete a user
* Delete a user
*
*
* @param targetUserId The target User ID
* @param targetUserId
The target User ID
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
public
void
deleteUser
(
Integer
targetUserId
)
throws
IOException
{
public
void
deleteUser
(
Integer
targetUserId
)
throws
IOException
{
...
@@ -342,8 +344,9 @@ public class GitlabAPI {
...
@@ -342,8 +344,9 @@ public class GitlabAPI {
/**
/**
* Creates a Group
* Creates a Group
*
*
* @param name The name of the group. The name will also be used as the path
* @param name The name of the group. The
* of the group.
* name will also be used as the path
* of the group.
* @return The GitLab Group
* @return The GitLab Group
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
...
@@ -366,9 +369,9 @@ public class GitlabAPI {
...
@@ -366,9 +369,9 @@ public class GitlabAPI {
/**
/**
* Creates a Group
* Creates a Group
*
*
* @param name The name of the group
* @param name
The name of the group
* @param path The path for the group
* @param path
The path for the group
* @param ldapCn LDAP Group Name to sync with, null otherwise
* @param ldapCn
LDAP Group Name to sync with, null otherwise
* @param ldapAccess Access level for LDAP group members, null otherwise
* @param ldapAccess Access level for LDAP group members, null otherwise
* @return The GitLab Group
* @return The GitLab Group
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
...
@@ -389,8 +392,8 @@ public class GitlabAPI {
...
@@ -389,8 +392,8 @@ public class GitlabAPI {
/**
/**
* Add a group member.
* Add a group member.
*
*
* @param group the GitlabGroup
* @param group
the GitlabGroup
* @param user the GitlabUser
* @param user
the GitlabUser
* @param accessLevel the GitlabAccessLevel
* @param accessLevel the GitlabAccessLevel
* @return the GitlabGroupMember
* @return the GitlabGroupMember
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
...
@@ -402,8 +405,8 @@ public class GitlabAPI {
...
@@ -402,8 +405,8 @@ public class GitlabAPI {
/**
/**
* Add a group member.
* Add a group member.
*
*
* @param groupId the group id
* @param groupId
the group id
* @param userId the user id
* @param userId
the user id
* @param accessLevel the GitlabAccessLevel
* @param accessLevel the GitlabAccessLevel
* @return the GitlabGroupMember
* @return the GitlabGroupMember
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
...
@@ -421,7 +424,7 @@ public class GitlabAPI {
...
@@ -421,7 +424,7 @@ public class GitlabAPI {
* Delete a group member.
* Delete a group member.
*
*
* @param group the GitlabGroup
* @param group the GitlabGroup
* @param user the GitlabUser
* @param user
the GitlabUser
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
public
void
deleteGroupMember
(
GitlabGroup
group
,
GitlabUser
user
)
throws
IOException
{
public
void
deleteGroupMember
(
GitlabGroup
group
,
GitlabUser
user
)
throws
IOException
{
...
@@ -432,7 +435,7 @@ public class GitlabAPI {
...
@@ -432,7 +435,7 @@ public class GitlabAPI {
* Delete a group member.
* Delete a group member.
*
*
* @param groupId the group id
* @param groupId the group id
* @param userId the user id
* @param userId
the user id
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
public
void
deleteGroupMember
(
Integer
groupId
,
Integer
userId
)
throws
IOException
{
public
void
deleteGroupMember
(
Integer
groupId
,
Integer
userId
)
throws
IOException
{
...
@@ -480,26 +483,17 @@ public class GitlabAPI {
...
@@ -480,26 +483,17 @@ public class GitlabAPI {
/**
/**
* 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
* @param namespaceId The Namespace for the new project, otherwise null indicates to use the GitLab default (user)
* 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
* @param wallEnabled Whether The Wall should be enabled, otherwise null indicates to use GitLab default
* indicates to use GitLab default
* @param mergeRequestsEnabled Whether Merge Requests should be enabled, otherwise null indicates to use GitLab default
* @param wallEnabled Whether The Wall should be enabled, otherwise null
* @param wikiEnabled Whether a Wiki should be enabled, otherwise null indicates to use GitLab default
* indicates to use GitLab default
* @param snippetsEnabled Whether Snippets should be enabled, otherwise null indicates to use GitLab default
* @param mergeRequestsEnabled Whether Merge Requests should be enabled,
* @param publik Whether the project is public or private, if true same as setting visibilityLevel = 20, otherwise null indicates to use GitLab default
* otherwise null indicates to use GitLab default
* @param visibilityLevel The visibility level of the project, otherwise null indicates to use GitLab default
* @param wikiEnabled Whether a Wiki should be enabled, otherwise null
* @param importUrl The Import URL for the project, 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
* @param importUrl The Import URL for the project, otherwise null
* @return the Gitlab Project
* @return the Gitlab Project
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
...
@@ -526,7 +520,7 @@ public class GitlabAPI {
...
@@ -526,7 +520,7 @@ public class GitlabAPI {
* Creates a Project for a specific User
* Creates a Project for a specific User
*
*
* @param userId The id of the user to create the project for
* @param userId The id of the user to create the project for
* @param name The name of the project
* @param name
The name of the project
* @return The GitLab Project
* @return The GitLab Project
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
...
@@ -537,26 +531,17 @@ public class GitlabAPI {
...
@@ -537,26 +531,17 @@ public class GitlabAPI {
/**
/**
* Creates a Project for a specific User
* Creates a Project for a specific User
*
*
* @param userId The id of the user to create the project for
* @param userId The id of the user to create the project for
* @param name The name of the project
* @param name The name of the project
* @param description A description for the project, null otherwise
* @param description A description for the project, null otherwise
* @param defaultBranch The default branch for the project, otherwise null
* @param defaultBranch The default branch for the project, otherwise null indicates to use GitLab default (master)
* indicates to use GitLab default (master)
* @param issuesEnabled Whether Issues should be enabled, otherwise null indicates to use GitLab default
* @param issuesEnabled Whether Issues should be enabled, otherwise null
* @param wallEnabled Whether The Wall should be enabled, otherwise null indicates to use GitLab default
* indicates to use GitLab default
* @param mergeRequestsEnabled Whether Merge Requests should be enabled, otherwise null indicates to use GitLab default
* @param wallEnabled Whether The Wall should be enabled, otherwise null
* @param wikiEnabled Whether a Wiki should be enabled, otherwise null indicates to use GitLab default
* indicates to use GitLab default
* @param snippetsEnabled Whether Snippets should be enabled, otherwise null indicates to use GitLab default
* @param mergeRequestsEnabled Whether Merge Requests should be enabled,
* @param publik Whether the project is public or private, if true same as setting visibilityLevel = 20, otherwise null indicates to use GitLab default
* otherwise null indicates to use GitLab default
* @param visibilityLevel The visibility level of the project, 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
* @return The GitLab Project
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
...
@@ -581,24 +566,16 @@ public class GitlabAPI {
...
@@ -581,24 +566,16 @@ public class GitlabAPI {
/**
/**
* Updates a Project
* Updates a Project
*
*
* @param projectId The id of the project to update
* @param projectId The id of the project to update
* @param name The name of the project
* @param name The name of the project
* @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
* @param issuesEnabled Whether Issues should be enabled, otherwise null indicates to use GitLab default
* 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
* @param mergeRequestsEnabled Whether Merge Requests should be enabled, otherwise null indicates to use GitLab default
* indicates to use GitLab default
* @param wikiEnabled Whether a Wiki should be enabled, otherwise null indicates to use GitLab default
* @param mergeRequestsEnabled Whether Merge Requests should be enabled,
* @param snippetsEnabled Whether Snippets should be enabled, otherwise null indicates to use GitLab default
* 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 wikiEnabled Whether a Wiki should be enabled, otherwise null
* @param visibilityLevel The visibility level of the project, otherwise null indicates to use GitLab default
* 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
* @return the Gitlab Project
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
...
@@ -661,8 +638,8 @@ public class GitlabAPI {
...
@@ -661,8 +638,8 @@ public class GitlabAPI {
}
}
/**
/**
* @param project The Project
* @param project
The Project
* @param mergeRequestId Merge Request ID
* @param mergeRequestId
Merge Request ID
* @param mergeCommitMessage optional merge commit message. Null if not set
* @param mergeCommitMessage optional merge commit message. Null if not set
* @return new merge request status
* @return new merge request status
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
...
@@ -672,25 +649,24 @@ public class GitlabAPI {
...
@@ -672,25 +649,24 @@ public class GitlabAPI {
GitlabHTTPRequestor
requestor
=
retrieve
().
method
(
"PUT"
);
GitlabHTTPRequestor
requestor
=
retrieve
().
method
(
"PUT"
);
requestor
.
with
(
"id"
,
project
.
getId
());
requestor
.
with
(
"id"
,
project
.
getId
());
requestor
.
with
(
"merge_request_id"
,
mergeRequestId
);
requestor
.
with
(
"merge_request_id"
,
mergeRequestId
);
if
(
mergeCommitMessage
!=
null
)
{
if
(
mergeCommitMessage
!=
null
)
requestor
.
with
(
"merge_commit_message"
,
mergeCommitMessage
);
requestor
.
with
(
"merge_commit_message"
,
mergeCommitMessage
);
}
return
requestor
.
to
(
tailUrl
,
GitlabMergeRequest
.
class
);
return
requestor
.
to
(
tailUrl
,
GitlabMergeRequest
.
class
);
}
}
public
List
<
GitlabNote
>
getNotes
(
GitlabMergeRequest
mergeRequest
)
throws
IOException
{
public
List
<
GitlabNote
>
getNotes
(
GitlabMergeRequest
mergeRequest
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
mergeRequest
.
getProjectId
()
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
mergeRequest
.
getProjectId
()
+
+
GitlabMergeRequest
.
URL
+
"/"
+
mergeRequest
.
getId
()
GitlabMergeRequest
.
URL
+
"/"
+
mergeRequest
.
getId
()
+
+
GitlabNote
.
URL
;
GitlabNote
.
URL
;
GitlabNote
[]
notes
=
retrieve
().
to
(
tailUrl
,
GitlabNote
[].
class
);
GitlabNote
[]
notes
=
retrieve
().
to
(
tailUrl
,
GitlabNote
[].
class
);
return
Arrays
.
asList
(
notes
);
return
Arrays
.
asList
(
notes
);
}
}
public
List
<
GitlabNote
>
getAllNotes
(
GitlabMergeRequest
mergeRequest
)
throws
IOException
{
public
List
<
GitlabNote
>
getAllNotes
(
GitlabMergeRequest
mergeRequest
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
mergeRequest
.
getProjectId
()
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
mergeRequest
.
getProjectId
()
+
+
GitlabMergeRequest
.
URL
+
"/"
+
mergeRequest
.
getId
()
GitlabMergeRequest
.
URL
+
"/"
+
mergeRequest
.
getId
()
+
+
GitlabNote
.
URL
;
GitlabNote
.
URL
;
return
retrieve
().
getAll
(
tailUrl
,
GitlabNote
[].
class
);
return
retrieve
().
getAll
(
tailUrl
,
GitlabNote
[].
class
);
}
}
...
@@ -711,8 +687,8 @@ public class GitlabAPI {
...
@@ -711,8 +687,8 @@ public class GitlabAPI {
Query
query
=
new
Query
()
Query
query
=
new
Query
()
.
append
(
"ref_name"
,
mergeRequest
.
getSourceBranch
());
.
append
(
"ref_name"
,
mergeRequest
.
getSourceBranch
());
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
+
"/repository"
+
GitlabCommit
.
URL
+
query
.
toString
();
"/repository"
+
GitlabCommit
.
URL
+
query
.
toString
();
GitlabCommit
[]
commits
=
retrieve
().
to
(
tailUrl
,
GitlabCommit
[].
class
);
GitlabCommit
[]
commits
=
retrieve
().
to
(
tailUrl
,
GitlabCommit
[].
class
);
return
Arrays
.
asList
(
commits
);
return
Arrays
.
asList
(
commits
);
...
@@ -736,8 +712,8 @@ public class GitlabAPI {
...
@@ -736,8 +712,8 @@ public class GitlabAPI {
* Get raw file content
* Get raw file content
*
*
* @param project The Project
* @param project The Project
* @param sha The commit or branch name
* @param sha
The commit or branch name
* @param filepath The path of the file
* @param filepath
The path of the file
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
public
byte
[]
getRawFileContent
(
GitlabProject
project
,
String
sha
,
String
filepath
)
throws
IOException
{
public
byte
[]
getRawFileContent
(
GitlabProject
project
,
String
sha
,
String
filepath
)
throws
IOException
{
...
@@ -752,7 +728,7 @@ public class GitlabAPI {
...
@@ -752,7 +728,7 @@ public class GitlabAPI {
* Get the raw file contents for a blob by blob SHA.
* Get the raw file contents for a blob by blob SHA.
*
*
* @param project The Project
* @param project The Project
* @param sha The commit or branch name
* @param sha
The commit or branch name
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
public
byte
[]
getRawBlobContent
(
GitlabProject
project
,
String
sha
)
throws
IOException
{
public
byte
[]
getRawBlobContent
(
GitlabProject
project
,
String
sha
)
throws
IOException
{
...
@@ -775,10 +751,8 @@ public class GitlabAPI {
...
@@ -775,10 +751,8 @@ public class GitlabAPI {
* Get an archive of the repository
* Get an archive of the repository
*
*
* @param project The Project
* @param project The Project
* @param path The path inside the repository. Used to get content of
* @param path The path inside the repository. Used to get content of subdirectories (optional)
* subdirectories (optional)
* @param ref_name The name of a repository branch or tag or if not given the default branch (optional)
* @param ref_name The name of a repository branch or tag or if not given
* the default branch (optional)
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
public
List
<
GitlabRepositoryTree
>
getRepositoryTree
(
GitlabProject
project
,
String
path
,
String
ref_name
)
throws
IOException
{
public
List
<
GitlabRepositoryTree
>
getRepositoryTree
(
GitlabProject
project
,
String
path
,
String
ref_name
)
throws
IOException
{
...
@@ -789,11 +763,11 @@ public class GitlabAPI {
...
@@ -789,11 +763,11 @@ public class GitlabAPI {
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
"/repository"
+
GitlabRepositoryTree
.
URL
+
query
.
toString
();
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
"/repository"
+
GitlabRepositoryTree
.
URL
+
query
.
toString
();
GitlabRepositoryTree
[]
tree
=
retrieve
().
to
(
tailUrl
,
GitlabRepositoryTree
[].
class
);
GitlabRepositoryTree
[]
tree
=
retrieve
().
to
(
tailUrl
,
GitlabRepositoryTree
[].
class
);
return
Arrays
.
asList
(
tree
);
return
Arrays
.
asList
(
tree
);
}
}
public
GitlabNote
createNote
(
GitlabMergeRequest
mergeRequest
,
String
body
)
throws
IOException
{
public
GitlabNote
createNote
(
GitlabMergeRequest
mergeRequest
,
String
body
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
mergeRequest
.
getProjectId
()
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
mergeRequest
.
getProjectId
()
+
+
GitlabMergeRequest
.
URL
+
"/"
+
mergeRequest
.
getId
()
+
GitlabNote
.
URL
;
GitlabMergeRequest
.
URL
+
"/"
+
mergeRequest
.
getId
()
+
GitlabNote
.
URL
;
return
dispatch
().
with
(
"body"
,
body
).
to
(
tailUrl
,
GitlabNote
.
class
);
return
dispatch
().
with
(
"body"
,
body
).
to
(
tailUrl
,
GitlabNote
.
class
);
}
}
...
@@ -892,7 +866,7 @@ public class GitlabAPI {
...
@@ -892,7 +866,7 @@ public class GitlabAPI {
}
}
public
GitlabIssue
createIssue
(
int
projectId
,
int
assigneeId
,
int
milestoneId
,
String
labels
,
public
GitlabIssue
createIssue
(
int
projectId
,
int
assigneeId
,
int
milestoneId
,
String
labels
,
String
description
,
String
title
)
throws
IOException
{
String
description
,
String
title
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
GitlabIssue
.
URL
;
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
GitlabIssue
.
URL
;
GitlabHTTPRequestor
requestor
=
dispatch
();
GitlabHTTPRequestor
requestor
=
dispatch
();
applyIssue
(
requestor
,
projectId
,
assigneeId
,
milestoneId
,
labels
,
description
,
title
);
applyIssue
(
requestor
,
projectId
,
assigneeId
,
milestoneId
,
labels
,
description
,
title
);
...
@@ -901,7 +875,7 @@ public class GitlabAPI {
...
@@ -901,7 +875,7 @@ public class GitlabAPI {
}
}
public
GitlabIssue
editIssue
(
int
projectId
,
int
issueId
,
int
assigneeId
,
int
milestoneId
,
String
labels
,
public
GitlabIssue
editIssue
(
int
projectId
,
int
issueId
,
int
assigneeId
,
int
milestoneId
,
String
labels
,
String
description
,
String
title
,
GitlabIssue
.
Action
action
)
throws
IOException
{
String
description
,
String
title
,
GitlabIssue
.
Action
action
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
GitlabIssue
.
URL
+
"/"
+
issueId
;
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
GitlabIssue
.
URL
+
"/"
+
issueId
;
GitlabHTTPRequestor
requestor
=
retrieve
().
method
(
"PUT"
);
GitlabHTTPRequestor
requestor
=
retrieve
().
method
(
"PUT"
);
applyIssue
(
requestor
,
projectId
,
assigneeId
,
milestoneId
,
labels
,
description
,
title
);
applyIssue
(
requestor
,
projectId
,
assigneeId
,
milestoneId
,
labels
,
description
,
title
);
...
@@ -914,8 +888,8 @@ public class GitlabAPI {
...
@@ -914,8 +888,8 @@ public class GitlabAPI {
}
}
private
void
applyIssue
(
GitlabHTTPRequestor
requestor
,
int
projectId
,
private
void
applyIssue
(
GitlabHTTPRequestor
requestor
,
int
projectId
,
int
assigneeId
,
int
milestoneId
,
String
labels
,
String
description
,
int
assigneeId
,
int
milestoneId
,
String
labels
,
String
description
,
String
title
)
{
String
title
)
{
requestor
.
with
(
"title"
,
title
)
requestor
.
with
(
"title"
,
title
)
.
with
(
"description"
,
description
)
.
with
(
"description"
,
description
)
...
@@ -955,8 +929,8 @@ public class GitlabAPI {
...
@@ -955,8 +929,8 @@ public class GitlabAPI {
/**
/**
* Add a project member.
* Add a project member.
*
*
* @param project the GitlabProject
* @param project
the GitlabProject
* @param user the GitlabUser
* @param user
the GitlabUser
* @param accessLevel the GitlabAccessLevel
* @param accessLevel the GitlabAccessLevel
* @return the GitlabProjectMember
* @return the GitlabProjectMember
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
...
@@ -968,8 +942,8 @@ public class GitlabAPI {
...
@@ -968,8 +942,8 @@ public class GitlabAPI {
/**
/**
* Add a project member.
* Add a project member.
*
*
* @param projectId the project id
* @param projectId
the project id
* @param userId the user id
* @param userId
the user id
* @param accessLevel the GitlabAccessLevel
* @param accessLevel the GitlabAccessLevel
* @return the GitlabProjectMember
* @return the GitlabProjectMember
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
...
@@ -987,7 +961,7 @@ public class GitlabAPI {
...
@@ -987,7 +961,7 @@ public class GitlabAPI {
* Delete a project team member.
* Delete a project team member.
*
*
* @param project the GitlabProject
* @param project the GitlabProject
* @param user the GitlabUser
* @param user
the GitlabUser
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
public
void
deleteProjectMember
(
GitlabProject
project
,
GitlabUser
user
)
throws
IOException
{
public
void
deleteProjectMember
(
GitlabProject
project
,
GitlabUser
user
)
throws
IOException
{
...
@@ -998,7 +972,7 @@ public class GitlabAPI {
...
@@ -998,7 +972,7 @@ public class GitlabAPI {
* Delete a project team member.
* Delete a project team member.
*
*
* @param projectId the project id
* @param projectId the project id
* @param userId the user id
* @param userId
the user id
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
public
void
deleteProjectMember
(
Integer
projectId
,
Integer
userId
)
throws
IOException
{
public
void
deleteProjectMember
(
Integer
projectId
,
Integer
userId
)
throws
IOException
{
...
@@ -1019,7 +993,7 @@ public class GitlabAPI {
...
@@ -1019,7 +993,7 @@ public class GitlabAPI {
* This will fail, if the given namespace is a user and not a group
* This will fail, if the given namespace is a user and not a group
*
*
* @param namespace The namespace
* @param namespace The namespace
* @return A list of Gitlab Project members
* @return
A list of Gitlab Project members
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
public
List
<
GitlabProjectMember
>
getNamespaceMembers
(
GitlabNamespace
namespace
)
throws
IOException
{
public
List
<
GitlabProjectMember
>
getNamespaceMembers
(
GitlabNamespace
namespace
)
throws
IOException
{
...
@@ -1030,7 +1004,7 @@ public class GitlabAPI {
...
@@ -1030,7 +1004,7 @@ public class GitlabAPI {
* This will fail, if the given namespace is a user and not a group
* This will fail, if the given namespace is a user and not a group
*
*
* @param namespaceId Namespace ID
* @param namespaceId Namespace ID
* @return A list of Gitlab Project members
* @return
A list of Gitlab Project members
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
public
List
<
GitlabProjectMember
>
getNamespaceMembers
(
Integer
namespaceId
)
throws
IOException
{
public
List
<
GitlabProjectMember
>
getNamespaceMembers
(
Integer
namespaceId
)
throws
IOException
{
...
@@ -1042,7 +1016,7 @@ public class GitlabAPI {
...
@@ -1042,7 +1016,7 @@ public class GitlabAPI {
* Transfer a project to the given namespace
* Transfer a project to the given namespace
*
*
* @param namespaceId Namespace ID
* @param namespaceId Namespace ID
* @param projectId Project ID
* @param projectId
Project ID
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
public
void
transfer
(
Integer
namespaceId
,
Integer
projectId
)
throws
IOException
{
public
void
transfer
(
Integer
namespaceId
,
Integer
projectId
)
throws
IOException
{
...
@@ -1054,8 +1028,8 @@ public class GitlabAPI {
...
@@ -1054,8 +1028,8 @@ public class GitlabAPI {
* Create a new deploy key for the project
* Create a new deploy key for the project
*
*
* @param targetProjectId The id of the Gitlab project
* @param targetProjectId The id of the Gitlab project
* @param title The title of the ssh key
* @param title
The title of the ssh key
* @param key The public key
* @param key
The public key
* @return The new GitlabSSHKey
* @return The new GitlabSSHKey
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
...
@@ -1073,7 +1047,7 @@ public class GitlabAPI {
...
@@ -1073,7 +1047,7 @@ public class GitlabAPI {
* Delete a deploy key for a project
* Delete a deploy key for a project
*
*
* @param targetProjectId The id of the Gitlab project
* @param targetProjectId The id of the Gitlab project
* @param targetKeyId The id of the Gitlab ssh key
* @param targetKeyId
The id of the Gitlab ssh key
* @throws IOException on gitlab api call error
* @throws IOException on gitlab api call error
*/
*/
public
void
deleteDeployKey
(
Integer
targetProjectId
,
Integer
targetKeyId
)
throws
IOException
{
public
void
deleteDeployKey
(
Integer
targetProjectId
,
Integer
targetKeyId
)
throws
IOException
{
...
...
src/main/java/org/gitlab/api/TokenType.java
View file @
2341a37b
package
org
.
gitlab
.
api
;
package
org
.
gitlab
.
api
;
public
enum
TokenType
{
public
enum
TokenType
{
PRIVATE_TOKEN
(
"private_token"
),
ACCESS_TOKEN
(
"access_token"
),;
PRIVATE_TOKEN
(
"private_token"
)
,
ACCESS_TOKEN
(
"access_token"
),
;
private
final
String
tokenParamName
;
private
final
String
tokenParamName
;
TokenType
(
String
tokenParamName
)
{
TokenType
(
String
tokenParamName
)
{
this
.
tokenParamName
=
tokenParamName
;
this
.
tokenParamName
=
tokenParamName
;
}
}
public
String
getTokenParamName
()
{
public
String
getTokenParamName
()
{
return
tokenParamName
;
return
tokenParamName
;
}
}
}
}
src/main/java/org/gitlab/api/http/GitlabHTTPRequestor.java
View file @
2341a37b
...
@@ -20,8 +20,8 @@ import java.util.regex.Pattern;
...
@@ -20,8 +20,8 @@ import java.util.regex.Pattern;
import
java.util.zip.GZIPInputStream
;
import
java.util.zip.GZIPInputStream
;
/**
/**
* Gitlab HTTP Requestor
Responsible for handling HTTP requests to the Gitlab
* Gitlab HTTP Requestor
* API
*
Responsible for handling HTTP requests to the Gitlab
API
*
*
* @author @timols (Tim O)
* @author @timols (Tim O)
*/
*/
...
@@ -57,8 +57,8 @@ public class GitlabHTTPRequestor {
...
@@ -57,8 +57,8 @@ public class GitlabHTTPRequestor {
}
}
/**
/**
* Sets the HTTP Request method for the request.
Has a fluent api for method
* Sets the HTTP Request method for the request.
* chaining.
*
Has a fluent api for method
chaining.
*
*
* @param method The HTTP method
* @param method The HTTP method
* @return this
* @return this
...
@@ -74,11 +74,11 @@ public class GitlabHTTPRequestor {
...
@@ -74,11 +74,11 @@ public class GitlabHTTPRequestor {
}
}
/**
/**
* Sets the HTTP Form Post parameters for the request
Has a fluent api for
* Sets the HTTP Form Post parameters for the request
* method chaining
*
Has a fluent api for
method chaining
*
*
* @param key Form parameter Key
* @param key
Form parameter Key
* @param value Form parameter Value
* @param value
Form parameter Value
* @return this
* @return this
*/
*/
public
GitlabHTTPRequestor
with
(
String
key
,
Object
value
)
{
public
GitlabHTTPRequestor
with
(
String
key
,
Object
value
)
{
...
@@ -100,11 +100,10 @@ public class GitlabHTTPRequestor {
...
@@ -100,11 +100,10 @@ public class GitlabHTTPRequestor {
* Opens the HTTP(S) connection, submits any data and parses the response.
* Opens the HTTP(S) connection, submits any data and parses the response.
* Will throw an error
* Will throw an error
*
*
* @param <T> The return type of the method
* @param <T> The return type of the method
* @param tailAPIUrl The url to open a connection to (after the host and
* @param tailAPIUrl The url to open a connection to (after the host and namespace)
* namespace)
* @param type The type of the response to be deserialized from
* @param type The type of the response to be deserialized from
* @param instance The instance to update from the response
* @param instance The instance to update from the response
* @return An object of type T
* @return An object of type T
* @throws java.io.IOException on gitlab api error
* @throws java.io.IOException on gitlab api error
*/
*/
...
@@ -114,7 +113,7 @@ public class GitlabHTTPRequestor {
...
@@ -114,7 +113,7 @@ public class GitlabHTTPRequestor {
connection
=
setupConnection
(
root
.
getAPIUrl
(
tailAPIUrl
));
connection
=
setupConnection
(
root
.
getAPIUrl
(
tailAPIUrl
));
if
(
hasOutput
())
{
if
(
hasOutput
())
{
submitData
(
connection
);
submitData
(
connection
);
}
else
if
(
"PUT"
.
equals
(
method
))
{
}
else
if
(
"PUT"
.
equals
(
method
))
{
// PUT requires Content-Length: 0 even when there is no body (eg: API for protecting a branch)
// PUT requires Content-Length: 0 even when there is no body (eg: API for protecting a branch)
connection
.
setDoOutput
(
true
);
connection
.
setDoOutput
(
true
);
...
@@ -232,15 +231,17 @@ public class GitlabHTTPRequestor {
...
@@ -232,15 +231,17 @@ public class GitlabHTTPRequestor {
if
(
matcher
.
find
())
{
if
(
matcher
.
find
())
{
Integer
page
=
Integer
.
parseInt
(
matcher
.
group
(
2
))
+
1
;
Integer
page
=
Integer
.
parseInt
(
matcher
.
group
(
2
))
+
1
;
this
.
url
=
new
URL
(
matcher
.
replaceAll
(
matcher
.
group
(
1
)
+
"page="
+
page
));
this
.
url
=
new
URL
(
matcher
.
replaceAll
(
matcher
.
group
(
1
)
+
"page="
+
page
));
}
else
if
(
GitlabCommit
[].
class
==
type
)
{
// there is a bug in the Gitlab CE API
// (https://gitlab.com/gitlab-org/gitlab-ce/issues/759)
// that starts pagination with page=0 for commits
this
.
url
=
new
URL
(
url
+
"&page=1"
);
}
else
{
}
else
{
// Since the page query was not present, its safe to assume that we just
if
(
GitlabCommit
[].
class
==
type
)
{
// currently used the first page, so we can default to page 2
// there is a bug in the Gitlab CE API
this
.
url
=
new
URL
(
url
+
"&page=2"
);
// (https://gitlab.com/gitlab-org/gitlab-ce/issues/759)
// that starts pagination with page=0 for commits
this
.
url
=
new
URL
(
url
+
"&page=1"
);
}
else
{
// Since the page query was not present, its safe to assume that we just
// currently used the first page, so we can default to page 2
this
.
url
=
new
URL
(
url
+
"&page=2"
);
}
}
}
}
}
};
};
...
@@ -285,7 +286,7 @@ public class GitlabHTTPRequestor {
...
@@ -285,7 +286,7 @@ public class GitlabHTTPRequestor {
try
{
try
{
reader
=
new
InputStreamReader
(
wrapStream
(
connection
,
connection
.
getInputStream
()),
"UTF-8"
);
reader
=
new
InputStreamReader
(
wrapStream
(
connection
,
connection
.
getInputStream
()),
"UTF-8"
);
if
(
byte
[].
class
==
type
)
{
if
(
byte
[].
class
==
type
)
{
return
type
.
cast
(
IOUtils
.
toByteArray
(
reader
));
return
type
.
cast
(
IOUtils
.
toByteArray
(
reader
));
}
}
String
data
=
IOUtils
.
toString
(
reader
);
String
data
=
IOUtils
.
toString
(
reader
);
if
(
type
!=
null
)
{
if
(
type
!=
null
)
{
...
@@ -333,19 +334,19 @@ public class GitlabHTTPRequestor {
...
@@ -333,19 +334,19 @@ public class GitlabHTTPRequestor {
private
void
ignoreCertificateErrors
()
{
private
void
ignoreCertificateErrors
()
{
TrustManager
[]
trustAllCerts
=
new
TrustManager
[]{
TrustManager
[]
trustAllCerts
=
new
TrustManager
[]{
new
X509TrustManager
()
{
new
X509TrustManager
()
{
public
java
.
security
.
cert
.
X509Certificate
[]
getAcceptedIssuers
()
{
public
java
.
security
.
cert
.
X509Certificate
[]
getAcceptedIssuers
()
{
return
null
;
return
null
;
}
}
public
void
checkClientTrusted
(
public
void
checkClientTrusted
(
java
.
security
.
cert
.
X509Certificate
[]
certs
,
String
authType
)
{
java
.
security
.
cert
.
X509Certificate
[]
certs
,
String
authType
)
{
}
}
public
void
checkServerTrusted
(
public
void
checkServerTrusted
(
java
.
security
.
cert
.
X509Certificate
[]
certs
,
String
authType
)
{
java
.
security
.
cert
.
X509Certificate
[]
certs
,
String
authType
)
{
}
}
}
}
};
};
// Added per https://github.com/timols/java-gitlab-api/issues/44
// Added per https://github.com/timols/java-gitlab-api/issues/44
HostnameVerifier
nullVerifier
=
new
HostnameVerifier
()
{
HostnameVerifier
nullVerifier
=
new
HostnameVerifier
()
{
...
...
src/main/java/org/gitlab/api/http/Query.java
View file @
2341a37b
...
@@ -8,12 +8,12 @@ import java.util.ArrayList;
...
@@ -8,12 +8,12 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
/**
/**
* Models the Query aspect of a URL
* Models the Query
* aspect of a URL
*/
*/
public
class
Query
{
public
class
Query
{
private
class
Tuple
<
T1
,
T2
>
{
private
class
Tuple
<
T1
,
T2
>
{
T1
_1
;
T1
_1
;
T2
_2
;
T2
_2
;
...
@@ -24,19 +24,18 @@ public class Query {
...
@@ -24,19 +24,18 @@ public class Query {
}
}
/**
/**
* The type of params is:
Tuple<name,
* The type of params is:
* Tuple<value, URLEncoder.encode(value, "UTF-8")>>
* Tuple<
name, Tuple<
value, URLEncoder.encode(value, "UTF-8")>>
*/
*/
private
final
List
<
Tuple
<
String
,
Tuple
<
String
,
String
>>>
params
=
new
ArrayList
<
Tuple
<
String
,
Tuple
<
String
,
String
>>>();
private
final
List
<
Tuple
<
String
,
Tuple
<
String
,
String
>>>
params
=
new
ArrayList
<
Tuple
<
String
,
Tuple
<
String
,
String
>>>();
/**
/**
* Appends a parameter to the query
* Appends a parameter to the query
*
*
* @param name Parameter name
* @param name
Parameter name
* @param value Parameter value
* @param value Parameter value
* @return this
* @return this
* @throws java.io.UnsupportedEncodingException If the provided value cannot
* @throws java.io.UnsupportedEncodingException If the provided value cannot be URL Encoded
* be URL Encoded
*/
*/
public
Query
append
(
final
String
name
,
final
String
value
)
throws
UnsupportedEncodingException
{
public
Query
append
(
final
String
name
,
final
String
value
)
throws
UnsupportedEncodingException
{
params
.
add
(
new
Tuple
<
String
,
Tuple
<
String
,
String
>>(
name
,
new
Tuple
<
String
,
String
>(
value
,
URLEncoder
.
encode
(
value
,
"UTF-8"
))));
params
.
add
(
new
Tuple
<
String
,
Tuple
<
String
,
String
>>(
name
,
new
Tuple
<
String
,
String
>(
value
,
URLEncoder
.
encode
(
value
,
"UTF-8"
))));
...
@@ -44,14 +43,13 @@ public class Query {
...
@@ -44,14 +43,13 @@ public class Query {
}
}
/**
/**
* Conditionally append a parameter to the query
if the value of the
* Conditionally append a parameter to the query
* parameter is not null
*
if the value of the
parameter is not null
*
*
* @param name Parameter name
* @param name
Parameter name
* @param value Parameter value
* @param value Parameter value
* @return this
* @return this
* @throws java.io.UnsupportedEncodingException If the provided value cannot
* @throws java.io.UnsupportedEncodingException If the provided value cannot be URL Encoded
* be URL Encoded
*/
*/
public
Query
appendIf
(
final
String
name
,
final
String
value
)
throws
UnsupportedEncodingException
{
public
Query
appendIf
(
final
String
name
,
final
String
value
)
throws
UnsupportedEncodingException
{
if
(
value
!=
null
)
{
if
(
value
!=
null
)
{
...
@@ -61,14 +59,13 @@ public class Query {
...
@@ -61,14 +59,13 @@ public class Query {
}
}
/**
/**
* Conditionally append a parameter to the query
if the value of the
* Conditionally append a parameter to the query
* parameter is not null
*
if the value of the
parameter is not null
*
*
* @param name Parameter name
* @param name
Parameter name
* @param value Parameter value
* @param value Parameter value
* @return this
* @return this
* @throws java.io.UnsupportedEncodingException If the provided value cannot
* @throws java.io.UnsupportedEncodingException If the provided value cannot be URL Encoded
* be URL Encoded
*/
*/
public
Query
appendIf
(
final
String
name
,
final
Integer
value
)
throws
UnsupportedEncodingException
{
public
Query
appendIf
(
final
String
name
,
final
Integer
value
)
throws
UnsupportedEncodingException
{
if
(
value
!=
null
)
{
if
(
value
!=
null
)
{
...
@@ -78,14 +75,13 @@ public class Query {
...
@@ -78,14 +75,13 @@ public class Query {
}
}
/**
/**
* Conditionally append a parameter to the query
if the value of the
* Conditionally append a parameter to the query
* parameter is not null
*
if the value of the
parameter is not null
*
*
* @param name Parameter name
* @param name
Parameter name
* @param value Parameter value
* @param value Parameter value
* @return this
* @return this
* @throws java.io.UnsupportedEncodingException If the provided value cannot
* @throws java.io.UnsupportedEncodingException If the provided value cannot be URL Encoded
* be URL Encoded
*/
*/
public
Query
appendIf
(
final
String
name
,
final
Boolean
value
)
throws
UnsupportedEncodingException
{
public
Query
appendIf
(
final
String
name
,
final
Boolean
value
)
throws
UnsupportedEncodingException
{
if
(
value
!=
null
)
{
if
(
value
!=
null
)
{
...
@@ -95,14 +91,13 @@ public class Query {
...
@@ -95,14 +91,13 @@ public class Query {
}
}
/**
/**
* Conditionally append a parameter to the query
if the value of the
* Conditionally append a parameter to the query
* parameter is not null
*
if the value of the
parameter is not null
*
*
* @param name Parameter name
* @param name
Parameter name
* @param value Parameter value
* @param value Parameter value
* @return this
* @return this
* @throws java.io.UnsupportedEncodingException If the provided value cannot
* @throws java.io.UnsupportedEncodingException If the provided value cannot be URL Encoded
* be URL Encoded
*/
*/
public
Query
appendIf
(
final
String
name
,
final
GitlabAccessLevel
value
)
throws
UnsupportedEncodingException
{
public
Query
appendIf
(
final
String
name
,
final
GitlabAccessLevel
value
)
throws
UnsupportedEncodingException
{
if
(
value
!=
null
)
{
if
(
value
!=
null
)
{
...
@@ -112,7 +107,8 @@ public class Query {
...
@@ -112,7 +107,8 @@ public class Query {
}
}
/**
/**
* Returns a Query suitable for appending to a URI
* Returns a Query suitable for appending
* to a URI
*/
*/
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
...
...
src/main/java/org/gitlab/api/models/GitlabBranch.java
View file @
2341a37b
...
@@ -3,7 +3,6 @@ package org.gitlab.api.models;
...
@@ -3,7 +3,6 @@ package org.gitlab.api.models;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
public
class
GitlabBranch
{
public
class
GitlabBranch
{
public
final
static
String
URL
=
"/repository/branches/"
;
public
final
static
String
URL
=
"/repository/branches/"
;
@JsonProperty
(
"name"
)
@JsonProperty
(
"name"
)
...
...
src/main/java/org/gitlab/api/models/GitlabBranchCommit.java
View file @
2341a37b
...
@@ -5,7 +5,6 @@ import java.util.Date;
...
@@ -5,7 +5,6 @@ import java.util.Date;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
public
class
GitlabBranchCommit
{
public
class
GitlabBranchCommit
{
public
static
String
URL
=
"/users"
;
public
static
String
URL
=
"/users"
;
private
String
id
;
private
String
id
;
...
...
src/main/java/org/gitlab/api/models/GitlabMergeRequest.java
View file @
2341a37b
...
@@ -5,7 +5,6 @@ import java.util.Date;
...
@@ -5,7 +5,6 @@ import java.util.Date;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
public
class
GitlabMergeRequest
{
public
class
GitlabMergeRequest
{
public
static
final
String
URL
=
"/merge_requests"
;
public
static
final
String
URL
=
"/merge_requests"
;
private
Integer
id
;
private
Integer
id
;
...
...
src/main/java/org/gitlab/api/models/GitlabNamespace.java
View file @
2341a37b
...
@@ -5,7 +5,6 @@ import java.util.Date;
...
@@ -5,7 +5,6 @@ import java.util.Date;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
public
class
GitlabNamespace
{
public
class
GitlabNamespace
{
public
static
final
String
URL
=
"/groups"
;
public
static
final
String
URL
=
"/groups"
;
private
Integer
id
;
private
Integer
id
;
...
...
src/main/java/org/gitlab/api/models/GitlabProjectAccessLevel.java
View file @
2341a37b
...
@@ -10,6 +10,7 @@ public class GitlabProjectAccessLevel {
...
@@ -10,6 +10,7 @@ public class GitlabProjectAccessLevel {
@JsonProperty
(
"notification_level"
)
@JsonProperty
(
"notification_level"
)
private
int
notificationLevel
;
private
int
notificationLevel
;
public
GitlabAccessLevel
getAccessLevel
()
{
public
GitlabAccessLevel
getAccessLevel
()
{
return
GitlabAccessLevel
.
fromAccessValue
(
accessLevel
);
return
GitlabAccessLevel
.
fromAccessValue
(
accessLevel
);
}
}
...
@@ -18,6 +19,7 @@ public class GitlabProjectAccessLevel {
...
@@ -18,6 +19,7 @@ public class GitlabProjectAccessLevel {
this
.
accessLevel
=
accessLevel
.
accessValue
;
this
.
accessLevel
=
accessLevel
.
accessValue
;
}
}
public
int
getNoficationLevel
()
{
public
int
getNoficationLevel
()
{
return
notificationLevel
;
return
notificationLevel
;
}
}
...
@@ -26,4 +28,5 @@ public class GitlabProjectAccessLevel {
...
@@ -26,4 +28,5 @@ public class GitlabProjectAccessLevel {
this
.
accessLevel
=
notificationLevel
;
this
.
accessLevel
=
notificationLevel
;
}
}
}
}
src/main/java/org/gitlab/api/models/GitlabRepositoryTree.java
View file @
2341a37b
package
org
.
gitlab
.
api
.
models
;
package
org
.
gitlab
.
api
.
models
;
public
class
GitlabRepositoryTree
{
public
class
GitlabRepositoryTree
{
public
static
String
URL
=
"/tree"
;
public
static
String
URL
=
"/tree"
;
private
String
name
;
private
String
type
;
private
String
mode
;
private
String
id
;
private
String
name
;
public
String
getName
()
{
private
String
type
;
return
name
;
private
String
mode
;
}
private
String
id
;
public
String
getName
(
)
{
public
void
setName
(
String
name
)
{
return
name
;
this
.
name
=
name
;
}
}
public
void
setName
(
String
name
)
{
public
String
getType
(
)
{
this
.
name
=
nam
e
;
return
typ
e
;
}
}
public
String
getType
(
)
{
public
void
setType
(
String
type
)
{
return
type
;
this
.
type
=
type
;
}
}
public
void
setType
(
String
type
)
{
public
String
getMode
(
)
{
this
.
type
=
typ
e
;
return
mod
e
;
}
}
public
String
getMode
(
)
{
public
void
setMode
(
String
mode
)
{
return
mode
;
this
.
mode
=
mode
;
}
}
public
void
setMode
(
String
mode
)
{
public
String
getId
(
)
{
this
.
mode
=
mode
;
return
id
;
}
}
public
String
getId
()
{
public
void
setId
(
String
id
)
{
return
id
;
this
.
id
=
id
;
}
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
}
}
src/main/java/org/gitlab/api/models/GitlabSSHKey.java
View file @
2341a37b
package
org
.
gitlab
.
api
.
models
;
package
org
.
gitlab
.
api
.
models
;
public
class
GitlabSSHKey
{
public
class
GitlabSSHKey
{
public
static
String
KEYS_URL
=
"/keys"
;
public
static
String
KEYS_URL
=
"/keys"
;
private
Integer
_id
;
private
Integer
_id
;
...
...
src/main/java/org/gitlab/api/models/GitlabUser.java
View file @
2341a37b
...
@@ -5,7 +5,6 @@ import java.util.Date;
...
@@ -5,7 +5,6 @@ import java.util.Date;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
public
class
GitlabUser
{
public
class
GitlabUser
{
public
static
String
URL
=
"/users"
;
public
static
String
URL
=
"/users"
;
public
static
String
USERS_URL
=
"/users"
;
public
static
String
USERS_URL
=
"/users"
;
public
static
String
USER_URL
=
"/user"
;
// for sudo based ops
public
static
String
USER_URL
=
"/user"
;
// for sudo based ops
...
...
src/test/java/org/gitlab/api/GitlabAPIT.java
View file @
2341a37b
...
@@ -24,6 +24,7 @@ public class GitlabAPIT {
...
@@ -24,6 +24,7 @@ public class GitlabAPIT {
String
rand
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
).
substring
(
0
,
8
);
String
rand
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
).
substring
(
0
,
8
);
@Before
@Before
public
void
setup
()
throws
IOException
{
public
void
setup
()
throws
IOException
{
api
=
GitlabAPI
.
connect
(
TEST_URL
,
TEST_TOKEN
);
api
=
GitlabAPI
.
connect
(
TEST_URL
,
TEST_TOKEN
);
...
@@ -61,6 +62,7 @@ public class GitlabAPIT {
...
@@ -61,6 +62,7 @@ public class GitlabAPIT {
String
password
=
randVal
(
"$%password"
);
String
password
=
randVal
(
"$%password"
);
GitlabUser
gitUser
=
api
.
createUser
(
randVal
(
"testEmail@gitlabapitest.com"
),
GitlabUser
gitUser
=
api
.
createUser
(
randVal
(
"testEmail@gitlabapitest.com"
),
password
,
password
,
randVal
(
"userName"
),
randVal
(
"userName"
),
...
@@ -89,11 +91,14 @@ public class GitlabAPIT {
...
@@ -89,11 +91,14 @@ public class GitlabAPIT {
10
/* project limit does not come back on GET */
,
gitUser
.
getExternUid
(),
gitUser
.
getExternProviderName
(),
10
/* project limit does not come back on GET */
,
gitUser
.
getExternUid
(),
gitUser
.
getExternProviderName
(),
gitUser
.
getBio
(),
gitUser
.
isAdmin
(),
gitUser
.
isCanCreateGroup
());
gitUser
.
getBio
(),
gitUser
.
isAdmin
(),
gitUser
.
isCanCreateGroup
());
GitlabUser
postUpdate
=
api
.
getUserViaSudo
(
gitUser
.
getUsername
());
GitlabUser
postUpdate
=
api
.
getUserViaSudo
(
gitUser
.
getUsername
());
assertNotNull
(
postUpdate
);
assertNotNull
(
postUpdate
);
assertEquals
(
postUpdate
.
getSkype
(),
"newSkypeId"
);
assertEquals
(
postUpdate
.
getSkype
(),
"newSkypeId"
);
api
.
deleteUser
(
postUpdate
.
getId
());
api
.
deleteUser
(
postUpdate
.
getId
());
// expect a 404, but we have no access to it
// expect a 404, but we have no access to it
...
@@ -104,6 +109,7 @@ public class GitlabAPIT {
...
@@ -104,6 +109,7 @@ public class GitlabAPIT {
assertTrue
(
true
);
// expected
assertTrue
(
true
);
// expected
}
}
}
}
private
String
randVal
(
String
postfix
)
{
private
String
randVal
(
String
postfix
)
{
...
...
src/test/java/org/gitlab/api/http/QueryTest.java
View file @
2341a37b
...
@@ -32,6 +32,7 @@ public class QueryTest {
...
@@ -32,6 +32,7 @@ public class QueryTest {
Query
query
=
new
Query
()
Query
query
=
new
Query
()
.
append
(
"p1"
,
"v1"
);
.
append
(
"p1"
,
"v1"
);
query
.
append
(
"p2"
,
"v2"
);
query
.
append
(
"p2"
,
"v2"
);
query
=
query
.
append
(
"p3"
,
"v3"
);
query
=
query
.
append
(
"p3"
,
"v3"
);
...
...
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