Search in sources :

Example 1 with Link

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);
}
Also used : ArrayList(java.util.ArrayList) Link(org.ovirt.engine.api.model.Link)

Example 2 with Link

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;
}
Also used : Link(org.ovirt.engine.api.model.Link) DetailedLink(org.ovirt.engine.api.model.DetailedLink)

Example 3 with 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;
}
Also used : Link(org.ovirt.engine.api.model.Link) DetailedLink(org.ovirt.engine.api.model.DetailedLink)

Example 4 with 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());
}
Also used : Link(org.ovirt.engine.api.model.Link)

Example 5 with Link

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

Aggregations

Link (org.ovirt.engine.api.model.Link)19 List (java.util.List)5 HashSet (java.util.HashSet)4 Set (java.util.Set)4 Collectors.toList (java.util.stream.Collectors.toList)4 V3Adapter (org.ovirt.engine.api.v3.V3Adapter)4 V3OutAdapters.adaptOut (org.ovirt.engine.api.v3.adapters.V3OutAdapters.adaptOut)4 DetailedLink (org.ovirt.engine.api.model.DetailedLink)3 V3Link (org.ovirt.engine.api.v3.types.V3Link)3 V3Status (org.ovirt.engine.api.v3.types.V3Status)3 Method (java.lang.reflect.Method)2 TimeZone (org.ovirt.engine.api.model.TimeZone)2 Vm (org.ovirt.engine.api.model.Vm)2 V3CustomProperties (org.ovirt.engine.api.v3.types.V3CustomProperties)2 V3KatelloErrata (org.ovirt.engine.api.v3.types.V3KatelloErrata)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 LinkedList (java.util.LinkedList)1 Optional (java.util.Optional)1