Package org.platformlayer

Examples of org.platformlayer.PlatformLayerClient


    super("get", "sshkey");
  }

  @Override
  public Object runCommand() throws PlatformLayerClientException {
    PlatformLayerClient client = getPlatformLayerClient();

    String sshKey = client.getSshPublicKey(serviceType);

    return sshKey;
  }
View Full Code Here


    super("list", "jobs");
  }

  @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);
    }
    // if (path != null) {
    // PlatformLayerKey resolved = path.resolve(getContext());
    //
    // JobDataList matches = JobDataList.create();
View Full Code Here

  protected ActionCommandBase(String verb) {
    super(verb, "item");
  }

  protected JobData runAction(ItemPath path, Action action) throws PlatformLayerClientException {
    PlatformLayerClient client = getPlatformLayerClient();

    PlatformLayerKey key = path.resolve(getContext());

    JobData ret = client.doAction(key, action);
    return ret;
  }
View Full Code Here

  }

  @Override
  public Object runCommand() throws PlatformLayerClientException {
    // Should this be a tag?
    PlatformLayerClient client = getPlatformLayerClient();

    PlatformLayerKey key = path.resolve(getContext());

    UntypedItem untypedItem = client.getItemUntyped(key, Format.XML);
    List<EndpointInfo> endpoints = EndpointInfo.getEndpoints(untypedItem.getTags());

    return endpoints;
  }
View Full Code Here

    super("list", "runs");
  }

  @Override
  public Object runCommand() throws PlatformLayerClientException {
    PlatformLayerClient client = getPlatformLayerClient();

    JobExecutionList runs;
    if (jobId == null) {
      runs = client.listJobExecutions();
    } else {
      runs = client.listJobExecutions(jobId);
    }

    return runs;
  }
View Full Code Here

    super("get", "log");
  }

  @Override
  public Object runCommand() throws PlatformLayerClientException {
    PlatformLayerClient client = getPlatformLayerClient();

    if (jobId.contains("/") && executionId == null) {
      String[] tokens = jobId.split("/");
      if (tokens.length == 2) {
        jobId = tokens[0];
        executionId = tokens[1];
      }
    }
    List<JobLog> logs = Lists.newArrayList();

    if (Strings.isNullOrEmpty(executionId)) {
      JobExecutionList jobExecutions = client.listJobExecutions(jobId);

      List<JobExecutionData> runs = jobExecutions.getRuns();

      sort(runs);

      // TODO: Remove limit (or iterate)
      if (runs.size() > 10) {
        runs = Lists.newArrayList(runs.subList(runs.size() - 10, runs.size()));
      }

      // TODO: Fix 1+N slowness...
      for (JobExecutionData execution : runs) {
        if (execution.getState() == JobState.PRESTART) {
          continue;
        }

        String executionId = execution.getExecutionId();
        try {
          JobLog jobLog = client.getJobExecutionLog(jobId, executionId);
          logs.add(jobLog);
        } catch (PlatformLayerClientNotFoundException e) {
          // TODO: Warn?
        }
      }
    } else {
      JobLog jobLog = client.getJobExecutionLog(jobId, executionId);
      logs.add(jobLog);
    }

    return logs;
  }
View Full Code Here

  }

  public static Object activateService(String serviceType, Object properties) throws PlatformLayerClientException,
      JSONException {
    PlatformLayerCliContext context = PlatformLayerCliContext.get();
    PlatformLayerClient client = context.getPlatformLayerClient();
    String json = properties.toString();
    String wrapper = "{ \"data\": \"" + json + "\" }";
    String retvalJsonString = client.activateService(serviceType, wrapper, Format.JSON);
    JSONObject retvalJsonObject = new JSONObject(retvalJsonString);
    return toPython(retvalJsonObject);
  }
View Full Code Here

    return toPython(retvalJsonObject);
  }

  public static Object getActivation(String serviceType) throws PlatformLayerClientException, JSONException {
    PlatformLayerCliContext context = PlatformLayerCliContext.get();
    PlatformLayerClient client = context.getPlatformLayerClient();
    String retvalJsonString = client.getActivation(serviceType, Format.JSON);
    JSONObject retvalJsonObject = new JSONObject(retvalJsonString);
    return toPython(retvalJsonObject);
  }
View Full Code Here

    return toPython(retvalJsonObject);
  }

  public static Object getSshPublicKey(String serviceType) throws PlatformLayerClientException, JSONException {
    PlatformLayerCliContext context = PlatformLayerCliContext.get();
    PlatformLayerClient client = context.getPlatformLayerClient();
    String key = client.getSshPublicKey(serviceType);
    return toPython(key);
  }
View Full Code Here

    return toPython(key);
  }

  public static Object getSchema(String serviceType) throws PlatformLayerClientException, JSONException {
    PlatformLayerCliContext context = PlatformLayerCliContext.get();
    PlatformLayerClient client = context.getPlatformLayerClient();
    String retval = client.getSchema(serviceType, Format.XML);
    return retval;
  }
View Full Code Here

TOP

Related Classes of org.platformlayer.PlatformLayerClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.