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;
}
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;
}
}
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;
}
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;
}
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;
}
Aggregations