Search in sources :

Example 1 with ManagedItemId

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;
}
Also used : PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) ManagedItemId(org.platformlayer.ids.ManagedItemId)

Example 2 with ManagedItemId

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;
}
Also used : JaxbHelper(org.platformlayer.xml.JaxbHelper) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) ManagedItemId(org.platformlayer.ids.ManagedItemId)

Example 3 with ManagedItemId

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
}
Also used : PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) PublicEndpoint(org.platformlayer.ops.networks.PublicEndpoint) ManagedItemId(org.platformlayer.ids.ManagedItemId) InstanceBuilder(org.platformlayer.ops.instances.InstanceBuilder)

Example 4 with ManagedItemId

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;
}
Also used : PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) JobData(org.platformlayer.jobs.model.JobData) ManagedItemId(org.platformlayer.ids.ManagedItemId) Path(javax.ws.rs.Path)

Example 5 with ManagedItemId

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));
}
Also used : ServiceInfo(org.platformlayer.core.model.ServiceInfo) ServiceType(org.platformlayer.ids.ServiceType) ItemType(org.platformlayer.ids.ItemType) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) Map(java.util.Map) ManagedItemId(org.platformlayer.ids.ManagedItemId) FederationKey(org.platformlayer.ids.FederationKey)

Aggregations

ManagedItemId (org.platformlayer.ids.ManagedItemId)20 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)13 ProjectId (org.platformlayer.ids.ProjectId)9 RepositoryException (org.platformlayer.RepositoryException)7 ItemType (org.platformlayer.ids.ItemType)5 ServiceType (org.platformlayer.ids.ServiceType)5 FederationKey (org.platformlayer.ids.FederationKey)4 JobData (org.platformlayer.jobs.model.JobData)4 OpsException (org.platformlayer.ops.OpsException)4 JdbcTransaction (com.fathomdb.jdbc.JdbcTransaction)3 SQLException (java.sql.SQLException)3 AesCryptoKey (com.fathomdb.crypto.AesCryptoKey)2 CryptoKey (com.fathomdb.crypto.CryptoKey)2 Path (javax.ws.rs.Path)2 SecretProvider (org.platformlayer.auth.crypto.SecretProvider)2 ModelClass (org.platformlayer.xaas.services.ModelClass)2 ServiceProvider (org.platformlayer.xaas.services.ServiceProvider)2 JaxbHelper (org.platformlayer.xml.JaxbHelper)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1