A service integrated with the service activation wizard must have some special definitions as explained in the following sections.
In this document:
The application service must set the status of the resources following the scenario. For this effect, its definition must comply with the following rules:
provision
method must set the new APS resource to the aps:activating
status.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 the demo project from the previous step.
In the next sections, you should update the scripts/vpses.php
file.
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 {
...
}
Add the definition of the provision
method that must set the resource status to aps:activating
:
public function provision() {
$this->aps->status = "aps:activating";
}
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.
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.