Skip to content

Commit

Permalink
Merge pull request #49 from rundeck/rundeck-cli-44
Browse files Browse the repository at this point in the history
Add SCM commands
  • Loading branch information
gschueler authored Dec 14, 2016
2 parents fc9656f + 4e8654b commit 206775f
Show file tree
Hide file tree
Showing 17 changed files with 716 additions and 48 deletions.
16 changes: 16 additions & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,22 @@ List and manage projects.
readme - Manage Project readme
scm - Manage Project SCM

### projects scm

Manage Project SCM

Available commands:

config - Get SCM Config for a Project
disable - Disable plugin
enable - Enable plugin
inputs - Get SCM action inputs
perform - Perform SCM action
plugins - List SCM plugins
setup - Setup SCM Config for a Project
setupinputs - Get SCM Setup inputs
status - Get SCM Status for a Project

## run

Run a Job.
Expand Down
123 changes: 121 additions & 2 deletions src/main/java/org/rundeck/client/api/RundeckApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import retrofit2.Call;
import retrofit2.http.*;

import java.io.File;
import java.net.URL;
import java.util.Date;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -461,6 +459,127 @@ Call<ScmActionResult> setupScmConfig(
@Body RequestBody body
);

/**
* <a href="http://rundeck.org/docs/api/index.html#setup-scm-plugin-for-a-project">Setup SCM Config for a
* Project</a>
*
* @param project project
* @param integration integration
*
* @return result
*/
@Headers("Accept: application/json")
@GET("project/{project}/scm/{integration}/status")
Call<ScmProjectStatusResult> getScmProjectStatus(
@Path("project") String project,
@Path("integration") String integration
);

/**
* <a href="http://rundeck.org/docs/api/index.html#get-scm-plugin-input-fields">Get SCM Setup Inputs for a
* Project</a>
*
* @param project project
* @param integration integration
* @param type plugin type
*
* @return result
*/
@Headers("Accept: application/json")
@GET("project/{project}/scm/{integration}/plugin/{type}/input")
Call<ScmSetupInputsResult> getScmSetupInputs(
@Path("project") String project,
@Path("integration") String integration,
@Path("type") String type
);

/**
* <a href="http://rundeck.org/docs/api/index.html#get-project-scm-action-input-fields">Get SCM Action Inputs for a
* Project</a>
*
* @param project project
* @param integration integration
* @param action plugin type
*
* @return result
*/
@Headers("Accept: application/json")
@GET("project/{project}/scm/{integration}/action/{action}/input")
Call<ScmActionInputsResult> getScmActionInputs(
@Path("project") String project,
@Path("integration") String integration,
@Path("action") String action
);

/**
* <a href="http://rundeck.org/docs/api/index.html#get-project-scm-action-input-fields">Get SCM Action Inputs for a
* Project</a>
*
* @param project project
* @param integration integration
* @param action plugin type
*
* @return result
*/
@Headers("Accept: application/json")
@POST("project/{project}/scm/{integration}/action/{action}")
Call<ScmActionResult> performScmAction(
@Path("project") String project,
@Path("integration") String integration,
@Path("action") String action,
@Body ScmActionPerform body
);

/**
* <a href="http://rundeck.org/docs/api/index.html#get-project-scm-action-input-fields">Get SCM Action Inputs for a
* Project</a>
*
* @param project project
* @param integration integration
*
* @return result
*/
@Headers("Accept: application/json")
@GET("project/{project}/scm/{integration}/plugins")
Call<ScmPluginsResult> listScmPlugins(
@Path("project") String project,
@Path("integration") String integration
);

/**
* <a href="http://rundeck.org/docs/api/index.html#enable-scm-plugin-for-a-project">Enable SCM Integration for a
* Project</a>
*
* @param project project
* @param integration integration
* @param type type
*
*/
@Headers("Accept: application/json")
@POST("project/{project}/scm/{integration}/plugin/{type}/enable")
Call<Void> enableScmPlugin(
@Path("project") String project,
@Path("integration") String integration,
@Path("type") String type
);

/**
* <a href="http://rundeck.org/docs/api/index.html#enable-scm-plugin-for-a-project">Disable SCM Integration for a
* Project</a>
*
* @param project project
* @param integration integration
* @param type type
*
*/
@Headers("Accept: application/json")
@POST("project/{project}/scm/{integration}/plugin/{type}/disable")
Call<Void> disableScmPlugin(
@Path("project") String project,
@Path("integration") String integration,
@Path("type") String type
);

