Search in sources :

Example 71 with DELETE

use of javax.ws.rs.DELETE in project opennms by OpenNMS.

the class ForeignSourceRestService method deletePendingForeignSource.

/**
 * <p>deletePendingForeignSource</p>
 *
 * @param foreignSource a {@link java.lang.String} object.
 * @return a {@link javax.ws.rs.core.Response} object.
 */
@DELETE
@Path("{foreignSource}")
@Transactional
public Response deletePendingForeignSource(@PathParam("foreignSource") final String foreignSource) {
    writeLock();
    try {
        ForeignSource fs = getForeignSource(foreignSource);
        LOG.debug("deletePendingForeignSource: deleting foreign source {}", foreignSource);
        m_pendingForeignSourceRepository.delete(fs);
        return Response.accepted().build();
    } finally {
        writeUnlock();
    }
}
Also used : ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Transactional(org.springframework.transaction.annotation.Transactional)

Example 72 with DELETE

use of javax.ws.rs.DELETE in project opennms by OpenNMS.

the class ForeignSourceRestService method deleteDeployedForeignSource.

/**
 * <p>deleteDeployedForeignSource</p>
 *
 * @param foreignSource a {@link java.lang.String} object.
 * @return a {@link javax.ws.rs.core.Response} object.
 */
@DELETE
@Path("deployed/{foreignSource}")
@Transactional
public Response deleteDeployedForeignSource(@PathParam("foreignSource") final String foreignSource) {
    writeLock();
    try {
        ForeignSource fs = getForeignSource(foreignSource);
        LOG.debug("deleteDeployedForeignSource: deleting foreign source {}", foreignSource);
        if ("default".equals(foreignSource)) {
            m_deployedForeignSourceRepository.resetDefaultForeignSource();
        } else {
            m_deployedForeignSourceRepository.delete(fs);
        }
        return Response.accepted().build();
    } finally {
        writeUnlock();
    }
}
Also used : ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Transactional(org.springframework.transaction.annotation.Transactional)

Example 73 with DELETE

use of javax.ws.rs.DELETE in project opennms by OpenNMS.

the class NodeRestService method deleteNode.

/**
 * <p>deleteNode</p>
 *
 * @param nodeCriteria a {@link java.lang.String} object.
 * @return a {@link javax.ws.rs.core.Response} object.
 */
@DELETE
@Path("{nodeCriteria}")
public Response deleteNode(@PathParam("nodeCriteria") final String nodeCriteria) {
    writeLock();
    try {
        final OnmsNode node = m_nodeDao.get(nodeCriteria);
        if (node == null)
            throw getException(Status.BAD_REQUEST, "Node {} was not found.", nodeCriteria);
        LOG.debug("deleteNode: deleting node {}", nodeCriteria);
        Event e = EventUtils.createDeleteNodeEvent("OpenNMS.REST", node.getId(), -1L);
        sendEvent(e);
        return Response.noContent().build();
    } finally {
        writeUnlock();
    }
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) Event(org.opennms.netmgt.xml.event.Event) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 74 with DELETE

use of javax.ws.rs.DELETE in project opennms by OpenNMS.

the class OnmsMonitoredServiceResource method deleteService.

/**
 * <p>deleteService</p>
 *
 * @param nodeCriteria a {@link java.lang.String} object.
 * @param ipAddress a {@link java.lang.String} object.
 * @param serviceName a {@link java.lang.String} object.
 * @return a {@link javax.ws.rs.core.Response} object.
 */
@DELETE
@Path("{service}")
public Response deleteService(@PathParam("nodeCriteria") final String nodeCriteria, @PathParam("ipAddress") final String ipAddress, @PathParam("service") final String serviceName) {
    writeLock();
    try {
        OnmsNode node = m_nodeDao.get(nodeCriteria);
        if (node == null)
            throw getException(Status.BAD_REQUEST, "Node {} was not found.", nodeCriteria);
        OnmsIpInterface intf = node.getIpInterfaceByIpAddress(ipAddress);
        if (intf == null)
            throw getException(Status.BAD_REQUEST, "IP Interface {} was not found on node {}.", ipAddress, nodeCriteria);
        OnmsMonitoredService service = intf.getMonitoredServiceByServiceType(serviceName);
        if (service == null)
            throw getException(Status.CONFLICT, "Monitored Service {} was not found on IP Interface {} and node {}.", serviceName, ipAddress, nodeCriteria);
        LOG.debug("deleteService: deleting service {} from node {}", serviceName, nodeCriteria);
        Event e = EventUtils.createDeleteServiceEvent("OpenNMS.REST", node.getId(), ipAddress, serviceName, -1L);
        sendEvent(e);
        return Response.noContent().build();
    } finally {
        writeUnlock();
    }
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) Event(org.opennms.netmgt.xml.event.Event) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 75 with DELETE

use of javax.ws.rs.DELETE in project opennms by OpenNMS.

the class OnmsSnmpInterfaceResource method deleteSnmpInterface.

/**
 * <p>deleteSnmpInterface</p>
 *
 * @param nodeCriteria a {@link java.lang.String} object.
 * @param ifIndex a int.
 * @return a {@link javax.ws.rs.core.Response} object.
 */
@DELETE
@Path("{ifIndex}")
public Response deleteSnmpInterface(@PathParam("nodeCriteria") final String nodeCriteria, @PathParam("ifIndex") final int ifIndex) {
    writeLock();
    try {
        final OnmsNode node = m_nodeDao.get(nodeCriteria);
        if (node == null)
            throw getException(Status.BAD_REQUEST, "Node {} was not found.", nodeCriteria);
        final OnmsEntity snmpInterface = node.getSnmpInterfaceWithIfIndex(ifIndex);
        if (snmpInterface == null)
            throw getException(Status.BAD_REQUEST, "Can't find SNMP interface with ifIndex {} for node {}", Integer.toString(ifIndex), nodeCriteria);
        LOG.debug("deletSnmpInterface: deleting interface with ifIndex {} from node {}", ifIndex, nodeCriteria);
        node.getSnmpInterfaces().remove(snmpInterface);
        m_nodeDao.saveOrUpdate(node);
        // TODO Add important events here
        return Response.noContent().build();
    } finally {
        writeUnlock();
    }
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsEntity(org.opennms.netmgt.model.OnmsEntity) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Aggregations

DELETE (javax.ws.rs.DELETE)587 Path (javax.ws.rs.Path)539 Produces (javax.ws.rs.Produces)194 ApiOperation (io.swagger.annotations.ApiOperation)153 ApiResponses (io.swagger.annotations.ApiResponses)127 Consumes (javax.ws.rs.Consumes)78 Timed (com.codahale.metrics.annotation.Timed)59 Response (javax.ws.rs.core.Response)54 IOException (java.io.IOException)47 WebApplicationException (javax.ws.rs.WebApplicationException)46 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)42 Identity (org.olat.core.id.Identity)36 AuditEvent (org.graylog2.audit.jersey.AuditEvent)32 NotFoundException (javax.ws.rs.NotFoundException)23 POST (javax.ws.rs.POST)21 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)20 ApiResponse (io.swagger.annotations.ApiResponse)20 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)20 HashMap (java.util.HashMap)19 GET (javax.ws.rs.GET)19