Difference between revisions of "Command Center API Reference"

From Lingoport Wiki
Jump to: navigation, search
Line 23: Line 23:
 
</pre>
 
</pre>
   
  +
= API to retrieve Data =
= List Command Center projects =
 
  +
== List Command Center projects ==
   
 
The <code>listprojects</code> returns a list of projects associated with the username/token passed in the call. That list may hence not be exhaustive of all the projects on-boarded with Command Center.
 
The <code>listprojects</code> returns a list of projects associated with the username/token passed in the call. That list may hence not be exhaustive of all the projects on-boarded with Command Center.
   
== The Call ==
+
=== The Call ===
   
 
curl "COMMAND_CENTER_URL/api/listprojects" -d '{"username":"API_USER","token":"API_TOKEN"}' --header "Content-Type: application/json"
 
curl "COMMAND_CENTER_URL/api/listprojects" -d '{"username":"API_USER","token":"API_TOKEN"}' --header "Content-Type: application/json"
Line 43: Line 44:
 
}
 
}
   
== The Result ==
+
=== The Result ===
   
 
The result would look like:
 
The result would look like:
Line 58: Line 59:
 
</pre>
 
</pre>
   
= Command Center Project Status =
+
== Command Center Project Status ==
 
The <code>getStatus</code> command provides a high level status on the Globalyzer and the Localyzer side of a given project.
 
The <code>getStatus</code> command provides a high level status on the Globalyzer and the Localyzer side of a given project.
   
== The Call ==
+
=== The Call ===
 
curl "COMMAND_CENTER_URL/api/getStatus" -d '{"username":"API_USER","token":"API_TOKEN", "source":{"group_name": "GROUP","project_name": "PROJECT","module_name": "MODULE"}}' --header "Content-Type: application/json"
 
curl "COMMAND_CENTER_URL/api/getStatus" -d '{"username":"API_USER","token":"API_TOKEN", "source":{"group_name": "GROUP","project_name": "PROJECT","module_name": "MODULE"}}' --header "Content-Type: application/json"
   
Line 82: Line 83:
 
}
 
}
   
== The Result ==
+
=== The Result ===
   
 
The result would look like:
 
The result would look like:
Line 118: Line 119:
 
</pre>
 
</pre>
   
= Command Center Project Get Locales=
+
== Command Center Project Get Locales==
 
The <code>getLocales</code> command provides a JSON output of the source and target locales of a Command Center project.
 
The <code>getLocales</code> command provides a JSON output of the source and target locales of a Command Center project.
   
== The Call ==
+
=== The Call == =
   
 
curl "COMMAND_CENTER_URL/api/getLocales" -d '{"username":"API_USER","token":"API_TOKEN", "source":{"group_name": "GROUP","project_name": "PROJECT","module_name": "MODULE"}}' --header "Content-Type: application/json"
 
curl "COMMAND_CENTER_URL/api/getLocales" -d '{"username":"API_USER","token":"API_TOKEN", "source":{"group_name": "GROUP","project_name": "PROJECT","module_name": "MODULE"}}' --header "Content-Type: application/json"
Line 143: Line 144:
 
}
 
}
   
== The Result ==
+
=== The Result ===
 
The results would look like:
 
The results would look like:
 
<pre>
 
<pre>
Line 199: Line 200:
 
</pre>
 
</pre>
   
= Command Center Translate =
+
== List Command Center users ==
  +
  +
The command below lists users by role. Roles are:
  +
* administrator
  +
* manager
  +
* developer
  +
* translator
  +
* api
  +
  +
===The Call===
  +
curl "COMMAND_CENTER_URL/api/listUsers" -d '{"role": "ROLE","username":"API_USER","token":"API_TOKEN"}' --header "Content-Type: application/json" -o users.json
  +
  +
Example:
  +
curl "http://localhost:8080/command-center/api/listUsers" -d '{"role": "developer","username":"APIuser","token":"CTMNzj**********CP"}' --header "Content-Type: application/json"
  +
  +
or
  +
curl "https://dockertest2.lingoport.io/command-center/api/listUsers" -d @'''listusers.json''' --header "Content-Type: application/json"
  +
  +
