org.opennms.web.rest
Class ForeignSourceRestService

java.lang.Object
  extended by org.opennms.web.rest.OnmsRestService
      extended by org.opennms.web.rest.ForeignSourceRestService

@Component
@PerRequest
@Scope(value="prototype")
public class ForeignSourceRestService
extends OnmsRestService

RESTful service to the OpenNMS Provisioning Foreign Source definitions. Foreign source definitions are used to control the scanning (service detection) of services for SLA monitoring as well as the data collection settings for physical interfaces (resources).

This API supports CRUD operations for managing the Provisioner's foreign source definitions. Foreign source definitions are POSTed and will be deployed when the corresponding requisition (provisioning group) gets imported by provisiond.

Example 1: Create a new foreign sourceNote: The foreign-source attribute typically has a 1 to 1 relationship to a provisioning group (a.k.a. requisition). The relationship is only implied by name and it is a best practice to use the same name for all three. If a requisition exists with the same name as a foreign source, it will be used during the provisioning (import) operations in lieu of the default foreign source.

curl -X POST \
     -H "Content-Type: application/xml" \
     -d <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
         <foreign-source date-stamp="2009-03-07T20:22:45.625-05:00" name="Cisco"
           xmlns:ns2="http://xmlns.opennms.org/xsd/config/model-import" 
           xmlns="http://xmlns.opennms.org/xsd/config/foreign-source">
           <scan-interval>1d</scan-interval>
           <detectors>
             <detector class="org.opennms.netmgt.provision.detector.dhcp.DhcpDetector" name="DHCP"/>
             <detector class="org.opennms.netmgt.provision.detector.datagram.DnsDetector" name="DNS"/>
             <detector class="org.opennms.netmgt.provision.detector.simple.FtpDetector" name="FTP"/>
             <detector class="org.opennms.netmgt.provision.detector.simple.HttpDetector" name="HTTP"/>
             <detector class="org.opennms.netmgt.provision.detector.simple.HttpsDetector" name="HTTPS"/>
             <detector class="org.opennms.netmgt.provision.detector.icmp.IcmpDetector" name="ICMP"/>
             <detector class="org.opennms.netmgt.provision.detector.simple.LdapDetector" name="LDAP"/>
             <detector class="org.opennms.netmgt.provision.detector.radius.RadiusDetector" name="Radius"/>
             <detector class="org.opennms.netmgt.provision.detector.snmp.SnmpDetector" name="SNMP"/>
             <detector class="org.opennms.netmgt.provision.detector.ssh.SshDetector" name="SSH"/>
           </detectors>
           <policies>
             <policy class="org.opennms.netmgt.provision.persist.policies.MatchingInterfacePolicy" name="policy1">
               <parameter value="~10\.*\.*\.*" key="ipAddress"/>
             </policy>
           </policies>
         </foreign-source> \
     -u admin:admin \
     http://localhost:8980/opennms/rest/foreignSources

Example 2: Query SNMP community string.

curl -X GET \
     -H "Content-Type: application/xml" \
     -u admin:admin \
        http://localhost:8980/opennms/rest/foreignSources/deployed \
        2>/dev/null \
        |xmllint --format -

Author:
Benjamin Reed

Nested Class Summary
 
Nested classes/interfaces inherited from class org.opennms.web.rest.OnmsRestService
OnmsRestService.ComparisonOperation
 
Constructor Summary
ForeignSourceRestService()
           
 
Method Summary
 javax.ws.rs.core.Response addDetector(String foreignSource, DetectorWrapper detector)
           
 javax.ws.rs.core.Response addForeignSource(ForeignSource foreignSource)
           
 javax.ws.rs.core.Response addPolicy(String foreignSource, PolicyWrapper policy)
           
 javax.ws.rs.core.Response deleteDeployedForeignSource(String foreignSource)
           
 javax.ws.rs.core.Response deleteDetector(String foreignSource, String detector)
           
 javax.ws.rs.core.Response deletePendingForeignSource(String foreignSource)
           
 javax.ws.rs.core.Response deletePolicy(String foreignSource, String policy)
           
 ForeignSource getDefaultForeignSource()
           
 int getDeployedCount()
          returns a plaintext string being the number of pending foreign sources
 ForeignSourceCollection getDeployedForeignSources()
          Returns all the deployed foreign sources
 DetectorWrapper getDetector(String foreignSource, String detector)
           
 DetectorCollection getDetectors(String foreignSource)
           
 ForeignSource getForeignSource(String foreignSource)
          Returns the requested ForeignSource
 ForeignSourceCollection getForeignSources()
          Returns the union of deployed and pending foreign sources
 PolicyCollection getPolicies(String foreignSource)
           
 PolicyWrapper getPolicy(String foreignSource, String policy)
           
 int getTotalCount()
          returns a plaintext string being the number of pending foreign sources
 javax.ws.rs.core.Response updateForeignSource(String foreignSource, MultivaluedMapImpl params)
           
 
Methods inherited from class org.opennms.web.rest.OnmsRestService
addFiltersToCriteria, addOrdering, convertNameToPropertyName, log, setLimitOffset, setLimitOffset, setProperties, throwException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForeignSourceRestService

public ForeignSourceRestService()
Method Detail

getDefaultForeignSource

public ForeignSource getDefaultForeignSource()
                                      throws ParseException
Throws:
ParseException

getDeployedForeignSources

public ForeignSourceCollection getDeployedForeignSources()
                                                  throws ParseException
Returns all the deployed foreign sources

Returns:
Collection of OnmsForeignSources (ready to be XML-ified)
Throws:
ParseException

getDeployedCount

public int getDeployedCount()
returns a plaintext string being the number of pending foreign sources

Returns:

getForeignSources

public ForeignSourceCollection getForeignSources()
                                          throws ParseException
Returns the union of deployed and pending foreign sources

Returns:
Collection of OnmsForeignSources (ready to be XML-ified)
Throws:
ParseException

getTotalCount

public int getTotalCount()
                  throws ParseException
returns a plaintext string being the number of pending foreign sources

Returns:
Throws:
ParseException

getForeignSource

public ForeignSource getForeignSource(String foreignSource)
Returns the requested ForeignSource

Parameters:
foreignSource - the foreign source name
Returns:
the foreign source

getDetectors

public DetectorCollection getDetectors(String foreignSource)

getDetector

public DetectorWrapper getDetector(String foreignSource,
                                   String detector)

getPolicies

public PolicyCollection getPolicies(String foreignSource)

getPolicy

public PolicyWrapper getPolicy(String foreignSource,
                               String policy)

addForeignSource

@Transactional
public javax.ws.rs.core.Response addForeignSource(ForeignSource foreignSource)

addDetector

@Transactional
public javax.ws.rs.core.Response addDetector(String foreignSource,
                                                           DetectorWrapper detector)

addPolicy

@Transactional
public javax.ws.rs.core.Response addPolicy(String foreignSource,
                                                         PolicyWrapper policy)

updateForeignSource

@Transactional
public javax.ws.rs.core.Response updateForeignSource(String foreignSource,
                                                                   MultivaluedMapImpl params)

deletePendingForeignSource

@Transactional
public javax.ws.rs.core.Response deletePendingForeignSource(String foreignSource)

deleteDeployedForeignSource

@Transactional
public javax.ws.rs.core.Response deleteDeployedForeignSource(String foreignSource)

deleteDetector

@Transactional
public javax.ws.rs.core.Response deleteDetector(String foreignSource,
                                                              String detector)

deletePolicy

@Transactional
public javax.ws.rs.core.Response deletePolicy(String foreignSource,
                                                            String policy)


Copyright © 2009. All Rights Reserved.