6.9. Resource definitions

6.9.1. name

Mandatory. This is a human readable title of the resource.

6.9.2. description

Mandatory. This is a human readable description of the resource and what it does.

6.9.3. application

Mandatory. The application name that the resource is associated with. This is stored in the resource row as the application ID (appid).

6.9.4. account

Mandatory. The account name that holds the application name. This is not stored in the DB, but is used in the full resource URL and also because multiple applications can have the same namne.

6.9.5. method

Mandatory. This is the REST method for the resource. Only 'get', 'post', 'put' and 'delete' are allowed.

6.9.6. uri

Mandatory. This is the URI part that is used to locate the resource.

6.9.7. ttl

Mandatory. This is the cache time for a resource (in microseconds). 0 indicates no caching.

6.9.8. security

Optional. This allows you to add validation that a user has access to the resource.

6.9.9. process

Mandatory. This is the body of the resource, where you define all the data logic that will take place, and the result will be passed to the output.

6.9.10. output

Optional. If no output section is defined then ApiOpenStudio will look for the Accept header to find the output type.

You can have multiple outputs defined, to allow you to return the process result in the response in an opinionated format and also to upload to remote locations or send in an email/s.

If you have multiple outputs, the response output is defined by not having any destination attributes.

If you define a response output, then the Accept header in th request will be ignored.

Warning: Having multiple response formats may result in unpredictable responses.

6.9.10.1. Examples:

Always return the result in JSON format

output:
    processor: json
    id: output_response_json

Upload the result in XML format to a remote server. The response will contain true or false, depending on the process success or failure.

output:
    processor: file
    id: output_file_remote_destination
    filename: apiopenstudio.xml
    destination: 'http://this.server.com/drop/box
    method: post
    options:
        - skip_status: true

Return the response in JSON format and upload in HTML format to a remote server

output:
    -
        processor: json
        id: output_response_json
    -
        processor: xml
        id: output_xml_remote_destination
        filename: apiopenstudio.xml
        destination: 'http://this.server.com/drop/box
        method: post
        options:
            - skip_status: true