'''listusers.json''':
  +
{
  +
"role": "developer",
  +
"username":"APIuser",
  +
"token":"CTMNzj**********CP"
  +
}
  +
  +
=== The Result ===
  +
The result would look like:
  +
<pre>
  +
{
  +
"users": [
  +
{
  +
"id": "4",
  +
"full_name": "Guest",
  +
"login_name": "guest",
  +
"email": "guest@lingoport.com"
  +
},
  +
{
  +
"id": "16",
  +
"full_name": "Mary Dev",
  +
"login_name": "maryDev",
  +
"email": "marydev@lingoport.com"
  +
}
  +
]
  +
}
  +
</pre>
  +
  +
= Calls to Take Action =
  +
== Command Center Translate ==
 
The <code>translate</code> command triggers sending a new prep kit to translation if some strings need to be sent. Some projects may be 100% translated for instance, in which case nothing will be sent to translation.
 
The <code>translate</code> command triggers sending a new prep kit to translation if some strings need to be sent. Some projects may be 100% translated for instance, in which case nothing will be sent to translation.
   
Line 222: Line 270:
 
}
 
}
   
= Pseudo-localize a Command Center Project =
+
== Pseudo-localize a Command Center Project ==
 
For Localyzer project with a pseudo-locale configure, the <code>pseudoloc</code> command will create or update the pseudo-localized files from the source locale files and will update the repository with the latest.
 
For Localyzer project with a pseudo-locale configure, the <code>pseudoloc</code> command will create or update the pseudo-localized files from the source locale files and will update the repository with the latest.
   
Line 246: Line 294:
 
}
 
}
   
= Duplicate Command Center project =
+
== Duplicate Command Center project ==
 
The <code>createFromTemplateProject</code> command duplicates an existing project with the same configuration as the source project, on a different repository or branch of a repository. The API user will also be set on that target project as it is part of the source project.
 
The <code>createFromTemplateProject</code> command duplicates an existing project with the same configuration as the source project, on a different repository or branch of a repository. The API user will also be set on that target project as it is part of the source project.
   
Line 285: Line 333:
 
The <code>dupProject.json</code> file can be used for all the commands. Only the required values will be used.
 
The <code>dupProject.json</code> file can be used for all the commands. Only the required values will be used.
   
= List Command Center users =
 
   
The command below lists users by role. Roles are:
 
* administrator
 
* manager
 
* developer
 
* translator
 
* api
 
 
==The Call==
 
curl "COMMAND_CENTER_URL/api/listUsers" -d '{"role": "ROLE","username":"API_USER","token":"API_TOKEN"}' --header "Content-Type: application/json" -o users.json
 
 
Example:
 
curl "http://localhost:8080/command-center/api/listUsers" -d '{"role": "developer","username":"APIuser","token":"CTMNzj**********CP"}' --header "Content-Type: application/json"
 
 
or
 
curl "https://dockertest2.lingoport.io/command-center/api/listUsers" -d @'''listusers.json''' --header "Content-Type: application/json"
 
 
'''listusers.json''':
 
{
 
"role": "developer",
 
"username":"APIuser",
 
"token":"CTMNzj**********CP"
 
}
 
 
== The Result ==
 
The result would look like:
 
<pre>
 
{
 
"users": [
 
{
 
"id": "4",
 
"full_name": "Guest",
 
"login_name": "guest",
 
"email": "guest@lingoport.com"
 
},
 
{
 
"id": "16",
 
"full_name": "Mary Dev",
 
"login_name": "maryDev",
 
"email": "marydev@lingoport.com"
 
}
 
]
 
}
 
</pre>
 
   
= Add Users to a Team =
+
== Add Users to a Team ==
   
 
The command below add users to a team, via their IDs.
 
The command below add users to a team, via their IDs.

Revision as of 21:49, 26 December 2024

Introduction

The API commands provide some high level information or actions for individual projects in Command Center. The usage scenario is to get basic information on a project, for instance from a CI/CD system, or to trigger some overall action at the project level or on users.

