use of org.platformlayer.jobs.model.JobDataList in project platformlayer by platformlayer.
the class JobsCollectionResource method getActiveJobs.
@GET
@Produces({ XML, JSON })
public JobDataList getActiveJobs() throws OpsException {
JobQuery jobQuery = JobQuery.build(getProject(), filterTarget);
List<JobData> jobList = jobRegistry.listRecentJobs(jobQuery);
JobDataList jobs = JobDataList.create();
jobs.jobs = Lists.newArrayList();
for (JobData jobData : jobList) {
jobs.jobs.add(jobData);
}
return jobs;
}
use of org.platformlayer.jobs.model.JobDataList in project platformlayer by platformlayer.
the class ListJobs method formatRaw.
@Override
public void formatRaw(Object o, PrintWriter writer) {
JobDataList jobs = (JobDataList) o;
switch(getFormat()) {
case JSON:
JsonHelper<JobDataList> jsonHelper = JsonHelper.build(JobDataList.class);
boolean formatted = true;
try {
String json = jsonHelper.marshal(jobs, formatted);
writer.println(json);
return;
} catch (IOException e) {
throw new CliException("Error formatting for output", e);
}
}
Ansi ansi = new Ansi(writer);
for (JobData job : jobs.getJobs()) {
// JobState state = job.state;
// if (state != null) {
// ansi.setColorBlue();
// switch (job.state) {
// case FAILED:
// ansi.setColorRed();
// break;
//
// case SUCCESS:
// ansi.setColorGreen();
// break;
//
// case RUNNING:
// ansi.setColorBlue();
// break;
//
// default:
// ansi.setColorBlue();
// break;
// }
// }
writer.println(job.key);
}
ansi.reset();
}
use of org.platformlayer.jobs.model.JobDataList in project platformlayer by platformlayer.
the class ListJobs method runCommand.
@Override
public Object runCommand() throws PlatformLayerClientException {
PlatformLayerClient client = getPlatformLayerClient();
JobDataList jobs;
if (path == null) {
jobs = client.listJobs();
} else {
PlatformLayerKey resolved = path.resolve(getContext());
jobs = client.listJobs(resolved);
}
return jobs;
}
use of org.platformlayer.jobs.model.JobDataList in project platformlayer by platformlayer.
the class HttpPlatformLayerClient method listJobs.
@Override
public JobDataList listJobs() throws PlatformLayerClientException {
String relativePath = "jobs";
JobDataList jobs = doRequest(HttpMethod.GET, relativePath, JobDataList.class, Format.XML, null, null);
return jobs;
}
use of org.platformlayer.jobs.model.JobDataList in project platformlayer by platformlayer.
the class HttpPlatformLayerClient method listJobs.
@Override
public JobDataList listJobs(PlatformLayerKey key) throws PlatformLayerClientException {
String relativePath = buildRelativePath(key) + "/jobs";
JobDataList jobs = doRequest(HttpMethod.GET, relativePath, JobDataList.class, Format.XML, null, null);
return jobs;
}
Aggregations