Search in sources :

Example 1 with JobDataList

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;
}
Also used : JobQuery(org.platformlayer.ops.tasks.JobQuery) JobDataList(org.platformlayer.jobs.model.JobDataList) JobData(org.platformlayer.jobs.model.JobData) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with JobDataList

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();
}
Also used : CliException(com.fathomdb.cli.CliException) JobDataList(org.platformlayer.jobs.model.JobDataList) IOException(java.io.IOException) JobData(org.platformlayer.jobs.model.JobData) Ansi(com.fathomdb.cli.commands.Ansi)

Example 3 with JobDataList

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;
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) JobDataList(org.platformlayer.jobs.model.JobDataList) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey)

Example 4 with JobDataList

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;
}
Also used : JobDataList(org.platformlayer.jobs.model.JobDataList)

Example 5 with JobDataList

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;
}
Also used : JobDataList(org.platformlayer.jobs.model.JobDataList)

Aggregations

JobDataList (org.platformlayer.jobs.model.JobDataList)5 JobData (org.platformlayer.jobs.model.JobData)2 CliException (com.fathomdb.cli.CliException)1 Ansi (com.fathomdb.cli.commands.Ansi)1 IOException (java.io.IOException)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 PlatformLayerClient (org.platformlayer.PlatformLayerClient)1 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)1 JobQuery (org.platformlayer.ops.tasks.JobQuery)1