Previous topic

Resource Model Overview

Next topic

JSON Schema

DOCUMENTATION
Last updated 15-Jul-2016

Type Definition

APS Type (hereafter, type) is a formal JSON schema [JSON-SCH] used for creating and managing a set of APS resources instantiated from the type. All resources of a certain type must be provisioned and managed by a certain service, which is the resource factory for this type on the application side. It means every service declared in a package must be bound to a type defined in the same package. According to the diagram below, when the APS controller receives a REST request for an operation, e.g. POST, over a resource of a certain type, e.g. “vps”, it forwards the request to the service bound with this type, i.e. to the “/vpses” service.

../../_images/type-service.png

When a service is declared in an Package, the Application Services declaration must include the reference to the schema file that defines the related type.

../../_images/aps-type-vs-service.png

Before you start working with types (schemas), get familiar with the following formal terms derived from JSON definition in [RFC-4627]:

  • In a schema file, each part inside curly brackets { } is a JSON object. It means, a type itself is a JSON object and it contains a number of embedded JSON objects.
  • A type is a collection of name: value pairs (colon is inside separator), separated from other pairs by comma, where name is a string, and value is a string, number, boolean, null, array, or object.
  • An array is represented as a pair of square brackets [ ] surrounding zero or more values.
  • A string begins and ends with quotation marks, e.g. “VPS Cloud”.
  • MIME type of JSON files is application/json.

Walk through the following sections to get familiar with type definition.