/**
* <a href="http://rundeck.org/docs/api/index.html#list-tokens">List Tokens</a>
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.rundeck.client.api.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;

/**
* @author greg
* @since 12/13/16
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class ScmActionInputsResult {
public String title;
public String description;
public String integration;
public String actionId;
public List<ScmInputField> fields;
public List<ScmImportItem> importItems;
public List<ScmExportItem> exportItems;
}
53 changes: 53 additions & 0 deletions src/main/java/org/rundeck/client/api/model/ScmActionPerform.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package org.rundeck.client.api.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.List;
import java.util.Map;

/**
* @author greg
* @since 12/14/16
*/

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ScmActionPerform {
private Map<String, String> input;
private List<String> jobs;
private List<String> items;
private List<String> deleted;

public Map<String, String> getInput() {
return input;
}

public void setInput(Map<String, String> input) {
this.input = input;
}

public List<String> getJobs() {
return jobs;
}

public void setJobs(List<String> jobs) {
this.jobs = jobs;
}

public List<String> getItems() {
return items;
}

public void setItems(List<String> items) {
this.items = items;
}

public List<String> getDeleted() {
return deleted;
}

public void setDeleted(List<String> deleted) {
this.deleted = deleted;
}
}
33 changes: 33 additions & 0 deletions src/main/java/org/rundeck/client/api/model/ScmExportItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.rundeck.client.api.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.HashMap;
import java.util.Map;

/**
* @author greg
* @since 12/13/16
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class ScmExportItem {
public String itemId;
public String originalId;
public ScmJobItem job;
public Boolean renamed;
public Boolean deleted;

public Map toMap() {
HashMap<String, Object> map = new HashMap<>();
map.put("itemId", itemId);
if (null != originalId) {
map.put("originalId", originalId);
}
if (null != job) {
map.put("job", job.toMap());
}
map.put("renamed", renamed);
map.put("deleted", deleted);
return map;
}
}
25 changes: 25 additions & 0 deletions src/main/java/org/rundeck/client/api/model/ScmImportItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.rundeck.client.api.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.HashMap;
import java.util.Map;

/**
* @author greg
* @since 12/13/16
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class ScmImportItem {
public String itemId;
public Boolean tracked;
public ScmJobItem job;

public Map toMap() {
HashMap<String, Object> map = new HashMap<>();
map.put("itemId", itemId);
map.put("tracked", tracked);
map.put("job", job.toMap());
return map;
}
}
34 changes: 34 additions & 0 deletions src/main/java/org/rundeck/client/api/model/ScmInputField.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.rundeck.client.api.model;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @author greg
* @since 12/13/16
*/
public class ScmInputField {
public String defaultValue;
public String description;
public String name;
public Boolean required;
public Map<String, String> renderingOptions;
public String scope;
public String title;
public String type;
public List<String> values;

public Map toMap() {
HashMap<String, Object> map = new HashMap<>();
map.put("name", name);
map.put("title", title);
map.put("description", description);
map.put("defaultValue", defaultValue);
map.put("required", required);
map.put("scope", scope);
map.put("renderingOptions", renderingOptions);
map.put("values", values);
return map;
}
}
24 changes: 24 additions & 0 deletions src/main/java/org/rundeck/client/api/model/ScmJobItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.rundeck.client.api.model;

import org.simpleframework.xml.Element;

import java.util.HashMap;
import java.util.Map;

/**
* @author greg
* @since 12/13/16
*/
public class ScmJobItem {
public String jobId;
public String jobName;
public String groupPath;

public Map<String, Object> toMap() {
HashMap<String, Object> map = new HashMap<>();
map.put("jobId", jobId);
map.put("jobName", jobName);
map.put("groupPath", groupPath);
return map;
}
}
26 changes: 26 additions & 0 deletions src/main/java/org/rundeck/client/api/model/ScmPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.rundeck.client.api.model;

import java.util.HashMap;
import java.util.Map;

/**
* @author greg
* @since 12/13/16
*/
public class ScmPlugin {
public String type;
public String title;
public String description;
public Boolean configured;
public Boolean enabled;

public Map toMap() {
HashMap<String, Object> map = new HashMap<>();
map.put("type", type);
map.put("title", title);
map.put("description", description);
map.put("configured", configured);
map.put("enabled", enabled);
return map;
}
}
12 changes: 12 additions & 0 deletions src/main/java/org/rundeck/client/api/model/ScmPluginsResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.rundeck.client.api.model;

import java.util.List;

/**
* @author greg
* @since 12/13/16
*/
public class ScmPluginsResult {
public String integration;
public List<ScmPlugin> plugins;
}
Loading

0 comments on commit 206775f

Please sign in to comment.