# API-Vitam Version Alpha - Worker interne version v1

http://worker.internal.vitam.gouv.fr/{version}

- version: required(v1)

### Avertissements

Cette version d'API présente des fonctionnalités sous différents statuts :

- Supportées : rien n'est spécifié, la fonctionnalité ou la donnée est supportée
- Non supportées : le mot clef UNSUPPORTED est indiqué et précise que cette fonctionnalité ou donnée n'est pas supportée par l'implémentaton courante

Cette version d'API présente des fonctionnalités sous différentes versions :

- Alpha : l'API est dans une première version, susceptible d'évoluer fortement
- Beta : l'API est proche de sa version stable
- Production : l'API est considérée comme "production ready"
- Deprecated : l'API est considérée comme obsolète et devrait disparaître dans une version majeure prochaine

Pour le moment, la partie /containers/{cid} des paths n'est pas encore pris en compte mais doit être ajoutée à terme.

### Licence

Ce document est distribué sous les termes de la Licence Ouverte V2.0

### Tasks

Le principe proposé serait le suivant:

- Affectation par le Moteur d'exécution (Distribution):
  - POST /tasks
- Suivi pour un worker pour une tâche:
  - GET / tasks/id_async
- Possibilité future d'agir sur une tâche en cours d'exécution (ou plusieurs):
  - PATCH /tasks
  - PATCH /tasks/id_async

Questions ou remarques:

- Le /status pourrait être étendu pour avoir des informations statistiques sur le Worker.

### Tasks

Administration des Tâches Asynchrones (Steps).

#### /tasks get post put

get

Permet de lister les tâches en cours

post

Permet de soumettre une tâche (steps + contexte + item)

put

Permet si nécessaire d'interagir avec une tâche (cancel)

#### get /tasks

Permet de lister les tâches en cours

Secured by VitamPlatform

Based on Platform Secret

### Headers

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

### Body

Media type: application/json

Type: object

Example:

    {
      "query": "name='abcdef*'&since>'2015-07-14'"
    }

## HTTP status code 200

### Body

Media type: application/json

Type: object

Example:

    {
      "hits": {
        "total": 10,
        "size": 3,
        "offset": 0,
        "limit": 100,
        "time_out": false,
        "next": "async_id_next"
      },
      "context": {
        "query": "name='abcdef*'&since>'2015-07-14'"
      },
      "results": [ "id1", "id2", "id3" ]
    }

## HTTP status code 401

Unauthorized, authentication in error

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

## HTTP status code 404

Not Found, requested resource does not exist

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

## HTTP status code 409

Conflict, operation requested is in conflict with existing data

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

## HTTP status code 412

Precondition Failed, some predicates are incorrect, therefore the operation is not possible

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

# Secured by VitamPlatform

### Headers

- X-Vitam-Key: required(string)

  Vitam Platform Key

#### post /tasks

Permet de soumettre une tâche (steps + contexte + item)

Secured by VitamPlatform

Based on Platform Secret

### Headers

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

### Body

Media type: application/json

Type: object

Example:

    { "Step": "name",
    	"otherInfo": "other info",
    	"actions": [{
    		"action": "id_action",
    		"arguments": {
    			"nom_champ_1": "jxpath1",
    			"nom_champ_2": "jxpath2"
    		},
    		"results": {
    			"nom_champ_3": null,
    			"nom_champ_4": null
    		},
    		"status" : "Running",
    		"post_assign": [{
    			"target": "jxpath3",
    			"result": "construction1"
    		}],
    		"start_time" : "1990-12-31T23:59:60Z",
    		"end_time" : "1990-12-31T23:59:60Z"
    	}]
    }

## HTTP status code 201

### Body

Media type: application/json

Type: object