All API commands require a username and token to authenticate and authorize those calls. API Users are set in the Command Center User Settings panel, and can be added to the Access set of users for a project.

Calls and Returns

Some API calls are to retrieve data, in which case the sections below will show an example of the returned data, otherwise, only the call is described.

Errors

API calls may also return errors. For instance, the project below is not associated with an API user, so calls that necessitate a project as input to the different calls may return this error.

Project not found. Make sure the API user is set and the project name is spelled correctly.

 For the following project
 -------------------------
{
  "group_name": "expressLingoport",
  "project_name": "simpleJson",
  "module_name": "main"
}

API to retrieve Data

List Command Center projects

The listprojects returns a list of projects associated with the username/token passed in the call. That list may hence not be exhaustive of all the projects on-boarded with Command Center.

The Call

 curl "COMMAND_CENTER_URL/api/listprojects" -d '{"username":"API_USER","token":"API_TOKEN"}'  --header "Content-Type: application/json"

Example:

 curl "http://localhost:8080/command-center/api/listprojects" -d '{"username":"APIuser","token":"CTMNzj**********CP"}'  --header "Content-Type: application/json"

or

 curl "https://dockertest2.lingoport.io/command-center/api/listprojects" -d @listprojects.json --header "Content-Type: application/json"
 listprojects.json:
 {
  "username":"APIuser",
  "token":"CTMNzj**********CP"
 }

The Result

The result would look like:

{
  "projects": [
    "olivierLingoport--simpleProperties--F8829",
    "Lingoport--Figma--B8024",
    "Lingoport--Command-CenterDebug--main",
    "lingoport-public--Rebel-Outfitters--tim"
  ]
}

Command Center Project Status

The getStatus command provides a high level status on the Globalyzer and the Localyzer side of a given project.

The Call

 curl "COMMAND_CENTER_URL/api/getStatus" -d '{"username":"API_USER","token":"API_TOKEN", "source":{"group_name": "GROUP","project_name": "PROJECT","module_name": "MODULE"}}'  --header "Content-Type: application/json"


Example:

 curl "http://localhost:8080/command-center/api/getStatus" -d '{"username":"APIuser","token":"CTMNzj**********CP", "source":{"group_name": "Lingoport","project_name": "CET-WorldWindExplorer","module_name": "lili"}}'  --header "Content-Type: application/json"

or

 curl "http://localhost:8080/command-center/api/getStatus" -d @getStatus.json  --header "Content-Type: application/json"
 getStatus.json: 
 {
    "username":"APIuser",
    "token":"CTMNzj**********CP",
    "source":{
        "group_name": "Lingoport",
        "project_name": "CET-WorldWindExplorer",
        "module_name": ""
     }
 }

The Result

The result would look like:

{
  "group_name": "Lingoport",
  "project_name": "CET-WorldWindExplorer",
  "module_name": ""
}

 The status:
 -------------------------
{
  "Localyzer": {
    "Kits out for translation": "1 ",
    "Developer Error Number": 0,
    "keys": 1625,
    "words": 5682,
    "words-sent": 113640,
    "words-translated": 113440,
    "words-outstanding": 200
  },
  "Globalyzer": {
    "Embedded Strings": 2,
    "Embedded Strings Density": "0.02%",
    "Locale-Sensitive Methods": 40,
    "Locale-Sensitive Methods Density": "0.46%",
    "Static File References": 3,
    "Static File References Density": "0.03%",
    "General Patterns": 21,
    "General Patterns Density": "0.24%"
  }
}

Command Center Project Get Locales

The getLocales command provides a JSON output of the source and target locales of a Command Center project.

== The Call ==

 curl "COMMAND_CENTER_URL/api/getLocales" -d '{"username":"API_USER","token":"API_TOKEN", "source":{"group_name": "GROUP","project_name": "PROJECT","module_name": "MODULE"}}'  --header "Content-Type: application/json"


Example:

 curl "http://localhost:8080/command-center/api/getLocales" -d '{"username":"APIuser","token":"CTMNzj**********CP", "source":{"group_name": "Lingoport","project_name": "CET-WorldWindExplorer","module_name": "lili"}}'  --header "Content-Type: application/json"

