Search in sources :

Example 1 with OnmsMonitoredServiceDetailList

use of org.opennms.netmgt.model.OnmsMonitoredServiceDetailList in project opennms by OpenNMS.

the class IfServicesRestService method getServices.

@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML })
public OnmsMonitoredServiceDetailList getServices(@Context final UriInfo uriInfo) {
    final Criteria c = getCriteria(uriInfo.getQueryParameters());
    final OnmsMonitoredServiceDetailList servicesList = new OnmsMonitoredServiceDetailList();
    final List<OnmsMonitoredService> services = m_serviceDao.findMatching(c);
    for (OnmsMonitoredService svc : services) {
        servicesList.add(new OnmsMonitoredServiceDetail(svc));
    }
    c.setLimit(null);
    c.setOffset(null);
    c.setOrders(new ArrayList<Order>());
    servicesList.setTotalCount(m_serviceDao.countMatching(c));
    return servicesList;
}
Also used : OnmsMonitoredServiceDetailList(org.opennms.netmgt.model.OnmsMonitoredServiceDetailList) OnmsMonitoredServiceDetail(org.opennms.netmgt.model.OnmsMonitoredServiceDetail) Order(org.opennms.core.criteria.Order) Criteria(org.opennms.core.criteria.Criteria) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with OnmsMonitoredServiceDetailList

use of org.opennms.netmgt.model.OnmsMonitoredServiceDetailList in project opennms by OpenNMS.

the class IfServicesRestServiceIT method testGetServices.

@Test
@JUnitTemporaryDatabase
public void testGetServices() throws Exception {
    String url = "/ifservices";
    OnmsMonitoredServiceDetailList list = getXmlObject(JaxbUtils.getContextFor(OnmsMonitoredServiceDetailList.class), url, 200, OnmsMonitoredServiceDetailList.class);
    for (OnmsMonitoredServiceDetail detail : list.getObjects()) {
        assertFalse("F".equals(detail.getStatusCode()));
    }
    // Mark all services as forced unmanaged
    sendPut(url, "status=F", 204);
    // Verify that all statuses were updated
    list = getXmlObject(JaxbUtils.getContextFor(OnmsMonitoredServiceDetailList.class), url, 200, OnmsMonitoredServiceDetailList.class);
    for (OnmsMonitoredServiceDetail detail : list.getObjects()) {
        assertEquals("F", detail.getStatusCode());
    }
}
Also used : OnmsMonitoredServiceDetailList(org.opennms.netmgt.model.OnmsMonitoredServiceDetailList) OnmsMonitoredServiceDetail(org.opennms.netmgt.model.OnmsMonitoredServiceDetail) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Aggregations

OnmsMonitoredServiceDetail (org.opennms.netmgt.model.OnmsMonitoredServiceDetail)2 OnmsMonitoredServiceDetailList (org.opennms.netmgt.model.OnmsMonitoredServiceDetailList)2 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 Test (org.junit.Test)1 Criteria (org.opennms.core.criteria.Criteria)1 Order (org.opennms.core.criteria.Order)1 JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)1 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)1