To meet the updated resource model, the application APS types must be updated accordingly.
In this document:
To support relationship with users, each VPS resource must have a relation with a user.
The best way is to make the vps
APS type implement the UserService standard APS type.
Besides, for convenience, it would be fine to add a property to the VPS type for presenting the VPS owners.
To allow service users to manage the assigned VPSes, the application should have the respective custom operations.
This section continues the demo project from the previous step.
Edit the scripts/vpses.php
file to update the vps
type:
Make the vps
type implement the user service type. Therefore, the PHP annotations
for the main class must look as follows:
/**
* @type("http://aps-standard.org/samples/suwizard1p/vps/1.0")
* @implements("http://aps-standard.org/types/core/user/service/1.0")
*/
class vps extends APS\ResourceBase { ... }
In the vps
class, add the userName
property presenting a user as the VPS owner:
/**
* @type("string")
* @title("User Name")
* @description("VPS Owner Name")
*/
public $userName;
Ensure there are custom operations called on pressing Start and Stop buttons in service user UI:
/**
* @verb(GET)
* @path("/start")
* @return(string,text/json)
*/
public function start() {
$this->state = 'Running';
$apsc = \APS\Request::getController();
$apsc->updateResource($this);
}
/**
* @verb(GET)
* @path("/stop")
* @return(string,text/json)
*/
public function stop() {
$this->state = 'Stopped';
$apsc = \APS\Request::getController();
$apsc->updateResource($this);
}
This completes the development of the provisioning logic.
The project files you have created and updated are similar to the respective files in the
sample package
.