-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
155 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/main/java/org/rundeck/client/api/model/ScheduledJobItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package org.rundeck.client.api.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Created by greg on 7/8/16. | ||
*/ | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class ScheduledJobItem extends JobItem { | ||
private String serverNodeUUID; | ||
private boolean scheduled; | ||
private boolean scheduleEnabled; | ||
private boolean enabled; | ||
private boolean serverOwner; | ||
|
||
|
||
public String getServerNodeUUID() { | ||
return serverNodeUUID; | ||
} | ||
|
||
public void setServerNodeUUID(String serverNodeUUID) { | ||
this.serverNodeUUID = serverNodeUUID; | ||
} | ||
|
||
public boolean isScheduled() { | ||
return scheduled; | ||
} | ||
|
||
public void setScheduled(boolean scheduled) { | ||
this.scheduled = scheduled; | ||
} | ||
|
||
public boolean isScheduleEnabled() { | ||
return scheduleEnabled; | ||
} | ||
|
||
public void setScheduleEnabled(boolean scheduleEnabled) { | ||
this.scheduleEnabled = scheduleEnabled; | ||
} | ||
|
||
public boolean isEnabled() { | ||
return enabled; | ||
} | ||
|
||
public void setEnabled(boolean enabled) { | ||
this.enabled = enabled; | ||
} | ||
|
||
public boolean isServerOwner() { | ||
return serverOwner; | ||
} | ||
|
||
public void setServerOwner(boolean serverOwner) { | ||
this.serverOwner = serverOwner; | ||
} | ||
|
||
public Map<String, Object> toMap() { | ||
HashMap<String, Object> map = new HashMap<>(); | ||
map.put("job", toBasicString()); | ||
map.put("serverNodeUUID", getServerNodeUUID()); | ||
map.put("scheduled", scheduled); | ||
map.put("scheduleEnabled", scheduleEnabled); | ||
map.put("enabled", enabled); | ||
map.put("serverOwner", serverOwner); | ||
return map; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return super.toBasicString() + | ||
"\n serverNodeUUID='" + serverNodeUUID + '\'' + | ||
", scheduled=" + scheduled + | ||
", scheduleEnabled=" + scheduleEnabled + | ||
", enabled=" + enabled + | ||
", serverOwner=" + serverOwner; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/org/rundeck/client/tool/commands/Scheduler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.rundeck.client.tool.commands; | ||
|
||
import com.lexicalscope.jewel.cli.CommandLineInterface; | ||
import com.lexicalscope.jewel.cli.Option; | ||
import org.rundeck.client.api.RundeckApi; | ||
import org.rundeck.client.api.model.JobItem; | ||
import org.rundeck.client.api.model.ScheduledJobItem; | ||
import org.rundeck.client.api.model.SystemInfo; | ||
import org.rundeck.client.tool.options.ProjectCreateOptions; | ||
import org.rundeck.client.util.Client; | ||
import org.rundeck.util.toolbelt.Command; | ||
import org.rundeck.util.toolbelt.CommandOutput; | ||
import retrofit2.Call; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Created by greg on 7/8/16. | ||
*/ | ||
@Command(description = "View scheduler information") | ||
public class Scheduler extends ApiCommand { | ||
public Scheduler(final Client<RundeckApi> client) { | ||
super(client); | ||
} | ||
|
||
|
||
@CommandLineInterface(application = "jobs") interface SchedulerJobs { | ||
|
||
|
||
@Option(shortName = "u", | ||
longName = "uuid", | ||
description = "Server UUID to query, or blank to select the target server") | ||
String getUuid(); | ||
|
||
boolean isUuid(); | ||
} | ||
|
||
@Command(description = "List jobs for the current target server, or a specified server.") | ||
public void jobs(SchedulerJobs options, CommandOutput output) throws IOException { | ||
Call<List<ScheduledJobItem>> call; | ||
if (options.isUuid()) { | ||
call = client.getService().listSchedulerJobs(options.getUuid()); | ||
} else { | ||
call = client.getService().listSchedulerJobs(); | ||
} | ||
List<ScheduledJobItem> jobInfo = client.checkError(call); | ||
output.output(jobInfo.stream().map(ScheduledJobItem::toMap).collect(Collectors.toList())); | ||
} | ||
} |