Job API v2

From Memsource
Jump to: navigation, search

Create New Job

action: api/v2/job/create
    token                       string
    project                     domain(Project)
    file                        file
    path                        string                   O         // destination directory 
    targetLang                  locale
    due                         datetime                 O
    linguist                    domain(User)             O
    zipCharset                  charset                  O

response: JSON
    {
      "unsupportedFiles": [ "document.pdf" ],
      "jobParts" : [
        {
          "id": 9371,
          "task": "5023cd08e4b015e0656c4a8f",
          "fileName": "document.txt",
          "targetLang": "de"
        },
        {
          "id": 9372,
          "task": "5087ab08eac015e0656c4a00",
          "fileName": "document.doc",
          "targetLang": "de"
        }
      ]
    }

error codes
    JobCreateError

Delete Job

action: api/v2/job/delete
    token                       string
    jobPart                     domain(JobPart)

response: empty

Get Job

action: api/v2/job/get
    token                       string
    jobPart                     domain(JobPart)

response: JSON
    {
      "id": 9372,
      "task": "5087ab08eac015e0656c4a00",
      "status": "NEW",
      "isParentJobSplit": false,
      "assignedTo": {
        "id": 501,
        "userName": "admin",
        "email": "support@memsource.com"
      }
    }

Get Original File

By Job Part

action: api/v2/job/getOriginalFile
    token                       string
    jobPart                     domain(JobPart)

response: binary

response headers
    Content-Disposition         file name
    X-Memsource                 json
        {
          "fileName": "agreement.doc"
        }

By Task

action: api/v2/job/getOriginalFileByTask
    token                       string
    task                        task

response: binary

response headers
    Content-Disposition         file name
    X-Memsource                 json
        {
          "fileName": "agreement.doc"
        }

Get Bilingual File

action: api/v2/job/getBilingualFile
    token                       string
    jobPart                     domain(JobPart)
    format                      enum(BilingualFormat)    O(Mxlf)

response: binary

response headers
    Content-Disposition         file name

Get Preview File

action: api/v2/job/getPreviewFile
    token                       string
    bilingualFile               file
    task                        task

response: binary

response headers
    Content-Disposition         file name
    X-Memsource                 json
        {
          "fileName": "agreement-en-de-C.doc"
        }

Get Completed File

action: api/v2/job/getCompletedFile
    token                       string
    jobPart                     domain(JobPart)

response: binary

Upload Bilingual File

action: api/v2/job/uploadBilingualFile
    token                       string
    bilingualFile               file
    format                      enum(BilingualFormat)    O(Mxlf)
    saveToTransMemory           enum(TransMemSave)       O(Confirmed)
    setCompleted                boolean                  O(false)

response: empty JSON

Convert Bilingual File

action: api/v2/job/convertBilingualFile
    token                       string
    bilingualFile               file
    from                        enum(BilingualFormat)
    to                          enum(BilingualFormat)

response: binary

Machine Translation

action: api/v2/job/machineTranslate
    token                       string
    task                        task
    text                        list(string)

response: JSON
    {
      "translations": [ "Hallo", "Welt" ]
    }

error codes
    MachineTranslateNotSelected

Get Translation Resources

action: api/v2/job/getTranslationResources
    token                       string
    task                        task
    workflowLevel               integer

response: JSON
    {
       "termBases":[
         {
           "id": 286,
           "name": "My TB"
         }
       ],
       "transMemories":[
         {
           "id": 724,
           "name": "My TM"
         }
       ],  
       "targetLang":"de",
       "fileName":"small.properties",
       "machineTranslator":{
         "name":"Google",
         "type":"GoogleTranslate"    // see MachineTranslator enum for all possible values
      }
    }

Set Status

action: api/v2/job/setStatus
    token                       string
    jobPart                     domain(JobPart)
    status                      enum(JobStatus)

response: empty

Get Segments Count (Progress)

action: api/v2/job/getSegmentsCount
    token                       string
    jobPart                     domain(JobPart)

response: JSON
   {
     "counts":{
       "segmentsCount":3,
       "segmentGroupsCount":3,
       "qualityAssurance":{
         "warningsCount":0,
         "segmentsCount":0,
         "ignoredWarningsCount":0
       },
       "translatedSegmentsCount":0
     }
   }