Skip to content

lappsgrid-incubator/api-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LAPPS Grid API Services

The services available at https://api.lappsgrid.org are typically proof-of-concept prototype services implemented as Groovlets. A Groovlet is simply a Groovy script that is run inside a Java Servlet container. Currently calls to https://api.lappsgrid.org will forward to a Jetty server (see server.groovy) that serves these scripts as web services.

Note The Groovlets repository has a GitHub webhook enabled so pushing code to the master branch automatically deploys these services to api.lappsgrid.org.

Service Index

  • password - generates random strings for use as passwords or secret keys
  • uuid - generates a type 4 UUID
  • services - list all services installed on a particular node
  • metadata - fetch the metadata for a given service
  • docker - list images on docker.lappsgrid.org
  • soap-proxy - RESTful proxy for LAPPS SOAP services
  • json-compiler - compiles the LAPPS Alternate Syntax into JSON
  • json-validator - validates JSON documents agains the LAPPS JSON Schema
  • version - returns the version defined in the project's pom.xml file

Available Services

The password service uses a cryptographically secure random number generator to produce a random sequence of characters. Use the password service any time a secure password and/or security key is required.

Methods GET
URL /password?type=:type&length=:length&chars=:string
Returns text/plain

URL Parameters

  • type one of default, safe, or hex
  • chars the set of characters used to generate the password
  • length the number of characters to produce.

If chars is specified then type is ignored. Returns 400 Bad Request if neither of type or chars is specified, or if type is not one of default, safe, or hex.

Types

  • default the set of most printable ASCII characters (minus quotes).
  • safe letters (upper and lower case), digits, and the characters _-=,.
    The safe type is intended to be used to generate passwords or keys that can be safely included in scripts.
  • hex the hexadecimal digits 0123456789abcde

Examples

> curl https://api.lappsgrid.org/password
=F9sXKGn2lteDdvk

> curl https://api.lappsgrid.org/password?type=hex&length=32
a0edc2709c4ebb9ee43f35415c12af5b

> curl https://api.lappsgrid.org/password?chars=01&length=32
00001001101101111101000000001001

The password service will always produce at least 16 characters of output.

Generates a Type 4 UUID (Universally Unique IDentifier) according to RFC 4122. In practice the service simply calls java.util.UUID.randomUUID().toString()

Methods GET
URL /uuid
Returns text/plain

Example

> curl https://api.lappsgrid.org/uuid

d085f907-0c00-4dd6-b500-5f98cbc0827f

Display the services installed on a service manager instance.

Methods GET
URL /services/:node?:key=:value [&:key=value...]
Returns application/json, text/html

Path Parameters

  • node One of vassar or brandeis

URL Parameters

  • key a Service Manager search key used to filter services
  • value the value to be matched. The value matches if it is a substring of the key's value. Text matches are case-insensitive.

Valid search keys are:

  • active
  • endpointUrl
  • instanceType
  • ownerUserId
  • registeredDate
  • serviceDescription
  • serviceId
  • serviceName
  • serviceType
  • serviceTypeDomain
  • updatedDate

If no key/value pairs are specified as search terms then all services registered on the Service Manager instance will be listed.

Example

curl -H 'Accept: text/html' https://api.lappsgrid.org/services/brandeis
curl https://api.lappsgrid.org/services/vassar?serviceName=gate

Display metadata about a single service.

Methods GET
URL /metadata?id=:id
Returns application/json, text/html, application/x-cmdi+xml

If an Accept header is not specified application/json will be returned.

URL Parameters

  • id the ID, including gridId, of the service to get metadata from.

Example

curl https://api.lappsgrid.org/metadata?id=anc:gate.tokenizer_2.2.0
curl -H 'Accept: application/x-cmdi+xml' https://api.lappsgrid.org/metadata?id=anc:stanford.tagger_2.0.0

List Docker images available from https://docker.lappsgrid.org. NOTE: There is no Docker Hub style user interface at docker.lappsgrid.org.

Methods GET
URL /docker
Returns text/html

A RESTful proxy service for LAPPS Grid SOAP services.

Methods POST
URL /soap-proxy
Accepts text/plain
Returns application/json

URL Parameters

  • id the ID of the service to invoke.

Example

> curl -i -H 'Content-Type: text/plain' -X POST -d 'Karen flew to New York.' https://api.lappsgrid.org/soap-proxy?id=anc:wrap.lif_1.0.0

HTTP/1.1 200 
Server: nginx/1.4.6 (Ubuntu)
Date: Mon, 16 Oct 2017 16:59:50 GMT
Content-Type: text/plain;charset=UTF-8
Content-Length: 241
Connection: keep-alive

{
    "discriminator": "http://vocab.lappsgrid.org/ns/media/jsonld#lif",
    "payload": {
        "@context": "http://vocab.lappsgrid.org/context-1.0.0.jsonld",
        "metadata": {
            
        },
        "text": {
            "@value": "Karen flew to New York.",
            "@language": "en"
        },
        "views": []
    },
    "parameters": {}
}

Compiles the LAPPS Alternative Syntax into an equivalent JSON document.

Methods POST
URL /json-compiler
Accepts text/plain
Returns application/json

Example

> curl -i -X POST -H "Content-type: text/plain" --data "type object; properties { name string }" https://api.lappsgrid.org/json-compiler

HTTP/1.1 200 OK
Server: nginx/1.4.6 (Ubuntu)
Date: Sun, 18 Jun 2017 18:30:18 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive

{
    "type": "object",
    "properties": {
        "name": "string"
    }
}

Validates JSON documents against the JSON schema for LIF documents or the schema for service metadata.

Methods POST
URL /validate/data
/validate/container
/validate/metadata
Accepts application/ld+json
Returns application/json

Example

> curl -H 'Content-type: application/ld+json' -d @input.lif https://api.lappsgrid.org/validate/data
{
    "level": "ok",
    "message": "No problems found."
}
Methods POST
URL /validate/schema
Returns application/json

Examples

> curl -H "Content-type: text/plain" --data-binary @lif.schema http://api.lappsgrid.org/validate/schema
Methods GET
URL /validate/metadata?id=:id
/validate/metadata?url=:url
Returns application/json

URL Parameters

  • id the ID of the service to be validated.
  • url the URL of a LAPPS service

When sending a GET request include either the service ID or the URL of a LAPPS service. It is an error to include both the id and url URL parameters.

Example

> curl https://api.lappsgrid.org/validate/metadata?id=anc:stanford.tokenizer_2.1.0
{
    "level": "ok",
    "message": "Metadata passed validation."
}

> curl https://api.lappsgrid.org/validate/metadata?url=http://vassar.lappsgrid.org/invoker/anc:stanford.tokenizer_2.1.0
{
    "level": "ok",
    "message": "Metadata passed validation."
}

Return the version string defined in the pom.xml file.

Methods GET
URL /version
Returns text/plain

Example

> curl https://api.lappsgrid.org/version

1.0.1