diff --git a/Conductor/Api/ITaskResourceApi.cs b/Conductor/Api/ITaskResourceApi.cs index d0e59d5..e54cded 100644 --- a/Conductor/Api/ITaskResourceApi.cs +++ b/Conductor/Api/ITaskResourceApi.cs @@ -213,6 +213,22 @@ public interface ITaskResourceApi : IApiAccessor /// string string UpdateTask(Dictionary body, string workflowId, string taskRefName, string status, string workerid = null); + /// + /// Update a task By Ref Name, evaluates the workflow and returns the updated workflow + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// + /// + /// + /// (optional) + /// Workflow + Workflow UpdateTaskSync(Dictionary output, string workflowId, string taskRefName, TaskResult.StatusEnum status, string workerid = null); + + #endregion Synchronous Operations #region Asynchronous Operations @@ -415,6 +431,22 @@ public interface ITaskResourceApi : IApiAccessor /// (optional) /// string ThreadTask.Task UpdateTaskAsync(Dictionary body, string workflowId, string taskRefName, string status, string workerid = null); + + /// + /// Update a task By Ref Name, evaluates the workflow and returns the updated workflow + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// + /// + /// + /// (optional) + /// Workflow + ThreadTask.Task UpdateTaskSyncAsync(Dictionary output, string workflowId, string taskRefName, TaskResult.StatusEnum status, string workerid = null); + #endregion Asynchronous Operations } } diff --git a/Conductor/Api/IWorkflowResourceApi.cs b/Conductor/Api/IWorkflowResourceApi.cs index 3eb3770..0d83808 100644 --- a/Conductor/Api/IWorkflowResourceApi.cs +++ b/Conductor/Api/IWorkflowResourceApi.cs @@ -55,9 +55,11 @@ public interface IWorkflowResourceApi : IApiAccessor /// /// Update the value of the workflow variables for the given workflow id /// - /// - /// ApiResponse of Object(void) - Object UpdateWorkflowVariables(Workflow workflow); + /// + /// + /// Workflow + Workflow UpdateWorkflowVariables(string workflowId, Dictionary variables); + /// /// Gets the workflow by workflow id /// @@ -71,6 +73,18 @@ public interface IWorkflowResourceApi : IApiAccessor /// Workflow Workflow GetExecutionStatus(string workflowId, bool? includeTasks = null, bool? summarize = null); + /// + /// Gets the workflow by workflow id + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// (optional, default to true) + /// Workflow + Workflow GetWorkflow(string workflowId, bool? includeTasks = null); + /// /// Gets the workflow tasks by workflow id /// @@ -384,6 +398,18 @@ public interface IWorkflowResourceApi : IApiAccessor /// Object Object UploadCompletedWorkflows(); + /// + /// Update a workflow state by updating variables or in progress task Updates the workflow variables, tasks and triggers evaluation. + /// + /// Thrown when fails to make API call + /// + /// + /// (optional) + /// (optional, default to 10) + /// WorkflowRun + WorkflowRun UpdateWorkflow(string workflowId, WorkflowStateUpdate request, + List waitUntilTaskRefs = null, int? waitForSeconds = null); + #endregion Synchronous Operations #region Asynchronous Operations @@ -428,9 +454,11 @@ public interface IWorkflowResourceApi : IApiAccessor /// /// Asynchronous Update the value of the workflow variables for the given workflow id /// - /// - /// ApiResponse of Object(void) - ThreadTask.Task UpdateWorkflowVariablesAsync(Workflow workflow); + /// + /// /// + /// Workflow + ThreadTask.Task UpdateWorkflowVariablesAsync(string workflowId, Dictionary variables); + /// /// Asynchronous Gets the workflow by workflow id @@ -445,6 +473,18 @@ public interface IWorkflowResourceApi : IApiAccessor /// Workflow ThreadTask.Task GetExecutionStatusAsync(string workflowId, bool? includeTasks = null, bool? summarize = null); + /// + /// Asynchronous Gets the workflow by workflow id + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// (optional, default to true) + /// Workflow + ThreadTask.Task GetWorkflowAsync(string workflowId, bool? includeTasks = null); + /// /// Asynchronous Gets the workflow tasks by workflow id /// @@ -758,6 +798,18 @@ public interface IWorkflowResourceApi : IApiAccessor /// Object ThreadTask.Task UploadCompletedWorkflowsAsync(); + /// + /// Update a workflow state by updating variables or in progress task Updates the workflow variables, tasks and triggers evaluation. + /// + /// Thrown when fails to make API call + /// + /// + /// (optional) + /// (optional, default to 10) + /// WorkflowRun + ThreadTask.Task UpdateWorkflowAsync(string workflowId, WorkflowStateUpdate request, + List waitUntilTaskRefs = null, int? waitForSeconds = null); + #endregion Asynchronous Operations } } diff --git a/Conductor/Api/TaskResourceApi.cs b/Conductor/Api/TaskResourceApi.cs index 4b8e0c7..aa2fa3d 100644 --- a/Conductor/Api/TaskResourceApi.cs +++ b/Conductor/Api/TaskResourceApi.cs @@ -1532,14 +1532,131 @@ public ApiResponse UpdateTaskWithHttpInfo(Dictionary bod (string)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(string))); } - // public ExternalStorageLocation GetExternalStorageLocation(string path, string operation, string payloadType) - // { - // throw new NotImplementedException(); - // } - - // public ApiResponse GetExternalStorageLocationWithHttpInfo(string path, string operation, string payloadType) - // { - // throw new NotImplementedException(); - // } + /// + /// Update a task By Ref Name, evaluates the workflow and returns the updated workflow + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// + /// + /// + /// (optional) + /// Workflow + public Workflow UpdateTaskSync(Dictionary output, string workflowId, string taskRefName, + TaskResult.StatusEnum status, string workerid = null) + { + var response = UpdateTaskSyncWithHttpInfo(output, workflowId, taskRefName, status, workerid); + return response.Data; + } + + /// + /// Update a task By Ref Name, evaluates the workflow and returns the updated workflow + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// + /// + /// + /// (optional) + /// Workflow + public async ThreadTask.Task UpdateTaskSyncAsync(Dictionary output, string workflowId, + string taskRefName, TaskResult.StatusEnum status, string workerid = null) + { + ApiResponse localVarResponse = await ThreadTask.Task.FromResult(UpdateTaskSyncWithHttpInfo(output, workflowId, taskRefName, status, workerid)); + return localVarResponse.Data; + } + + /// + /// Update a task By Ref Name + /// + /// Thrown when fails to make API call + /// + /// + /// + /// + /// ApiResponse of string + public ApiResponse UpdateTaskSyncWithHttpInfo(Dictionary output, string workflowId, string taskRefName, TaskResult.StatusEnum status, string workerid = null) + { + // verify the required parameter 'body' is set + if (output == null) + throw new ApiException(400, "Missing required parameter 'body' when calling TaskResourceApi->UpdateTask"); + // verify the required parameter 'workflowId' is set + if (workflowId == null) + throw new ApiException(400, "Missing required parameter 'workflowId' when calling TaskResourceApi->UpdateTask"); + // verify the required parameter 'taskRefName' is set + if (taskRefName == null) + throw new ApiException(400, "Missing required parameter 'taskRefName' when calling TaskResourceApi->UpdateTask"); + // verify the required parameter 'status' is set + if (status == null) + throw new ApiException(400, "Missing required parameter 'status' when calling TaskResourceApi->UpdateTask"); + + var localVarPath = "/tasks/{workflowId}/{taskRefName}/{status}/sync"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(this.Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + "application/json" + }; + String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "text/plain" + }; + String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (workerid == null) + { + workerid = Environment.MachineName; + } + + if (workflowId != null) localVarPathParams.Add("workflowId", this.Configuration.ApiClient.ParameterToString(workflowId)); // path parameter + if (taskRefName != null) localVarPathParams.Add("taskRefName", this.Configuration.ApiClient.ParameterToString(taskRefName)); // path parameter + if (status != null) localVarPathParams.Add("status", this.Configuration.ApiClient.ParameterToString(status)); // path parameter + if (workerid != null) localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "workerid", workerid)); // query parameter + if (output != null && output.GetType() != typeof(byte[])) + { + localVarPostBody = this.Configuration.ApiClient.Serialize(output); // http body (model) parameter + } + else + { + localVarPostBody = output; // byte array + } + // authentication (api_key) required + if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) + { + localVarHeaderParams["X-Authorization"] = this.Configuration.AccessToken; + } + + // make the HTTP request + RestResponse localVarResponse = (RestResponse)this.Configuration.ApiClient.CallApi(localVarPath, + Method.Post, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int)localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("UpdateTask", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), + (Workflow)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(Workflow))); + } } } diff --git a/Conductor/Api/WorkflowResourceApi.cs b/Conductor/Api/WorkflowResourceApi.cs index b8baf2c..2f5dca4 100644 --- a/Conductor/Api/WorkflowResourceApi.cs +++ b/Conductor/Api/WorkflowResourceApi.cs @@ -365,43 +365,45 @@ public ApiResponse ExecuteWorkflowWithHttpInfo(StartWorkflowRequest /// /// Update the Workflow variables synchronously /// - /// - /// - public Object UpdateWorkflowVariables(Workflow workflow) + /// + /// + /// Workflow + public Workflow UpdateWorkflowVariables(string workflowId, Dictionary variables) { - ApiResponse localVarResponse = UpdateWorkflowVariablesWithHttpInfo(workflow); + ApiResponse localVarResponse = UpdateWorkflowVariablesWithHttpInfo(workflowId, variables); return localVarResponse.Data; } /// /// Asynchronous Update the Workflow variables /// - /// - /// - public async ThreadTask.Task UpdateWorkflowVariablesAsync(Workflow workflow) + /// + /// + /// Workflow + public async ThreadTask.Task UpdateWorkflowVariablesAsync(string workflowId, Dictionary variables) { - ApiResponse localVarResponse = await ThreadTask.Task.FromResult(UpdateWorkflowVariablesWithHttpInfo(workflow)); + ApiResponse localVarResponse = await ThreadTask.Task.FromResult(UpdateWorkflowVariablesWithHttpInfo(workflowId, variables)); return localVarResponse.Data; } /// /// Update the Workflow variables /// - /// - /// - public ApiResponse UpdateWorkflowVariablesWithHttpInfo(Workflow workflow) + /// + /// + /// Workflow + public ApiResponse UpdateWorkflowVariablesWithHttpInfo(string workflowId, Dictionary variables) { // verify the required parameter 'body' is set - if (workflow == null) - throw new ApiException(400, "Missing required parameter 'body' when calling WorkflowResourceApi->Update"); + if (workflowId == null) + throw new ApiException(400, "Missing required parameter 'workflowId' when calling WorkflowResourceApi->UpdateWorkflowVariables"); - if (string.IsNullOrEmpty(workflow.WorkflowId)) - throw new ApiException(400, "Missing required parameter 'WorkflowId' when calling WorkflowResourceApi->Update"); - if (workflow.Variables == null) - throw new ApiException(400, "Missing required parameter 'Variables' when calling WorkflowResourceApi->Update"); - var localVarPath = $"/workflow/{workflow.WorkflowId}/variables"; + if (variables == null) + throw new ApiException(400, "Missing required parameter 'variables' when calling WorkflowResourceApi->UpdateWorkflowVariables"); + + var localVarPath = $"/workflow/{workflowId}/variables"; var localVarPathParams = new Dictionary(); var localVarQueryParams = new List>(); var localVarHeaderParams = new Dictionary(this.Configuration.DefaultHeader); @@ -411,22 +413,19 @@ public ApiResponse UpdateWorkflowVariablesWithHttpInfo(Workflow workflow // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { - "application/json" - }; + "application/json" + }; String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { - "*/*" - }; + "*/*" + }; String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); - if (workflow != null && workflow.GetType() != typeof(byte[])) - { - localVarPostBody = this.Configuration.ApiClient.Serialize(workflow.Variables); - } + localVarPostBody = this.Configuration.ApiClient.Serialize(variables); // authentication (api_key) required if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) @@ -434,9 +433,11 @@ public ApiResponse UpdateWorkflowVariablesWithHttpInfo(Workflow workflow localVarHeaderParams["X-Authorization"] = this.Configuration.AccessToken; } + // make the HTTP request RestResponse localVarResponse = (RestResponse)this.Configuration.ApiClient.CallApi(localVarPath, - Method.Post, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, - localVarPathParams, localVarHttpContentType); + Method.Post, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) @@ -445,9 +446,9 @@ public ApiResponse UpdateWorkflowVariablesWithHttpInfo(Workflow workflow if (exception != null) throw exception; } - return new ApiResponse(localVarStatusCode, - localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), - (Object)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(Object))); + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), + (Workflow)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(Workflow))); } /// @@ -464,6 +465,19 @@ public Workflow GetExecutionStatus(string workflowId, bool? includeTasks = null, return localVarResponse.Data; } + /// + /// Gets the workflow by workflow id + /// + /// Thrown when fails to make API call + /// + /// (optional, default to true) + /// (optional, default to false) + /// Workflow + public Workflow GetWorkflow(string workflowId, bool? includeTasks = null) + { + return GetExecutionStatus(workflowId, includeTasks); + } + /// /// Asynchronous Gets the workflow by workflow id @@ -479,6 +493,19 @@ public async ThreadTask.Task GetExecutionStatusAsync(string workflowId return localVarResponse.Data; } + /// + /// Asynchronous Gets the workflow by workflow id + /// + /// Thrown when fails to make API call + /// + /// (optional, default to true) + /// (optional, default to false) + /// Workflow + public async ThreadTask.Task GetWorkflowAsync(string workflowId, bool? includeTasks = null) + { + return await GetExecutionStatusAsync(workflowId, includeTasks); + } + /// /// Gets the workflow by workflow id @@ -2713,13 +2740,13 @@ public ApiResponse UploadCompletedWorkflowsWithHttpInfo() // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { - }; + }; String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { - "*/*" - }; + "*/*" + }; String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); @@ -2747,5 +2774,121 @@ public ApiResponse UploadCompletedWorkflowsWithHttpInfo() localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), (Object)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(Object))); } + + /// + /// Update a workflow state by updating variables or in progress task Updates the workflow variables, tasks and triggers evaluation. + /// + /// Thrown when fails to make API call + /// + /// + /// (optional) + /// (optional, default to 10) + /// WorkflowRun + public WorkflowRun UpdateWorkflow(string workflowId, WorkflowStateUpdate request, + List waitUntilTaskRefs = null, int? waitForSeconds = null) + { + var response = UpdateWorkflowWithHttpInfo(workflowId, request, waitUntilTaskRefs, waitForSeconds); + return response.Data; + } + /// + /// Update a workflow state by updating variables or in progress task Updates the workflow variables, tasks and triggers evaluation. + /// + /// Thrown when fails to make API call + /// + /// + /// (optional) + /// (optional, default to 10) + /// WorkflowRun + public async ThreadTask.Task UpdateWorkflowAsync(string workflowId, WorkflowStateUpdate request, + List waitUntilTaskRefs = null, int? waitForSeconds = null) + { + ApiResponse localVarResponse = await ThreadTask.Task.FromResult(UpdateWorkflowWithHttpInfo(workflowId, request, waitUntilTaskRefs, waitForSeconds)); + return localVarResponse.Data; + } + + /// + /// Update a workflow state by updating variables or in progress task Updates the workflow variables, tasks and triggers evaluation. + /// + /// Thrown when fails to make API call + /// + /// + /// (optional) + /// (optional, default to 10) + /// ApiResponse of WorkflowRun + public ApiResponse UpdateWorkflowWithHttpInfo(string workflowId, WorkflowStateUpdate request, + List waitUntilTaskRefs = null, int? waitForSeconds = null) + { + string requestId = Guid.NewGuid().ToString(); + string waitUntilTaskRef = waitUntilTaskRefs != null && waitUntilTaskRefs.Count > 0 ? + waitUntilTaskRefs.Aggregate((a, b) => a + ", " + b) : null; + + // verify the required parameter 'request' is set + if (request == null) + throw new ApiException(400, "Missing required parameter 'request' when calling WorkflowResourceApi->UpdateWorkflowAndTaskState"); + // verify the required parameter 'requestId' is set + if (requestId == null) + throw new ApiException(400, "Missing required parameter 'requestId' when calling WorkflowResourceApi->UpdateWorkflowAndTaskState"); + // verify the required parameter 'workflowId' is set + if (workflowId == null) + throw new ApiException(400, "Missing required parameter 'workflowId' when calling WorkflowResourceApi->UpdateWorkflowAndTaskState"); + + var localVarPath = "/workflow/{workflowId}/state"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new List>(); + var localVarHeaderParams = new Dictionary(this.Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + "application/json" + }; + String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + "*/*" + }; + String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (workflowId != null) localVarPathParams.Add("workflowId", this.Configuration.ApiClient.ParameterToString(workflowId)); // path parameter + if (requestId != null) localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "requestId", requestId)); // query parameter + if (waitUntilTaskRef != null) localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "waitUntilTaskRef", waitUntilTaskRef)); // query parameter + if (waitForSeconds != null) localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "waitForSeconds", waitForSeconds)); // query parameter + if (request != null && request.GetType() != typeof(byte[])) + { + localVarPostBody = this.Configuration.ApiClient.Serialize(request); // http body (model) parameter + } + else + { + localVarPostBody = request; // byte array + } + + // authentication (api_key) required + if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) + { + localVarHeaderParams["X-Authorization"] = this.Configuration.AccessToken; + } + + // make the HTTP request + RestResponse localVarResponse = (RestResponse)this.Configuration.ApiClient.CallApi(localVarPath, + Method.Post, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int)localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("UpdateWorkflowAndTaskState", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), + (WorkflowRun)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(WorkflowRun))); + } } } \ No newline at end of file diff --git a/Conductor/Client/Models/IdempotencyStrategy.cs b/Conductor/Client/Models/IdempotencyStrategy.cs new file mode 100644 index 0000000..7d44f46 --- /dev/null +++ b/Conductor/Client/Models/IdempotencyStrategy.cs @@ -0,0 +1,15 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Conductor.Client.Models +{ + [JsonConverter(typeof(StringEnumConverter))] + public enum IdempotencyStrategy + { + [EnumMember(Value = "FAIL")] + FAIL = 0, + [EnumMember(Value = "RETURN_EXISTING")] + RETURN_EXISTING = 1 + } +} \ No newline at end of file diff --git a/Conductor/Client/Models/StartWorkflowRequest.cs b/Conductor/Client/Models/StartWorkflowRequest.cs index 013751e..6fb62e7 100644 --- a/Conductor/Client/Models/StartWorkflowRequest.cs +++ b/Conductor/Client/Models/StartWorkflowRequest.cs @@ -1,22 +1,21 @@ -using System.Linq; -using System.IO; using System; -using System.Text; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; using System.Runtime.Serialization; +using System.Text; using Newtonsoft.Json; -using System.ComponentModel.DataAnnotations; namespace Conductor.Client.Models { /// - /// StartWorkflowRequest + /// StartWorkflowRequest /// [DataContract] - public partial class StartWorkflowRequest : IEquatable, IValidatableObject + public class StartWorkflowRequest : IEquatable, IValidatableObject { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// correlationId. /// createdBy. @@ -27,17 +26,14 @@ public partial class StartWorkflowRequest : IEquatable, IV /// taskToDomain. /// version. /// workflowDef. - public StartWorkflowRequest(string correlationId = default(string), string createdBy = default(string), string externalInputPayloadStoragePath = default(string), Dictionary input = default(Dictionary), string name = default(string), int? priority = default(int?), Dictionary taskToDomain = default(Dictionary), int? version = default(int?), WorkflowDef workflowDef = default(WorkflowDef)) + public StartWorkflowRequest(string correlationId = default, string createdBy = default, + string externalInputPayloadStoragePath = default, Dictionary input = default, + string name = default, int? priority = default, Dictionary taskToDomain = default, + int? version = default, WorkflowDef workflowDef = default, + string idempotencyKey = default(string), + IdempotencyStrategy idempotencyStrategy = IdempotencyStrategy.FAIL) { - // to ensure "name" is required (not null) - if (name == null) - { - throw new InvalidDataException("name is a required property for StartWorkflowRequest and cannot be null"); - } - else - { - this.Name = name; - } + this.Name = name; this.CorrelationId = correlationId; this.CreatedBy = createdBy; this.ExternalInputPayloadStoragePath = externalInputPayloadStoragePath; @@ -46,64 +42,142 @@ public partial class StartWorkflowRequest : IEquatable, IV this.TaskToDomain = taskToDomain; this.Version = version; this.WorkflowDef = workflowDef; + this.IdempotencyKey = idempotencyKey; + this.IdempotencyStrategy = idempotencyStrategy; } + [DataMember(Name = "idempotencyStrategy", EmitDefaultValue = true)] + public IdempotencyStrategy IdempotencyStrategy { get; set; } + + [DataMember(Name = "idempotencyKey", EmitDefaultValue = false)] + public string IdempotencyKey { get; set; } + /// - /// Gets or Sets CorrelationId + /// Gets or Sets CorrelationId /// [DataMember(Name = "correlationId", EmitDefaultValue = false)] public string CorrelationId { get; set; } /// - /// Gets or Sets CreatedBy + /// Gets or Sets CreatedBy /// [DataMember(Name = "createdBy", EmitDefaultValue = false)] public string CreatedBy { get; set; } /// - /// Gets or Sets ExternalInputPayloadStoragePath + /// Gets or Sets ExternalInputPayloadStoragePath /// [DataMember(Name = "externalInputPayloadStoragePath", EmitDefaultValue = false)] public string ExternalInputPayloadStoragePath { get; set; } /// - /// Gets or Sets Input + /// Gets or Sets Input /// [DataMember(Name = "input", EmitDefaultValue = false)] - public Dictionary Input { get; set; } + public Dictionary Input { get; set; } /// - /// Gets or Sets Name + /// Gets or Sets Name /// [DataMember(Name = "name", EmitDefaultValue = false)] public string Name { get; set; } /// - /// Gets or Sets Priority + /// Gets or Sets Priority /// [DataMember(Name = "priority", EmitDefaultValue = false)] public int? Priority { get; set; } /// - /// Gets or Sets TaskToDomain + /// Gets or Sets TaskToDomain /// [DataMember(Name = "taskToDomain", EmitDefaultValue = false)] public Dictionary TaskToDomain { get; set; } /// - /// Gets or Sets Version + /// Gets or Sets Version /// [DataMember(Name = "version", EmitDefaultValue = false)] public int? Version { get; set; } /// - /// Gets or Sets WorkflowDef + /// Gets or Sets WorkflowDef /// [DataMember(Name = "workflowDef", EmitDefaultValue = false)] public WorkflowDef WorkflowDef { get; set; } /// - /// Returns the string presentation of the object + /// Returns true if StartWorkflowRequest instances are equal + /// + /// Instance of StartWorkflowRequest to be compared + /// Boolean + public bool Equals(StartWorkflowRequest input) + { + if (input == null) + return false; + + return + ( + CorrelationId == input.CorrelationId || + (CorrelationId != null && + CorrelationId.Equals(input.CorrelationId)) + ) && + ( + CreatedBy == input.CreatedBy || + (CreatedBy != null && + CreatedBy.Equals(input.CreatedBy)) + ) && + ( + ExternalInputPayloadStoragePath == input.ExternalInputPayloadStoragePath || + (ExternalInputPayloadStoragePath != null && + ExternalInputPayloadStoragePath.Equals(input.ExternalInputPayloadStoragePath)) + ) && + ( + Input == input.Input || + (Input != null && + input.Input != null && + Input.SequenceEqual(input.Input)) + ) && + ( + Name == input.Name || + (Name != null && + Name.Equals(input.Name)) + ) && + ( + Priority == input.Priority || + (Priority != null && + Priority.Equals(input.Priority)) + ) && + ( + TaskToDomain == input.TaskToDomain || + (TaskToDomain != null && + input.TaskToDomain != null && + TaskToDomain.SequenceEqual(input.TaskToDomain)) + ) && + ( + Version == input.Version || + (Version != null && + Version.Equals(input.Version)) + ) && + ( + WorkflowDef == input.WorkflowDef || + (WorkflowDef != null && + WorkflowDef.Equals(input.WorkflowDef)) + ); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + + /// + /// Returns the string presentation of the object /// /// String presentation of the object public override string ToString() @@ -124,7 +198,7 @@ public override string ToString() } /// - /// Returns the JSON string presentation of the object + /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object public virtual string ToJson() @@ -133,114 +207,44 @@ public virtual string ToJson() } /// - /// Returns true if objects are equal + /// Returns true if objects are equal /// /// Object to be compared /// Boolean public override bool Equals(object input) { - return this.Equals(input as StartWorkflowRequest); - } - - /// - /// Returns true if StartWorkflowRequest instances are equal - /// - /// Instance of StartWorkflowRequest to be compared - /// Boolean - public bool Equals(StartWorkflowRequest input) - { - if (input == null) - return false; - - return - ( - this.CorrelationId == input.CorrelationId || - (this.CorrelationId != null && - this.CorrelationId.Equals(input.CorrelationId)) - ) && - ( - this.CreatedBy == input.CreatedBy || - (this.CreatedBy != null && - this.CreatedBy.Equals(input.CreatedBy)) - ) && - ( - this.ExternalInputPayloadStoragePath == input.ExternalInputPayloadStoragePath || - (this.ExternalInputPayloadStoragePath != null && - this.ExternalInputPayloadStoragePath.Equals(input.ExternalInputPayloadStoragePath)) - ) && - ( - this.Input == input.Input || - this.Input != null && - input.Input != null && - this.Input.SequenceEqual(input.Input) - ) && - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ) && - ( - this.Priority == input.Priority || - (this.Priority != null && - this.Priority.Equals(input.Priority)) - ) && - ( - this.TaskToDomain == input.TaskToDomain || - this.TaskToDomain != null && - input.TaskToDomain != null && - this.TaskToDomain.SequenceEqual(input.TaskToDomain) - ) && - ( - this.Version == input.Version || - (this.Version != null && - this.Version.Equals(input.Version)) - ) && - ( - this.WorkflowDef == input.WorkflowDef || - (this.WorkflowDef != null && - this.WorkflowDef.Equals(input.WorkflowDef)) - ); + return Equals(input as StartWorkflowRequest); } /// - /// Gets the hash code + /// Gets the hash code /// /// Hash code public override int GetHashCode() { unchecked // Overflow is fine, just wrap { - int hashCode = 41; - if (this.CorrelationId != null) - hashCode = hashCode * 59 + this.CorrelationId.GetHashCode(); - if (this.CreatedBy != null) - hashCode = hashCode * 59 + this.CreatedBy.GetHashCode(); - if (this.ExternalInputPayloadStoragePath != null) - hashCode = hashCode * 59 + this.ExternalInputPayloadStoragePath.GetHashCode(); - if (this.Input != null) - hashCode = hashCode * 59 + this.Input.GetHashCode(); - if (this.Name != null) - hashCode = hashCode * 59 + this.Name.GetHashCode(); - if (this.Priority != null) - hashCode = hashCode * 59 + this.Priority.GetHashCode(); - if (this.TaskToDomain != null) - hashCode = hashCode * 59 + this.TaskToDomain.GetHashCode(); - if (this.Version != null) - hashCode = hashCode * 59 + this.Version.GetHashCode(); - if (this.WorkflowDef != null) - hashCode = hashCode * 59 + this.WorkflowDef.GetHashCode(); + var hashCode = 41; + if (CorrelationId != null) + hashCode = hashCode * 59 + CorrelationId.GetHashCode(); + if (CreatedBy != null) + hashCode = hashCode * 59 + CreatedBy.GetHashCode(); + if (ExternalInputPayloadStoragePath != null) + hashCode = hashCode * 59 + ExternalInputPayloadStoragePath.GetHashCode(); + if (Input != null) + hashCode = hashCode * 59 + Input.GetHashCode(); + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + if (Priority != null) + hashCode = hashCode * 59 + Priority.GetHashCode(); + if (TaskToDomain != null) + hashCode = hashCode * 59 + TaskToDomain.GetHashCode(); + if (Version != null) + hashCode = hashCode * 59 + Version.GetHashCode(); + if (WorkflowDef != null) + hashCode = hashCode * 59 + WorkflowDef.GetHashCode(); return hashCode; } } - - /// - /// To validate all properties of the instance - /// - /// Validation context - /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { - yield break; - } } -} +} \ No newline at end of file diff --git a/Conductor/Client/Models/TaskDef.cs b/Conductor/Client/Models/TaskDef.cs index 789c15e..186a1ff 100644 --- a/Conductor/Client/Models/TaskDef.cs +++ b/Conductor/Client/Models/TaskDef.cs @@ -99,24 +99,8 @@ public enum TimeoutPolicyEnum /// updatedBy. public TaskDef(int? backoffScaleFactor = default(int?), int? concurrentExecLimit = default(int?), long? createTime = default(long?), string createdBy = default(string), string description = default(string), string executionNameSpace = default(string), List inputKeys = default(List), Dictionary inputTemplate = default(Dictionary), string isolationGroupId = default(string), string name = default(string), List outputKeys = default(List), string ownerApp = default(string), string ownerEmail = default(string), int? pollTimeoutSeconds = default(int?), int? rateLimitFrequencyInSeconds = default(int?), int? rateLimitPerFrequency = default(int?), long? responseTimeoutSeconds = default(long?), int? retryCount = default(int?), int? retryDelaySeconds = default(int?), RetryLogicEnum? retryLogic = default(RetryLogicEnum?), TimeoutPolicyEnum? timeoutPolicy = default(TimeoutPolicyEnum?), long? timeoutSeconds = default(long?), long? updateTime = default(long?), string updatedBy = default(string)) { - // to ensure "name" is required (not null) - if (name == null) - { - throw new InvalidDataException("name is a required property for TaskDef and cannot be null"); - } - else - { - this.Name = name; - } - // to ensure "timeoutSeconds" is required (not null) - if (timeoutSeconds == null) - { - throw new InvalidDataException("timeoutSeconds is a required property for TaskDef and cannot be null"); - } - else - { - this.TimeoutSeconds = timeoutSeconds; - } + this.Name = name; + this.TimeoutSeconds = timeoutSeconds; this.BackoffScaleFactor = backoffScaleFactor; this.ConcurrentExecLimit = concurrentExecLimit; this.CreateTime = createTime; diff --git a/Conductor/Client/Models/TaskResult.cs b/Conductor/Client/Models/TaskResult.cs index 38acbcd..9eb10c1 100644 --- a/Conductor/Client/Models/TaskResult.cs +++ b/Conductor/Client/Models/TaskResult.cs @@ -63,24 +63,8 @@ public enum StatusEnum /// workflowInstanceId (required). public TaskResult(long? callbackAfterSeconds = default(long?), string externalOutputPayloadStoragePath = default(string), List logs = default(List), Dictionary outputData = default(Dictionary), string reasonForIncompletion = default(string), StatusEnum? status = default(StatusEnum?), string subWorkflowId = default(string), string taskId = default(string), string workerId = default(string), string workflowInstanceId = default(string)) { - // to ensure "taskId" is required (not null) - if (taskId == null) - { - throw new InvalidDataException("taskId is a required property for TaskResult and cannot be null"); - } - else - { - this.TaskId = taskId; - } - // to ensure "workflowInstanceId" is required (not null) - if (workflowInstanceId == null) - { - throw new InvalidDataException("workflowInstanceId is a required property for TaskResult and cannot be null"); - } - else - { - this.WorkflowInstanceId = workflowInstanceId; - } + this.TaskId = taskId; + this.WorkflowInstanceId = workflowInstanceId; this.CallbackAfterSeconds = callbackAfterSeconds; this.ExternalOutputPayloadStoragePath = externalOutputPayloadStoragePath; this.Logs = logs; diff --git a/Conductor/Client/Models/WorkflowStateUpdate.cs b/Conductor/Client/Models/WorkflowStateUpdate.cs new file mode 100644 index 0000000..fcb344a --- /dev/null +++ b/Conductor/Client/Models/WorkflowStateUpdate.cs @@ -0,0 +1,143 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using Newtonsoft.Json; + +namespace Conductor.Client.Models +{ + /// + /// WorkflowStateUpdate + /// + [DataContract] + public partial class WorkflowStateUpdate : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// taskReferenceName. + /// taskResult. + /// variables. + public WorkflowStateUpdate(string taskReferenceName = default(string), + TaskResult taskResult = default(TaskResult), + Dictionary variables = default(Dictionary)) + { + this.TaskReferenceName = taskReferenceName; + this.TaskResult = taskResult; + this.Variables = variables; + } + + /// + /// Gets or Sets TaskReferenceName + /// + [DataMember(Name = "taskReferenceName", EmitDefaultValue = false)] + public string TaskReferenceName { get; set; } + + /// + /// Gets or Sets TaskResult + /// + [DataMember(Name = "taskResult", EmitDefaultValue = false)] + public TaskResult TaskResult { get; set; } + + /// + /// Gets or Sets Variables + /// + [DataMember(Name = "variables", EmitDefaultValue = false)] + public Dictionary Variables { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class WorkflowStateUpdate {\n"); + sb.Append(" TaskReferenceName: ").Append(TaskReferenceName).Append("\n"); + sb.Append(" TaskResult: ").Append(TaskResult).Append("\n"); + sb.Append(" Variables: ").Append(Variables).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as WorkflowStateUpdate); + } + + /// + /// Returns true if WorkflowStateUpdate instances are equal + /// + /// Instance of WorkflowStateUpdate to be compared + /// Boolean + public bool Equals(WorkflowStateUpdate input) + { + if (input == null) + return false; + + return + ( + this.TaskReferenceName == input.TaskReferenceName || + (this.TaskReferenceName != null && + this.TaskReferenceName.Equals(input.TaskReferenceName)) + ) && + ( + this.TaskResult == input.TaskResult || + (this.TaskResult != null && + this.TaskResult.Equals(input.TaskResult)) + ) && + ( + this.Variables == input.Variables || + this.Variables != null && + input.Variables != null && + this.Variables.SequenceEqual(input.Variables) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.TaskReferenceName != null) + hashCode = hashCode * 59 + this.TaskReferenceName.GetHashCode(); + if (this.TaskResult != null) + hashCode = hashCode * 59 + this.TaskResult.GetHashCode(); + if (this.Variables != null) + hashCode = hashCode * 59 + this.Variables.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate( + ValidationContext validationContext) + { + yield break; + } + } +} \ No newline at end of file diff --git a/Tests/Api/WorkflowResourceApiTest.cs b/Tests/Api/WorkflowResourceApiTest.cs index be9fb62..97ffb35 100644 --- a/Tests/Api/WorkflowResourceApiTest.cs +++ b/Tests/Api/WorkflowResourceApiTest.cs @@ -1,3 +1,4 @@ +using System; using conductor.csharp.Client.Extensions; using Conductor.Api; using Conductor.Client.Extensions; @@ -6,8 +7,12 @@ using Conductor.Definition.TaskType; using Microsoft.Extensions.Logging; using System.Collections.Generic; +using System.Linq; +using conductor_csharp.Api; using Tests.Worker; using Xunit; +using Xunit.Abstractions; +using Task = Conductor.Client.Models.Task; namespace conductor_csharp.test.Api { @@ -22,14 +27,19 @@ public class WorkflowResourceApiTest private const string OWNER_EMAIL = "developer@orkes.io"; private readonly WorkflowResourceApi _workflowClient; + private readonly ITaskResourceApi _taskClient; private readonly MetadataResourceApi _metadataResourceApi; private readonly ILogger _logger; + private readonly ITestOutputHelper _testOutputHelper; - public WorkflowResourceApiTest() + + public WorkflowResourceApiTest(ITestOutputHelper testOutputHelper) { _workflowClient = ApiExtensions.GetClient(); + _taskClient = ApiExtensions.GetClient(); _metadataResourceApi = ApiExtensions.GetClient(); _logger = ApplicationLogging.CreateLogger(); + _testOutputHelper = testOutputHelper; } [Fact] @@ -105,11 +115,10 @@ public async void UpdateWorkflowVariables() {WORKFLOW_VARIABLE_1,"Value1" }, {WORKFLOW_VARIABLE_2,"Value2" }, }; - var updateVariableData = new Workflow() { WorkflowId = workflowId, Variables = updateDict }; + // Update the work flow variables - _workflowClient.UpdateWorkflowVariables(updateVariableData); - // Fetch latest workflow data to validate the change in variables - var _updatedWorkFlow = _workflowClient.GetWorkflowStatusSummary(workflowId, includeVariables: true); + var _updatedWorkFlow = _workflowClient.UpdateWorkflowVariables(workflowId, updateDict); + // Verify workflow variables data is equal with input passed Assert.Equal(_updatedWorkFlow.Variables, updateDict); @@ -147,17 +156,141 @@ private void DeleteWorkflowExecution(string workflowId) Assert.DoesNotContain(workflowId, res.Data); } - //[Fact] - //public void DeleteAllWorkflowExecution() - //{ + [Fact] + public void TestWorkflowOperations() + { + // Start Workflow + var correlationId = Guid.NewGuid().ToString(); + var startWorkflowRequest = new StartWorkflowRequest + { + Name = "csharp_sync_task_variable_updates", + Version = 1, + Input = new Dictionary(), + CorrelationId = correlationId + }; + var workflowId = _workflowClient.StartWorkflow(startWorkflowRequest); + _testOutputHelper.WriteLine($"Started workflow with id {workflowId}"); + + // Update a variable inside the workflow + _workflowClient.UpdateWorkflowVariables(workflowId, new Dictionary { { "case", "case1" } }); + + // Get workflow execution status + var workflow = _workflowClient.GetWorkflow(workflowId, true); + var lastTask = workflow.Tasks.Last(); + _testOutputHelper.WriteLine( + $"Workflow status is {workflow.Status} and currently running task is {lastTask.ReferenceTaskName}"); + + workflow = _taskClient.UpdateTaskSync(new Dictionary { { "a", "b" } }, workflowId, + lastTask.ReferenceTaskName, TaskResult.StatusEnum.COMPLETED, "test_worker"); + + // Get updated workflow status + lastTask = workflow.Tasks.Last(); + Assert.Equal(lastTask.Status, Task.StatusEnum.INPROGRESS); + _testOutputHelper.WriteLine( + $"Workflow status is {workflow.Status} and currently running task is {lastTask.ReferenceTaskName}"); + + // Terminate the workflow + _workflowClient.Terminate(workflowId, "testing termination"); + workflow = _workflowClient.GetWorkflow(workflowId, true); + Assert.Equal(Workflow.StatusEnum.TERMINATED, workflow.Status); + lastTask = workflow.Tasks.Last(); + _testOutputHelper.WriteLine( + $"Workflow status is {workflow.Status} and status of last task {lastTask.Status}"); + + // Retry the workflow + _workflowClient.Retry(workflowId); + workflow = _workflowClient.GetWorkflow(workflowId, true); + Assert.Equal(Workflow.StatusEnum.RUNNING, workflow.Status); + lastTask = workflow.Tasks.Last(); + _testOutputHelper.WriteLine( + $"Workflow status is {workflow.Status} and status of last task {lastTask.ReferenceTaskName} is {lastTask.Status}"); + + // Mark the WAIT task as completed by calling Task completion API + var taskResult = new TaskResult + { + WorkflowInstanceId = workflowId, + TaskId = lastTask.TaskId, + Status = TaskResult.StatusEnum.COMPLETED, + OutputData = new Dictionary { { "greetings", "hello from Orkes" } } + }; + workflow = _taskClient.UpdateTaskSync( + new Dictionary { { "greetings", "hello from Orkes" } }, + workflowId, lastTask.ReferenceTaskName, TaskResult.StatusEnum.COMPLETED, ""); + + lastTask = workflow.Tasks.Last(); + Assert.Equal(Task.StatusEnum.SCHEDULED, lastTask.Status); + _testOutputHelper.WriteLine( + $"Workflow status is {workflow.Status} and status of last task {lastTask.ReferenceTaskName} is {lastTask.Status}"); - // var res = _workflowClient.GetRunningWorkflowWithHttpInfo(WORKFLOW_NAME); + // Terminate the workflow again + _workflowClient.Terminate(workflowId, "terminating for testing"); + workflow = _workflowClient.GetWorkflow(workflowId, true); + Assert.Equal(Workflow.StatusEnum.TERMINATED, workflow.Status); - // res.Data.ForEach(x => _workflowClient.Delete(x)); - // res = _workflowClient.GetRunningWorkflowWithHttpInfo(WORKFLOW_NAME); + // Rerun workflow from a specific task + var rerunRequest = new RerunWorkflowRequest + { + ReRunFromTaskId = workflow.Tasks[3].TaskId + }; + _workflowClient.Rerun(rerunRequest, workflowId); + workflow = _workflowClient.GetWorkflow(workflowId, true); + Assert.Equal(Workflow.StatusEnum.RUNNING, workflow.Status); + + + // Restart the workflow + _workflowClient.Terminate(workflowId, "terminating so we can do a restart"); + workflow = _workflowClient.GetWorkflow(workflowId, true); + Assert.Equal(Workflow.StatusEnum.TERMINATED, workflow.Status); + + _workflowClient.Restart(workflowId); + workflow = _workflowClient.GetWorkflow(workflowId, true); + Assert.Equal(Workflow.StatusEnum.RUNNING, workflow.Status); + + // Pause the workflow + _workflowClient.PauseWorkflow(workflowId); + workflow = _workflowClient.GetWorkflow(workflowId, true); + Assert.Equal(Workflow.StatusEnum.PAUSED, workflow.Status); + _testOutputHelper.WriteLine($"Workflow status is {workflow.Status}"); + + workflow = _workflowClient.GetWorkflow(workflowId, true); + // Wait task should have completed + var waitTask = workflow.Tasks[0]; + Assert.Equal(Task.StatusEnum.INPROGRESS, waitTask.Status); + _testOutputHelper.WriteLine($"Workflow status is {workflow.Status} and wait task is {waitTask.Status}"); + - // Assert.Equal(0, res.Data.Count); - //} + // Because workflow is paused, no further task should have been scheduled, making WAIT the last task + // Expecting only 1 task + _testOutputHelper.WriteLine($"Number of tasks in workflow is {workflow.Tasks.Count}"); + Assert.Single(workflow.Tasks); + + // Resume the workflow + _workflowClient.ResumeWorkflow(workflowId); + lastTask = workflow.Tasks.Last(); + workflow = _taskClient.UpdateTaskSync(new Dictionary { { "a", "b" } }, workflowId, + lastTask.ReferenceTaskName, TaskResult.StatusEnum.COMPLETED, "test_worker"); + + workflow = _workflowClient.GetWorkflow(workflowId, true); + + // There should be 3 tasks + _testOutputHelper.WriteLine( + $"Number of tasks in workflow is {workflow.Tasks.Count} and last task is {workflow.Tasks.Last().ReferenceTaskName}"); + Assert.Equal(3, workflow.Tasks.Count); + + // Search for workflows + var searchResults = _workflowClient.Search(start: 0, size: 100, freeText: "*", + query: $"correlationId = '{correlationId}'"); + _testOutputHelper.WriteLine( + $"Found {searchResults.Results.Count} execution with correlation_id '{correlationId}'"); + Assert.Single(searchResults.Results); + + correlationId = Guid.NewGuid().ToString(); + searchResults = _workflowClient.Search(start: 0, size: 100, freeText: "*", + query: $"status IN (RUNNING) AND correlationId = \"{correlationId}\""); + // Shouldn't find anything! + _testOutputHelper.WriteLine( + $"Found {searchResults.Results.Count} workflows with correlation id {correlationId}"); + } } } diff --git a/csharp-examples/WorkFlowExamples.cs b/csharp-examples/WorkFlowExamples.cs index eceb93a..8f34dc5 100644 --- a/csharp-examples/WorkFlowExamples.cs +++ b/csharp-examples/WorkFlowExamples.cs @@ -69,11 +69,7 @@ public void TestUpdateWorkflowVariablesWithWorkFlowId() { VARIABLE_NAME_2, VARIABLE_NEW_VALUE_2 } }; - workflowClient.UpdateWorkflowVariables(new Conductor.Client.Models.Workflow() - { - WorkflowId = WORKFLOW_ID, - Variables = workFlowVariables - }); + workflowClient.UpdateWorkflowVariables(WORKFLOW_ID, workFlowVariables); } ///