Example:

    {
        "id": "$id_async$",
        "type": "ingest",
        "state": "done",
        "task_status": "commit",
        "start_date": "2014-01-10T03:06:17.396Z",
        "end_date": "2014-01-20T03:06:17.396Z",
        "expiration_date": "2014-02-20T03:06:17.396Z",
        "result_link": "https://xxx/v1/ingests/456",
        "error": {
          "http_code": 404,
          "code": "ingest",
          "state": "File_Not_Found",
          "message": "File is not found",
          "description": "Operation on file xxx cannot be done since file is not found",
          "errors": [
            { "http_code": 415, "code": "ingest", "state": "Unsupported_Media_Type", "message": "Unsupported media type detected", "description": "File xxx has an unsupported media type yyy" },
            { "http_code": 412, "code": "ingest", "state": "Precondition_Failed", "message": "Precondition in error", "description": "Operation on file xxx cannot continue since precondition is in error" }
          ]
        }
    }

## HTTP status code 401

Unauthorized, authentication in error

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

## HTTP status code 404

Not Found, requested resource does not exist

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

## HTTP status code 409

Conflict, operation requested is in conflict with existing data

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

## HTTP status code 412

Precondition Failed, some predicates are incorrect, therefore the operation is not possible

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

# Secured by VitamPlatform

### Headers

- X-Vitam-Key: required(string)

  Vitam Platform Key

#### put /tasks

Permet si nécessaire d'interagir avec une tâche (cancel)

Secured by VitamPlatform

Based on Platform Secret

### Headers

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

### Body

Media type: application/json

Type: object

Example:

    {
      "X-RequestId": "id",
      "code": 201,
      "vitamCode": 123456,
      "timestamp": "2015-07-14T17:07:14Z",
      "message": "message informatif retour"
    }

## HTTP status code 200

### Body

Media type: application/json

Type: object

Example:

    {
        "id": "$id_async$",
        "type": "ingest",
        "state": "done",
        "task_status": "commit",
        "start_date": "2014-01-10T03:06:17.396Z",
        "end_date": "2014-01-20T03:06:17.396Z",
        "expiration_date": "2014-02-20T03:06:17.396Z",
        "result_link": "https://xxx/v1/ingests/456",
        "error": {
          "http_code": 404,
          "code": "ingest",
          "state": "File_Not_Found",
          "message": "File is not found",
          "description": "Operation on file xxx cannot be done since file is not found",
          "errors": [
            { "http_code": 415, "code": "ingest", "state": "Unsupported_Media_Type", "message": "Unsupported media type detected", "description": "File xxx has an unsupported media type yyy" },
            { "http_code": 412, "code": "ingest", "state": "Precondition_Failed", "message": "Precondition in error", "description": "Operation on file xxx cannot continue since precondition is in error" }
          ]
        }
    }

## HTTP status code 401

Unauthorized, authentication in error

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

## HTTP status code 404

Not Found, requested resource does not exist

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

## HTTP status code 409

Conflict, operation requested is in conflict with existing data

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

## HTTP status code 412

Precondition Failed, some predicates are incorrect, therefore the operation is not possible

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

# Secured by VitamPlatform

### Headers

- X-Vitam-Key: required(string)

  Vitam Platform Key

#### /tasks/{id_async} get put

get

Permet de récupérer le statut d'une Tâche en cours

put

Permet si nécessaire d'interagir avec une Tâche (cancel)

#### get /tasks/{id_async}

Permet de récupérer le statut d'une Tâche en cours

Secured by VitamPlatform

Based on Platform Secret

### URI Parameters

- id_async: required(string)

### Headers

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

## HTTP status code 200

### Body

Media type: application/json

Type: object

Example:

    {
        "id": "$id_async$",
        "type": "ingest",
        "state": "done",
        "task_status": "commit",
        "start_date": "2014-01-10T03:06:17.396Z",
        "end_date": "2014-01-20T03:06:17.396Z",
        "expiration_date": "2014-02-20T03:06:17.396Z",
        "result_link": "https://xxx/v1/ingests/456",
        "error": {
          "http_code": 404,
          "code": "ingest",
          "state": "File_Not_Found",
          "message": "File is not found",
          "description": "Operation on file xxx cannot be done since file is not found",
          "errors": [
            { "http_code": 415, "code": "ingest", "state": "Unsupported_Media_Type", "message": "Unsupported media type detected", "description": "File xxx has an unsupported media type yyy" },
            { "http_code": 412, "code": "ingest", "state": "Precondition_Failed", "message": "Precondition in error", "description": "Operation on file xxx cannot continue since precondition is in error" }
          ]
        }
    }

