Skip to content

Instantly share code, notes, and snippets.

@stain
Created June 12, 2013 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stain/5763598 to your computer and use it in GitHub Desktop.
Save stain/5763598 to your computer and use it in GitHub Desktop.
Proposal: JSON as SCUFL2's configuration format. <configuration.json> represents a complete configuration of the REST activity. This JSON validates according to the JSON Schema <schema.json>. <context.json> is a JSON-LD context (linked to with "@context") that can be used to create the RDF in <rdf-from-json.ttl>. This RDF shows clearly a very si…
{
"@context": "http://ns.taverna.org.uk/2010/activity/rest.context",
"outgoingDataFormat": "String",
"escapeParameters": false,
"request": {
"httpMethod": "POST",
"headers": [
{ "header": "Accept",
"value": "audio/mpeg" },
{ "header": "Content-Type",
"value": "application/xml" },
{ "header": "Expect",
"value": "100-continue"},
{ "header": "X-Custom",
"value": "User-added header"}
],
"absoluteURITemplate": "http://www.uniprot.org/uniprot/{id}.xml"
}
}
{
"@context": {
"@vocab": "http://ns.taverna.org.uk/2010/activity/rest#",
"httpv": "http://www.w3.org/2011/http#",
"headers": {
"@id": "httpv:headers",
"@container": "@list"
},
"header": "httpv:fieldName",
"value": "httpv:fieldValue",
"httpMethod": "httpv:methodName"
}
}
<Configuration rdf:about="configuration/REST_Service/">
<rdf:type rdf:resource="http://ns.taverna.org.uk/2010/activity/rest#Config"/>
<name>REST_Service</name>
<configure rdf:resource="activity/REST_Service/"/>
<outgoingDataFormat:outgoingDataFormat xmlns:outgoingDataFormat="http://ns.taverna.org.uk/2010/activity/rest#"
xmlns="http://ns.taverna.org.uk/2010/activity/rest#">String</outgoingDataFormat:outgoingDataFormat>
<request:request xmlns:request="http://ns.taverna.org.uk/2010/activity/rest#"
xmlns="http://ns.taverna.org.uk/2010/activity/rest#">
<Request>
<absoluteURITemplate>http://www.uniprot.org/uniprot/{id}.xml</absoluteURITemplate>
<headers:headers xmlns:headers="http://www.w3.org/2011/http#" xmlns="http://www.w3.org/2011/http#"
rdf:parseType="Collection">
<rdf:li>
<RequestHeader>
<fieldName>Accept</fieldName>
<fieldValue>audio/mpeg</fieldValue>
</RequestHeader>
</rdf:li>
<rdf:li>
<RequestHeader>
<fieldName>Content-Type</fieldName>
<fieldValue>application/xml</fieldValue>
</RequestHeader>
</rdf:li>
<rdf:li>
<RequestHeader>
<use100Continue xmlns="http://ns.taverna.org.uk/2010/activity/rest#"
rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</use100Continue>
<fieldName>Expect</fieldName>
</RequestHeader>
</rdf:li>
<rdf:li>
<RequestHeader>
<fieldName>Test</fieldName>
<fieldValue>Hello</fieldValue>
</RequestHeader>
</rdf:li>
</headers:headers>
<mthd:mthd xmlns:mthd="http://www.w3.org/2011/http#" xmlns="http://www.w3.org/2011/http#"
rdf:resource="http://www.w3.org/2011/http-methods#POST"/>
</Request>
</request:request>
<showRedirectionOutputPort:showRedirectionOutputPort
xmlns:showRedirectionOutputPort="http://ns.taverna.org.uk/2010/activity/rest#"
xmlns="http://ns.taverna.org.uk/2010/activity/rest#"
rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</showRedirectionOutputPort:showRedirectionOutputPort>
</Configuration>
<!-- Path to JSON within the workflow bundle -->
<Configuration rdf:about="configuration/REST_Service.json">
<rdf:type rdf:resource="http://ns.taverna.org.uk/2010/activity/rest#Config"/>
<name>REST_Service</name>
<configure rdf:resource="activity/REST_Service/"/>
<!-- Path to schema within the workflow bundle -->
<schema rdf:resource="../schemas/rest.json" />
</Configuration>
@prefix http: <http://www.w3.org/2011/http#> .
@prefix rest: <http://ns.taverna.org.uk/2010/activity/rest#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<> rest:outgoingDataFormat "String";
rest:escapeParameters "false"^^xsd:boolean;
rest:request [
http:methodName "POST";
http:headers (
[ http:fieldName "Accept";
http:fieldValue "audio/mpeg" ]
[ http:fieldName "Content-Type";
http:fieldValue "application/xml" ]
[ http:fieldName "Expect";
http:fieldValue "100-continue" ]
[ http:fieldName "X-Custom";
http:fieldValue "Used-added header" ] );
rest:absoluteURITemplate "http://www.uniprot.org/uniprot/{id}.xml"
] .
{
"$schema": "http://json-schema.org/draft-03/schema#",
"id": "http://ns.taverna.org.uk/2010/activity/rest.schema.json",
"title": "REST activity configuration",
"type": "object",
"properties": {
"@context": {
"required": true,
"description": "JSON-LD context for interpreting the configuration as RDF",
"enum": ["http://ns.taverna.org.uk/2010/activity/rest.context.json"]
},
"request": {
"type": "object",
"description": "The HTTP request the REST activity is to perform",
"properties": {
"httpMethod": {
"description": "The HTTP method of the REST request",
"default": "GET",
"enum": ["GET", "POST", "PUT", "DELETE"]
},
"absoluteURITemplate": {
"type": "string",
"required": true,
"description": "The URI template for this request. The template is an URI with 0 or more {variables}, e.g. http://example.com/user/{username}?page={page} (RFC6570 Level 1). Matching activity input ports are created for each variable, so the variable name must be a valid Taverna input port name. "
},
"headers": {
"description": "HTTP headers of the request. GET requests SHOULD include Accept. PUT and POST request SHOULD include Content-Type. The header Expect: 100-continue is recognized and supported by the REST activity for POST and PUT requests.",
"type": "array",
"items": {
"type": "object",
"properties": {
"header": {
"type": "string",
"required": true,
"description": "The HTTP header name, e.g. Accept or Content-Type"
},
"value": {
"type": "string",
"required": true,
"description": "The value of the HTTP header, e.g. text/plain"
}
}
}
}
}
},
"outgoingDataFormat": {
"description": "Format of the POSTed content",
"default": "String",
"enum": ["String", "Binary"]
},
"showRedirectionOutputPort": {
"type": "boolean",
"default": false,
"description": "If set, the output port 'redirection' is added, showing the URL of the requested body. This is particularly useful for following redirection. "
},
"escapeParameters": {
"type": "boolean",
"default": true,
"description": "If true (default), input port values are URI-escaped (RFC 2396) before expanding variables in the URI template."
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment