use of org.platformlayer.ids.ManagedItemId in project platformlayer by platformlayer.
the class FederatedPlatformLayerClient method mapToChildForCreate.
private MappedPlatformLayerKey mapToChildForCreate(PlatformLayerKey plk) {
if (plk.getItemId() != null) {
throw new IllegalArgumentException();
}
FederationMapping childKey = federationMap.getClientForCreate(plk);
ManagedItemId childItemId;
ChildClient childClient = getClient(childKey);
childItemId = null;
MappedPlatformLayerKey mapped = new MappedPlatformLayerKey();
mapped.child = childClient;
mapped.key = new PlatformLayerKey(childKey.host, childKey.project, plk.getServiceType(), plk.getItemType(), childItemId);
return mapped;
}
use of org.platformlayer.ids.ManagedItemId in project platformlayer by platformlayer.
the class TypedPlatformLayerClient method toKey.
public <T> PlatformLayerKey toKey(Class<T> itemClass, String id) throws PlatformLayerClientException {
JaxbHelper jaxbHelper = PlatformLayerClientBase.toJaxbHelper(itemClass, new Class[0]);
ManagedItemId itemId = new ManagedItemId(id);
PlatformLayerKey key = PlatformLayerClientBase.toKey(jaxbHelper, itemId, itemClass, platformLayerClient.listServices(true));
return key;
}
use of org.platformlayer.ids.ManagedItemId in project platformlayer by platformlayer.
the class DnsServerController method addChildren.
@Override
protected void addChildren() throws OpsException {
InstanceBuilder vm = InstanceBuilder.build(model.dnsName, this, model.getTags());
// TODO: Do we need a DnsCluster concept?
// For now, we fake it
PlatformLayerKey key = model.getKey();
String groupId = key.withId(new ManagedItemId("primary")).getUrl();
groupId = groupId.replace("/dnsServer/", "/dnsCluster/");
vm.hostPolicy.configureSpread(groupId);
vm.addTagToManaged = true;
vm.publicPorts.add(53);
// vm.minimumMemoryMb = 512;
addChild(vm);
vm.addChild(DnsServerInstall.class);
vm.addChild(DnsServerInstance.class);
{
PublicEndpoint endpoint = injected(PublicEndpoint.class);
// endpoint.network = null;
endpoint.publicPort = 53;
endpoint.backendPort = 53;
endpoint.dnsName = model.dnsName;
endpoint.protocol = Protocol.Udp;
endpoint.tagItem = model.getKey();
endpoint.parentItem = model.getKey();
vm.addChild(endpoint);
}
// TODO: Refresh other DNS servers so they also point to this server
}
use of org.platformlayer.ids.ManagedItemId in project platformlayer by platformlayer.
the class JobsCollectionResource method getJob.
@Path("{jobId}")
public JobResource getJob(@PathParam("jobId") String jobId) throws OpsException {
PlatformLayerKey jobKey = JobData.buildKey(getProject(), new ManagedItemId(jobId));
JobData record = jobRegistry.getJob(jobKey);
if (record == null) {
raiseNotFound();
}
JobResource jobResource = jobResourceProvider.get();
jobResource.init(record);
return jobResource;
}
use of org.platformlayer.ids.ManagedItemId in project platformlayer by platformlayer.
the class PlatformLayerCliContext method pathToItem.
public PlatformLayerKey pathToItem(ProjectId project, String path) throws PlatformLayerClientException {
String serviceType = null;
String itemType = null;
String itemId = null;
if (path.contains("://")) {
return PlatformLayerKey.parse(path);
}
List<String> components = Lists.newArrayList(path.split("/"));
if (components.size() <= 1) {
throw new IllegalArgumentException("Cannot resolve path: " + path);
}
String head = components.get(0);
{
Map<String, ServiceInfo> services = listServices();
if (services.containsKey(head)) {
serviceType = services.get(head).serviceType;
components.remove(0);
if (components.size() <= 1) {
throw new IllegalArgumentException("Cannot resolve path: " + path);
}
head = components.get(0);
}
}
Multimap<String, ServiceInfo> items = listItemTypes();
if (items.containsKey(head)) {
Collection<ServiceInfo> services = items.get(head);
if (services.size() > 1) {
throw new IllegalArgumentException("Cannot resolve path (ambiguous item type): " + path);
}
ServiceInfo serviceInfo = Iterables.getOnlyElement(services);
itemType = head;
if (serviceType != null) {
if (!Objects.equal(serviceType, serviceInfo.serviceType)) {
throw new IllegalArgumentException("Cannot resolve path (service/item type mismatch): " + path);
}
} else {
serviceType = serviceInfo.serviceType;
}
components.remove(0);
} else {
throw new IllegalArgumentException("Cannot resolve path (unknown item type): " + path);
}
itemId = Joiner.on('/').join(components);
if (serviceType == null) {
throw new IllegalArgumentException("Cannot resolve path (service type not resolved): " + path);
}
if (itemType == null) {
throw new IllegalArgumentException("Cannot resolve path (item type not resolved): " + path);
}
if (Strings.isNullOrEmpty(itemId)) {
throw new IllegalArgumentException("Cannot resolve path (item id not resolved): " + path);
}
FederationKey host = null;
return new PlatformLayerKey(host, project, new ServiceType(serviceType), new ItemType(itemType), new ManagedItemId(itemId));
}
Aggregations