Search in sources :

Example 56 with PlatformLayerKey

use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.

the class UntypedItemFormatter method formatItem.

public static void formatItem(UntypedItem o, Ansi ansi, boolean fullPath) {
    UntypedItemXml item = (UntypedItemXml) o;
    Ansi.Action action = null;
    switch(item.getState()) {
        case ACTIVE:
            action = Ansi.TEXT_COLOR_GREEN;
            break;
        case BUILD_ERROR:
            action = Ansi.TEXT_COLOR_RED;
            break;
        case DELETED:
            action = Ansi.TEXT_COLOR_MAGENTA;
            break;
        default:
            action = Ansi.TEXT_COLOR_BLUE;
            break;
    }
    Ansi.Action undo = null;
    if (action != null) {
        undo = ansi.doAction(action);
    }
    try {
        PlatformLayerKey plk = item.getKey();
        if (fullPath) {
            ansi.print(plk.getUrl());
        } else {
            ansi.print(plk.getItemId().getKey());
        }
    } finally {
        if (undo != null) {
            ansi.doAction(undo);
        }
    }
    ansi.println();
}
Also used : UntypedItemXml(org.platformlayer.UntypedItemXml) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) Ansi(com.fathomdb.cli.commands.Ansi)

Example 57 with PlatformLayerKey

use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.

the class Utils method reformatText.

public static String reformatText(PlatformLayerCliContext context, String text) {
    if (text.startsWith("platform://")) {
        // This looks like a PlatformLayerKey
        try {
            PlatformLayerKey key = PlatformLayerKey.parse(text);
            text = formatUrl(context, key);
        } catch (Exception e) {
        // Ignore
        }
    }
    return text;
}
Also used : PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey)

Example 58 with PlatformLayerKey

use of org.platformlayer.core.model.PlatformLayerKey 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 59 with PlatformLayerKey

use of org.platformlayer.core.model.PlatformLayerKey in project platformlayer by platformlayer.

the class ListMetrics method runCommand.

@Override
public Object runCommand() throws PlatformLayerClientException {
    PlatformLayerClient client = getPlatformLayerClient();
    PlatformLayerKey key = getContext().pathToItem(getProject(), path);
    MetricInfoCollection items = client.listMetrics(key);
    return items;
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) MetricInfoCollection(org.platformlayer.metrics.model.MetricInfoCollection)

Example 60 with PlatformLayerKey

use of org.platformlayer.core.model.PlatformLayerKey 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)

Aggregations

PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)86 PlatformLayerClient (org.platformlayer.PlatformLayerClient)21 OpsException (org.platformlayer.ops.OpsException)16 ItemBase (org.platformlayer.core.model.ItemBase)14 ManagedItemId (org.platformlayer.ids.ManagedItemId)13 UntypedItem (org.platformlayer.common.UntypedItem)10 ProjectId (org.platformlayer.ids.ProjectId)10 Tag (org.platformlayer.core.model.Tag)8 RepositoryException (org.platformlayer.RepositoryException)7 ServiceType (org.platformlayer.ids.ServiceType)7 JobData (org.platformlayer.jobs.model.JobData)7 InstanceBase (org.platformlayer.core.model.InstanceBase)6 ItemType (org.platformlayer.ids.ItemType)6 OpsTarget (org.platformlayer.ops.OpsTarget)6 JaxbHelper (org.platformlayer.xml.JaxbHelper)6 Handler (org.platformlayer.ops.Handler)5 TypedPlatformLayerClient (org.platformlayer.TypedPlatformLayerClient)4 UntypedItemXml (org.platformlayer.UntypedItemXml)4 FederationKey (org.platformlayer.ids.FederationKey)4 Machine (org.platformlayer.ops.Machine)4