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();
}
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;
}
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;
}
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;
}
Aggregations