use of org.ovirt.engine.api.model.Link in project ovirt-engine by oVirt.
the class AbstractBackendResource method removeIfExist.
protected <B extends BaseResource> void removeIfExist(B model, String relation) {
List<Link> linksCopy = new ArrayList<>(model.getLinks());
for (Link link : model.getLinks()) {
if (link.getRel().equals(relation)) {
linksCopy.remove(link);
break;
}
}
model.getLinks().retainAll(linksCopy);
}
use of org.ovirt.engine.api.model.Link in project ovirt-engine by oVirt.
the class LinkCreator method createSearchLink.
/**
* Create a search link with the given parameters
* @param url the url
* @param rel the link to add
* @return link with search
*/
public static Link createSearchLink(String url, String rel) {
Link link = new Link();
link.setRel(rel + SEARCH_RELATION);
link.setHref(combine(url, rel) + SEARCH_TEMPLATE);
return link;
}
use of org.ovirt.engine.api.model.Link in project ovirt-engine by oVirt.
the class LinkCreator method createLink.
public static Link createLink(String url, String rel) {
Link link = new Link();
link.setRel(rel);
link.setHref(url);
return link;
}
use of org.ovirt.engine.api.model.Link in project ovirt-engine by oVirt.
the class BackendApiResourceTest method verifyApi.
protected void verifyApi(Api api) {
assertNotNull(api);
assertNotNull(api.getTime());
assertNotNull(api.getLinks());
assertEquals(relationships.length, api.getLinks().size());
for (int i = 0; i < relationships.length; i++) {
Link l = api.getLinks().get(i);
assertNotNull(l);
assertEquals(relationships[i], l.getRel());
assertEquals(hrefs[i], l.getHref());
}
assertNotNull(api.getSpecialObjects());
assertContainsRootTag(api.getSpecialObjects());
assertContainsBlankTemplate(api.getSpecialObjects());
assertNotNull(api.getProductInfo());
assertNotNull(api.getProductInfo().getVersion());
assertNotNull(api.getProductInfo().getVersion().getFullVersion());
assertEquals(MAJOR, api.getProductInfo().getVersion().getMajor().intValue());
assertEquals(MINOR, api.getProductInfo().getVersion().getMinor().intValue());
assertEquals(BUILD, api.getProductInfo().getVersion().getBuild().intValue());
assertEquals(REVISION, api.getProductInfo().getVersion().getRevision().intValue());
assertNotNull(api.getSummary());
assertEquals(TOTAL_VMS, api.getSummary().getVms().getTotal().intValue());
assertEquals(ACTIVE_VMS, api.getSummary().getVms().getActive().intValue());
assertEquals(TOTAL_HOSTS, api.getSummary().getHosts().getTotal().intValue());
assertEquals(ACTIVE_HOSTS, api.getSummary().getHosts().getActive().intValue());
assertEquals(TOTAL_USERS, api.getSummary().getUsers().getTotal().intValue());
assertEquals(ACTIVE_USERS, api.getSummary().getUsers().getActive().intValue());
assertEquals(TOTAL_STORAGE_DOMAINS, api.getSummary().getStorageDomains().getTotal().intValue());
assertEquals(ACTIVE_STORAGE_DOMAINS, api.getSummary().getStorageDomains().getActive().intValue());
}
use of org.ovirt.engine.api.model.Link 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;
}
Aggregations