Talend CommandLine – Partie 2

Après la documentation de Talend CommandLine et la fonction PowerShell Get-Telnet,

nous voila prêt à agir!

La solution est en 2 parties :

  • le script PowerShell : maCmdLine.ps1 
  • le script des instructions Talend CommandLine : livraison.txt

l’appel au Get-Telnet et tous les paramètres :

Get-Telnet -Commands (Get-Content "c:\scripts\livraison.txt") -RemoteHost "192.168.10.1" -OutputPath "\\server\bbb\Command.log" -WaitTime 1500

Voici un exemple d’un script Talend CommandLine pour exporter depuis la TAC de Recette (REC) et importer sur la TAC de Production (PRD)

initRemote "MonUrlDeConnexionRecette" -ul talend@talend.fr -up MotDePasse
logonProject -pn MonProjet
exportItems /Path/NomDeMonExport.zip -if '(type=process)and(label=NomDeMonJob)' -d
logoffProject
initRemote "MonUrlDeConnexionProduction" -ul talend@talend.fr -up MotDePasse
logonProject -pn MonProjet
importItems /Path/NomDeMonExport.zip
logoffProject

Talend CommandLine – Partie 1

Talend CommandLine est un ensemble de commandes qui permettent de piloter l’environnement Talend sans passer par la TAC.

 
Il est possible de commander la TAC sans passer par l’interface graphique, ni par le Webservice REST : pour cela, il y a le talend CommandLine.

Le talend CommandLine est utilisable via un commandeline.bat qui permet de lancer l’application studio sans interface graphique.

3 options possibles :

  • shell : ouverture d’un shell pour exécution manuel
  • ScriptFile : exécution d’un script
  • en mode server : lancement d’un service accessible via telnet

Mais ce que Talend ne dit pas trop fort, c’est que le CommandLine du serveur de production (ou recette) est lui aussi accessible par telnet.

Il devient donc facile d’imaginer des scripts pour automatiser la communication avec la TAC : envoi de l’env de recette vers la prod, création des instances en masse, modification des instances en masse, gestions des users, gestions des projets, …
 

Communiquer avec telnet dans un script PowerShell et envoyer les commandes.

 
Pour communiquer avec le serveur hébergent un commandLine
Merci à Martin9700
sources : Using Powershell as a Telnet Client ; Get-Telnet – Telnet to a device and issue commands
[su_accordion]
[su_spoiler title= »Get-Telnet » style= »fancy »]

Function Get-Telnet
{   Param (
        [Parameter(ValueFromPipeline=$true)]
        [String[]]$Commands = @("username","password","disable clipaging","sh config"),
        [string]$RemoteHost = "HostnameOrIPAddress",
        [string]$Port = "23",
        [int]$WaitTime = 1000,
        [string]$OutputPath = "\\server\share\switchbackup.txt"
    )
    #Attach to the remote device, setup streaming requirements
    $Socket = New-Object System.Net.Sockets.TcpClient($RemoteHost, $Port)
    If ($Socket)
    {   $Stream = $Socket.GetStream()
        $Writer = New-Object System.IO.StreamWriter($Stream)
        $Buffer = New-Object System.Byte[] 1024 
        $Encoding = New-Object System.Text.AsciiEncoding

        #Now start issuing the commands
        ForEach ($Command in $Commands)
        {   $Writer.WriteLine($Command) 
            $Writer.Flush()
            Start-Sleep -Milliseconds $WaitTime
        }
        #All commands issued, but since the last command is usually going to be
        #the longest let's wait a little longer for it to finish
        Start-Sleep -Milliseconds ($WaitTime * 4)
        $Result = ""
        #Save all the results
        While($Stream.DataAvailable) 
        {   $Read = $Stream.Read($Buffer, 0, 1024) 
            $Result += ($Encoding.GetString($Buffer, 0, $Read))
        }
    }
    Else     
    {   $Result = "Unable to connect to host: $($RemoteHost):$Port"
    }
    #Done, now save the results to a file
    $Result | Out-File $OutputPath
}

[/su_spoiler]
[/su_accordion]
Voici l’aide du commandeline pour la version 5.4.2

