Provisioning Logic

A service integrated with the service activation wizard must have some special definitions as explained in the following sections.

../../../../_images/activate-step-model.png ../../../../_images/activate-step-meta.png ../../../../_images/activate-step-provision-b.png ../../../../_images/activate-step-presentation.png ../../../../_images/activate-step-deploy.png ../../../../_images/activate-step-provisioning.png

Requirements to Provisioning Logic

The application service must set the status of the resources following the scenario. For this effect, its definition must comply with the following rules:

  • The APS type bound to the service must implement the UserService APS type.

  • The provision method must set the new APS resource to the aps:activating status.

  • The service definition must contain the activate custom operation that sets the activation parameter of the new resource and then require the APS controller to set the resource status to aps:ready. The operation will be called by the service activation wizard. The input argument of the respective method is the JSON representation of the new APS resource.

Continue Your Demo Project

Continue the demo project from the previous step. In the next sections, you should update the scripts/vpses.php file.

Implement Core User Service

Make sure the vps type implements the APS core UserService type:

/**
 * @type("http://aps-standard.org/samples/srv-activate/vps/1.0")
 * @implements("http://aps-standard.org/types/core/user/service/1.0")
 */
class vps extends APS\ResourceBase {
   ...
}

Resource Provisioning

Add the definition of the provision method that must set the resource status to aps:activating:

public function provision() {
   $this->aps->status = "aps:activating";
}

Resource Activation

Add a custom operation, for example, activate($body) that receives the new resource representation, requires the APS controller to update the resource properties and especially its status, and then returns the new resource representation.

/**
 * @verb(PUT)
 * @path("/activate")
 * @param(object,body)
 * @access(referrer, true)
 */
public function activate($body) {
   $this->aps->status = "aps:ready";
   $this->name = $body->name;
   $apsc = \APS\Request::getController();
   $apsc->updateResource($this);
   return $this;
}

Since service users by default are assigned the referrer role towards the linked resources, the access attribute extends their permissions to ensure they can run the custom operation. The activate method changes the name and status of the required resource.

Conclusion

This completes the modification of the provisioning logic, which is now able to interact with the service activation wizard. The vpses.php file you have updated is similar to the respective file in the sample package

Note

When developing the presentation logic, ensure it calls the correct custom operation added in this step to activate a resource.