Commit 43744140 authored by Greg Messner's avatar Greg Messner
Browse files

Updated title.

parent 8ba7f8c9
GitlLab API for Java (gitlab4j-api) # GitlLab4J&trade; API (gitlab4j-api)<br />Java Client Library for the GitLab REST API
===================================
[![Maven Central](https://img.shields.io/maven-central/v/org.gitlab4j/gitlab4j-api.svg)](http://mvnrepository.com/artifact/org.gitlab4j/gitlab4j-api) [![Maven Central](https://img.shields.io/maven-central/v/org.gitlab4j/gitlab4j-api.svg)](http://mvnrepository.com/artifact/org.gitlab4j/gitlab4j-api)
GitLab API for Java (gitlab4j-api) provides a full featured and easy to consume Java API for working with GitLab repositories via the GitLab REST API. Additionally, full support for working with GitLab webhooks and system hooks is also provided. GitLab4J&trade; API (gitlab4j-api) provides a full featured and easy to consume Java library for working with GitLab repositories via the GitLab REST API. Additionally, full support for working with GitLab webhooks and system hooks is also provided.
--- ---
To utilize the GitLab API for Java in your project, simply add the following dependency to your project's build file: To utilize GitLab4J&trade; API in your Java project, simply add the following dependency to your project's build file:<br />
**Gradle: build.gradle**
**Gradle: build.gradle** ```java
```java dependencies {
dependencies { ...
... compile group: 'org.gitlab4j', name: 'gitlab4j-api', version: '4.10.9'
compile group: 'org.gitlab4j', name: 'gitlab4j-api', version: '4.10.9' }
} ```
```
**NOTE:** Pulling dependencies may fail when using Gradle prior to 4.5. See [Gradle issue 3065](https://github.com/gradle/gradle/issues/3065#issuecomment-364092456)
**NOTE:** Pulling dependencies may fail when using Gradle prior to 4.5. See [Gradle issue 3065](https://github.com/gradle/gradle/issues/3065#issuecomment-364092456)
**Maven: pom.xml**
**Maven: pom.xml** ```xml
```xml <dependency>
<dependency> <groupId>org.gitlab4j</groupId>
<groupId>org.gitlab4j</groupId> <artifactId>gitlab4j-api</artifactId>
<artifactId>gitlab4j-api</artifactId> <version>4.10.9</version>
<version>4.10.9</version> </dependency>
</dependency> ```
```
**Ivy and SBT**<br/>
**Ivy and SBT**<br/> There have been reports of problems resolving some dependencies when using Ivy or SBT, for help resolving those issues see:<br/>
There have been reports of problems resolving some dependencies when using Ivy or SBT, for help resolving those issues see:<br/> <a href="https://github.com/eclipse-ee4j/jaxrs-api/issues/571">JAX-RS API Issue #571</a><br/>
<a href="https://github.com/eclipse-ee4j/jaxrs-api/issues/571">JAX-RS API Issue #571</a><br/> <a href="https://github.com/eclipse-ee4j/jaxrs-api/issues/572">JAX-RS API Issue #572</a>
<a href="https://github.com/eclipse-ee4j/jaxrs-api/issues/572">JAX-RS API Issue #572</a>
---
---
## Javadocs
## Javadocs Javadocs are available here: <a href="http://www.messners.com/gitlab4j-api/javadocs/index.html?overview-summary.html" target="_top">Javadocs</a>
Javadocs are available here: <a href="http://www.messners.com/gitlab4j-api/javadocs/index.html?overview-summary.html" target="_top">Javadocs</a>
---
---
## Java 8 Requirement
## Java 8 Requirement As of GitLab4J-API 4.8.0, Java 8+ is now required to use GitLab4J-API.
As of GitLab4J-API 4.8.0, Java 8+ is now required to use GitLab4J-API.
---
---
## Using GitLab4J
## Using GitLab4J
GitLab4J-API is quite simple to use, all you need is the URL to your GitLab server and the Private Token from your GitLab Account Settings page. Once you have that info it is as simple as:
GitLab4J-API is quite simple to use, all you need is the URL to your GitLab server and the Private Token from your GitLab Account Settings page. Once you have that info it is as simple as: ```java
```java // Create a GitLabApi instance to communicate with your GitLab server
// Create a GitLabApi instance to communicate with your GitLab server GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.server.com", "YOUR_PRIVATE_TOKEN");
GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.server.com", "YOUR_PRIVATE_TOKEN");
// Get the list of projects your account has access to
// Get the list of projects your account has access to List<Project> projects = gitLabApi.getProjectApi().getProjects();
List<Project> projects = gitLabApi.getProjectApi().getProjects(); ```
```
You can also login to your GitLab server with username, and password:
You can also login to your GitLab server with username, and password: ```java
```java // Log in to the GitLab server using a username and password
// Log in to the GitLab server using a username and password GitLabApi gitLabApi = GitLabApi.login("http://your.gitlab.server.com", "your-username", "your-password");
GitLabApi gitLabApi = GitLabApi.login("http://your.gitlab.server.com", "your-username", "your-password"); ```
``` As of GitLab4J-API 4.6.6, all API requests support performing the API call as if you were another user, provided you are authenticated as an administrator:
As of GitLab4J-API 4.6.6, all API requests support performing the API call as if you were another user, provided you are authenticated as an administrator: ```java
```java // Create a GitLabApi instance to communicate with your GitLab server (must be an administrator)
// Create a GitLabApi instance to communicate with your GitLab server (must be an administrator) GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.server.com", "YOUR_PRIVATE_TOKEN");
GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.server.com", "YOUR_PRIVATE_TOKEN");
// sudo as as a different user, in this case the user named "johndoe", all future calls will be done as "johndoe"
// sudo as as a different user, in this case the user named "johndoe", all future calls will be done as "johndoe" gitLabApi.sudo("johndoe")
gitLabApi.sudo("johndoe")
// To turn off sudo mode
// To turn off sudo mode gitLabApi.unsudo();
gitLabApi.unsudo(); ```
```
---
--- ## Connecting Through a Proxy Server
## Connecting Through a Proxy Server As of GitLab4J-API 4.8.2 support has been added for connecting to the GitLab server using an HTTP proxy server:
As of GitLab4J-API 4.8.2 support has been added for connecting to the GitLab server using an HTTP proxy server: ```java
```java // Log in to the GitLab server using a proxy server (with basic auth on proxy)
// Log in to the GitLab server using a proxy server (with basic auth on proxy) Map<String, Object> proxyConfig = ProxyClientConfig.createProxyClientConfig(
Map<String, Object> proxyConfig = ProxyClientConfig.createProxyClientConfig( "http://your-proxy-server", "proxy-username", "proxy-password");
"http://your-proxy-server", "proxy-username", "proxy-password"); GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.com", "YOUR_PRIVATE_TOKEN", null, proxyConfig);
GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.com", "YOUR_PRIVATE_TOKEN", null, proxyConfig);
// Log in to the GitLab server using a proxy server (no auth on proxy)
// Log in to the GitLab server using a proxy server (no auth on proxy) Map<String, Object> proxyConfig = ProxyClientConfig.createProxyClientConfig("http://your-proxy-server");
Map<String, Object> proxyConfig = ProxyClientConfig.createProxyClientConfig("http://your-proxy-server"); GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.com", "YOUR_PRIVATE_TOKEN", null, proxyConfig);
GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.com", "YOUR_PRIVATE_TOKEN", null, proxyConfig); ```
``` See the Javadoc on the GitLabApi class for a complete list of methods accepting the proxy configuration (clientConfiguration parameter)
See the Javadoc on the GitLabApi class for a complete list of methods accepting the proxy configuration (clientConfiguration parameter)
---
--- ## GitLab API V3 and V4 Support
## GitLab API V3 and V4 Support As of GitLab4J-API 4.2.0 support has been added for GitLab API V4. If your application requires GitLab API V3,
As of GitLab4J-API 4.2.0 support has been added for GitLab API V4. If your application requires GitLab API V3, you can still use GitLab4J-API by creating your GitLabApi instance as follows:
you can still use GitLab4J-API by creating your GitLabApi instance as follows: ```java
```java // Create a GitLabApi instance to communicate with your GitLab server using GitLab API V3
// Create a GitLabApi instance to communicate with your GitLab server using GitLab API V3 GitLabApi gitLabApi = new GitLabApi(ApiVersion.V3, "http://your.gitlab.server.com", "YOUR_PRIVATE_TOKEN");
GitLabApi gitLabApi = new GitLabApi(ApiVersion.V3, "http://your.gitlab.server.com", "YOUR_PRIVATE_TOKEN"); ```
```
**NOTICE**:
**NOTICE**: As of GitLab 11.0 support for the GitLab API v3 has been removed (see https://about.gitlab.com/2018/06/01/api-v3-removal-impending/). Support for GitLab API v3 will be removed from this library in January 2019. If you are utilizing the v3 support, please update your code before January 2019.
As of GitLab 11.0 support for the GitLab API v3 has been removed (see https://about.gitlab.com/2018/06/01/api-v3-removal-impending/). Support for GitLab API v3 will be removed from this library in January 2019. If you are utilizing the v3 support, please update your code before January 2019.
---
--- ## Logging of API Requests and Responses
## Logging of API Requests and Responses As of GitLab4J-API 4.8.39 support has been added to log the requests to and the responses from the
As of GitLab4J-API 4.8.39 support has been added to log the requests to and the responses from the GitLab API. Enable logging using one of the following methods on the GitLabApi instance:
GitLab API. Enable logging using one of the following methods on the GitLabApi instance: ```java
```java GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.server.com", "YOUR_PRIVATE_TOKEN");
GitLabApi gitLabApi = new GitLabApi("http://your.gitlab.server.com", "YOUR_PRIVATE_TOKEN");
// Log using the shared logger and default level of FINE
// Log using the shared logger and default level of FINE gitLabApi.enableRequestResponseLogging();
gitLabApi.enableRequestResponseLogging();
// Log using the shared logger and the INFO level
// Log using the shared logger and the INFO level gitLabApi.enableRequestResponseLogging(java.util.logging.Level.INFO);
gitLabApi.enableRequestResponseLogging(java.util.logging.Level.INFO);
// Log using the specified logger and the INFO level
// Log using the specified logger and the INFO level gitLabApi.enableRequestResponseLogging(youtLoggerInstance, java.util.logging.Level.INFO);
gitLabApi.enableRequestResponseLogging(youtLoggerInstance, java.util.logging.Level.INFO);
// Log using the shared logger, at the INFO level, and include up to 1024 bytes of entity logging
// Log using the shared logger, at the INFO level, and include up to 1024 bytes of entity logging gitLabApi.enableRequestResponseLogging(java.util.logging.Level.INFO, 1024);
gitLabApi.enableRequestResponseLogging(java.util.logging.Level.INFO, 1024);
// Log using the specified logger, at the INFO level, and up to 1024 bytes of entity logging
// Log using the specified logger, at the INFO level, and up to 1024 bytes of entity logging gitLabApi.enableRequestResponseLogging(youtLoggerInstance, java.util.logging.Level.INFO, 1024);
gitLabApi.enableRequestResponseLogging(youtLoggerInstance, java.util.logging.Level.INFO, 1024); ```
```
---
--- ## Results Paging
## Results Paging GitLab4J-API provides an easy to use paging mechanism to page through lists of results from the GitLab API.
GitLab4J-API provides an easy to use paging mechanism to page through lists of results from the GitLab API. Here are a couple of examples on how to use the Pager:
Here are a couple of examples on how to use the Pager: ```java
```java // Get a Pager instance that will page through the projects with 10 projects per page
// Get a Pager instance that will page through the projects with 10 projects per page Pager<Project> projectPager = gitlabApi.getProjectsApi().getProjects(10);
Pager<Project> projectPager = gitlabApi.getProjectsApi().getProjects(10);
// Iterate through the pages and print out the name and description
// Iterate through the pages and print out the name and description while (projectsPager.hasNext())) {
while (projectsPager.hasNext())) { for (Project project : projectPager.next()) {
for (Project project : projectPager.next()) { System.out.println(project.getName() + " -: " + project.getDescription());
System.out.println(project.getName() + " -: " + project.getDescription()); }
} }
} ```
```
As of GitLab4J-API 4.9.2, you can also fetch all the items as a single list using a Pager instance:
As of GitLab4J-API 4.9.2, you can also fetch all the items as a single list using a Pager instance: ```java
```java // Get a Pager instance so we can load all the projects into a single list, 10 items at a time:
// Get a Pager instance so we can load all the projects into a single list, 10 items at a time: Pager<Project> projectPager = gitlabApi.getProjectsApi().getProjects(10);
Pager<Project> projectPager = gitlabApi.getProjectsApi().getProjects(10); List<Project> allProjects = projectPager.all();
List<Project> allProjects = projectPager.all(); ```
```
---
--- ## Java 8 Stream Support
## Java 8 Stream Support As of GitLab4J-API 4.9.2, all GitLabJ-API methods that return a List result have a similarlly named method that returns a Java 8 Stream. The Stream returning methods use the following naming convention: ```getXxxxxStream()```.
As of GitLab4J-API 4.9.2, all GitLabJ-API methods that return a List result have a similarlly named method that returns a Java 8 Stream. The Stream returning methods use the following naming convention: ```getXxxxxStream()```.
**IMPORTANT**
**IMPORTANT** The built-in methods that return a Stream do so using ___eager evaluation___, meaning all items are pre-fetched from the GitLab server and a Stream is returned which will stream those items. **Eager evaluation does NOT support paralell reading of data from ther server, it does however allow for paralell processing of the Stream post data fetch.**
The built-in methods that return a Stream do so using ___eager evaluation___, meaning all items are pre-fetched from the GitLab server and a Stream is returned which will stream those items. **Eager evaluation does NOT support paralell reading of data from ther server, it does however allow for paralell processing of the Stream post data fetch.**
To stream using ___lazy evaluation___, use the GitLab4J-API methods that return a ```Pager``` instance, and then call the ```lazyStream()``` method on the ```Pager``` instance to create a lazy evaluation Stream. The Stream utilizes the ```Pager``` instance to page through the available items. **A lazy Stream does NOT support parallel operations or skipping.**
To stream using ___lazy evaluation___, use the GitLab4J-API methods that return a ```Pager``` instance, and then call the ```lazyStream()``` method on the ```Pager``` instance to create a lazy evaluation Stream. The Stream utilizes the ```Pager``` instance to page through the available items. **A lazy Stream does NOT support parallel operations or skipping.**
**Eager evaluation example usage:**
**Eager evaluation example usage:**
```java
```java // Stream the visible projects printing out the project name.
// Stream the visible projects printing out the project name. Stream<Project> projectStream = gitlabApi.getProjectApi().getProjectsStream();
Stream<Project> projectStream = gitlabApi.getProjectApi().getProjectsStream(); projectStream.map(Project::getName).forEach(name -> System.out.println(name));
projectStream.map(Project::getName).forEach(name -> System.out.println(name));
// Operate on the stream in parallel, this example sorts User instances by username
// Operate on the stream in parallel, this example sorts User instances by username // NOTE: Fetching of the users is not done in paralell,
// NOTE: Fetching of the users is not done in paralell, // only the sorting of the users is a paralell operation.
// only the sorting of the users is a paralell operation. Stream<User> stream = gitlabApi.getUserApi().getUsersStream();
Stream<User> stream = gitlabApi.getUserApi().getUsersStream(); List<User> users = stream.parallel().sorted(comparing(User::getUsername)).collect(toList());
List<User> users = stream.parallel().sorted(comparing(User::getUsername)).collect(toList()); ```
```
**Lazy evaluation example usage:**
**Lazy evaluation example usage:**
```java
```java // Get a Pager instance to that will be used to lazily stream Project instances.
// Get a Pager instance to that will be used to lazily stream Project instances. // In this example, 10 Projects per page will be pre-fetched.
// In this example, 10 Projects per page will be pre-fetched. Pager<Project> projectPager = gitlabApi.getProjectApi().getProjects(10);
Pager<Project> projectPager = gitlabApi.getProjectApi().getProjects(10);
// Lazily stream the Projects, printing out each project name, limit the output to 5 project names
// Lazily stream the Projects, printing out each project name, limit the output to 5 project names projectPager.lazyStream().limit(5).map(Project::getName).forEach(name -> System.out.println(name));
projectPager.lazyStream().limit(5).map(Project::getName).forEach(name -> System.out.println(name)); ```
```
---
--- ## Java 8 Optional&lt;T&gt; Support
## Java 8 Optional&lt;T&gt; Support GitLab4J-API supports Java 8 Optional&lt;T&gt; for API calls that result in the return of a single item. Here is an example on how to use the Java 8 Optional&lt;T&gt; API calls:
GitLab4J-API supports Java 8 Optional&lt;T&gt; for API calls that result in the return of a single item. Here is an example on how to use the Java 8 Optional&lt;T&gt; API calls: ```java
```java Optional<Group> optionalGroup = gitlabApi.getGroupApi().getGroup("my-group-path");
Optional<Group> optionalGroup = gitlabApi.getGroupApi().getGroup("my-group-path"); if (optionalGroup.isPresent())
if (optionalGroup.isPresent()) return optionalGroup.get();
return optionalGroup.get();
return gitlabApi.getGroupApi().addGroup("my-group-name", "my-group-path");
return gitlabApi.getGroupApi().addGroup("my-group-name", "my-group-path"); ```
```
---
--- ## Issue Time Estimates
## Issue Time Estimates GitLab issues allow for time tracking. The following time units are currently available:
GitLab issues allow for time tracking. The following time units are currently available:
* months (mo)
* months (mo) * weeks (w)
* weeks (w) * days (d)
* days (d) * hours (h)
* hours (h) * minutes (m)
* minutes (m)
Conversion rates are 1mo = 4w, 1w = 5d and 1d = 8h.
Conversion rates are 1mo = 4w, 1w = 5d and 1d = 8h.
---
--- ## Making API Calls
## Making API Calls The API has been broken up into sub API classes to make it easier to consume and to separate concerns. The GitLab4J sub API classes typically have a one-to-one relationship with the API documentation at [GitLab API](https://docs.gitlab.com/ce/api/). Following is a sample of the GitLab4J sub API class mapping to the GitLab API documentation:
The API has been broken up into sub API classes to make it easier to consume and to separate concerns. The GitLab4J sub API classes typically have a one-to-one relationship with the API documentation at [GitLab API](https://docs.gitlab.com/ce/api/). Following is a sample of the GitLab4J sub API class mapping to the GitLab API documentation:
```org.gitlab4j.api.GroupApi``` -> https://docs.gitlab.com/ce/api/groups.html<br/>
```org.gitlab4j.api.GroupApi``` -> https://docs.gitlab.com/ce/api/groups.html<br/> ```org.gitlab4j.api.MergeRequestApi``` -> https://docs.gitlab.com/ce/api/merge_requests.html<br/>
```org.gitlab4j.api.MergeRequestApi``` -> https://docs.gitlab.com/ce/api/merge_requests.html<br/> ```org.gitlab4j.api.ProjectApi``` -> https://docs.gitlab.com/ce/api/projects.html<br/>
```org.gitlab4j.api.ProjectApi``` -> https://docs.gitlab.com/ce/api/projects.html<br/> ```org.gitlab4j.api.UserApi``` -> https://docs.gitlab.com/ce/api/users.html<br/>
```org.gitlab4j.api.UserApi``` -> https://docs.gitlab.com/ce/api/users.html<br/>
The following is a list of the available sub APIs along with a sample use of each API. See the <a href="http://www.messners.com/gitlab4j-api/javadocs/index.html?org/gitlab4j/api/package-summary.html" target="_top">Javadocs</a> for a complete list of available methods for each sub API.
The following is a list of the available sub APIs along with a sample use of each API. See the <a href="http://www.messners.com/gitlab4j-api/javadocs/index.html?org/gitlab4j/api/package-summary.html" target="_top">Javadocs</a> for a complete list of available methods for each sub API.
### Available Sub APIs
### Available Sub APIs ------------------
------------------ &nbsp;&nbsp;[AwardEmojiApi](#awardemojiapi)<br/>
&nbsp;&nbsp;[AwardEmojiApi](#awardemojiapi)<br/> &nbsp;&nbsp;[BoardsApi](#boardsapi)<br/>
&nbsp;&nbsp;[BoardsApi](#boardsapi)<br/> &nbsp;&nbsp;[CommitsApi](#commitsapi)<br/>
&nbsp;&nbsp;[CommitsApi](#commitsapi)<br/> &nbsp;&nbsp;[DeployKeysApi](#deploykeysapi)<br/>
&nbsp;&nbsp;[DeployKeysApi](#deploykeysapi)<br/> &nbsp;&nbsp;[DiscussionsApi](#discussionsapi)<br/>
&nbsp;&nbsp;[DiscussionsApi](#discussionsapi)<br/> &nbsp;&nbsp;[EpicsApi](#epicsapi)<br/>
&nbsp;&nbsp;[EpicsApi](#epicsapi)<br/> &nbsp;&nbsp;[EventsApi](#eventsapi)<br/>
&nbsp;&nbsp;[EventsApi](#eventsapi)<br/> &nbsp;&nbsp;[GroupApi](#groupapi)<br/>
&nbsp;&nbsp;[GroupApi](#groupapi)<br/> &nbsp;&nbsp;[HealthCheckApi](#healthcheckapi)<br/>
&nbsp;&nbsp;[HealthCheckApi](#healthcheckapi)<br/> &nbsp;&nbsp;[IssuesApi](#issuesapi)<br/>
&nbsp;&nbsp;[IssuesApi](#issuesapi)<br/> &nbsp;&nbsp;[JobApi](#jobapi)<br/>
&nbsp;&nbsp;[JobApi](#jobapi)<br/> &nbsp;&nbsp;[LabelsApi](#labelsapi)<br/>
&nbsp;&nbsp;[LabelsApi](#labelsapi)<br/> &nbsp;&nbsp;[MergeRequestApi](#mergerequestapi)<br/>
&nbsp;&nbsp;[MergeRequestApi](#mergerequestapi)<br/> &nbsp;&nbsp;[MilestonesApi](#milestonesapi)<br/>
&nbsp;&nbsp;[MilestonesApi](#milestonesapi)<br/> &nbsp;&nbsp;[NamespaceApi](#namespaceapi)<br/>
&nbsp;&nbsp;[NamespaceApi](#namespaceapi)<br/> &nbsp;&nbsp;[NotesApi](#notesapi)<br/>
&nbsp;&nbsp;[NotesApi](#notesapi)<br/> &nbsp;&nbsp;[NotificationSettingsApi](#notificationsettingsapi)<br/>
&nbsp;&nbsp;[NotificationSettingsApi](#notificationsettingsapi)<br/> &nbsp;&nbsp;[PackagesApi](#packagesapi)<br/>
&nbsp;&nbsp;[PackagesApi](#packagesapi)<br/> &nbsp;&nbsp;[PipelineApi](#pipelineapi)<br/>
&nbsp;&nbsp;[PipelineApi](#pipelineapi)<br/> &nbsp;&nbsp;[ProjectApi](#projectapi)<br/>
&nbsp;&nbsp;[ProjectApi](#projectapi)<br/> &nbsp;&nbsp;[ProtectedBranchesApi](#protectedbranchesapi) <br/>
&nbsp;&nbsp;[ProtectedBranchesApi](#protectedbranchesapi) <br/> &nbsp;&nbsp;[RepositoryApi](#repositoryapi)<br/>
&nbsp;&nbsp;[RepositoryApi](#repositoryapi)<br/> &nbsp;&nbsp;[RepositoryFileApi](#repositoryfileapi)<br/>
&nbsp;&nbsp;[RepositoryFileApi](#repositoryfileapi)<br/> &nbsp;&nbsp;[RunnersApi](#runnersapi) <br/>
&nbsp;&nbsp;[RunnersApi](#runnersapi) <br/> &nbsp;&nbsp;[ServicesApi](#servicesapi)<br/>
&nbsp;&nbsp;[ServicesApi](#servicesapi)<br/> &nbsp;&nbsp;[SessionApi](#sessionapi)<br/>
&nbsp;&nbsp;[SessionApi](#sessionapi)<br/> &nbsp;&nbsp;[SnippetsApi](#snippetsapi)<br/>
&nbsp;&nbsp;[SnippetsApi](#snippetsapi)<br/> &nbsp;&nbsp;[SystemHooksApi](#systemhooksapi)<br/>
&nbsp;&nbsp;[SystemHooksApi](#systemhooksapi)<br/> &nbsp;&nbsp;[UserApi](#userapi)<br/>
&nbsp;&nbsp;[UserApi](#userapi)<br/> &nbsp;&nbsp;[WikisApi](#wikisapi)
&nbsp;&nbsp;[WikisApi](#wikisapi)
### Sub API Examples
### Sub API Examples ----------------
----------------
#### AwardEmojiApi
#### AwardEmojiApi ```java
```java // Get a list of AwardEmoji belonging to the specified issue (group ID = 1, issues IID = 1)
// Get a list of AwardEmoji belonging to the specified issue (group ID = 1, issues IID = 1) List<AwardEmoji> awardEmojis = gitLabApi.getAwardEmojiApi().getIssuAwardEmojis(1, 1);
List<AwardEmoji> awardEmojis = gitLabApi.getAwardEmojiApi().getIssuAwardEmojis(1, 1); ```
```
#### BoardsApi
#### BoardsApi ```java
```java // Get a list of the Issue Boards belonging to the specified project
// Get a list of the Issue Boards belonging to the specified project List<Board> boards = gitLabApi.getBoardsApi().getBoards(projectId);
List<Board> boards = gitLabApi.getBoardsApi().getBoards(projectId); ```
```
#### CommitsApi
#### CommitsApi ```java
```java // Get a list of commits associated with the specified branch that fall within the specified time window
// Get a list of commits associated with the specified branch that fall within the specified time window // This uses the ISO8601 date utilities the in org.gitlab4j.api.utils.ISO8601 class
// This uses the ISO8601 date utilities the in org.gitlab4j.api.utils.ISO8601 class Date since = ISO8601.toDate("2017-01-01T00:00:00Z");
Date since = ISO8601.toDate("2017-01-01T00:00:00Z"); Date until = new Date(); // now
Date until = new Date(); // now List<Commit> commits = gitLabApi.getCommitsApi().getCommits(1234, "new-feature", since, until);
List<Commit> commits = gitLabApi.getCommitsApi().getCommits(1234, "new-feature", since, until); ```
```
#### DeployKeysApi
#### DeployKeysApi ```java
```java // Get a list of DeployKeys for the authenticated user
// Get a list of DeployKeys for the authenticated user List<DeployKey> deployKeys = gitLabApi.getDeployKeysApi().getDeployKeys();
List<DeployKey> deployKeys = gitLabApi.getDeployKeysApi().getDeployKeys(); ```
```
#### DiscussionsApi
#### DiscussionsApi ```java
```java // Get a list of Discussions for the specified merge request
// Get a list of Discussions for the specified merge request List<DeployKey> deployKeys = gitLabApi.getDiscussionsApi().getMergeRequestDiscussions(projectId, mergeRequestIid);
List<DeployKey> deployKeys = gitLabApi.getDiscussionsApi().getMergeRequestDiscussions(projectId, mergeRequestIid); ```
```
#### EpicsApi
#### EpicsApi ```java
```java // Get a list epics of the requested group and its subgroups.
// Get a list epics of the requested group and its subgroups. List<Epic> epics = gitLabApi.getEpicsApi().getEpics(1);
List<Epic> epics = gitLabApi.getEpicsApi().getEpics(1); ```
```
#### EventsApi
#### EventsApi ```java
```java // Get a list of Events for the authenticated user
// Get a list of Events for the authenticated user Date after = new Date(0); // After Epoch
Date after = new Date(0); // After Epoch Date before = new Date(); // Before now
Date before = new Date(); // Before now List<Event> events = gitLabApi.getEventsApi().getAuthenticatedUserEvents(null, null, before, after, DESC);
List<Event> events = gitLabApi.getEventsApi().getAuthenticatedUserEvents(null, null, before, after, DESC); ```
```
#### GroupApi
#### GroupApi ```java
```java // Get a list of groups that you have access to
// Get a list of groups that you have access to List<Group> groups = gitLabApi.getGroupApi().getGroups();
List<Group> groups = gitLabApi.getGroupApi().getGroups(); ```
```
#### HealthCheckApi
#### HealthCheckApi ```java
```java // Get the liveness endpoint health check results. Assumes ip_whitelisted per:
// Get the liveness endpoint health check results. Assumes ip_whitelisted per: // https://docs.gitlab.com/ee/administration/monitoring/ip_whitelist.html
// https://docs.gitlab.com/ee/administration/monitoring/ip_whitelist.html HealthCheckInfo healthCheck = gitLabApi.getHealthCheckApi().getLiveness();
HealthCheckInfo healthCheck = gitLabApi.getHealthCheckApi().getLiveness(); ```
```
#### IssuesApi
#### IssuesApi ```java
```java // Get a list of issues for the specified project ID
// Get a list of issues for the specified project ID List<Issue> issues = gitLabApi.getIssuesApi().getIssues(1234);
List<Issue> issues = gitLabApi.getIssuesApi().getIssues(1234); ```
```
#### JobApi
#### JobApi ```java
```java // Get a list of jobs for the specified project ID
// Get a list of jobs for the specified project ID List<Job> jobs = gitLabApi.getJobApi().getJobs(1234);
List<Job> jobs = gitLabApi.getJobApi().getJobs(1234); ```
```
#### LabelsApi
#### LabelsApi ```java
```java // Get a list of labels for the specified project ID
// Get a list of labels for the specified project ID List<Label> labels = gitLabApi.getLabelsApi().getLabels(1234);
List<Label> labels = gitLabApi.getLabelsApi().getLabels(1234); ```
```
#### MergeRequestApi
#### MergeRequestApi ```java
```java // Get a list of the merge requests for the specified project
// Get a list of the merge requests for the specified project List<MergeRequest> mergeRequests = gitLabApi.getMergeRequestApi().getMergeRequests(1234);
List<MergeRequest> mergeRequests = gitLabApi.getMergeRequestApi().getMergeRequests(1234); ```
```
#### MilestonesApi
#### MilestonesApi ```java
```java // Get a list of the milestones for the specified project
// Get a list of the milestones for the specified project List<Milestone> milestones = gitLabApi.getMilestonesApi().getMilestones(1234);
List<Milestone> milestones = gitLabApi.getMilestonesApi().getMilestones(1234); ```
```
#### NamespaceApi
#### NamespaceApi ```java
```java // Get all namespaces that match "foobar" in their name or path
// Get all namespaces that match "foobar" in their name or path List<Namespace> namespaces = gitLabApi.getNamespaceApi().findNamespaces("foobar");
List<Namespace> namespaces = gitLabApi.getNamespaceApi().findNamespaces("foobar"); ```
```
#### NotesApi
#### NotesApi ```java
```java // Get a list of the issues's notes for project ID 1234, issue IID 1
// Get a list of the issues's notes for project ID 1234, issue IID 1 List<Note> notes = gitLabApi.getNotesApi().getNotes(1234, 1);
List<Note> notes = gitLabApi.getNotesApi().getNotes(1234, 1); ```
```
#### NotificationSettingsApi
#### NotificationSettingsApi ```java
```java // Get the current global notification settings
// Get the current global notification settings NotificationSettings settings = gitLabApi.getNotificationSettingsApi().getGlobalNotificationSettings();
NotificationSettings settings = gitLabApi.getNotificationSettingsApi().getGlobalNotificationSettings(); ```
```
#### PackagesApi
#### PackagesApi ```java
```java // Get all packages for the specified project ID
// Get all packages for the specified project ID List<Packages> packages = gitLabApi.getPackagesApi().getPackages(1234);
List<Packages> packages = gitLabApi.getPackagesApi().getPackages(1234); ```
```
#### PipelineApi
#### PipelineApi ```java
```java // Get all pipelines for the specified project ID
// Get all pipelines for the specified project ID List<Pipeline> pipelines = gitLabApi.getPipelineApi().getPipelines(1234);
List<Pipeline> pipelines = gitLabApi.getPipelineApi().getPipelines(1234); ```
```
#### ProjectApi
#### ProjectApi ```java
```java // Get a list of accessible projects
// Get a list of accessible projects public List<Project> projects = gitLabApi.getProjectApi().getProjects();
public List<Project> projects = gitLabApi.getProjectApi().getProjects(); ```
``` ```java
```java // Create a new project
// Create a new project Project projectSpec = new Project()
Project projectSpec = new Project() .withName("my-project")
.withName("my-project") .withDescription("My project for demonstration.")
.withDescription("My project for demonstration.") .withIssuesEnabled(true)
.withIssuesEnabled(true) .withMergeRequestsEnabled(true)
.withMergeRequestsEnabled(true) .withWikiEnabled(true)
.withWikiEnabled(true) .withSnippetsEnabled(true)
.withSnippetsEnabled(true) .withPublic(true);
.withPublic(true);
Project newProject = gitLabApi.getProjectApi().createProject(projectSpec);
Project newProject = gitLabApi.getProjectApi().createProject(projectSpec); ```
```
#### ProtectedBranchesApi
#### ProtectedBranchesApi ```java
```java List<ProtectedBranch> branches = gitLabApi.getProtectedBranchesApi().getProtectedBranches(project.getId());
List<ProtectedBranch> branches = gitLabApi.getProtectedBranchesApi().getProtectedBranches(project.getId()); ```
```
#### RepositoryApi
#### RepositoryApi ```java
```java // Get a list of repository branches from a project, sorted by name alphabetically
// Get a list of repository branches from a project, sorted by name alphabetically List<Branch> branches = gitLabApi.getRepositoryApi().getBranches();
List<Branch> branches = gitLabApi.getRepositoryApi().getBranches(); ```
```
#### RepositoryFileApi
#### RepositoryFileApi ```java
```java // Get info (name, size, ...) and the content from a file in repository
// Get info (name, size, ...) and the content from a file in repository RepositoryFile file = gitLabApi.getRepositoryFileApi().getFile("file-path", 1234, "ref");
RepositoryFile file = gitLabApi.getRepositoryFileApi().getFile("file-path", 1234, "ref"); ```
```
#### RunnersApi
#### RunnersApi ```java
```java // Get All Runners.
// Get All Runners. List<Runner> runners = gitLabApi.getRunnersApi().getAllRunners();
List<Runner> runners = gitLabApi.getRunnersApi().getAllRunners(); ```
```
#### ServicesApi
#### ServicesApi ```java
```java // Activate/Update the Slack Notifications service
// Activate/Update the Slack Notifications service SlackService slackService = new SlackService()
SlackService slackService = new SlackService() .withMergeRequestsEvents(true)
.withMergeRequestsEvents(true) .withWebhook("https://hooks.slack.com/services/ABCDEFGHI/KJLMNOPQR/wetrewq7897HKLH8998wfjjj")
.withWebhook("https://hooks.slack.com/services/ABCDEFGHI/KJLMNOPQR/wetrewq7897HKLH8998wfjjj") .withUsername("GitLab4J");
.withUsername("GitLab4J"); gitLabApi.getServicesApi().updateSlackService("project-path", slackService);
gitLabApi.getServicesApi().updateSlackService("project-path", slackService); ```
```
#### SessionApi
#### SessionApi ```java
```java // Log in to the GitLab server and get the session info
// Log in to the GitLab server and get the session info gitLabApi.getSessionApi().login("your-username", "your-email", "your-password");
gitLabApi.getSessionApi().login("your-username", "your-email", "your-password"); ```
```
#### SnippetsApi
#### SnippetsApi ```java
```java // Get a list of the authenticated user's snippets
// Get a list of the authenticated user's snippets List<Snippet> snippets = gitLabApi.getSnippetsApi().getSnippets();
List<Snippet> snippets = gitLabApi.getSnippetsApi().getSnippets(); ```
```
#### SystemHooksApi
#### SystemHooksApi ```java
```java // Get a list of installed system hooks
// Get a list of installed system hooks List<SystemHook> hooks = gitLabApi.getSystemHooksApi().getSystemHooks();
List<SystemHook> hooks = gitLabApi.getSystemHooksApi().getSystemHooks(); ```
```
#### UserApi
#### UserApi ```java
```java // Get the User info for user_id 1
// Get the User info for user_id 1 User user = gitLabApi.getUserApi().getUser(1);
User user = gitLabApi.getUserApi().getUser(1);
// Create a new user with no password who will recieve a reset password email
// Create a new user with no password who will recieve a reset password email User userConfig = new User()
User userConfig = new User() .withEmail("jdoe@example.com")
.withEmail("jdoe@example.com") .withName("Jane Doe")
.withName("Jane Doe") .withUsername("jdoe");
.withUsername("jdoe"); String password = null;
String password = null; boolean sendResetPasswordEmail = true;
boolean sendResetPasswordEmail = true; gitLabApi.getUserApi().createUser(userConfig, password, sendResetPasswordEmail);
gitLabApi.getUserApi().createUser(userConfig, password, sendResetPasswordEmail); ```
```
#### WikisApi
#### WikisApi ```java
```java // Get a list of pages in project wiki
// Get a list of pages in project wiki List<WikiPage> wikiPages = gitLabApi.getWikisApi().getPages();
List<WikiPage> wikiPages = gitLabApi.getWikisApi().getPages(); ```
```
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment