use of org.platformlayer.core.model.Tag in project platformlayer by platformlayer.
the class DirectPlatformLayerClient method listChildrenTyped.
@Override
public List<ItemBase> listChildrenTyped(PlatformLayerKey parentKey, boolean includeDeleted) throws OpsException {
parentKey = resolveKey(parentKey);
Tag parentTag = Tag.buildParentTag(parentKey);
Filter filter = TagFilter.byTag(parentTag);
if (!includeDeleted) {
filter = StateFilter.excludeDeleted(filter);
}
List<ItemBase> items = itemService.listAll(auth, filter);
return items;
}
use of org.platformlayer.core.model.Tag in project platformlayer by platformlayer.
the class OwnedEndpoint method buildItemTemplate.
@Override
protected PublicEndpointBase buildItemTemplate() throws OpsException {
InstanceBase instance = OpsContext.get().getInstance(InstanceBase.class);
PlatformLayerKey instanceKey = instance.getKey();
PublicEndpointBase publicEndpoint = platformLayerCloudHelpers.createPublicEndpoint(instance, parentItem);
// publicEndpoint.network = network;
publicEndpoint.publicPort = publicPort;
publicEndpoint.publicPortCluster = publicPortCluster;
publicEndpoint.backendPort = backendPort;
publicEndpoint.instance = instanceKey;
publicEndpoint.key = PlatformLayerKey.fromId(instance.getId() + "_" + publicPort);
if (transport != null) {
publicEndpoint.transport = transport.toString();
}
// publicEndpoint.getTags().add(OpsSystem.get().createParentTag(instance));
Tag uniqueTag = UniqueTag.build(instance, String.valueOf(publicPort));
publicEndpoint.getTags().add(uniqueTag);
return publicEndpoint;
}
use of org.platformlayer.core.model.Tag in project platformlayer by platformlayer.
the class PropertiesFileStore method findFirst.
public String findFirst(List<Tag> tags) throws OpsException {
List<String> keys = getKeys();
for (String key : keys) {
Properties properties = readProperties(key);
boolean valid = true;
for (Tag tag : tags) {
// String tagKey = PropertiesFileStore.PROPERTY_PREFIX_TAG + tag.key;
String tagKey = tag.key;
String tagValue = properties.getProperty(tagKey);
if (!Objects.equal(tagValue, tag.getValue())) {
valid = false;
break;
}
}
if (valid) {
return key;
}
}
return null;
}
use of org.platformlayer.core.model.Tag in project platformlayer by platformlayer.
the class PropertiesFileStore method find.
public List<String> find(List<Tag> tags) throws OpsException {
List<String> matches = Lists.newArrayList();
List<String> keys = getKeys();
for (String key : keys) {
Properties properties = readProperties(key);
boolean valid = true;
for (Tag tag : tags) {
// String tagKey = PropertiesFileStore.PROPERTY_PREFIX_TAG + tag.key;
String tagKey = tag.key;
String tagValue = properties.getProperty(tagKey);
if (!Comparisons.equalsIgnoreCase(tagValue, tag.getValue())) {
valid = false;
break;
}
}
if (valid) {
matches.add(key);
}
}
return matches;
}
use of org.platformlayer.core.model.Tag in project platformlayer by platformlayer.
the class PlatformLayerHelpers method getOrCreateUuid.
public UUID getOrCreateUuid(ItemBase model) throws PlatformLayerClientException {
Tags tags = model.getTags();
UUID uuid = Tag.UUID.findUnique(tags);
if (uuid != null) {
return uuid;
}
uuid = UUID.randomUUID();
Tag uuidTag = Tag.UUID.build(uuid);
tags.add(uuidTag);
this.addTag(model.getKey(), uuidTag);
return uuid;
}
Aggregations