Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

addService($package, array $vars=null, $parent_package=null, $parent_service=null, $status="pending")

This method attempts to to add a service given the package and input vars, as well as the intended status. If this service is an addon service, the parent package will be given. The parent service will also be given if the parent service has already been provisioned. This method returns an array containing a an array of key=>value list of service fields and their valuesfields for each service field and its value, as well as whether the value should be encrypted.

...

editService($package, $service, array $vars=array(), $parent_package=null, $parent_service=null)

 

cancelService($package, $service, $parent_package=null, $parent_service=null)

 

This method attempts to update an existing service given the package, the service, and any input vars. If this service is an addon service, the parent package will be given. The parent service will also be given if the parent service has already been provisioned. This method returns an array containing an array of key=>value fields for each service field and its value, as well as whether the value should be encrypted.

This method is very similar to addService().

cancelService($package, $service, $parent_package=null, $parent_service=null)

This method attempts to cancel an existing service given the package and the service. If this service is an addon service, the parent package will be given. The parent service will also be given if the parent service has already been provisioned. This method may return null, or the service fields as an array containing an array of key=>value fields for each service field and its value, as well as whether the value should be encrypted.

Code Block
languagephp
class MyModule extends Module {
...
	public function cancelService($package, $service, $parent_package=null, $parent_service=null) {
		// Get the module row used for this service
		if (($row = $this->getModuleRow())) {
			// Format the list of service fields as an object
			$service_fields = $this->serviceFieldsToObject($service->fields);

			// Set the URL to where the remote request is being sent (assuming 'host_name' is a valid module row meta field)
			$remote_url = $row->meta->host_name;
			$this->log($remote_url . "|api_command", serialize($service_fields), "input", true);

			// Provision the service remotely (this is dependent on the module's API, omitted here)
			$response = $this->makeRequest($service_fields);
		}
		return null;
	}

	private function makeRequest($params) {
		// Get the module row used for this service
		$row = $this->getModuleRow();

		// Perform the remote request (this is dependent on the module's API, omitted here)
		$response = $this->apiCall($params);

		// Retrieve the response from the module and evaluate its result as true/false, setting any input errors
		$success = true;
		if (isset($response->status) && !$response->status) {
			$this->Input->setErrors(array('api' => array('response' => "The request could not be performed.")));
			$success = false;
		}
		
		// Log the response
		$this->log($row->meta->host_name, $response, "output", $success);

		// Return the result
		if (!$success)
			return;
		return $response;
	}

	private function apiCall($params) {
		// Make the API call to the module (this is dependent on the module's API, omitted here)
		return (object)array('status' => false);
	}
...
}

 

suspendService($package, $service, $parent_suspendService($package, $service, $parent_package=null, $parent_service=null)

Code Block
languagephp
 

 

unsuspendService($package, $service, $parent_package=null, $parent_service=null)

...