Search in sources :

Example 51 with PlatformLayerKey

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

the class DeleteLink method runCommand.

@Override
public Object runCommand() throws PlatformLayerClientException {
    PlatformLayerClient client = getPlatformLayerClient();
    PlatformLayerKey resolved = path.resolve(getContext());
    UntypedItemXml item = (UntypedItemXml) client.getItemUntyped(resolved, Format.XML);
    Links links = item.getLinks();
    Link existing = links.findLink(name);
    List<Link> linkList = links.getLinks();
    if (existing != null) {
        linkList.remove(existing);
        item.setLinks(links);
        String xml = item.serialize();
        UntypedItemXml updated = (UntypedItemXml) client.putItem(resolved, xml, Format.XML);
        return updated.getLinks().getLinks();
    } else {
        return linkList;
    }
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) UntypedItemXml(org.platformlayer.UntypedItemXml) Links(org.platformlayer.core.model.Links) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) Link(org.platformlayer.core.model.Link)

Example 52 with PlatformLayerKey

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

the class DeleteTag method runCommand.

@Override
public Object runCommand() throws PlatformLayerClientException {
    PlatformLayerClient client = getPlatformLayerClient();
    PlatformLayerKey key = path.resolve(getContext());
    UntypedItem ret = client.getItemUntyped(key, Format.XML);
    TagChanges tagChanges = new TagChanges();
    for (Tag tag : ret.getTags()) {
        if (!tagKey.equals(tag.getKey())) {
            continue;
        }
        if (tagValue != null && !tagValue.equals(tag.getValue())) {
            continue;
        }
        tagChanges.removeTags.add(tag);
    }
    Tags newTags = client.changeTags(key, tagChanges, null);
    return newTags;
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) UntypedItem(org.platformlayer.common.UntypedItem) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) Tag(org.platformlayer.core.model.Tag) TagChanges(org.platformlayer.core.model.TagChanges) Tags(org.platformlayer.core.model.Tags)

Example 53 with PlatformLayerKey

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

the class DoAction method runCommand.

@Override
public Object runCommand() throws PlatformLayerClientException {
    String json;
    try {
        JSONObject data;
        if (this.json != null) {
            data = new JSONObject(this.json);
        } else {
            data = new JSONObject();
        }
        data.put("type", action.getKey());
        json = data.toString();
    } catch (JSONException e) {
        throw new IllegalStateException("Error building JSON", e);
    }
    PlatformLayerClient client = getPlatformLayerClient();
    PlatformLayerKey key = path.resolve(getContext());
    JobData ret = client.doAction(key, json, Format.JSON);
    return ret;
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) JobData(org.platformlayer.jobs.model.JobData)

Example 54 with PlatformLayerKey

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

the class GetEndpoint method runCommand.

@Override
public Object runCommand() throws PlatformLayerClientException {
    // Should this be a tag?
    PlatformLayerClient client = getPlatformLayerClient();
    PlatformLayerKey key = path.resolve(getContext());
    UntypedItem untypedItem = client.getItemUntyped(key, Format.XML);
    List<EndpointInfo> endpoints = EndpointInfo.getEndpoints(untypedItem.getTags());
    return endpoints;
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) UntypedItem(org.platformlayer.common.UntypedItem) EndpointInfo(org.platformlayer.core.model.EndpointInfo) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey)

Example 55 with PlatformLayerKey

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

the class ActionCommandBase method runAction.

protected JobData runAction(ItemPath path, Action action) throws PlatformLayerClientException {
    PlatformLayerClient client = getPlatformLayerClient();
    PlatformLayerKey key = path.resolve(getContext());
    JobData ret = client.doAction(key, action);
    return ret;
}
Also used : PlatformLayerClient(org.platformlayer.PlatformLayerClient) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) JobData(org.platformlayer.jobs.model.JobData)

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