private Models.ApiCommandRequestUpdateEsbTask CreateEsbUpdateRequest(Models.UpdateEsbTaskSettings updateSettings, Models.EsbTask esbTask) { var repositoryName = string.IsNullOrWhiteSpace(updateSettings.Repository) ? esbTask.repositoryName : updateSettings.Repository; var repositoryType = RepositoryEnumExtensions.Parse(repositoryName); var snapshotString = (repositoryType == RepositoryEnum.Snapshots) ? "-SNAPSHOT" : String.Empty; var versionID = string.IsNullOrWhiteSpace(updateSettings.VersionID) ? esbTask.applicationVersion.Replace("-SNAPSHOT", String.Empty) : updateSettings.VersionID; var featureVersion = $"{versionID}{snapshotString}"; var contextName = string.IsNullOrWhiteSpace(updateSettings.ContextName) ? esbTask.contextName : updateSettings.ContextName; var cleanFeatureName = string.IsNullOrWhiteSpace(updateSettings.FeatureName) ? esbTask.applicationName.Replace("-feature", String.Empty) : updateSettings.FeatureName; var mvnUrl = esbTask.applicationFeatureURL.Replace("mvn:", String.Empty); var originalGroupID = mvnUrl.Substring(0, mvnUrl.IndexOf('/')); var groupID = string.IsNullOrWhiteSpace(updateSettings.JobGroup) ? originalGroupID : updateSettings.JobGroup; return(new Models.ApiCommandRequestUpdateEsbTask { authPass = _password, authUser = _username, actionName = TalendAdminApiCommands.UPDATE_ESB_TASK, description = updateSettings.Description ?? cleanFeatureName, featureName = $"{cleanFeatureName}-feature", featureUrl = $"mvn:{groupID}/{cleanFeatureName}-feature/{featureVersion}/xml", featureType = esbTask.applicationType, repository = repositoryName, featureVersion = featureVersion, runtimeContext = contextName, runtimePropertyId = esbTask.pid, runtimeServerName = esbTask.jobServerLabelHost, taskId = updateSettings.EsbTaskID ?? esbTask.id, taskName = updateSettings.EsbTaskName }); }
/// <summary> /// Updates an ESB task with the given information. /// </summary> /// <param name="request"></param> public void UpdateEsbTask(Models.UpdateEsbTaskSettings request) { if (string.IsNullOrWhiteSpace(request.EsbTaskName)) { throw new ArgumentNullException(nameof(request.EsbTaskName)); } var taskDetails = GetEsbTaskByName(request.EsbTaskName); if (taskDetails == null) { throw new ArgumentException($"Unable to find task {request.EsbTaskName}."); } var command = CreateEsbUpdateRequest(request, taskDetails); var data = ExecuteCommand <Models.TalendApiResponseTaskId>(command); if (data.ReturnCode != 0) { throw new Exception($"Failed to update task {request.EsbTaskName}: " + data.Error); } }
public static void UpdateEsbTask(this ICakeContext context, Models.UpdateEsbTaskSettings esbTaskSettings, TalendAdminApiSettings settings) { var api = new TalendAdminApi(settings.TalendAdminAddress, settings.TalendAdminUsername, settings.TalendAdminPassword); api.UpdateEsbTask(esbTaskSettings); }