Service Properties

Many provisioning modules require storage of additional information for products. You can fufill this requirement using service properties.

Service properties are key/value pairs for a specific instance of a product or product addon. They facilitate storing and working with extra data. Service properties use custom fields to store this data in a consistent format that provisioning modules can access programmatically.

Using Service Properties

The system passes a model instance that represents the service or addon that the module is performing an action against to all module function invocations as part of the module parameters.

Example

For example:

    /**
     * @param array $params
     *
     * @return string
     */
    function samplemodule_CreateAccount(array $params)
    {
        try {
            // Perform actions to provision service and receive back an order number
            $orderNumber = '12345';

            // Save order number to Service Properties
            $params['model']->serviceProperties->save(['Order Number' => $orderNumber]);

            return 'success';
        } catch (\Exception $e) {
            return $e->getMessage();
        }
    }

    function samplemodule_SuspendAccount(array $params)
    {
        try {
            // Utilise Service Properties to retrieve the Order Number
            $orderNumber = $params['model']->serviceProperties->get('Order Number');

            // Perform actions using order number here

            return 'success';
            } catch (\Exception $e) {
                return $e->getMessage();
            }
    }

The save method will look up a custom field with the given name. If it does not find an existing field, it will create a new custom field to store the value.

Supported Fields

When using service properties against a service (for example, a directly-created product and not an addon), the system may use a dedicated core field rather than a custom field.

This occurs for the following field names:

  • Username
  • Password
  • Domain
  • License Key
  • Dedicated IP
  • Disk Usage
  • Disk Limit
  • Bandwidth Usage
  • Bandwidth Limit
  • Last Update

Using these field names with an addon will create a custom field.

Last modified: November 19, 2024