Search in sources :

Example 16 with JobData

use of org.platformlayer.jobs.model.JobData in project platformlayer by platformlayer.

the class DeleteItem method formatRaw.

@Override
public void formatRaw(Object o, PrintWriter writer) {
    JobData jobData = (JobData) o;
    writer.println(jobData.getJobId());
}
Also used : JobData(org.platformlayer.jobs.model.JobData)

Example 17 with JobData

use of org.platformlayer.jobs.model.JobData in project platformlayer by platformlayer.

the class DoAction method runCommand.

@Override
public Object runCommand() throws PlatformLayerClientException {
    String json;
    try {
        JSONObject data;
        if (this.json != null) {
            data = new JSONObject(this.json);
        } else {
            data = new JSONObject();
        }
        data.put("type", action.getKey());
        json = data.toString();
    } catch (JSONException e) {
        throw new IllegalStateException("Error building JSON", e);
    }
    PlatformLayerClient client = getPlatformLayerClient();
    PlatformLayerKey key = path.resolve(getContext());
    JobData ret = client.doAction(key, json, Format.JSON);
    return ret;
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) JobData(org.platformlayer.jobs.model.JobData)

Example 18 with JobData

use of org.platformlayer.jobs.model.JobData in project platformlayer by platformlayer.

the class DoAction method formatRaw.

@Override
public void formatRaw(Object o, PrintWriter writer) {
    JobData jobData = (JobData) o;
    writer.println(jobData.getJobId());
}
Also used : JobData(org.platformlayer.jobs.model.JobData)

Example 19 with JobData

use of org.platformlayer.jobs.model.JobData in project platformlayer by platformlayer.

the class FederatedPlatformLayerClient method doAction.

@Override
public JobData doAction(PlatformLayerKey key, Action action) throws PlatformLayerClientException {
    MappedPlatformLayerKey mapped = mapToChild(key);
    JobData result = mapped.child.client.doAction(mapped.key, action);
    return mapped.child.setHost(result);
}
Also used : JobData(org.platformlayer.jobs.model.JobData)

Example 20 with JobData

use of org.platformlayer.jobs.model.JobData 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)

Aggregations

JobData (org.platformlayer.jobs.model.JobData)24 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)7 PlatformLayerClient (org.platformlayer.PlatformLayerClient)4 RepositoryException (org.platformlayer.RepositoryException)4 ManagedItemId (org.platformlayer.ids.ManagedItemId)4 OpsException (org.platformlayer.ops.OpsException)4 ItemBase (org.platformlayer.core.model.ItemBase)3 ProjectId (org.platformlayer.ids.ProjectId)3 SecretProvider (org.platformlayer.auth.crypto.SecretProvider)2 JobDataList (org.platformlayer.jobs.model.JobDataList)2 JobExecutionData (org.platformlayer.jobs.model.JobExecutionData)2 OpsContext (org.platformlayer.ops.OpsContext)2 ServiceProvider (org.platformlayer.xaas.services.ServiceProvider)2 CliException (com.fathomdb.cli.CliException)1 Ansi (com.fathomdb.cli.commands.Ansi)1 JdbcTransaction (com.fathomdb.jdbc.JdbcTransaction)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 SQLException (java.sql.SQLException)1 List (java.util.List)1