or

 curl "http://localhost:8080/command-center/api/getLocales" -d @getLocales.json  --header "Content-Type: application/json"
 getStatus.json: 
 {
    "username":"APIuser",
    "token":"CTMNzj**********CP",
    "source":{
        "group_name": "Lingport",
        "project_name": "CET-WorldWindExplorer",
        "module_name": "lili"
     }
 }

The Result

The results would look like:


{
  "projectName": "Lingoport--CET-WorldWindExplorer--lili",
  "sourceLocale": {
    "repositoryLocaleCode": "en-US",
    "localeName": "English (United States)",
    "tmsLocaleCode": "en-US"
  },
  "targetLocales": [
    {
      "repositoryLocaleCode": "sv",
      "localeName": "Swedish (Sweden)",
      "tmsLocaleCode": "sv-SE"
    },
    {
      "repositoryLocaleCode": "tr",
      "localeName": "Turkish (Turkey)",
      "tmsLocaleCode": "tr-TR"
    },
    {
      "repositoryLocaleCode": "no",
      "localeName": "Norwegian Nynorsk (Norway)",
      "tmsLocaleCode": "nn-NO"
    },
    {
      "repositoryLocaleCode": "pl",
      "localeName": "Polish (Poland)",
      "tmsLocaleCode": "pl-PL"
    },
    {
      "repositoryLocaleCode": "fr",
      "localeName": "French (France)",
      "tmsLocaleCode": "fr-FR"
    },
    {
      "repositoryLocaleCode": "cs",
      "localeName": "Czech (Czechia)",
      "tmsLocaleCode": "cs-CZ"
    },
    {
      "repositoryLocaleCode": "ru",
      "localeName": "Russian (Russia)",
      "tmsLocaleCode": "ru-RU"
    },
    {
      "repositoryLocaleCode": "pt-PT",
      "localeName": "Portuguese (Portugal)",
      "tmsLocaleCode": "pt-PT"
    }
  ]
}

List Command Center users

The command below lists users by role. Roles are:

  • administrator
  • manager
  • developer
  • translator
  • api

The Call

 curl "COMMAND_CENTER_URL/api/listUsers" -d '{"role": "ROLE","username":"API_USER","token":"API_TOKEN"}'  --header "Content-Type: application/json" -o users.json

Example:

 curl "http://localhost:8080/command-center/api/listUsers" -d '{"role": "developer","username":"APIuser","token":"CTMNzj**********CP"}'  --header "Content-Type: application/json"

or

 curl "https://dockertest2.lingoport.io/command-center/api/listUsers" -d @listusers.json --header "Content-Type: application/json"
 listusers.json:
 {
  "role": "developer",
  "username":"APIuser",
  "token":"CTMNzj**********CP"
 }

The Result

The result would look like:

{
  "users": [
    {
      "id": "4",
      "full_name": "Guest",
      "login_name": "guest",
      "email": "guest@lingoport.com"
    },
    {
      "id": "16",
      "full_name": "Mary Dev",
      "login_name": "maryDev",
      "email": "marydev@lingoport.com"
    }
  ]
}

Calls to Take Action

Command Center Translate

The translate command triggers sending a new prep kit to translation if some strings need to be sent. Some projects may be 100% translated for instance, in which case nothing will be sent to translation.

 curl "COMMAND_CENTER_URL/api/translate" -d '{"username":"API_USER","token":"API_TOKEN", "source":{"group_name": "GROUP","project_name": "PROJECT","module_name": "MODULE"}}'  --header "Content-Type: application/json"


Example:

 curl "http://localhost:8080/command-center/api/translate" -d '{"username":"APIuser","token":"CTMNzj**********CP", "source":{"group_name": "Lingoport","project_name": "CET-WorldWindExplorer","module_name": "lili"}}'  --header "Content-Type: application/json"

