Class RequisitionRestService


  • @Component("requisitionRestService")
    public class RequisitionRestService
    extends OnmsRestService

    RESTful service to the OpenNMS Provisioning Groups. In this API, these "groups" of nodes are aptly named and treated as requisitions.

    This current implementation supports CRUD operations for managing provisioning requisitions. Requisitions are first POSTed and no provisioning (import) operations are taken. This is done so that a) the XML can be verified and b) so that the operations can happen at a later time. They are moved to the deployed state (put in the active requisition repository) when an import is run.

    • GET/PUT/POST pending requisitions
    • GET pending and deployed count

    Example 1: Create a new requisition Note: The foreign-source attribute typically has a 1 to 1 relationship to a provisioning group and to the name used in this requisition. The relationship is implied by name and it is best practice to use the same for all three. If a foreign source definition exists with the same name, 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"?>
             <model-import xmlns="http://xmlns.opennms.org/xsd/config/model-import"
                 date-stamp="2009-03-07T17:56:53.123-05:00"
                 last-import="2009-03-07T17:56:53.117-05:00" foreign-source="site1">
               <node node-label="p-brane" foreign-id="1" >
                 <interface ip-addr="10.0.1.3" descr="en1" status="1" snmp-primary="P">
                   <monitored-service service-name="ICMP"/>
                   <monitored-service service-name="SNMP"/>
                 </interface>
                 <category name="Production"/>
                 <category name="Routers"/>
               </node>
             </model-import>" \
         -u admin:admin \
         http://localhost:8980/opennms/rest/requisitions
    

    Example 2: Query all deployed requisitions

    curl -X GET \
         -H "Content-Type: application/xml" \
         -u admin:admin \
            http://localhost:8980/opennms/rest/requisitions/deployed \
            2>/dev/null \
            |xmllint --format -
    Since:
    1.8.1
    Version:
    $Id: $
    Author:
    Benjamin Reed
    • Constructor Detail

      • RequisitionRestService

        public RequisitionRestService()
    • Method Detail

      • tearDown

        @PreDestroy
        protected void tearDown()
      • getDeployedCount

        public java.lang.String getDeployedCount()
        get a plain text numeric string of the number of deployed requisitions
        Returns:
        a int.
      • getDeployedStats

        public DeployedStats getDeployedStats()
        get the statistics for the deployed requisitions
        Returns:
        a DeployedStats.
      • getDeployedStats

        public DeployedRequisitionStats getDeployedStats​(java.lang.String foreignSource)
        get the statistics for a given deployed requisition
        Returns:
        a DeployedRequisitionStats.
      • getForeignSourceRepositoryStrategy

        public java.lang.String getForeignSourceRepositoryStrategy()
        get a plain text with the current selected foreign source repository strategy
        Returns:
        the current strategy.
      • getDeployedRequisitions

        public RequisitionCollection getDeployedRequisitions()
                                                      throws java.text.ParseException
        Get all the deployed requisitions
        Returns:
        a RequisitionCollection object.
        Throws:
        java.text.ParseException - if any.
      • getRequisitions

        public RequisitionCollection getRequisitions()
                                              throws java.text.ParseException
        Get all the pending requisitions
        Returns:
        a RequisitionCollection object.
        Throws:
        java.text.ParseException - if any.
      • getPendingCount

        public java.lang.String getPendingCount()
        get a plain text numeric string of the number of pending requisitions
        Returns:
        a int.
      • getRequisition

        public Requisition getRequisition​(java.lang.String foreignSource)

        getRequisition

        Parameters:
        foreignSource - a String object.
        Returns:
        a Requisition object.
      • getNodes

        public RequisitionNodeCollection getNodes​(java.lang.String foreignSource)
                                           throws java.text.ParseException
        Returns all nodes for a given requisition
        Parameters:
        foreignSource - a String object.
        Returns:
        a RequisitionNodeCollection object.
        Throws:
        java.text.ParseException - if any.
      • getNode

        public RequisitionNode getNode​(java.lang.String foreignSource,
                                       java.lang.String foreignId)
                                throws java.text.ParseException
        Returns the node with the foreign ID specified for the given foreign source
        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        Returns:
        a RequisitionNode object.
        Throws:
        java.text.ParseException - if any.
      • getInterfacesForNode

        public RequisitionInterfaceCollection getInterfacesForNode​(java.lang.String foreignSource,
                                                                   java.lang.String foreignId)
                                                            throws java.text.ParseException
        Returns a collection of interfaces for a given node in the specified foreign source
        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        Returns:
        a RequisitionInterfaceCollection object.
        Throws:
        java.text.ParseException - if any.
      • getInterfaceForNode

        public RequisitionInterface getInterfaceForNode​(java.lang.String foreignSource,
                                                        java.lang.String foreignId,
                                                        java.lang.String ipAddress)
                                                 throws java.text.ParseException
        Returns the interface with the given foreign source/foreignid/ipaddress combination.
        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        ipAddress - a String object.
        Returns:
        a RequisitionInterface object.
        Throws:
        java.text.ParseException - if any.
      • getServicesForInterface

        public RequisitionMonitoredServiceCollection getServicesForInterface​(java.lang.String foreignSource,
                                                                             java.lang.String foreignId,
                                                                             java.lang.String ipAddress)
                                                                      throws java.text.ParseException
        Returns a collection of services for a given foreignSource/foreignId/interface combination.
        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        ipAddress - a String object.
        Returns:
        a RequisitionMonitoredServiceCollection object.
        Throws:
        java.text.ParseException - if any.
      • getServiceForInterface

        public RequisitionMonitoredService getServiceForInterface​(java.lang.String foreignSource,
                                                                  java.lang.String foreignId,
                                                                  java.lang.String ipAddress,
                                                                  java.lang.String service)
                                                           throws java.text.ParseException
        Returns a service for a given foreignSource/foreignId/interface/service-name combination.
        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        ipAddress - a String object.
        service - a String object.
        Returns:
        a RequisitionMonitoredService object.
        Throws:
        java.text.ParseException - if any.
      • getCategories

        public RequisitionCategoryCollection getCategories​(java.lang.String foreignSource,
                                                           java.lang.String foreignId)
                                                    throws java.text.ParseException
        Returns a collection of categories for a given node in the specified foreign source
        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        Returns:
        a RequisitionCategoryCollection object.
        Throws:
        java.text.ParseException - if any.
      • getCategory

        public RequisitionCategory getCategory​(java.lang.String foreignSource,
                                               java.lang.String foreignId,
                                               java.lang.String category)
                                        throws java.text.ParseException
        Returns the requested category for a given node in the specified foreign source
        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        category - a String object.
        Returns:
        a RequisitionCategory object.
        Throws:
        java.text.ParseException - if any.
      • getAssetParameters

        public RequisitionAssetCollection getAssetParameters​(java.lang.String foreignSource,
                                                             java.lang.String foreignId)
                                                      throws java.text.ParseException
        Returns a collection of assets for a given node in the specified foreign source
        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        Returns:
        a RequisitionAssetCollection object.
        Throws:
        java.text.ParseException - if any.
      • getAssetParameter

        public RequisitionAsset getAssetParameter​(java.lang.String foreignSource,
                                                  java.lang.String foreignId,
                                                  java.lang.String parameter)
                                           throws java.text.ParseException
        Returns the requested category for a given node in the specified foreign source
        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        parameter - a String object.
        Returns:
        a RequisitionAsset object.
        Throws:
        java.text.ParseException - if any.
      • addOrReplaceRequisition

        @Transactional
        public javax.ws.rs.core.Response addOrReplaceRequisition​(@Context
                                                                 javax.ws.rs.core.UriInfo uriInfo,
                                                                 Requisition requisition)
        Updates or adds a complete requisition with foreign source "foreignSource"
        Parameters:
        requisition - a Requisition object.
        Returns:
        a Response object.
      • addOrReplaceNode

        @Transactional
        public javax.ws.rs.core.Response addOrReplaceNode​(@Context
                                                          javax.ws.rs.core.UriInfo uriInfo,
                                                          java.lang.String foreignSource,
                                                          RequisitionNode node)
        Updates or adds a node to a requisition
        Parameters:
        foreignSource - a String object.
        node - a RequisitionNode object.
        Returns:
        a Response object.
      • addOrReplaceInterface

        @Transactional
        public javax.ws.rs.core.Response addOrReplaceInterface​(@Context
                                                               javax.ws.rs.core.UriInfo uriInfo,
                                                               java.lang.String foreignSource,
                                                               java.lang.String foreignId,
                                                               RequisitionInterface iface)
        Updates or adds an interface to a node
        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        iface - a RequisitionInterface object.
        Returns:
        a Response object.
      • addOrReplaceService

        @Transactional
        public javax.ws.rs.core.Response addOrReplaceService​(@Context
                                                             javax.ws.rs.core.UriInfo uriInfo,
                                                             java.lang.String foreignSource,
                                                             java.lang.String foreignId,
                                                             java.lang.String ipAddress,
                                                             RequisitionMonitoredService service)
        Updates or adds a service to an interface
        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        ipAddress - a String object.
        service - a RequisitionMonitoredService object.
        Returns:
        a Response object.
      • addOrReplaceNodeCategory

        @Transactional
        public javax.ws.rs.core.Response addOrReplaceNodeCategory​(@Context
                                                                  javax.ws.rs.core.UriInfo uriInfo,
                                                                  java.lang.String foreignSource,
                                                                  java.lang.String foreignId,
                                                                  RequisitionCategory category)
        Updates or adds a category to a node
        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        category - a RequisitionCategory object.
        Returns:
        a Response object.
      • addOrReplaceNodeAssetParameter

        @Transactional
        public javax.ws.rs.core.Response addOrReplaceNodeAssetParameter​(@Context
                                                                        javax.ws.rs.core.UriInfo uriInfo,
                                                                        java.lang.String foreignSource,
                                                                        java.lang.String foreignId,
                                                                        RequisitionAsset asset)
        Updates or adds an asset parameter to a node
        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        asset - a RequisitionAsset object.
        Returns:
        a Response object.
      • importRequisition

        @Transactional
        public javax.ws.rs.core.Response importRequisition​(@Context
                                                           javax.ws.rs.core.UriInfo uriInfo,
                                                           java.lang.String foreignSource,
                                                           java.lang.String rescanExisting)

        importRequisition

        Parameters:
        foreignSource - a String object.
        Returns:
        a Response object.
      • updateRequisition

        @Transactional
        public javax.ws.rs.core.Response updateRequisition​(@Context
                                                           javax.ws.rs.core.UriInfo uriInfo,
                                                           java.lang.String foreignSource,
                                                           MultivaluedMapImpl params)
        Updates the requisition with foreign source "foreignSource"
        Parameters:
        foreignSource - a String object.
        params - a MultivaluedMapImpl object.
        Returns:
        a Response object.
      • updateNode

        @Transactional
        public javax.ws.rs.core.Response updateNode​(@Context
                                                    javax.ws.rs.core.UriInfo uriInfo,
                                                    java.lang.String foreignSource,
                                                    java.lang.String foreignId,
                                                    MultivaluedMapImpl params)
        Updates the node with foreign id "foreignId" in foreign source "foreignSource"
        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        params - a MultivaluedMapImpl object.
        Returns:
        a Response object.
      • updateInterface

        @Transactional
        public javax.ws.rs.core.Response updateInterface​(@Context
                                                         javax.ws.rs.core.UriInfo uriInfo,
                                                         java.lang.String foreignSource,
                                                         java.lang.String foreignId,
                                                         java.lang.String ipAddress,
                                                         MultivaluedMapImpl params)
        Updates a specific interface
        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        ipAddress - a String object.
        params - a MultivaluedMapImpl object.
        Returns:
        a Response object.
      • deletePendingRequisition

        @Transactional
        public javax.ws.rs.core.Response deletePendingRequisition​(java.lang.String foreignSource)
        Deletes the pending requisition with foreign source "foreignSource"
        Parameters:
        foreignSource - a String object.
        Returns:
        a Response object.
      • deleteDeployedRequisition

        @Transactional
        public javax.ws.rs.core.Response deleteDeployedRequisition​(java.lang.String foreignSource)
        Deletes the deployed requisition with foreign source "foreignSource"
        Parameters:
        foreignSource - a String object.
        Returns:
        a Response object.
      • deleteNode

        @Transactional
        public javax.ws.rs.core.Response deleteNode​(java.lang.String foreignSource,
                                                    java.lang.String foreignId)
        Delete the node with the given foreign ID for the specified foreign source
        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        Returns:
        a Response object.
      • deleteInterface

        @Transactional
        public javax.ws.rs.core.Response deleteInterface​(java.lang.String foreignSource,
                                                         java.lang.String foreignId,
                                                         java.lang.String ipAddress)

        deleteInterface

        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        ipAddress - a String object.
        Returns:
        a Response object.
      • deleteInterfaceService

        @Transactional
        public javax.ws.rs.core.Response deleteInterfaceService​(java.lang.String foreignSource,
                                                                java.lang.String foreignId,
                                                                java.lang.String ipAddress,
                                                                java.lang.String service)

        deleteInterfaceService

        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        ipAddress - a String object.
        service - a String object.
        Returns:
        a Response object.
      • deleteCategory

        @Transactional
        public javax.ws.rs.core.Response deleteCategory​(java.lang.String foreignSource,
                                                        java.lang.String foreignId,
                                                        java.lang.String category)

        deleteCategory

        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        category - a String object.
        Returns:
        a Response object.
      • deleteAssetParameter

        @Transactional
        public javax.ws.rs.core.Response deleteAssetParameter​(java.lang.String foreignSource,
                                                              java.lang.String foreignId,
                                                              java.lang.String parameter)

        deleteAssetParameter

        Parameters:
        foreignSource - a String object.
        foreignId - a String object.
        parameter - a String object.
        Returns:
        a Response object.