Search in sources :

Example 11 with UntypedItem

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

the class FederatedPlatformLayerClient method putItem.

// @Override
// public <T> T getItem(final Class<T> clazz, final PlatformLayerKey key) throws PlatformLayerClientException {
// MappedPlatformLayerKey mapped = mapToChild(key);
// T item = mapped.child.client.getItem(clazz, mapped.key);
// return mapped.child.setHost(item);
// }
// @Override
// public <T> T createItem(T item) throws PlatformLayerClientException {
// PlatformLayerKey key = toKey(item);
//
// MappedPlatformLayerKey mapped = mapToChildForCreate(key);
//
// T created = mapped.child.client.createItem(item);
// return mapped.child.setHost(created);
// }
//
// @Override
// public String createItem(ServiceType serviceType, ItemType itemType, String data, Format format) throws
// PlatformLayerClientException {
// throw new UnsupportedOperationException();
//
// // PlatformLayerKey key = new PlatformLayerKey(serviceType, itemType, null);
// // MappedPlatformLayerKey mapped = mapToChild(key);
// // String s = child.client.createItem(serviceType, itemType, data, format);
// // return child.setHost(s);
// }
@Override
public UntypedItem putItem(PlatformLayerKey key, String data, Format format) throws PlatformLayerClientException {
    MappedPlatformLayerKey mapped = mapToChildForPut(key);
    UntypedItemXml untypedItem = UntypedItemXml.build(data);
    untypedItem.setPlatformLayerKey(mapped.key);
    UntypedItem item = mapped.child.client.putItem(mapped.key, untypedItem.serialize(), format);
    return mapped.child.setHost(item);
}
Also used : UntypedItem(org.platformlayer.common.UntypedItem) UntypedItemXml(org.platformlayer.UntypedItemXml)

Example 12 with UntypedItem

use of org.platformlayer.common.UntypedItem 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 13 with UntypedItem

use of org.platformlayer.common.UntypedItem 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)

Example 14 with UntypedItem

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

the class HttpPlatformLayerClient method putItem.

@Override
public <T extends ItemBase> T putItem(T item) throws OpsException {
    JaxbHelper jaxbHelper = PlatformLayerClientBase.toJaxbHelper(item);
    String xml = PlatformLayerClientBase.serialize(jaxbHelper, item);
    PlatformLayerKey key = PlatformLayerClientBase.toKey(jaxbHelper, item, listServices(true));
    UntypedItem created = putItem(key, xml, Format.XML);
    Class<T> itemClass = (Class<T>) item.getClass();
    return promoteToTyped(created, itemClass);
}
Also used : UntypedItem(org.platformlayer.common.UntypedItem) JaxbHelper(org.platformlayer.xml.JaxbHelper) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey)

Example 15 with UntypedItem

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

the class ListRoots 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