## HTTP status code 401

Unauthorized, authentication in error

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

## HTTP status code 404

Not Found, requested resource does not exist

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

## HTTP status code 409

Conflict, operation requested is in conflict with existing data

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

## HTTP status code 412

Precondition Failed, some predicates are incorrect, therefore the operation is not possible

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

# Secured by VitamPlatform

### Headers

- X-Vitam-Key: required(string)

  Vitam Platform Key

#### put /tasks/{id_async}

Permet si nécessaire d'interagir avec une Tâche (cancel)

Secured by VitamPlatform

Based on Platform Secret

### URI Parameters

- id_async: required(string)

### Headers

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

### Body

Media type: application/json

Type: object

Example:

    {
      "X-RequestId": "id",
      "code": 201,
      "vitamCode": 123456,
      "timestamp": "2015-07-14T17:07:14Z",
      "message": "message informatif retour"
    }

## HTTP status code 200

### Body

Media type: application/json

Type: object

Example:

    {
        "id": "$id_async$",
        "type": "ingest",
        "state": "done",
        "task_status": "commit",
        "start_date": "2014-01-10T03:06:17.396Z",
        "end_date": "2014-01-20T03:06:17.396Z",
        "expiration_date": "2014-02-20T03:06:17.396Z",
        "result_link": "https://xxx/v1/ingests/456",
        "error": {
          "http_code": 404,
          "code": "ingest",
          "state": "File_Not_Found",
          "message": "File is not found",
          "description": "Operation on file xxx cannot be done since file is not found",
          "errors": [
            { "http_code": 415, "code": "ingest", "state": "Unsupported_Media_Type", "message": "Unsupported media type detected", "description": "File xxx has an unsupported media type yyy" },
            { "http_code": 412, "code": "ingest", "state": "Precondition_Failed", "message": "Precondition in error", "description": "Operation on file xxx cannot continue since precondition is in error" }
          ]
        }
    }

## HTTP status code 401

Unauthorized, authentication in error

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

## HTTP status code 404

Not Found, requested resource does not exist

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

## HTTP status code 409

Conflict, operation requested is in conflict with existing data

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

## HTTP status code 412

Precondition Failed, some predicates are incorrect, therefore the operation is not possible

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

# Secured by VitamPlatform

### Headers

- X-Vitam-Key: required(string)

  Vitam Platform Key

### /status

#### /status get

get

#### get /status

Secured by VitamPlatform

Based on Platform Secret

## HTTP status code 200

OK, operation in success

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

### Body

Media type: application/json

Type: object

Properties

- id: required(string)

  Id of the instance

- service: required(string)

  Service Name for this instance

- startDate: required(datetime)

  Date time for the start of this instance

- status: required(one of Active, Inactive, ShutdownInProgress, Unreachable)

  Status of this instance

Example:

    {
      "id": "abcdef",
      "service": "serviceName",
      "startDate": "2015-07-14T17:07:14Z",
      "status": "Active"
    }

## HTTP status code 401

Unauthorized, authentication in error

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

## HTTP status code 404

Not Found, requested resource does not exist

### Headers

- X-Request-Id: required(string)

  Unique Request Identifier

  Example:

      AbDUh67jj

- FullApiVersion: required(string)

  Complete Version of the API.

  Example:

      V1.25

- X-Application-Id: (string)

  Session Identifier from client Front-Office Application

  Example:

      SESSION-ID-00001

- X-Tenant-Id: (number)

  Unique Tenant Identifier

  Example:

      0

## HTTP status code 503

Service Unavailable, the requested service is unavailable

# Secured by VitamPlatform

### Headers

- X-Vitam-Key: required(string)

  Vitam Platform Key