Class ForeignSourceRestService
- java.lang.Object
 - 
- org.opennms.web.rest.v1.OnmsRestService
 - 
- org.opennms.web.rest.v1.ForeignSourceRestService
 
 
 
- 
@Component("foreignSourceRestService") public class ForeignSourceRestService extends OnmsRestServiceRESTful 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.
- GET/PUT/POST pending foreign sources
 - GET pending and deployed count
 
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.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.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/foreignSourcesExample 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 -- Since:
 - 1.8.1
 - Version:
 - $Id: $
 - Author:
 - Benjamin Reed
 
 
- 
- 
Nested Class Summary
- 
Nested classes/interfaces inherited from class org.opennms.web.rest.v1.OnmsRestService
OnmsRestService.ComparisonOperation 
 - 
 
- 
Field Summary
- 
Fields inherited from class org.opennms.web.rest.v1.OnmsRestService
DEFAULT_LIMIT 
 - 
 
- 
Constructor Summary
Constructors Constructor Description ForeignSourceRestService() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.ws.rs.core.ResponseaddDetector(javax.ws.rs.core.UriInfo uriInfo, java.lang.String foreignSource, DetectorWrapper detector)addDetectorjavax.ws.rs.core.ResponseaddForeignSource(javax.ws.rs.core.UriInfo uriInfo, ForeignSource foreignSource)addForeignSourcejavax.ws.rs.core.ResponseaddPolicy(javax.ws.rs.core.UriInfo uriInfo, java.lang.String foreignSource, PolicyWrapper policy)addPolicyjavax.ws.rs.core.ResponsedeleteDeployedForeignSource(java.lang.String foreignSource)deleteDeployedForeignSourcejavax.ws.rs.core.ResponsedeleteDetector(java.lang.String foreignSource, java.lang.String detector)deleteDetectorjavax.ws.rs.core.ResponsedeletePendingForeignSource(java.lang.String foreignSource)deletePendingForeignSourcejavax.ws.rs.core.ResponsedeletePolicy(java.lang.String foreignSource, java.lang.String policy)deletePolicyForeignSourcegetDefaultForeignSource()getDefaultForeignSourcejava.lang.StringgetDeployedCount()returns a plaintext string being the number of pending foreign sourcesForeignSourceCollectiongetDeployedForeignSources()Returns all the deployed foreign sourcesDetectorWrappergetDetector(java.lang.String foreignSource, java.lang.String detector)getDetectorDetectorCollectiongetDetectors(java.lang.String foreignSource)getDetectorsForeignSourcegetForeignSource(java.lang.String foreignSource)Returns the requestedForeignSourceForeignSourceCollectiongetForeignSources()Returns the union of deployed and pending foreign sourcesPolicyCollectiongetPolicies(java.lang.String foreignSource)getPoliciesPolicyWrappergetPolicy(java.lang.String foreignSource, java.lang.String policy)getPolicyjava.lang.StringgetTotalCount()returns a plaintext string being the number of pending foreign sourcesjavax.ws.rs.core.ResponseupdateForeignSource(javax.ws.rs.core.UriInfo uriInfo, java.lang.String foreignSource, MultivaluedMapImpl params)updateForeignSource- 
Methods inherited from class org.opennms.web.rest.v1.OnmsRestService
applyQueryFilters, applyQueryFilters, getBadRequestResponse, getBeanWrapperForClass, getException, getException, getNumericValue, getRedirectUri, readLock, readUnlock, removeParameter, removeParameter, setProperties, writeLock, writeUnlock 
 - 
 
 - 
 
- 
- 
Method Detail
- 
getDefaultForeignSource
public ForeignSource getDefaultForeignSource()
getDefaultForeignSource
- Returns:
 - a 
ForeignSourceobject. 
 
- 
getDeployedForeignSources
public ForeignSourceCollection getDeployedForeignSources()
Returns all the deployed foreign sources- Returns:
 - Collection of OnmsForeignSources (ready to be XML-ified)
 
 
- 
getDeployedCount
public java.lang.String getDeployedCount()
returns a plaintext string being the number of pending foreign sources- Returns:
 - a int.
 
 
