Skip to content

Commit ff28449

Browse files
lamdavgmessner
authored andcommitted
Runners API (#154)
Added RunnersApi implementation and tests.
1 parent 8e00f6e commit ff28449

File tree

5 files changed

+551
-27
lines changed

5 files changed

+551
-27
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ The API has been broken up into sub APIs classes to make it easier to learn and
152152
&nbsp;&nbsp;[ProtectedBranchesApi](#protectedbranchesapi) <br/>
153153
&nbsp;&nbsp;[RepositoryApi](#repositoryapi)<br/>
154154
&nbsp;&nbsp;[RepositoryFileApi](#repositoryfileapi)<br/>
155+
&nbsp;&nbsp;[RunnersApi](#runnersapi) <br/>
155156
&nbsp;&nbsp;[ServicesApi](#servicesapi)<br/>
156157
&nbsp;&nbsp;[SessionApi](#sessionapi)<br/>
157158
&nbsp;&nbsp;[SystemHooksApi](#systemhooksapi)<br/>
@@ -279,6 +280,12 @@ List<Branch> branches = gitLabApi.getRepositoryApi().getBranches();
279280
RepositoryFile file = gitLabApi.getRepositoryFileApi().getFile("file-path", 1234, "ref");
280281
```
281282

283+
#### RunnersApi
284+
```java
285+
// Get All Runners.
286+
List<Runner> runners = api.getRunnersApi().getAllRunners();
287+
```
288+
282289
#### ServicesApi
283290
```java
284291
// Activates the gitlab-ci service.

src/main/java/org/gitlab4j/api/GitLabApi.java

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ public String getApiNamespace() {
5555
private NotificationSettingsApi notificationSettingsApi;
5656
private PipelineApi pipelineApi;
5757
private ProjectApi projectApi;
58+
private ProtectedBranchesApi protectedBranchesApi;
5859
private RepositoryApi repositoryApi;
5960
private RepositoryFileApi repositoryFileApi;
61+
private RunnersApi runnersApi;
6062
private ServicesApi servicesApi;
6163
private SessionApi sessionApi;
6264
private SystemHooksApi systemHooksApi;
@@ -65,7 +67,6 @@ public String getApiNamespace() {
6567
private LabelsApi labelsApi;
6668
private NotesApi notesApi;
6769
private EventsApi eventsApi;
68-
private ProtectedBranchesApi protectedBranchesApi;
6970

7071
/**
7172
* Create a new GitLabApi instance that is logically a duplicate of this instance, with the exception off sudo state.
@@ -284,8 +285,7 @@ public static GitLabApi oauth2Login(ApiVersion apiVersion, String url, String us
284285
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
285286
*/
286287
public static GitLabApi oauth2Login(ApiVersion apiVersion, String url, String username, CharSequence password,
287-
String secretToken, Map<String, Object> clientConfigProperties, boolean ignoreCertificateErrors)
288-
throws GitLabApiException {
288+
String secretToken, Map<String, Object> clientConfigProperties, boolean ignoreCertificateErrors) throws GitLabApiException {
289289

290290
if (username == null || username.trim().length() == 0) {
291291
throw new IllegalArgumentException("both username and email cannot be empty or null");
@@ -318,7 +318,7 @@ class Oauth2Api extends AbstractApi {
318318
/**
319319
* <p>Logs into GitLab using provided {@code username} and {@code password}, and creates a new {@code GitLabApi} instance
320320
* using returned private token and the specified GitLab API version.</p>
321-
*
321+
*
322322
* <strong>NOTE</strong>: For GitLab servers 10.2 and above this will utilize OAUTH2 for login. For GitLab servers prior to
323323
* 10.2, the Session API login is utilized.
324324
*
@@ -338,7 +338,7 @@ public static GitLabApi login(ApiVersion apiVersion, String url, String username
338338
/**
339339
* <p>Logs into GitLab using provided {@code username} and {@code password}, and creates a new {@code GitLabApi} instance
340340
* using returned private token using GitLab API version 4.</p>
341-
*
341+
*
342342
* <strong>NOTE</strong>: For GitLab servers 10.2 and above this will utilize OAUTH2 for login. For GitLab servers prior to
343343
* 10.2, the Session API login is utilized.
344344
*
@@ -357,7 +357,7 @@ public static GitLabApi login(String url, String username, String password) thro
357357
/**
358358
* <p>Logs into GitLab using provided {@code username} and {@code password}, and creates a new {@code GitLabApi} instance
359359
* using returned private token and the specified GitLab API version.</p>
360-
*
360+
*
361361
* <strong>NOTE</strong>: For GitLab servers 10.2 and above this will utilize OAUTH2 for login. For GitLab servers prior to
362362
* 10.2, the Session API login is utilized.
363363
*
@@ -402,7 +402,7 @@ public static GitLabApi login(ApiVersion apiVersion, String url, String username
402402
/**
403403
* <p>Logs into GitLab using provided {@code username} and {@code password}, and creates a new {@code GitLabApi} instance
404404
* using returned private token using GitLab API version 4.</p>
405-
*
405+
*
406406
* <strong>NOTE</strong>: For GitLab servers 10.2 and above this will utilize OAUTH2 for login. For GitLab servers prior to
407407
* 10.2, the Session API login is utilized.
408408
*
@@ -1049,6 +1049,25 @@ public ProjectApi getProjectApi() {
10491049
return (projectApi);
10501050
}
10511051

1052+
/**
1053+
* Gets the ProtectedBranchesApi instance owned by this GitLabApi instance. The ProtectedBranchesApi is used
1054+
* to perform all protection related actions on a branch of a project.
1055+
*
1056+
* @return the ProtectedBranchesApi instance owned by this GitLabApi instance
1057+
*/
1058+
public ProtectedBranchesApi getProtectedBranchesApi() {
1059+
1060+
if (this.protectedBranchesApi == null) {
1061+
synchronized (this) {
1062+
if (this.protectedBranchesApi == null) {
1063+
this.protectedBranchesApi = new ProtectedBranchesApi(this);
1064+
}
1065+
}
1066+
}
1067+
1068+
return (this.protectedBranchesApi);
1069+
}
1070+
10521071
/**
10531072
* Gets the RepositoryApi instance owned by this GitLabApi instance. The RepositoryApi is used
10541073
* to perform all repository related API calls.
@@ -1087,6 +1106,25 @@ public RepositoryFileApi getRepositoryFileApi() {
10871106
return (repositoryFileApi);
10881107
}
10891108

1109+
/**
1110+
* Gets the RunnersApi instance owned by this GitLabApi instance. The RunnersApi is used
1111+
* to perform all Runner related API calls.
1112+
*
1113+
* @return the RunnerApi instance owned by this GitLabApi instance
1114+
*/
1115+
public RunnersApi getRunnersApi() {
1116+
1117+
if (runnersApi == null) {
1118+
synchronized (this) {
1119+
if (runnersApi == null) {
1120+
runnersApi = new RunnersApi(this);
1121+
}
1122+
}
1123+
}
1124+
1125+
return (runnersApi);
1126+
}
1127+
10901128
/**
10911129
* Gets the ServicesApi instance owned by this GitLabApi instance. The ServicesApi is used
10921130
* to perform all services related API calls.
@@ -1126,7 +1164,7 @@ public SessionApi getSessionApi() {
11261164
}
11271165

11281166
/**
1129-
* Gets the SystemHooksApi instance owned by this GitLabApi instance. All methods
1167+
* Gets the SystemHooksApi instance owned by this GitLabApi instance. All methods
11301168
* require administrator authorization.
11311169
*
11321170
* @return the SystemHooksApi instance owned by this GitLabApi instance
@@ -1163,25 +1201,6 @@ public UserApi getUserApi() {
11631201
return (userApi);
11641202
}
11651203

1166-
/**
1167-
* Gets the ProtectedBranchesApi instance owned by this GitLabApi instance. The ProtectedBranchesApi is used
1168-
* to perform all protection related actions on a branch of a project.
1169-
*
1170-
* @return the ProtectedBranchesApi instance owned by this GitLabApi instance
1171-
*/
1172-
public ProtectedBranchesApi getProtectedBranchesApi() {
1173-
1174-
if (this.protectedBranchesApi == null) {
1175-
synchronized (this) {
1176-
if (this.protectedBranchesApi == null) {
1177-
this.protectedBranchesApi = new ProtectedBranchesApi(this);
1178-
}
1179-
}
1180-
}
1181-
1182-
return (this.protectedBranchesApi);
1183-
}
1184-
11851204
/**
11861205
* Create and return an Optional instance associated with a GitLabApiException.
11871206
*

0 commit comments

Comments
 (0)