or

 curl "http://localhost:8080/command-center/api/translate" -d @translate.json  --header "Content-Type: application/json"
 translate.json: 
 {
    "username":"APIuser",
    "token":"CTMNzj**********CP",
    "source":{
        "group_name": "Lingport",
        "project_name": "CET-WorldWindExplorer",
        "module_name": "lili"
     }
 }

Pseudo-localize a Command Center Project

For Localyzer project with a pseudo-locale configure, the pseudoloc command will create or update the pseudo-localized files from the source locale files and will update the repository with the latest.


 curl "COMMAND_CENTER_URL/api/pseudoloc" -d '{"username":"API_USER","token":"API_TOKEN", "source":{"group_name": "GROUP","project_name": "PROJECT","module_name": "MODULE"}}'  --header "Content-Type: application/json"


Example:

 curl "http://localhost:8080/command-center/api/pseudoloc" -d '{"username":"APIuser","token":"CTMNzj**********CP", "source":{"group_name": "Lingoport","project_name": "CET-WorldWindExplorer","module_name": "lili"}}'  --header "Content-Type: application/json"

or

 curl "http://localhost:8080/command-center/api/pseudoloc" -d @project.json  --header "Content-Type: application/json"
 project.json: 
 {
    "username":"APIuser",
    "token":"CTMNzj**********CP",
    "source":{
        "group_name": "Lingport",
        "project_name": "CET-WorldWindExplorer",
        "module_name": "lili"
     }
 }

Duplicate Command Center project

The createFromTemplateProject command duplicates an existing project with the same configuration as the source project, on a different repository or branch of a repository. The API user will also be set on that target project as it is part of the source project.

 curl "COMMAND_CENTER_URLapi/createFromTemplateProject" -d '{"username":"API_USER","token":"API_TOKEN","source": {"group_name": "source_group","project_name": "source_project","module_name": "source_module"},"target": {"group_name":"target_group","project_name": "target_project","module_name": "target_module"}}'  --header "Content-Type: application/json"


  • For Git projects:
    • The target group name is the name of the Git organization
    • The target project name is the name of the Git project in that organization
    • The target module name is the branch of the Git Project in the organization


Example: For a target repository name https://github.com/Lingoport/Command-Center, branch 'liliDev', with a template called Lingoport Command-Center dev in Command Center using https://github.com, the following call would be make:

 curl "http://localhost:8080/command-center/api/createFromTemplateProject" -d '{"username":"APIuser","token":"CTMNzj**********CP","source": {"group_name": "Lingoport","project_name": "Command-Center","module_name": "dev"},"target": {"group_name":"Lingoport","project_name": "Command-Center","module_name": "liliDev"}}'  --header "Content-Type: application/json"

or

 curl "COMMAND_CENTER_URLapi/createFromTemplateProject" -d @dupProject.json  --header "Content-Type: application/json"
 dupProject.json:
  {
    "username":"APIuser",
    "token":"CTMNzj**********CP",
    "source":{
        "group_name": "Lingport",
        "project_name": "Command-Center",
        "module_name": "dev"
     },
     "target": {
         "group_name":"Lingoport",
         "project_name": "Command-Center",
         "module_name": "liliDev"
      }
  }

The dupProject.json file can be used for all the commands. Only the required values will be used.


Add Users to a Team

The command below add users to a team, via their IDs.

 curl "COMMAND_CENTER_URL/api/addUsersToTeam" -d '{"team": "TEAM","username":"API_USER","token":"API_TOKEN","userList":"COMMA SEPARATED LIST OF IDs"}'  --header "Content-Type: application/json" -o users.json

Example:

 curl "http://localhost:8080/command-center/api/addUsersToTeam" -d '{"team": "Dev","username":"APIuser","token":"CTMNzj**********CP", "userList":"4,5,7,19"}'  --header "Content-Type: application/json"

or

 curl "https://dockertest2.lingoport.io/command-center/api/addUsersToTeam" -d @userAssignment.json --header "Content-Type: application/json"
 userAssignment.json:
 {
   "team":"Dev",
   "username":"APIuser",
   "token":"9VwxxxxxxxxP14",
   "userList": "4,16"
 }

Note: Removing users from a team or managing users at large is better done via the Command Center user interface, not via an API call.