Subscription Lifecycle

For the most part resource lifecycles are decoupled from subscription lifecycles. However, in order to enable CPBM to provision and de-provision a resource when subscriptions need to be provisioned and terminated respectively, an connector should implement the below interface to handle provisioning and termination of resources managed by them. As before, CPBM expects the connector to maintain a handle on CPBM to refer to a resource that was provisioned as part of a subscription.


A SubscriptionHandle for a subscription represents the resource in the service corresponding to a subscription. It is defined as follows:
public class SubscriptionHandle {    /* A unique opaque handle to identify the service specific entity corresponding to       this resource */    public String getHandle();      /* Can store any json/string data and CPBM will preserve this as it is. This field        may be used to store any additional data the connector would like to associate with        this resource handle    */    public String getData();      /* Back reference to the subscription */    public Subscription getSubscription();  }  public class Subscription {  ...    /* Return the subscription handle if exists. Returns null otherwise */    public SubscriptionHandle getHandle();    /* Add a subscription handle to the resource */    public void addHandle(SubscriptionHandle handle);    /* Remove an subscription handle from this subscription */    public void removeHandle();    /* Returns provisioning data as a Map */    public Map<String, String> getConfigurationMap();  }

Provisioning configuration data for a given subscription can be retrieved from the subscription by calling getConfiguration(). This will contain all configuration information (resource component selections, filters, custom configuration data) used to provision a resource for this subscription.

The handle string should be the same one that is used to identify the resource in the usage record.


SubscriptionLifecycleHandlers are used to synchronize subscription states with the underlying service. The SubscriptionLifecycleHandler is defined as follows:
/**    * Handles subscription lifecycle.     */  public interface SubscriptionLifecycleHandler {      /* Create a resource based on configuration provided in subscription. Set the handle         of the resource back to subscription object as s.addHandle(handle).  Note        that unlike tenants and users where the same CPBM entity has representation in        multiple services, you do not need to identify the service instance for a        subscription as a subscription is already tied to a single service instance. */    public void provision(Subscription s);      /* Validate if the resouce tied to this subscription is still active. */    public void validate(Subscription s);      /* Destroy the resource and remove the subscription handle field by calling        s.removeHandle. Subscription configuration is no longer valid. */    public void destroy(Subscription s);  }
The SubscriptionLifecycleHandler methods should be implemented as follows:
  • provision: Provision a resource corresponding to this subscription based on configuration data provide by Subscription.getConfiguration()
  • validate: Validate whether a resource (if exists) continues to be active for a given subscription. This method will be called periodically or on demand to verify that the underlying resource tied to this subscription remains active. It is possible that resource is no longer active, if the resource failed to launch or if the resource was destroyed or removed directly on the service through other means.
  • destroy: Destroy the resource corresponding to this subscription as the subscription is now terminated.
Figure 1. Subscription Lifecycle Handler