lilt-java

Lilt API binding for java

View the Project on GitHub lilt/lilt-java

DocumentsApi

All URIs are relative to https://api.lilt.com

Method HTTP request Description
downloadDocument GET /v2/documents/files Download a Document
uploadDocument POST /v2/documents/files Upload a File

downloadDocument

byte[] downloadDocument(id, isXliff)

Download a Document

Export a Document that has been translated in the Lilt web application. Any Document can be downloaded in XLIFF 1.2 format, or can be retrieved in its original uploaded format by setting `is_xliff=false`. This endpoint will fail if either (a) export or (b) pre-translation operations are in-progress. The status of those operations can be determined by retrieving the Document resource. Example CURL command: ```bash curl -X GET https://api.lilt.com/v2/documents/files?key=API_KEY&id=274 -o from_lilt.xliff ```

Example

// Import classes:
import com.lilt.client.ApiClient;
import com.lilt.client.ApiException;
import com.lilt.client.Configuration;
import com.lilt.client.auth.*;
import com.lilt.client.models.*;
import com.lilt.client.api.DocumentsApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("https://api.lilt.com");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    // Configure HTTP basic authorization: BasicAuth
    HttpBasicAuth BasicAuth = (HttpBasicAuth) defaultClient.getAuthentication("BasicAuth");
    BasicAuth.setUsername("YOUR USERNAME");
    BasicAuth.setPassword("YOUR PASSWORD");

    DocumentsApi apiInstance = new DocumentsApi(defaultClient);
    Integer id = 56; // Integer | An unique Document identifier.
    Boolean isXliff = true; // Boolean | Download the document in XLIFF 1.2 format.
    try {
      byte[] result = apiInstance.downloadDocument(id, isXliff);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DocumentsApi#downloadDocument");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
id Integer An unique Document identifier.  
isXliff Boolean Download the document in XLIFF 1.2 format. [optional] [default to true]

Return type

byte[]

Authorization

ApiKeyAuth, BasicAuth

HTTP request headers

HTTP response details

| Status code | Description | Response headers | |————-|————-|——————| 200 | A file. | - | 401 | Unauthorized | - | 502 | File in pretranslation. | - | 0 | Unexpected error | - |

uploadDocument

DocumentWithSegments uploadDocument(name, projectId, body, pretranslate, autoAccept, caseSensitive, matchAttribution, configId)

Upload a File

Create a Document from a file in any of the formats documented in our knowledge base. Request parameters should be passed as JSON object with the header field `LILT-API`. File names in the header can only contain US-ASCII characters. File names with characters outside of US-ASCII should be URI encoded or transliterated to US-ASCII strings. Example CURL command: ```bash curl -X POST https://api.lilt.com/v2/documents/files?key=API_KEY \ –header \"LILT-API: {\\"name\\": \\"introduction.xliff\\",\\"pretranslate\\": \\"tm+mt\\",\\"project_id\\": 9}\" \ –header \"Content-Type: application/octet-stream\" \ –data-binary @Introduction.xliff ```

Example

// Import classes:
import com.lilt.client.ApiClient;
import com.lilt.client.ApiException;
import com.lilt.client.Configuration;
import com.lilt.client.auth.*;
import com.lilt.client.models.*;
import com.lilt.client.api.DocumentsApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("https://api.lilt.com");
    
    // Configure API key authorization: ApiKeyAuth
    ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    ApiKeyAuth.setApiKey("YOUR API KEY");
    // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
    //ApiKeyAuth.setApiKeyPrefix("Token");

    // Configure HTTP basic authorization: BasicAuth
    HttpBasicAuth BasicAuth = (HttpBasicAuth) defaultClient.getAuthentication("BasicAuth");
    BasicAuth.setUsername("YOUR USERNAME");
    BasicAuth.setPassword("YOUR PASSWORD");

    DocumentsApi apiInstance = new DocumentsApi(defaultClient);
    String name = "name_example"; // String | A file name.
    Integer projectId = 56; // Integer | A unique Project identifier.
    File body = new File("/path/to/file"); // File | The file contents to be uploaded. The entire POST body will be treated as the file. 
    String pretranslate = "pretranslate_example"; // String | An optional parameter indicating if and how the document will be pretranslated upon being uploaded. The accepted values are `TM`, or `TM+MT` 
    Boolean autoAccept = true; // Boolean | An optional parameter to auto-accept segments with 100% translation memory matches when the `pretranslate` option is also set, or to auto-accept any target data that is present when the uploaded file is XLIFF. If omitted it will default to your organization settings for `Accept and lock exact matches`, if set to `false`, no segments will be auto-accepted. 
    Boolean caseSensitive = true; // Boolean | An optional parameter to use case sensitive translation memory matching when the `pretranslate` option is also enabled. Matches must have identical character-by-character case to qualify as matches. Default value matches your organization settings for `Use case sensitive translation memory matching` setting 
    Boolean matchAttribution = true; // Boolean | An optional parameter to attribute translation authorship of exact matches to the author of the file when the `pretranslate` option is also enabled. Default value matches your organization settings for `Translation authorship` setting 
    Integer configId = 56; // Integer | An optional pararameter to specify an import configuration to be applied when extracting translatable content from this file. 
    try {
      DocumentWithSegments result = apiInstance.uploadDocument(name, projectId, body, pretranslate, autoAccept, caseSensitive, matchAttribution, configId);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling DocumentsApi#uploadDocument");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
name String A file name.  
projectId Integer A unique Project identifier.  
body File The file contents to be uploaded. The entire POST body will be treated as the file.  
pretranslate String An optional parameter indicating if and how the document will be pretranslated upon being uploaded. The accepted values are `TM`, or `TM+MT` [optional]
autoAccept Boolean An optional parameter to auto-accept segments with 100% translation memory matches when the `pretranslate` option is also set, or to auto-accept any target data that is present when the uploaded file is XLIFF. If omitted it will default to your organization settings for `Accept and lock exact matches`, if set to `false`, no segments will be auto-accepted. [optional]
caseSensitive Boolean An optional parameter to use case sensitive translation memory matching when the `pretranslate` option is also enabled. Matches must have identical character-by-character case to qualify as matches. Default value matches your organization settings for `Use case sensitive translation memory matching` setting [optional]
matchAttribution Boolean An optional parameter to attribute translation authorship of exact matches to the author of the file when the `pretranslate` option is also enabled. Default value matches your organization settings for `Translation authorship` setting [optional]
configId Integer An optional pararameter to specify an import configuration to be applied when extracting translatable content from this file. [optional]

Return type

DocumentWithSegments

Authorization

ApiKeyAuth, BasicAuth

HTTP request headers

HTTP response details

| Status code | Description | Response headers | |————-|————-|——————| 200 | A Document object. | - | 401 | Unauthorized | - | 0 | Unexpected error | - |