Application Packaging Standard

Last updated 18-Mar-2019

Special Operations

Get Resource Defaults

To get a pre-filled representation of a resource with default values, the APS controller may use a special collection element identified as $default. This is used to present default values in auto-generated UI forms. An application itself is responsible for this operation. If based on APS PHP runtime, for this purpose, it must define a custom operation named _getDefault() in the respective APS type.

Request example for default values provided by the containers service:

GET /containers/$default

Response example:

HTTP/1.1 200 OK

{
     "aps": {
       "type": "http://www.aps-standard.org/infrastructure/virtual-environment/1"
     },

     "hardware": {
       "bandwidth": 1024,
       "cpu": {
         "number": 1,
         "power": 6000
       },
       "diskspace": 10200,
       "memory": 4096
     },

     "platform": {
       "arch": "x86_64",
       "os": {
         "name": "Linux",
         "version": "centos-6"
       }
     }
 }

It is up to the application which properties it returns in a default representation and which it omits. Clients are not obligated to call this method before provisioning a resource.

In case the APS controller returns the HTTP 404 Not Found error code, the user should treat it as no default values are available and proceed with the resource provision without default values fetched from the application.

Get Resource Schema

If a resource schema (APS type) is not provided in an APS package, the APS controller or an APS utility may fetch the schema from the applicable service using the $schema identifier. If an application is based on the APS PHP runtime, the latter is responsible for this operation.

Request example:

GET /wordpress/$schema

Response example:

HTTP/1.1 200 OK

{
  "apsVersion": "2.0",
  "name": "Wordpress",
  "id": "http://www.odin.com/web/wordpress/1.0",
  "implements": [
    "http://aps-standard.org/types/core/application/1.0"
  ],
  "properties": {
    "adminName": {
      "type": "string",
      "title": "Administrator Name"
    },
    "adminPassword": {
      "encrypted": true,
      "type": "string",
      "title": "Administrator password"
    },
    "adminEmail": {
      "type": "string",
      "format":"email",
      "title": "Administrator E-Mail"
    },
    "title": {
      "type": "string",
      "title": "The blog title"
    },
    "locale": {
      "type": "string"
    }
  },
  "relations": {
    "db": {
      "type": "http://aps-standard.org/types/infrastructure/database/mysql/1.0",
      "link": "weak",
      "collection": false
    },
    "environment": {
      "type": "http://aps-standard.org/types/core/web-environment/1.0",
      "link": "strong",
      "requirement": "engines =='php', php.extensions =='xslt'",
      "collection": false
    },
    "user": {
      "type": "http://aps-standard.org/types/core/contact/1.0",
      "link": "weak",
      "collection": false
    }
  }
}

Get Resource Available Configurations

To get all available configurations for resources being newly created, it is necessary to use a collection of elements received from a suitable service through the $configurations identifier. The queried service must implement the following type: http://aps-standard.org/types/core/configuration/1.0.

Request example:

GET /VzEnvironment/$configurations

Response example:

HTTP/1.1 200 OK

[
  {
    "configuration" : "...,platform.os.name=eq=Linux,hardware.cpu.number=eq=1,hardware.diskspace=eq=20400,hardware.memory=eq=4096,...",
    "relations" : [
      {
        "name" : "context",
        "id" : "80a4b75e-58a7-40e4-a148-dff560e5fa4a"
      },
      {
        "name" : "sampleRef",
        "id" : "1203e863-e68f-400c-b06c-f4d15323e160"
      }
    ]
  },
  {
    "configuration" : "...,platform.os.name=eq=Windows,hardware.cpu.number=eq=1,hardware.diskspace=eq=10200,hardware.memory=eq=4096,...",
    "relations" : [
      {
        "name" : "context",
        "id" : "80a4b75e-58a7-40e4-a148-dff560e5fa4a"
      },
      {
        "name" : "sampleRef",
        "id" : "cca46d0c-6cc5-472c-b8ef-8e8cd3f45268"
      }
    ]
  },
  {
    ...
  }
]

When a new resource of a certain type is being created, not all combinations of property values make sense or can be supported. The application that declares the APS type should provide a collection of possible combinations of such properties. Each collection element must contain the configuration attribute. The attribute value is a record of properties in the RQL format (see Resource Query Language).

In addition, it is possible to set relations that are mandatory for the resource. Their values are returned as a relations array. In the elements of array, the name attribute specifies a relation name and the id attribute specifies a UID of the resource with which the newly created resource will have a relation.

If no configurations can be provided, an empty array must be returned.