Search in sources :

Example 16 with PlatformLayerClient

use of org.platformlayer.PlatformLayerClient in project platformlayer by platformlayer.

the class DeleteItem method runCommand.

@Override
public Object runCommand() throws PlatformLayerClientException {
    PlatformLayerClient client = getPlatformLayerClient();
    PlatformLayerKey key = path.resolve(getContext());
    JobData jobData = client.deleteItem(key);
    return jobData;
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) JobData(org.platformlayer.jobs.model.JobData)

Example 17 with PlatformLayerClient

use of org.platformlayer.PlatformLayerClient in project platformlayer by platformlayer.

the class DeleteLink method runCommand.

@Override
public Object runCommand() throws PlatformLayerClientException {
    PlatformLayerClient client = getPlatformLayerClient();
    PlatformLayerKey resolved = path.resolve(getContext());
    UntypedItemXml item = (UntypedItemXml) client.getItemUntyped(resolved, Format.XML);
    Links links = item.getLinks();
    Link existing = links.findLink(name);
    List<Link> linkList = links.getLinks();
    if (existing != null) {
        linkList.remove(existing);
        item.setLinks(links);
        String xml = item.serialize();
        UntypedItemXml updated = (UntypedItemXml) client.putItem(resolved, xml, Format.XML);
        return updated.getLinks().getLinks();
    } else {
        return linkList;
    }
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) UntypedItemXml(org.platformlayer.UntypedItemXml) Links(org.platformlayer.core.model.Links) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) Link(org.platformlayer.core.model.Link)

Example 18 with PlatformLayerClient

use of org.platformlayer.PlatformLayerClient in project platformlayer by platformlayer.

the class DeleteTag method runCommand.

@Override
public Object runCommand() throws PlatformLayerClientException {
    PlatformLayerClient client = getPlatformLayerClient();
    PlatformLayerKey key = path.resolve(getContext());
    UntypedItem ret = client.getItemUntyped(key, Format.XML);
    TagChanges tagChanges = new TagChanges();
    for (Tag tag : ret.getTags()) {
        if (!tagKey.equals(tag.getKey())) {
            continue;
        }
        if (tagValue != null && !tagValue.equals(tag.getValue())) {
            continue;
        }
        tagChanges.removeTags.add(tag);
    }
    Tags newTags = client.changeTags(key, tagChanges, null);
    return newTags;
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) UntypedItem(org.platformlayer.common.UntypedItem) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) Tag(org.platformlayer.core.model.Tag) TagChanges(org.platformlayer.core.model.TagChanges) Tags(org.platformlayer.core.model.Tags)

Example 19 with PlatformLayerClient

use of org.platformlayer.PlatformLayerClient 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 20 with PlatformLayerClient

use of org.platformlayer.PlatformLayerClient in project platformlayer by platformlayer.

the class GetEndpoint method runCommand.

@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;
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) UntypedItem(org.platformlayer.common.UntypedItem) EndpointInfo(org.platformlayer.core.model.EndpointInfo) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey)

Aggregations

PlatformLayerClient (org.platformlayer.PlatformLayerClient)36 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)21 UntypedItem (org.platformlayer.common.UntypedItem)7 TypedPlatformLayerClient (org.platformlayer.TypedPlatformLayerClient)4 PlatformLayerCliContext (org.platformlayer.client.cli.PlatformLayerCliContext)4 JobData (org.platformlayer.jobs.model.JobData)4 CliException (com.fathomdb.cli.CliException)3 InputStream (java.io.InputStream)3 HttpPlatformLayerClient (org.platformlayer.HttpPlatformLayerClient)3 UntypedItemXml (org.platformlayer.UntypedItemXml)3 Tag (org.platformlayer.core.model.Tag)3 ProjectId (org.platformlayer.ids.ProjectId)3 JobExecutionList (org.platformlayer.jobs.model.JobExecutionList)3 ClientAction (com.fathomdb.cli.output.ClientAction)2 NoCloseInputStream (com.fathomdb.io.NoCloseInputStream)2 IOException (java.io.IOException)2 JSONObject (org.codehaus.jettison.json.JSONObject)2 JSONObject (org.json.JSONObject)2 EndpointInfo (org.platformlayer.core.model.EndpointInfo)2 Link (org.platformlayer.core.model.Link)2