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