freme-project / freme-project.github.io

Apache License 2.0
2 stars 0 forks source link

pipelines: enhance API documentation #101

Closed ghsnd closed 8 years ago

ghsnd commented 8 years ago

Here is a description of the new CRUD operations of pipeline templates, and also the use of a template.

Use pipeline template

Uses a stored pipeline template on a given NIF or plain text input.

Method: POST

Endpoint: /pipelining/chain/{id}

id: Path parameter: id of the pipeline template to use.

Content-Type: HTTP Header parameter, can be one of text/turtle, application/json, application/ld+json, application/n-triples, application/rdf+xml, text/n3, text/plain, depending on the body.

Body: The input for the pipeline chain. This can be a NIF or plain text document.

Responses:

Creates and stores a pipeline on the server the request is sent to. The response contains the id of the created pipeline, which is to be used in further methods.

Method: POST.

Endpoint: /pipelining/templates/.

Content-Type: HTTP Header parameter, should be application/json.

persist: Optional parameter: values can be true or false. Indicates whether to persist the pipeline forever (true) or for just one week (false). If not given, it defaults to false.

visibility: Optional parameter: values can be PRIVATE or PUBLIC. A template with visibility PUBLIC is visible and usable by anyone. A template with visibility PRIVATE is only visible and usable by the owner. The default value is PUBLIC.

Body: The pipeline template as JSON string: It represents an object with a label, a description and a list of request objects. Example:

{
  "label": "Spotlight-Link",
  "description": "Recognises entities using Spotlight en enriches with geo information.",
  "serializedRequests": [
    {
      "method": "POST",
      "endpoint": "http://api.freme-project.eu/current/e-entity/dbpedia-spotlight/documents",
      "parameters": {
        "language": "en"
      },
      "headers": {
        "content-type": "text/plain",
        "accept": "text/turtle"
      }
    },
    {
      "method": "POST",
      "endpoint": "http://api.freme-project.eu/current/e-link/documents/",
      "parameters": {
        "templateid": "3"
      },
      "headers": {
        "content-type": "text/turtle",
        "accept": "text/turtle"
      }
    }
  ]
}

The fields of the returned object are:

Responses:

{
  "id": 1445246379051,
  "label": "Spotlight-Link",
  "description": "Recognises entities using Spotlight en enriches with geo information.",
  "persist": false,
  "visibility": "PUBLIC",
  "owner": "userwithpermission",
  "serializedRequests": [
    {
      "method": "POST",
      "endpoint": "http://api.freme-project.eu/current/e-entity/dbpedia-spotlight/documents",
      "parameters": {
        "language": "en"
      },
      "headers": {
        "content-type": "text/plain",
        "accept": "text/turtle"
      }
    },
    {
      "method": "POST",
      "endpoint": "http://api.freme-project.eu/current/e-link/documents/",
      "parameters": {
        "templateid": "3"
      },
      "headers": {
        "content-type": "text/turtle",
        "accept": "text/turtle"
      }
    }
  ]
}

The fields of the returned object are: * id: the generated id if the template. This is also the timestamp of creation, in milliseconds. * label: The name of the pipeline template. * description: a description of the pipeline template. * persist: if false, the template will not automatically be deleted; if false it will live only for one week. To be implemented. * owner: the owner, in this case the creator, of the pipeline template. * serializedRequests: the chained requests as described in /pipelining/chain.

Updates a pipeline template on the server the request is sent to.

Method: PUT.

Endpoint: /pipelining/templates/{id}.

Content-Type: HTTP Header parameter, should be application/json.

id: Path parameter: the id of the pipeline.

persist: Optional parameter: values can be true or false. Indicates whether to persist the pipeline forever (true) or for just one week (false). If not given, it defaults to false.

visibility: Optional parameter: values can be PRIVATE or PUBLIC. A template with visibility PUBLIC is visible and usable by anyone. A template with visibility PRIVATE is only visible and usable by the owner. The default value is PUBLIC.

owner: Optional parameter: the new owner of the pipeline.

Body: The updated pipeline template as JSON object, as described in Create pipeline template.

Responses:

Returns the pipeline with the given id found on the server the request is sent to.

Method: GET

Endpoint: /pipelining/templates/{pipelineid}

id: Path parameter: the id of the pipeline.

Responses:

Returns is list of all visible pipeline templates on the server the request is sent to.

Method: GET

Endpoint: /pipelining/templates

Responses:

[
  {
    "id": 1445259245610,
    "label": "Spotlight-Link",
    "description": "Recognises entities using Spotlight en enriches with geo information.",
    "persist": false,
    "visibility": "PUBLIC",
    "owner": "userwithpermission",
    "serializedRequests": [
      {
        "method": "POST",
        "endpoint": "http://api.freme-project.eu/current/e-entity/dbpedia-spotlight/documents",
        "parameters": {
          "language": "en"
        },
        "headers": {
          "content-type": "text/plain",
          "accept": "text/turtle"
        }
      },
      {
        "method": "POST",
        "endpoint": "http://api.freme-project.eu/current/e-link/documents/",
        "parameters": {
          "templateid": "3"
        },
        "headers": {
          "content-type": "text/turtle",
          "accept": "text/turtle"
        }
      }
    ]
  },
  {
    "id": 1445259245765,
    "label": "NER-Translate",
    "description": "Apply FRENE NER and then e-Translate",
    "persist": false,
    "visibility": "PRIVATE",
    "owner": "userwithpermission",
    "serializedRequests": [
      {
        "method": "POST",
        "endpoint": "http://api.freme-project.eu/current/e-entity/freme-ner/documents",
        "parameters": {
          "language": "en",
          "dataset": "dbpedia"
        },
        "headers": {
          "content-type": "text/plain",
          "accept": "text/turtle"
        }
      },
      {
        "method": "POST",
        "endpoint": "http://api.freme-project.eu/current/e-translation/tilde",
        "parameters": {
          "source-lang": "en",
          "target-lang": "fr"
        },
        "headers": {
          "content-type": "text/turtle",
          "accept": "text/turtle"
        }
      }
    ]
  }
]

Deletes the pipeline with a given id.

Method: DELETE

Endpoint: /pipelining/templates/{id}

id: Path parameter: the id of the pipeline template.

Responses:

josauder commented 8 years ago

I omitted the response examples because they are somewhat self explanatory.