Previous topic

Deployment

Next topic

Human Interface Guidelines

DOCUMENTATION
Last updated 18-May-2016

Custom Events on Resource Limit Change

A customer can increase limits on resources in a subscription through the resource upsell mechanism. Some applications need to be notified when this concerns subscriptions containing the application resources.

Since application resource limits are set in Operations Automation subscriptions, Operations Automation is the publisher of events triggered by changes in Operations Automation resource limits. An application is able to subscribe to such events happening in subscriptions that contain the application resources.

The event processing mechanism is the same as described in the Event Management section.

  1. Operations Automation is the publisher of the custom event type “http://parallels.com/aps/events/pa/subscription/limits/changed”. An event source can be only Operations Automation subscriptions whose APS type is “http://parallels.com/aps/types/pa/subscription/1.0”.

  2. An application can subscribe to events of this type that may happen in a Operations Automation subscription. There are two cases that should be considered.

    • The application needs to track all Operations Automation subscriptions by sending the following REST request to the APS controller:

      POST /aps/2/resources/<subscriberID>/aps/subscriptions
      
      {
          "event": "http://parallels.com/aps/events/pa/subscription/limits/changed",
          "source": {"type":"http://parallels.com/aps/types/pa/subscription/1.0"},
          "handler": "onLimitChange"
      }
      

      In the above code:

      • <subscriberID> - APS ID of the application resource, e.g. 426ac89c-0db8-4503-84a5-4c086f63ee97, that must be subscribed to the event type. The service of this resource must be able to receive and process event notifications by means of its declared handler.
      • event - the considered event type.
      • source.type - APS type of Operations Automation subscriptions.
      • handler - a custom method that the subscriber (application service) uses to process events of the specified type.
    • The application needs to track only a subscription with a certain APS ID by sending the following REST request to the APS controller:

      POST /aps/2/resources/<subscriberID>/aps/subscriptions
      
      {
          "event": "http://parallels.com/aps/events/pa/subscription/limits/changed",
          "source": {"id":"7868ed9c-969c-4a4b-aadd-db9198c711e9"},
          "handler": "onLimitChange"
      }
      

      In this example, source.id is the APS ID of the Operations Automation subscription whose resource limits must be tracked.

  3. Once the application is subscribed to events of this type, every time a resource limit in a tracked subscription is changed in Operations Automation, the APS controller will send an event notification to the subscriber whose ID in the above example is 426ac89c-0db8-4503-84a5-4c086f63ee97, e.g:

    POST /vpscloud/events/426ac89c-0db8-4503-84a5-4c086f63ee97/onLimitChange
    
    {
      "event": "http://parallels.com/aps/events/pa/subscription/limits/changed",
      "time": "2014-07-21T14:15:22Z",
      "serial": 11,
      "subscription": "5ee0fe9d-c812-4af8-a969-5ca28077b032",
      "source": {
        "id": "7868ed9c-969c-4a4b-aadd-db9198c711e9",
        "type": "http://parallels.com/aps/types/pa/subscription/1.0"
       }
    }
    

    In the above POST URL string, the following parts are used:

    • vpscloud - the application endpoint path
    • events - the service processing event notifications addressed to the subscriber
    • onLimitChange - the method processing on limit change events

    The HTTP body in the example contains the following JSON attributes of the event:

    • event - the considered event type
    • time - date and time when the event was recorded
    • serial - serial number of the event (monotonic growing)
    • subscription - APS ID of the event subscription
    • source.id - APS ID of the Operations Automation subscription whose resource limits changed
    • source.type - APS type of Operations Automation subscriptions

Note

Event notification carries only reference to the subscription where one or more resource limits have changed. The application itself can go through further steps to figure out which resource limits changed and respectively process the event.