Application Packaging Standard

Last updated 14-Nov-2018

Resource

The Resource type is the base type for any resource operations.

Schema

Resource schema: download

{
  "apsVersion": "2.0",

  "id": "http://aps-standard.org/types/core/resource/1.0",
  "name": "Resource",

  "operations": {
    "provision": {
      "name": "provision",
      "verb": "POST",
      "path": "/",
      "static": true,
      "access": {
          "admin": true,
          "owner": true,
          "referrer": false
      }
    },

    "retrieve": {
      "name": "retrieve",
      "verb": "GET",
      "path": "/",
      "access": {
          "admin": true,
          "owner": true,
          "referrer": true
      }
    },

    "configure": {
      "name": "configure",
      "verb": "PUT",
      "path": "/",
      "parameters": {
        "new": {
          "type": "self",
          "required": true,
          "kind": "body"
        }
      },
      "access": {
          "admin": true,
          "owner": true,
          "referrer": false
      }
    },

    "unprovision": {
      "name": "unprovision",
      "verb": "DELETE",
      "path": "/",
      "access": {
          "admin": true,
          "owner": true,
          "referrer": false
      }
    }
  },

  "structures": {

    "Counter": {
      "type": "object",
      "properties": {
        "usage": { "type": "integer" },
        "limit": { "type": "integer" }
      }
    },

    "Limit": {
      "type": "object",
      "properties": {
        "limit": { "type": "integer" }
      }
    },

    "Usage": {
      "type": "object",
      "properties": {
        "usage": { "type": "integer" }
      }
    },

    "NotificationSource":
    {
    	"type": "object",
    	"properties": {
            "type": {
                "type": "string",
                "format": "uri",
                "description": "APS Type of source resources"
            },
            "id": {
                "type": "string",
                "description": "Resource which is source of event"
            }
    	}
    },
    
    "Notification": {
      "type": "object",
      "description": "Event notification structure",

      "properties": {
        "type": {
           "type": "string",
           "format": "uri",
           "required": true,
           "description": "Type of event (URI)"
        },
        "time": {
           "type": "string",
           "format": "date-time",
           "description": "Date-time when event happens"
        },
        "serial": {
           "type": "number",
           "description": "Serial number of event (incrementing)"
        },
        "source": {
           "type": "NotificationSource",
           "description": "Resource originating the event"
        }
      }
    }
  }
}

Resource Properties

The base resource does not have any properties.

Resource Operations

The resource operations are basic for all APS resources and are described in details in resource operations.

Provision

See Provisioning Resources

Configure

See Resource Configuration

Unprovision

See Unprovisioning Resources

Resource Structures

The following structures allow the management platform or other applications to monitor resource usage and set limits on the application resources.

  • Limit - a structure used to specify a limit on a resource usage

    ...
    "diskspace": {
       "limit": 10000000
    }
    ...
    
  • Usage - a structure that allows the management platform or other applications to get the application resource usage

    ...
    "diskspace": {
       "usage": 1234567
    }
    ...
    
  • Counter - contains both limit and usage properties to make the application set a limit and return resource usage

    ...
    "diskspace": {
       "limit": 10000000,
       "usage": 1234567
    }
    ...
    

In an APS Type definition, a disk space counter like in the last example above will look like:

{
   "id": "http://webhosting.example.com/types/version/1.0",
   "implements": [
      "http://aps-standard.org/types/core/resource/1.0"
   ],

   "properties": {
      "siteName": {
         "type": "string",
         "title": "WebSite Name"
      },

      "diskspace": {
         "type": "http://aps-standard.org/types/core/resource/1.0#Counter",
         "title": "Website diskspace",
         "unit": "kb"
      }
   }
 }

In the platform, the following units are supported in definitions of APS Types that include the above-mentioned structures:

kb, mb, gb, unit, item, mb-h, mhzh, Kbit/sec-h, and item-h.

Note

  1. unit and item have the same meaning.
  2. mb-h, mhzh, Kbit/sec-h, and item-h are used as the units for additive counters.

3. The application is responsible for filling in the usage fields of structures on retrieve requests that the management platform sends periodically.

  1. If a Limit or Counter type is used and no limit is provided in the configuration then the value is unlimited.

Examples

Follow the Resource Counters demo project to get skills in using additive and non-additive resource counters.

Core