Search in sources :

Example 1 with Api

use of org.ovirt.engine.api.model.Api in project ovirt-engine by oVirt.

the class BackendApiResource method head.

@Override
public Response head() {
    appMode = getCurrent().getApplicationMode();
    Api api;
    if (appMode == ApplicationMode.GlusterOnly) {
        api = getGlusterApi();
    } else {
        api = getApi();
    }
    return getResponseBuilder(api).build();
}
Also used : Api(org.ovirt.engine.api.model.Api)

Example 2 with Api

use of org.ovirt.engine.api.model.Api in project ovirt-engine by oVirt.

the class V3ApiOutAdapter method adapt.

@Override
public V3API adapt(Api from) {
    V3API to = new V3API();
    if (from.isSetActions()) {
        to.setActions(adaptOut(from.getActions()));
    }
    // Remove the links for "rels" that are new in version 4 of the API:
    if (from.isSetLinks()) {
        List<Link> links = from.getLinks().stream().filter(link -> !RELS_TO_REMOVE.contains(link.getRel())).collect(toList());
        to.getLinks().addAll(adaptOut(links));
    }
    // In version 4 of the API the "capabilities" resource was removed, but it still exists in version 3, so we
    // need to explicitly add a the link:
    to.getLinks().add(0, makeCapabilitiesLink());
    if (from.isSetSpecialObjects()) {
        to.setSpecialObjects(adaptOut(from.getSpecialObjects()));
    }
    if (from.isSetProductInfo()) {
        to.setProductInfo(adaptOut(from.getProductInfo()));
    }
    if (from.isSetSummary()) {
        to.setSummary(adaptOut(from.getSummary()));
    }
    if (from.isSetTime()) {
        to.setTime(from.getTime());
    }
    return to;
}
Also used : HashSet(java.util.HashSet) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) V3API(org.ovirt.engine.api.v3.types.V3API) Link(org.ovirt.engine.api.model.Link) V3Adapter(org.ovirt.engine.api.v3.V3Adapter) Current(org.ovirt.engine.api.restapi.invocation.Current) CurrentManager(org.ovirt.engine.api.restapi.invocation.CurrentManager) Set(java.util.Set) Api(org.ovirt.engine.api.model.Api) V3OutAdapters.adaptOut(org.ovirt.engine.api.v3.adapters.V3OutAdapters.adaptOut) V3Link(org.ovirt.engine.api.v3.types.V3Link) V3API(org.ovirt.engine.api.v3.types.V3API) Link(org.ovirt.engine.api.model.Link) V3Link(org.ovirt.engine.api.v3.types.V3Link)

Example 3 with Api

use of org.ovirt.engine.api.model.Api in project ovirt-engine by oVirt.

the class BackendApiResource method getGlusterApi.

private Api getGlusterApi() {
    Api api = new Api();
    api.setTime(DateMapper.map(new Date(), null));
    for (DetailedLink detailedLink : getGlusterLinks()) {
        // add thin link
        api.getLinks().add(LinkCreator.createLink(detailedLink.getHref(), detailedLink.getRel()));
        // when required - add extra link for search
        if (detailedLink.isSetLinkCapabilities() && detailedLink.getLinkCapabilities().isSetSearchable() && detailedLink.getLinkCapabilities().isSearchable()) {
            api.getLinks().add(LinkCreator.createLink(detailedLink.getHref(), detailedLink.getRel(), detailedLink.getRequest().getUrl().getParametersSets()));
        }
        // add special links
        SpecialObjects specialObjects = new SpecialObjects();
        specialObjects.setRootTag(createRootTag());
        api.setSpecialObjects(specialObjects);
    }
    return api;
}
Also used : DetailedLink(org.ovirt.engine.api.model.DetailedLink) SpecialObjects(org.ovirt.engine.api.model.SpecialObjects) Api(org.ovirt.engine.api.model.Api) Date(java.util.Date)

Example 4 with Api

use of org.ovirt.engine.api.model.Api in project ovirt-engine by oVirt.

the class BackendApiResource method getApi.

private Api getApi() {
    Api api = new Api();
    api.setTime(DateMapper.map(new Date(), null));
    for (DetailedLink detailedLink : getLinks()) {
        // add thin link
        api.getLinks().add(LinkCreator.createLink(detailedLink.getHref(), detailedLink.getRel()));
        // when required - add extra link for search
        if (detailedLink.isSetLinkCapabilities() && detailedLink.getLinkCapabilities().isSetSearchable() && detailedLink.getLinkCapabilities().isSearchable()) {
            api.getLinks().add(LinkCreator.createLink(detailedLink.getHref(), detailedLink.getRel(), detailedLink.getRequest().getUrl().getParametersSets()));
        }
        // add special links
        SpecialObjects specialObjects = new SpecialObjects();
        specialObjects.setBlankTemplate(createBlankTemplate());
        specialObjects.setRootTag(createRootTag());
        api.setSpecialObjects(specialObjects);
    }
    return api;
}
Also used : DetailedLink(org.ovirt.engine.api.model.DetailedLink) SpecialObjects(org.ovirt.engine.api.model.SpecialObjects) Api(org.ovirt.engine.api.model.Api) Date(java.util.Date)

Aggregations

Api (org.ovirt.engine.api.model.Api)4 Date (java.util.Date)2 DetailedLink (org.ovirt.engine.api.model.DetailedLink)2 SpecialObjects (org.ovirt.engine.api.model.SpecialObjects)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Collectors.toList (java.util.stream.Collectors.toList)1 Link (org.ovirt.engine.api.model.Link)1 Current (org.ovirt.engine.api.restapi.invocation.Current)1 CurrentManager (org.ovirt.engine.api.restapi.invocation.CurrentManager)1 V3Adapter (org.ovirt.engine.api.v3.V3Adapter)1 V3OutAdapters.adaptOut (org.ovirt.engine.api.v3.adapters.V3OutAdapters.adaptOut)1 V3API (org.ovirt.engine.api.v3.types.V3API)1 V3Link (org.ovirt.engine.api.v3.types.V3Link)1