Search in sources :

Example 16 with UntypedItem

use of org.platformlayer.common.UntypedItem in project platformlayer by platformlayer.

the class ListTags method runCommand.

@Override
public Object runCommand() throws PlatformLayerClientException {
    PlatformLayerClient client = getPlatformLayerClient();
    PlatformLayerKey key = path.resolve(getContext());
    UntypedItem ret = client.getItemUntyped(key, getFormat());
    return ret.getTags();
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) UntypedItem(org.platformlayer.common.UntypedItem) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey)

Example 17 with UntypedItem

use of org.platformlayer.common.UntypedItem in project platformlayer by platformlayer.

the class PutItem method formatRaw.

@Override
public void formatRaw(Object o, PrintWriter writer) {
    UntypedItem item = (UntypedItem) o;
    writer.println(item.getKey());
}
Also used : UntypedItem(org.platformlayer.common.UntypedItem)

Example 18 with UntypedItem

use of org.platformlayer.common.UntypedItem in project platformlayer by platformlayer.

the class HttpPlatformLayerClient method getItemUntyped.

@Override
public UntypedItem getItemUntyped(PlatformLayerKey key, Format format) throws PlatformLayerClientException {
    String relativePath = buildRelativePath(key);
    String data = doRequest(HttpMethod.GET, relativePath, String.class, format, null, null);
    UntypedItem item;
    switch(format) {
        case XML:
            item = UntypedItemXml.build(data);
            break;
        case JSON:
            item = UntypedItemJson.build(data);
            break;
        default:
            throw new IllegalArgumentException("Format not supported");
    }
    return item;
}
Also used : UntypedItem(org.platformlayer.common.UntypedItem)

Example 19 with UntypedItem

use of org.platformlayer.common.UntypedItem in project platformlayer by platformlayer.

the class PlatformLayerClientBase method listChildrenTyped.

@Override
public List<ItemBase> listChildrenTyped(PlatformLayerKey parent, boolean includeDeleted) throws OpsException {
    List<ItemBase> ret = Lists.newArrayList();
    for (UntypedItem item : listChildren(parent, includeDeleted).getItems()) {
        ItemBase typedItem = promoteToTyped(item);
        ret.add(typedItem);
    }
    return ret;
}
Also used : UntypedItem(org.platformlayer.common.UntypedItem) ItemBase(org.platformlayer.core.model.ItemBase)

Example 20 with UntypedItem

use of org.platformlayer.common.UntypedItem in project platformlayer by platformlayer.

the class ListChildren method formatRaw.

@Override
public void formatRaw(Object o, PrintWriter writer) {
    Ansi ansi = new Ansi(writer);
    Iterable<UntypedItem> items = (Iterable<UntypedItem>) o;
    for (UntypedItem item : items) {
        UntypedItemFormatter.formatItem(item, ansi, true);
    }
    ansi.reset();
}
Also used : UntypedItem(org.platformlayer.common.UntypedItem) Ansi(com.fathomdb.cli.commands.Ansi)

Aggregations

UntypedItem (org.platformlayer.common.UntypedItem)22 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)10 PlatformLayerClient (org.platformlayer.PlatformLayerClient)7 Ansi (com.fathomdb.cli.commands.Ansi)3 UntypedItemXml (org.platformlayer.UntypedItemXml)3 JaxbHelper (org.platformlayer.xml.JaxbHelper)3 CliException (com.fathomdb.cli.CliException)2 ClientAction (com.fathomdb.cli.output.ClientAction)2 InetAddress (java.net.InetAddress)2 EndpointInfo (org.platformlayer.core.model.EndpointInfo)2 Tag (org.platformlayer.core.model.Tag)2 Tags (org.platformlayer.core.model.Tags)2 NoCloseInputStream (com.fathomdb.io.NoCloseInputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1 UntypedItemCollection (org.platformlayer.common.UntypedItemCollection)1 ItemBase (org.platformlayer.core.model.ItemBase)1