Services#

About#

This section will provide information on the service type. This is not one of the main OIH types. However, we will provide guidance here on describing services using schema.org.

It should be noted that this might be a simple link to an OpenAPI or some other descriptor document. Also, schema.org is not rich enough for complex descriptions and itself borrows from the Hydra vocabulary. It may be required to leverage Hydra if complex descriptions are needed.

The graph describes a service than can be invoked with:

curl --data-binary "@yourfile.jpg" -X POST https://us-central1-top-operand-112611.cloudfunctions.net/function-1

This with POST a jpeg to the service and get back a simple text response with some information about the image.

 1{
 2    "@context": {
 3        "@vocab": "https://schema.org/"
 4      },
 5    "@type": "Action",
 6    "@id": "https://us-central1-top-operand-112611.cloudfunctions.net/function-1",
 7    "result": {
 8      "@type": "DataDownload",
 9      "encodingFormat": "text/plain",
10      "description": "a simple text result for the RGB counts"
11    },
12    "target": {
13      "@type": "EntryPoint",
14      "urlTemplate": "https://us-central1-top-operand-112611.cloudfunctions.net/function-1",
15      "httpMethod": "POST",
16      "contentType": ["image/jpeg", "image/png"]
17    },
18    "object": {
19      "@type": "ImageObject",
20      "description": "A JPEG or PNG to analyze the RGB counts"
21    }
22  }
import json
from pyld import jsonld
import os, sys

currentdir = os.path.dirname(os.path.abspath(''))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)
from lib import jbutils

with open("./graphs/action.json") as dgraph:
    doc = json.load(dgraph)

context = {
    "@vocab": "https://schema.org/",
}

compacted = jsonld.compact(doc, context)
jbutils.show_graph(compacted)
../../_images/README_1_02.svg

References#