Talend Commandline Plugin :

  • arguments can be surrounded by " or ' characters
  • the semi-colon ; character can be used to separate commands from each other
  • special characters space \ " ' ; can be escaped using the character \

[table id=1 /]
Copyright (C) 2006-2013 Talend – www.talend.com

 

Voici un précision pour les filtres -if :

Filters are only applied on the last version of each item :
[table id=2 column_widths= »250px » /]

Talend MetaServlet

Talend metaservlet est un webservice REST qui permet de communiquer avec la TAC et effectuer des actions sur celle-ci.

 

communication REST

communication REST

 

Talend nous propose un outil complémentaire de l’interface web habituelle.

Talend metaservlet peut être utilisé avec le MetaServletCaller.bat (pour windows) ou MetaServletCaller.sh (pour linux) qui se trouve dans ./org.talend.administrator/WEB-INF/classes.

 

 

[su_quote cite= »gerald » url= »http://www.croes.org/gerald/blog/qu-est-ce-que-rest/447/ »]REST (Representational State Transfer) est l’un de ces acronymes qui représente une non technologie comme peuvent l’être Ajax, DHTML, Web 2.0 et autres.

REST est un style d’architecture qui repose sur le protocole HTTP : On accède à une ressource (par son URI unique) pour procéder à diverses opérations (GET lecture / POST écriture / PUT modification / DELETE suppression), opérations supportées nativement par HTTP.[/su_quote]

Logo RESTful

Logo RESTful

 

Quelles sont les possibilités de WS? Voilà l’aide pour la version 5.4.2

 

[su_accordion]
[su_spoiler title= »MetaservletCaller.bat --tac-url=http://MonServeur:8080/org.talend.administrator/ --help all » style= »fancy »]

Generic return codes    :
       0: Success
       1: Unknown error
       2: Invalid request
       3: Authentication error
       4: License problem
       5: Invalid parameter
       6: Error formatting response

----------------------------------------------------------
  Command: addLocks
----------------------------------------------------------
Description             : Allow to lock a repository item. Mainly used by the Studio.
Requires authentication : false
Since                   : 4.2
Sample                  :
{
  "actionName": "addLocks",
  "applicationName": "Studio",
  "authUser": "john.smith@company.com",
  "branch": "trunk",
  "locks": [{
    "itemId": "id1",
    "itemLabel": "label1",
    "itemType": "repository.process"
  }],
  "projectName": "P1"
}

----------------------------------------------------------
  Command: addServer
----------------------------------------------------------
Description             : Create a new execution server, parameter username/password (optional) are used for user authentication to access the JobServer.
Requires authentication : true
Since                   : 4.2
Sample                  :
{
  "actionName": "addServer",
  "adminConsolePort": 8040,
  "authPass": "admin",
  "authUser": "admin@company.com",
  "commandPort": 8000,
  "description": "Talend runtime server in production",
  "filePort": 8001,
  "host": "localhost",
  "instance": "trun",
  "label": "serverName1",
  "mgmtRegPort": 1099,
  "mgmtServerPort": 44444,
  "monitoringPort": 8888,
  "password": 111111,
  "useSSL": true,
  "username": "test@company.com"
}

----------------------------------------------------------
  Command: associatePreGeneratedJob
----------------------------------------------------------
Description             : Create a new execution task with a pre-generated zip file
Requires authentication : true
Since                   : 5.2
Sample                  :
{
  "actionName": "associatePreGeneratedJob",
  "active": true,
  "authPass": "admin",
  "authUser": "admin@company.com",
  "description": "task1's description",
  "executionServerName": "serv1",
  "filePath": "'/home/talend/generatedJob.zip'",
  "onUnknownStateJob": "WAIT",
  "taskName": "task1"
}
Specific error codes    :
       180: file is not a valid file or not exist

----------------------------------------------------------
  Command: createAuthorization
----------------------------------------------------------
Description             : Add user authorization to a project.
- authorizationType can be [ReadWrite, ReadOnly]
Requires authentication : true
Since                   : 3.2
Sample                  :
{
  "actionName": "createAuthorization",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "authorizationType": "ReadWrite",
  "projectName": "project",
  "userLogin": "user@company.com"
}
Specific error codes    :
       161: The authorizationType specified does not exist.

----------------------------------------------------------
  Command: createBranch
----------------------------------------------------------
Description             : Create a branch into a project
Requires authentication : true
Since                   : 4.2
Sample                  :
{
  "actionName": "createBranch",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "projectName": "project1",
  "source": "trunk",
  "target": "branches/branch1"
}
Specific error codes    :
       150: Database error while creating branch.

----------------------------------------------------------
  Command: createProject
----------------------------------------------------------
Description             : Create a new SVN project and return the project ID. 'trunk', 'branches' & 'tags' folders will also be created.
- TAC will get SVN url from configuration when 'projectSvnLocation' is not provided;
Requires authentication : true
Since                   : 3.2
Sample                  :
{
  "actionName": "createProject",
  "addTechNameAtURL": true,
  "authPass": "admin",
  "authUser": "admin@company.com",
  "projectName": "project1",
  "projectType": "[DI|DQ|MDM] (optional)",
  "storage": "[svn|none] (default is 'svn')"
}
Specific error codes    :
       10: Svn url not set in configuration

----------------------------------------------------------
  Command: createProjectReference
----------------------------------------------------------
Description             : Create project references for the specified project and branch(referenceProjects should use technical label)
Requires authentication : true
Since                   : 5.3
Sample                  :
{
  "actionName": "createProjectReference",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "branch": "trunk",
  "projectName": "project1",
  "referenceProjects": "Q1/trunk,Q2/branches/branch1,Q3/tags/tag1"
}

----------------------------------------------------------
  Command: createSandboxProject
----------------------------------------------------------
Description             : Allows to create a Sandbox project (internal use)
Requires authentication : false
Since                   : 4.2
Sample                  :
{
  "actionName": "createSandboxProject",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "projectName": "MetaProject2",
  "userFirstName": "David",
  "userLastName": "Bowie",
  "userLogin": "userSandbox4@talend.com",
  "userPassword": "admin"
}

----------------------------------------------------------
  Command: createTag
----------------------------------------------------------
Description             : Create a tag into a project
Requires authentication : true
Since                   : 5.3
Sample                  :
{
  "actionName": "createTag",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "projectName": "project1",
  "source": "trunk",
  "target": "tags/tag-1_0"
}
Specific error codes    :
       151: Database error while creating tag.

----------------------------------------------------------
  Command: createTask
----------------------------------------------------------
Description             : Add a new execution task in TAC and return the task ID.
- projectName and jobName: the project and job must exist.
- onUnknownStateJob: could be [WAIT, KILL_TASK, RESTART_TASK, RECOVER_TASK]
- contextName: "Default" is the default value.
Requires authentication : true
Since                   : 5.0
Sample                  :
{
  "actionName": "createTask",
  "active": true,
  "addStatisticsCodeEnabled": false,
  "applyContextToChildren": false,
  "authPass": "admin",
  "authUser": "admin@company.com",
  "branch": "trunk",
  "contextName": "Default",
  "description": "task1 for extracting data from DB1",
  "execStatisticsEnabled": false,
  "executionServerName": "serv1",
  "jobName": "job1",
  "jobVersion": "1.0",
  "onUnknownStateJob": "WAIT",
  "projectName": "tproject1",
  "regenerateJobOnChange": false,
  "taskName": "task1"
}

----------------------------------------------------------
  Command: createUser
----------------------------------------------------------
Description             : create a new user.
Requires authentication : true
Since                   : 3.2
Sample                  :
{
  "actionName": "createUser",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "userFirstName": "john",
  "userLastName": "smith",
  "userLogin": "john.smith@company.com",
  "userPassword": "kkE432",
  "userRole": [
    "Administrator",
    "Designer"
  ],
  "userSvnLogin": "jsmith",
  "userSvnPassword": "gvZ543uc",
  "userType": "DI"
}
Specific error codes    :
       100: Database error while creating a new User.
       101: Not enough allowed users available against license.

----------------------------------------------------------
  Command: deleteProject
----------------------------------------------------------
Description             : Delete a project.
Requires authentication : true
Since                   : 3.2
Sample                  :
{
  "actionName": "deleteProject",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "projectName": "project1"
}

----------------------------------------------------------
  Command: deleteUser
----------------------------------------------------------
Description             : Delete one user
Requires authentication : true
Since                   : 3.2
Sample                  :
{
  "actionName": "deleteUser",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "userLogin": "john.smith@company.com"
}
Specific error codes    :
       92: Database error while deleting User.
       93: The user is the last administrator, he can't be removed.

----------------------------------------------------------
  Command: enableSandboxProject
----------------------------------------------------------
Description             : Tells if Sandbox project feature is enabled in configuration.
Requires authentication : false
Since                   : 4.2
Sample                  :
{"actionName": "enableSandboxProject"}

----------------------------------------------------------
  Command: getArchivaUrl
----------------------------------------------------------
Description             : Returns Artifact repository connection information
Requires authentication : false
Since                   : 5.0
Sample                  :
{"actionName": "getArchivaUrl"}
Specific error codes    :
       40: Artifact repository cannot be reached
       41: TAC is not up to date
       42: Artifact repository url is not setup

----------------------------------------------------------
  Command: getCmdLineInfo
----------------------------------------------------------
Description             : Displays the host/port of the active command line. At least primary or secondary command line must be running.
Requires authentication : true
Since                   : 3.2
Sample                  :
{
  "actionName": "getCmdLineInfo",
  "authPass": "admin",
  "authUser": "admin@company.com"
}
Specific error codes    :
       20: Both command line are down

----------------------------------------------------------
  Command: getDroolsKey
----------------------------------------------------------
Description             : Return a key to be used for Drools
Requires authentication : true
Since                   : 5.2
Sample                  :
{
  "actionName": "getDroolsKey",
  "authPass": "admin",
  "authUser": "admin@company.com"
}

----------------------------------------------------------
  Command: getLibLocation
----------------------------------------------------------
Description             : Get the SVN lib location infomations
Requires authentication : true
Since                   : 5.4
Sample                  :
{
  "actionName": "getLibLocation",
  "authPass": "admin",
  "authUser": "admin@company.com"
}

----------------------------------------------------------
  Command: getLicenseKey
----------------------------------------------------------
Description             : Get license key and customer name
Requires authentication : true
Since                   : 5.2
Sample                  :
{
  "actionName": "getLicenseKey",
  "authPass": "admin",
  "authUser": "admin@company.com"
}

----------------------------------------------------------
  Command: getNameByTaskId
----------------------------------------------------------
Description             : Get task name by given id
Requires authentication : true
Since                   : 5.1
Sample                  :
{
  "actionName": "getNameByTaskId",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "taskId": 1
}

----------------------------------------------------------
  Command: getTaskIdByName
----------------------------------------------------------
Description             : Get task id by given label
Requires authentication : true
Since                   : 5.1
Sample                  :
{
  "actionName": "getTaskIdByName",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "label": "task1"
}
Specific error codes    :
       79: No task with input name.

----------------------------------------------------------
  Command: getTaskStatus
----------------------------------------------------------
Description             : Return the status of a specific task.
Requires authentication : true
Since                   : 4.2
Sample                  :
{
  "actionName": "getTaskStatus",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "taskId": 1
}

----------------------------------------------------------
  Command: getTasksRelatedToJobs
----------------------------------------------------------
Description             : Return the complete list of tasks defined in the jobconductor
Requires authentication : true
Since                   : 5.0
Sample                  :
{
  "actionName": "getTasksRelatedToJobs",
  "authPass": "admin",
  "authUser": "admin@company.com"
}

----------------------------------------------------------
  Command: help
----------------------------------------------------------
Description             : Displays the help
 - commandName is optional:  will print all the commands, will print the detailed info of this command
Requires authentication : false
Since                   : 5.2
Sample                  :
{
  "actionName": "help",
  "commandName": "help"
}

----------------------------------------------------------
  Command: importExecutionPlan
----------------------------------------------------------
Description             : Import the complete list of execution plans and tasks related defined in the execution plan to DB
Requires authentication : true
Since                   : 5.4
Sample                  :
{
  "actionName": "importExecutionPlan",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "result": {"ExecutionPlan": [{
    "desc": "desc",
    "errorStatus": "OK",
    "execPlanRollBack": "task1",
    "execPlanTimeOut": "3600",
    "idQuartzJob": "35",
    "label": "plan1",
    "requestId": "1382949884395_xLiwB",
    "status": "STOPPED"
  }]}
}
Specific error codes    :
       223: Task not exist in the DB.
       224: Error appears when parsing the date.

----------------------------------------------------------
  Command: listConnection
----------------------------------------------------------
Description             : List dashboard connections
Requires authentication : false
Since                   : 4.2
Sample                  :
{"actionName": "listConnection"}

----------------------------------------------------------
  Command: listESBTasks
----------------------------------------------------------
Description             : Return the complete list of esb tasks defined in the esb conductor
Requires authentication : true
Since                   : 5.4
License                 : Non disponible dans votre licence actuelle.
Sample                  :
{
  "actionName": "listESBTasks",
  "authPass": "admin",
  "authUser": "admin@company.com"
}

----------------------------------------------------------
  Command: listExecutionPlans
----------------------------------------------------------
Description             : Return the complete list of execution plans and tasks related defined in the execution plan
Requires authentication : true
Since                   : 5.4
Sample                  :
{
  "actionName": "listExecutionPlans",
  "authPass": "admin",
  "authUser": "admin@company.com"
}

----------------------------------------------------------
  Command: listLocks
----------------------------------------------------------
Description             : Returns all locked items for the specified project and branch
Requires authentication : false
Since                   : 4.2
Sample                  :
{
  "actionName": "listLocks",
  "branch": "trunk",
  "projectName": "project1"
}

----------------------------------------------------------
  Command: listProjects
----------------------------------------------------------
Description             : Returns list of all projects
Requires authentication : true
Since                   : 5.4
Sample                  :
{
  "actionName": "listProjects",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "onlyActive": true,
  "onlySvn": false,
  "withReference": false
}

----------------------------------------------------------
  Command: listTasks
----------------------------------------------------------
Description             : Return the complete list of tasks defined in the jobconductor
Requires authentication : true
Since                   : 5.2
Sample                  :
{
  "actionName": "listTasks",
  "authPass": "admin",
  "authUser": "admin@company.com"
}

----------------------------------------------------------
  Command: listUsers
----------------------------------------------------------
Description             : Returns list of users of the specified type
Requires authentication : true
Since                   : 5.3
Sample                  :
{
  "actionName": "listUsers",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "type": "MDM"
}

----------------------------------------------------------
  Command: pauseTask
----------------------------------------------------------
Description             : Pause all the triggers of a specified task.
Requires authentication : true
Since                   : 5.1
Sample                  :
{
  "actionName": "pauseTask",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "taskId": 1
}

----------------------------------------------------------
  Command: projectExist
----------------------------------------------------------
Description             : Returns true if the project exist.
Requires authentication : true
Since                   : 4.1
Sample                  :
{
  "actionName": "projectExist",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "projectName": "project1"
}

----------------------------------------------------------
  Command: removeLocks
----------------------------------------------------------
Description             : Allow to unlock a repository item. Mainly used by the Studio.
Requires authentication : false
Since                   : 4.2
Sample                  :
{
  "actionName": "removeLocks",
  "applicationName": "studio",
  "authUser": "john.smith@company.com",
  "branch": "trunk",
  "locks": [{
    "itemId": "_AMyZYFcAEeCQ34gn79PTjQ",
    "itemLabel": "BM2",
    "itemType": "repository.businessProcess"
  }],
  "projectName": "project1"
}

----------------------------------------------------------
  Command: removeServer
----------------------------------------------------------
Description             : Remove an execution server.
Requires authentication : true
Since                   : 4.2
Sample                  :
{
  "actionName": "removeServer",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "serverId": 101
}

----------------------------------------------------------
  Command: requestDeploy
----------------------------------------------------------
Description             : Deploy the job linked to the task given in parameter.
Requires authentication : true
Since                   : 5.0
Sample                  :
{
  "actionName": "requestDeploy",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "taskId": 1
}
Specific error codes    :
       170: Error while deploying the task

----------------------------------------------------------
  Command: requestGenerate
----------------------------------------------------------
Description             : Generate the job linked to the task given in parameter.
Requires authentication : true
Since                   : 5.0
Sample                  :
{
  "actionName": "requestGenerate",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "taskId": 1
}

----------------------------------------------------------
  Command: requestPauseTriggers
----------------------------------------------------------
Description             : Request to pause all the triggers of a task.
Requires authentication : true
Since                   : 5.0
Sample                  :
{
  "actionName": "requestPauseTriggers",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "taskId": 1
}

----------------------------------------------------------
  Command: requestResumeTriggers
----------------------------------------------------------
Description             : Request to resume all the triggers of a task.
Requires authentication : true
Since                   : 5.0
Sample                  :
{
  "actionName": "requestResumeTriggers",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "taskId": 1
}

----------------------------------------------------------
  Command: runTask
----------------------------------------------------------
Description             : Allows to run a task defined in Job conductor by its id. Mode can be 'asynchronous' or 'synchronous'
Requires authentication : true
Since                   : 4.2
Sample                  :
{
  "actionName": "runTask",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "mode": "synchronous",
  "taskId": 1
}
Specific error codes    :
       30: Error while launching task
       31: Thread interupted while running
       32: No right to run this task

----------------------------------------------------------
  Command: saveESBTask
----------------------------------------------------------
Description             : Add a new esb execution task in TAC and return the task ID.
- featureType: could be [ROUTE, SERVICE, GENERIC]
- runtimeContext: "Default" is the default value.
Requires authentication : true
Since                   : 5.4
License                 : Non disponible dans votre licence actuelle.
Sample                  :
{
  "actionName": "saveESBTask",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "description": "esbTask1's description",
  "featureName": "DemoRESTConsumer-feature",
  "featureType": "ROUTE",
  "featureUrl": "mvn:org.example/DemoRESTConsumer-feature/0.1.0-SNAPSHOT/xml",
  "featureVersion": "0.1.0-SNAPSHOT",
  "repository": "repo-snapshot",
  "runtimeContext": "Default",
  "runtimePropertyId": "DemoRESTConsumer",
  "runtimeServerName": "serv1",
  "tag": "tag1",
  "taskName": "esbTask1"
}

----------------------------------------------------------
  Command: setLicenseKey
----------------------------------------------------------
Description             : Set a new license for Talend Administrator Center
Requires authentication : true
Since                   : 5.2
Sample                  :
{
  "actionName": "setLicenseKey",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "licenseKeyPath": "c:/temp/TDQ_EE.license"
}
Specific error codes    :
       110: license is not file or not exist
       111: license file operation failed

----------------------------------------------------------
  Command: setRoleLimitation
----------------------------------------------------------
Description             : Remove or add module's right restriction to a role.
- userRole: must be one of those values [ADMIN_ROLE, DESIGNER_ROLE, OPERATION_MANAGER_ROLE, VIEWER_ROLE]
- rightKey: must be one of those values [LICENSE, CONFIG_MANAGMENT, CONFIG_READ, USERS_MANAGMENT, USERS_READ, PROJECTS_MANAGMENT, PROJECTS_READ, LOCK_MANAGMENT, LOCK_READ, SERVERS_MANAGMENT, SERVERS_R
EAD, JOB_CONDUCTOR_MANAGMENT, JOB_CONDUCTOR_READ, AUDIT_MANAGMENT, AUDIT_READ, SOA_MANAGMENT, DASH_SOA_MANAGMENT, SOA_READ, DASH_CONNECTIONS, DASH_JOBS, STUDIO, STUDIO_ALL_READ, STUDIO_READ_MAX, NOTIF
ICATIONS_MANAGMENT, NOTIFICATIONS_READ, DROOLS_READ, COMMANDLINE_MANAGMENT, BUSINESS_MODELER_MANAGMENT, BUSINESS_MODELER_READ, DOCUMENTATION_MANAGMENT, SOFTWAREUPDATE, TAGS_CREATION, ESB_CONDUCTOR_REA
D, ESB_CONDUCTOR_MGT, ESB_PUBLISHER_READ, ESB_PUBLISHER_MGT, ESB_SL_READ, ESB_SL_MGT, ESB_SAM_READ, ESB_AUTH_READ, ESB_AUTH_MGT, ESB_SR_READ, ESB_SR_MGT, CONFIG_RIGHTS_MGT, DATABASE_BACKUP]
- limitation: true if a restriction must applied, false otherwise.
Requires authentication : true
Since                   : 5.3
Sample                  :
{
  "actionName": "setRoleLimitation",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "limitation": true,
  "rightKey": "SERVERS_READ",
  "userRole": "DESIGNER_ROLE"
}

----------------------------------------------------------
  Command: stopTask
----------------------------------------------------------
Description             : Stop the execution of a given task
Requires authentication : true
Since                   : 5.1
Sample                  :
{
  "actionName": "stopTask",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "taskId": 1
}

----------------------------------------------------------
  Command: taskLog
----------------------------------------------------------
Description             : Retrieve the logs of the specified task
Requires authentication : true
Since                   : 5.1
Sample                  :
{
  "actionName": "taskLog",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "taskId": 1
}
Specific error codes    :
       220: Error happened when reading logs.

----------------------------------------------------------
  Command: updateTask
----------------------------------------------------------
Description             : Allows to update an existing execution task from TAC.
- projectName and jobName: the project and job must exist;
- onUnknownStateJob: could be [WAIT, KILL_TASK, RESTART_TASK, RECOVER_TASK]
- contextName: "Default" is the default value for it.
Requires authentication : true
Since                   : 5.0
Sample                  :
{
  "actionName": "updateTask",
  "active": true,
  "addStatisticsCodeEnabled": false,
  "applyContextToChildren": false,
  "authPass": "admin",
  "authUser": "admin@company.com",
  "branch": "trunk",
  "contextName": "Default",
  "description": "task1 for extracting data from DB1",
  "execStatisticsEnabled": false,
  "executionServerName": "serv1",
  "jobName": "job1",
  "jobVersion": "1.0",
  "onUnknownStateJob": "WAIT",
  "projectName": "tproject1",
  "regenerateJobOnChange": false,
  "taskId": 1,
  "taskName": "task1"
}

----------------------------------------------------------
  Command: userExist
----------------------------------------------------------
Description             : Return true if a user exist
Requires authentication : true
Since                   : 3.2
Sample                  :
{
  "actionName": "userExist",
  "authPass": "admin",
  "authUser": "admin@company.com",
  "userLogin": "john.smith@company.com"
}

Parameters and actions in metaServlet[/su_spoiler]
[/su_accordion]

Mais, pourquoi utiliser un outils non documenté pour faire quelque chose de standard?

 

Communiquer avec un WS REST est très facile avec par exemple PowerShell qui gère nativement des commandes pour communiquer avec un WS REST.

Voici quelques lignes (surement optimisable) qui permettent de communiquer de manière simple avec la TAC.
[su_accordion]
[su_spoiler title= »Invoke-RestMethod -Uri http://$server:8080/org.talend.administrator/metaServlet -Body  » style= »fancy »]

 # creation des parametres pour json
 $parameters = @{
                    "actionName"="help"
                    "commandName"="all"
                }
# mon serveur
$server = "monserveur"

# appel au WebService via Invoke-RestMethod
$response = Invoke-RestMethod -Uri http://$server:8080/org.talend.administrator/metaServlet -Body $(JsonToBase64 $parameters) -Method POST
$response.help

# Création du body en base64 à partir de la chaine json en entrée
Function JsonToBase64 ([System.Object]$MyparametersJson){
#conversion en Json
$json = $null
$json = $MyparametersJson | ConvertTo-Json
# conversion en base64
$tmp_convert = [System.Text.Encoding]::UTF8.GetBytes($json)
$MyBase64 = [System.Convert]::ToBase64String($tmp_convert)
return $MyBase64
}

[/su_spoiler]
[/su_accordion]