#%RAML 1.0

title: API-Vitam Version Alpha - Moteur d'exécution interne
version: v1
baseUri: http://processing.internal.vitam.gouv.fr/{version}
protocols: [ HTTP ]

uses:
  StandardTypes: libraries/StandardTypes.raml
  StandardTraits: libraries/StandardTraits.raml
  AccessTypes: libraries/AccessTypes.raml
  AccessTraits: libraries/AccessTraits.raml
  DslTypes: libraries/DslTypes.raml

securitySchemes:
  VitamPlatform: !include securitySchemes/SecuritySchemeVitamInternal.raml

securedBy: [ VitamPlatform ]

mediaType: application/json

types:
  _reserved:
    type: string

documentation:
  - title: Avertissements
    content: !include docs-fr/avertissement.md

  - title: Licence
    content: !include docs-fr/license.md

  - title: Workflows
    content: |

      Le principe proposé serait le suivant:
        - Permet de soumettre un workflow à l'exécution:
          - POST /operations/id
        - Obtenir le statut détaillé d'un workflow:
          - GET /operations/id
        - Obtenir le statut d'un workflow:
          - HEAD /operations/id
        - Permet d'intervenir sur le comportement de l'exécution et de la distribution (next,resume,pause)
          - PUT /operations/id
        - Permet à un worker d'informer de la fin d'exécution d'une étape
          - DELETE /operations/id


        - Permet de soumettre des operations à l'exécution:
          - POST /operations
        - Mettre à jour le statut des operations en cours d'un workflow:
          - PUT /operations

  - title: Worker_family
    content: |
      Le principe proposé serait le suivant:
        - Permet de définir les Workers dans des familles
          - POST /worker_family
        - Permet l'abonnement et la suppression d'un worker
          - POST /worker_family/id_family/workers

      Questions ou remarques:
        - Le /status pourrait être étendu pour remonter un état statistique du moteur

/operations:
  # root endpoint request
  displayName: Operations
  description: Administration des Workflows Asynchrones (opérations).
  is: [ StandardTraits.StandardOptionalHeader,
  StandardTraits.StandardHeader401, StandardTraits.StandardHeader404,
  StandardTraits.StandardHeader409, StandardTraits.StandardHeader412 ]
  post:
    description: Permet de soumettre une opération (workflow + contexte + lot)
    body:
      application/json:
        type: object
        example: !include libraries/samples/workflow.sample
    headers:
       X-Action:
        required: true
       X-Context-Id:
        required: false
    responses:
      201:
        body:
          application/json:
            type: object
            example: !include libraries/samples/async_status.sample
    
  put:
    description: Permet d'interagir avec la liste des opérations (pause, reprise, repriorisation par exemple)
    body:
      application/json:
        type: object
        example: !include libraries/samples/genericSample.sample
    responses:
      200:
        body:
          application/json:
            type: object
            example: !include libraries/samples/async_status.sample
    headers:
       X-Action:
        required: true
       X-Context-Id:
        required: false

  /{id}:
    displayName: Operation
    is: [ StandardTraits.StandardOptionalHeader,
    StandardTraits.StandardHeader401, StandardTraits.StandardHeader404,
    StandardTraits.StandardHeader409, StandardTraits.StandardHeader412 ]
    get:
      description: Permet de récupérer le statut du workflow en cours
      responses:
        202:
          body:
            application/json:
              type: object
              example: !include libraries/samples/async_status.sample
        200:
          body:
            application/json:
              type: object
              example: !include libraries/samples/workflow.sample
    post:
     description: |
       Permet de soumettre un workflow à l'exécution
     body:
      application/json:
        type: object
        example: !include libraries/samples/genericSample.sample
     headers:
      X-Action:
       required: true
      X-Context-Id:
       required: false
     responses:
        202:
          body:
            application/json:
              type: object
              example: !include libraries/samples/async_status.sample
        200:
          body:
            application/json:
              type: object
              example: !include libraries/samples/workflow.sample
    put:
      description: Permet d'interagir avec une opération (pause, reprise, repriorisation par exemple)
      headers:
       X-Action:
        required: true
       X-Context-Id:
        required: false
      body:
        application/json:
          type: object
          example: !include libraries/samples/genericSample.sample
      responses:
        200:
          body:
            application/json:
              type: object
              example: !include libraries/samples/async_status.sample
    delete:
     description: |
       pour annuler le workflow.
     responses:
       204:
         description: |
           Succesfully deleted resource
    head:
      description: |
        Obtenir le statut d'un workflow
      responses:
       200:
         description: |
           operation trouve et status retourne avec succes 
       204:
         description: |
          operation non trouve 