- 
getForeignSources
public ForeignSourceCollection getForeignSources()
Returns the union of deployed and pending foreign sources- Returns:
 - Collection of OnmsForeignSources (ready to be XML-ified)
 - Throws:
 java.text.ParseException- if any.
 
- 
getTotalCount
public java.lang.String getTotalCount()
returns a plaintext string being the number of pending foreign sources- Returns:
 - a int.
 
 
- 
getForeignSource
public ForeignSource getForeignSource(java.lang.String foreignSource)
Returns the requestedForeignSource- Parameters:
 foreignSource- the foreign source name- Returns:
 - the foreign source
 
 
- 
getDetectors
public DetectorCollection getDetectors(java.lang.String foreignSource)
getDetectors
- Parameters:
 foreignSource- aStringobject.- Returns:
 - a 
DetectorCollectionobject. 
 
- 
getDetector
public DetectorWrapper getDetector(java.lang.String foreignSource, java.lang.String detector)
getDetector
- Parameters:
 foreignSource- aStringobject.detector- aStringobject.- Returns:
 - a 
DetectorWrapperobject. 
 
- 
getPolicies
public PolicyCollection getPolicies(java.lang.String foreignSource)
getPolicies
- Parameters:
 foreignSource- aStringobject.- Returns:
 - a 
PolicyCollectionobject. 
 
- 
getPolicy
public PolicyWrapper getPolicy(java.lang.String foreignSource, java.lang.String policy)
getPolicy
- Parameters:
 foreignSource- aStringobject.policy- aStringobject.- Returns:
 - a 
PolicyWrapperobject. 
 
- 
addForeignSource
@Transactional public javax.ws.rs.core.Response addForeignSource(@Context javax.ws.rs.core.UriInfo uriInfo, ForeignSource foreignSource)addForeignSource
- Parameters:
 foreignSource- aForeignSourceobject.- Returns:
 - a 
Responseobject. 
 
- 
addDetector
@Transactional public javax.ws.rs.core.Response addDetector(@Context javax.ws.rs.core.UriInfo uriInfo, java.lang.String foreignSource, DetectorWrapper detector)addDetector
- Parameters:
 foreignSource- aStringobject.detector- aDetectorWrapperobject.- Returns:
 - a 
Responseobject. 
 
- 
addPolicy
@Transactional public javax.ws.rs.core.Response addPolicy(@Context javax.ws.rs.core.UriInfo uriInfo, java.lang.String foreignSource, PolicyWrapper policy)addPolicy
- Parameters:
 foreignSource- aStringobject.policy- aPolicyWrapperobject.- Returns:
 - a 
Responseobject. 
 
- 
updateForeignSource
@Transactional public javax.ws.rs.core.Response updateForeignSource(@Context javax.ws.rs.core.UriInfo uriInfo, java.lang.String foreignSource, MultivaluedMapImpl params)updateForeignSource
- Parameters:
 foreignSource- aStringobject.params- aMultivaluedMapImplobject.- Returns:
 - a 
Responseobject. 
 
- 
deletePendingForeignSource
@Transactional public javax.ws.rs.core.Response deletePendingForeignSource(java.lang.String foreignSource)
deletePendingForeignSource
- Parameters:
 foreignSource- aStringobject.- Returns:
 - a 
Responseobject. 
 
- 
deleteDeployedForeignSource
@Transactional public javax.ws.rs.core.Response deleteDeployedForeignSource(java.lang.String foreignSource)
deleteDeployedForeignSource
- Parameters:
 foreignSource- aStringobject.- Returns:
 - a 
Responseobject. 
 
- 
deleteDetector
@Transactional public javax.ws.rs.core.Response deleteDetector(java.lang.String foreignSource, java.lang.String detector)deleteDetector
- Parameters:
 foreignSource- aStringobject.detector- aStringobject.- Returns:
 - a 
Responseobject. 
 
- 
deletePolicy
@Transactional public javax.ws.rs.core.Response deletePolicy(java.lang.String foreignSource, java.lang.String policy)deletePolicy
- Parameters:
 foreignSource- aStringobject.policy- aStringobject.- Returns:
 - a 
Responseobject. 
 
 - 
 
 -