Skip to content

Commit

Permalink
Merge pull request #206 from ahormazabal/dev/apigap
Browse files Browse the repository at this point in the history
Add new commands to CLI.
  • Loading branch information
gschueler authored Nov 29, 2018
2 parents 6aeb65b + 02a2e82 commit 610de7a
Show file tree
Hide file tree
Showing 20 changed files with 1,475 additions and 26 deletions.
68 changes: 68 additions & 0 deletions rd-api-client/src/main/java/org/rundeck/client/api/RundeckApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import org.rundeck.client.api.model.*;
import org.rundeck.client.api.model.repository.ArtifactActionMessage;
import org.rundeck.client.api.model.repository.RepositoryArtifacts;
import org.rundeck.client.api.model.scheduler.ScheduledJobItem;
import org.rundeck.client.api.model.scheduler.SchedulerTakeover;
import org.rundeck.client.api.model.scheduler.SchedulerTakeoverResult;
import org.rundeck.client.util.Json;
import org.rundeck.client.util.Xml;
import retrofit2.Call;
Expand Down Expand Up @@ -445,6 +448,13 @@ Call<BulkExecutionDeleteResponse> deleteExecutions(
@Body BulkExecutionDelete delete
);

/**
* Delete all executions for a job.
*/
@Headers("Accept: application/json")
@DELETE("job/{id}/executions")
Call<BulkExecutionDeleteResponse> deleteAllJobExecutions(@Path("id") String id);

@Headers("Accept: application/json")
@GET("execution/{id}/abort")
Call<AbortResult> abortExecution(@Path("id") String id);
Expand All @@ -453,6 +463,9 @@ Call<BulkExecutionDeleteResponse> deleteExecutions(
@GET("execution/{id}")
Call<Execution> getExecution(@Path("id") String id);

@Headers("Accept: application/json")
@GET("execution/{id}/state")
Call<ExecutionStateResponse> getExecutionState(@Path("id") String id);

@Headers("Accept: application/json")
@DELETE("execution/{id}")
Expand Down Expand Up @@ -739,6 +752,15 @@ Call<Void> deleteSystemAclPolicy(
@GET("scheduler/server/{uuid}/jobs")
Call<List<ScheduledJobItem>> listSchedulerJobs(@Path("uuid") String uuid);

/**
* Tell a Rundeck server in cluster mode to claim all scheduled jobs from another cluster server.
*
* @see <a href="https://rundeck.org/docs/api/#takeover-schedule-in-cluster-mode">API</a>
*/
@Headers("Accept: application/json")
@PUT("scheduler/takeover")
Call<SchedulerTakeoverResult> takeoverSchedule(@Body SchedulerTakeover schedulerTakeover);


/**
* <a href="http://rundeck.org/docs/api/index.html#get-project-scm-config">
Expand Down Expand Up @@ -1085,4 +1107,50 @@ Call<Execution> retryJob(
@Headers("Accept: application/json")
@POST("plugins/uninstall/{pluginId}")
Call<ArtifactActionMessage> uninstallPlugin(@Path("pluginId") String pluginId);

/* Bulk toggle job execution. */

/**
* @see <a href="https://rundeck.org/docs/api/#bulk-toggle-job-execution">API</a>
*/
@Json
@Headers("Accept: application/json")
@POST("jobs/execution/enable")
Call<BulkToggleJobExecutionResponse> bulkEnableJobs(
@Body IdList ids
);

/**
* @see <a href="https://rundeck.org/docs/api/#bulk-toggle-job-execution">API</a>
*/
@Json
@Headers("Accept: application/json")
@POST("jobs/execution/disable")
Call<BulkToggleJobExecutionResponse> bulkDisableJobs(
@Body IdList ids
);

/* Bulk toggle job schedule. */

/**
* @see <a href="https://rundeck.org/docs/api/#bulk-toggle-job-schedules">API</a>
*/
@Json
@Headers("Accept: application/json")
@POST("jobs/schedule/enable")
Call<BulkToggleJobScheduleResponse> bulkEnableJobSchedule(
@Body IdList ids
);

/**
* @see <a href="https://rundeck.org/docs/api/#bulk-toggle-job-schedules">API</a>
*/
@Json
@Headers("Accept: application/json")
@POST("jobs/schedule/disable")
Call<BulkToggleJobScheduleResponse> bulkDisableJobSchedule(
@Body IdList ids
);


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Copyright 2017 Rundeck, Inc. (http://rundeck.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.rundeck.client.api.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class BulkToggleJobExecutionResponse {
private int requestCount;
private boolean enabled;
private boolean allsuccessful;
private List<Result> succeeded;
private List<Result> failed;

@JsonIgnoreProperties(ignoreUnknown = true)
public static class Result {
private String id;
private String errorCode;
private String message;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getErrorCode() {
return errorCode;
}

public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

@Override
public String toString() {
return String.format("* #%s: '%s'", id, message);
}
}

public int getRequestCount() {
return requestCount;
}

public void setRequestCount(int requestCount) {
this.requestCount = requestCount;
}

public boolean isEnabled() {
return enabled;
}

public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public boolean isAllsuccessful() {
return allsuccessful;
}

public void setAllsuccessful(boolean allsuccessful) {
this.allsuccessful = allsuccessful;
}

public List<Result> getSucceeded() {
return succeeded;
}

public void setSucceeded(List<Result> succeeded) {
this.succeeded = succeeded;
}

public List<Result> getFailed() {
return failed;
}

public void setFailed(List<Result> failed) {
this.failed = failed;
}

@Override
public String toString() {
return "BulkToggleJobExecutionResponse{" +
"requestCount=" + requestCount +
", enabled=" + enabled +
", allsuccessful=" + allsuccessful +
", succeeded=" + succeeded +
", failed=" + failed +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Copyright 2017 Rundeck, Inc. (http://rundeck.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.rundeck.client.api.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class BulkToggleJobScheduleResponse {
private int requestCount;
private boolean enabled;
private boolean allsuccessful;
private List<Result> succeeded;
private List<Result> failed;

@JsonIgnoreProperties(ignoreUnknown = true)
public static class Result {
private String id;
private String errorCode;
private String message;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getErrorCode() {
return errorCode;
}

public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

@Override
public String toString() {
return String.format("* #%s: '%s'", id, message);
}
}

public int getRequestCount() {
return requestCount;
}

public void setRequestCount(int requestCount) {
this.requestCount = requestCount;
}

public boolean isEnabled() {
return enabled;
}

public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public boolean isAllsuccessful() {
return allsuccessful;
}

public void setAllsuccessful(boolean allsuccessful) {
this.allsuccessful = allsuccessful;
}

public List<Result> getSucceeded() {
return succeeded;
}

public void setSucceeded(List<Result> succeeded) {
this.succeeded = succeeded;
}

public List<Result> getFailed() {
return failed;
}

public void setFailed(List<Result> failed) {
this.failed = failed;
}

@Override
public String toString() {
return "BulkToggleJobScheduleResponse{" +
"requestCount=" + requestCount +
", enabled=" + enabled +
", allsuccessful=" + allsuccessful +
", succeeded=" + succeeded +
", failed=" + failed +
'}';
}
}
Loading

0 comments on commit 610de7a

Please sign in to comment.