/worker_family:
  # root endpoint request
  displayName: Worker's family
  description: Administration des familles de Workers.
  is: [ StandardTraits.StandardOptionalHeader,
  StandardTraits.StandardHeader401, StandardTraits.StandardHeader404,
  StandardTraits.StandardHeader409, StandardTraits.StandardHeader412 ]
  get:
    description: Permet de lister les familles
    body:
      application/json:
        type: object
        example: !include libraries/samples/collectionQuery.sample
    responses:
      200:
        body:
          application/json:
            type: object
            example: !include libraries/samples/familyList.sample
  put:
    description: Permet d'interagir avec les workers de la famille
    body:
      application/json:
        type: object
        example: !include libraries/samples/genericSample.sample
    responses:
      200:
        body:
          application/json:
            type: object
            example: !include libraries/samples/async_status.sample

  /{id_family}:
    displayName: Worker family
    is: [ StandardTraits.StandardOptionalHeader,
    StandardTraits.StandardHeader401, StandardTraits.StandardHeader404,
    StandardTraits.StandardHeader409, StandardTraits.StandardHeader412 ]
    get:
      description: Permet de récupérer le statut de la famille
      responses:
        200:
          body:
            application/json:
              type: object
              example: !include libraries/samples/family.sample
    post:
      description: Permet de créer une famille de Worker
      body:
        application/json:
          type: object
          example: !include libraries/samples/class.sample
      responses:
        201:
          body:
            application/json:
              type: object
              example: !include libraries/samples/processing.sample
    put:
      description: Permet d'interagir avec la famille
      body:
        application/json:
          type: object
          example: !include libraries/samples/genericSample.sample
      responses:
        200:
          body:
            application/json:
              type: object
              example: !include libraries/samples/async_status.sample
    delete:
      description: Efface une famille si vide
      responses:
        200:
          body:
            application/json:
              type: object
              example: !include libraries/samples/async_status.sample
    /workers:
      displayName: Workers
      description: API de gestion des Workers d'une famille.
      is: [ StandardTraits.StandardOptionalHeader,
      StandardTraits.StandardHeader401, StandardTraits.StandardHeader404,
      StandardTraits.StandardHeader409, StandardTraits.StandardHeader412 ]
      get:
        description: Permet de sélectionner un sous-ensemble de Workers.
        body:
          application/json:
            type: object
            example: !include libraries/samples/collectionQuery.sample
        responses:
          200:
            body:
              application/json:
                type: object
                example: !include libraries/samples/workersList.sample
      delete:
        description: Efface un sous-ensemble de Workers. Le Delete de tout ou partie des workers d'une famille entraîne l'appel à "unregister" depuis le moteur vers le(s) worker(s) concerné(s), comme pour l'appel direct à un Worker
        body:
          application/json:
            type: object
            example: !include libraries/samples/collectionQuery.sample
        responses:
          200:
            body:
              application/json:
                type: object
                example: !include libraries/samples/workersList.sample

      /{id_worker}:
        displayName: Worker
        description: API permettant la gestion d'un Worker.
        is: [ StandardTraits.StandardOptionalHeader,
        StandardTraits.StandardHeader401, StandardTraits.StandardHeader404,
        StandardTraits.StandardHeader409, StandardTraits.StandardHeader412 ]
        get:
          description: Accès à un statut d'un Worker.
          responses:
            200:
              body:
                application/json:
                  type: object
                  example: !include libraries/samples/worker.sample
        post:
          description: Ajoute un nouveau Worker (abonnement) dans une famille.
          body:
            application/json:
              type: object
              example: !include libraries/samples/worker.sample
          responses:
            201:
              body:
                application/json:
                  type: object
                  example: !include libraries/samples/processing.sample
        put:
          description: Mise à jour d'un paramètre pour ce Worker
          body:
            application/json:
              type: object
              example: !include libraries/samples/worker.sample
          responses:
            200:
              body:
                application/json:
                  type: object
                  example: !include libraries/samples/async_status.sample
        delete:
          description: Permet le retrait d'un Worker à cete famille (désabonnement).
          responses:
            200:
              body:
                application/json:
                  type: object
                  example: !include libraries/samples/processing.sample

/status:
  get:
  is: [ StandardTraits.Status, StandardTraits.StandardHeader200,
  StandardTraits.StandardHeader401, StandardTraits.StandardHeader404, StandardTraits.StandardHeader503 ]
