Skip to content

Commit

Permalink
Updated set of APIs (#103)
Browse files Browse the repository at this point in the history
* New APIS

1. UpdateTaskSync
2. UpdateWorkflowState
3. Fix the contract for UpdateVariables

* idempotency strategy

* Linter
  • Loading branch information
v1r3n authored Feb 5, 2024
1 parent 78adcf2 commit 00a4bec
Show file tree
Hide file tree
Showing 11 changed files with 828 additions and 225 deletions.
32 changes: 32 additions & 0 deletions Conductor/Api/ITaskResourceApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,22 @@ public interface ITaskResourceApi : IApiAccessor
/// <returns>string</returns>
string UpdateTask(Dictionary<string, Object> body, string workflowId, string taskRefName, string status, string workerid = null);

/// <summary>
/// Update a task By Ref Name, evaluates the workflow and returns the updated workflow
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="Conductor.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="output"></param>
/// <param name="workflowId"></param>
/// <param name="taskRefName"></param>
/// <param name="status"></param>
/// <param name="workerid"> (optional)</param>
/// <returns>Workflow</returns>
Workflow UpdateTaskSync(Dictionary<string, Object> output, string workflowId, string taskRefName, TaskResult.StatusEnum status, string workerid = null);


#endregion Synchronous Operations

#region Asynchronous Operations
Expand Down Expand Up @@ -415,6 +431,22 @@ public interface ITaskResourceApi : IApiAccessor
/// <param name="workerid"> (optional)</param>
/// <returns>string</returns>
ThreadTask.Task<string> UpdateTaskAsync(Dictionary<string, Object> body, string workflowId, string taskRefName, string status, string workerid = null);

/// <summary>
/// Update a task By Ref Name, evaluates the workflow and returns the updated workflow
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="Conductor.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="output"></param>
/// <param name="workflowId"></param>
/// <param name="taskRefName"></param>
/// <param name="status"></param>
/// <param name="workerid"> (optional)</param>
/// <returns>Workflow</returns>
ThreadTask.Task<Workflow> UpdateTaskSyncAsync(Dictionary<string, Object> output, string workflowId, string taskRefName, TaskResult.StatusEnum status, string workerid = null);

#endregion Asynchronous Operations
}
}
64 changes: 58 additions & 6 deletions Conductor/Api/IWorkflowResourceApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ public interface IWorkflowResourceApi : IApiAccessor
/// <summary>
/// Update the value of the workflow variables for the given workflow id
/// </summary>
/// <param name="workflow"></param>
/// <returns>ApiResponse of Object(void)</returns>
Object UpdateWorkflowVariables(Workflow workflow);
/// <param name="workflowId"></param>
/// <param name="variables"></param>
/// <returns>Workflow</returns>
Workflow UpdateWorkflowVariables(string workflowId, Dictionary<string, Object> variables);

/// <summary>
/// Gets the workflow by workflow id
/// </summary>
Expand All @@ -71,6 +73,18 @@ public interface IWorkflowResourceApi : IApiAccessor
/// <returns>Workflow</returns>
Workflow GetExecutionStatus(string workflowId, bool? includeTasks = null, bool? summarize = null);

/// <summary>
/// Gets the workflow by workflow id
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="Conductor.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="workflowId"></param>
/// <param name="includeTasks"> (optional, default to true)</param>
/// <returns>Workflow</returns>
Workflow GetWorkflow(string workflowId, bool? includeTasks = null);

/// <summary>
/// Gets the workflow tasks by workflow id
/// </summary>
Expand Down Expand Up @@ -384,6 +398,18 @@ public interface IWorkflowResourceApi : IApiAccessor
/// <returns>Object</returns>
Object UploadCompletedWorkflows();

/// <summary>
/// Update a workflow state by updating variables or in progress task Updates the workflow variables, tasks and triggers evaluation.
/// </summary>
/// <exception cref="Conductor.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="request"></param>
/// <param name="workflowId"></param>
/// <param name="waitUntilTaskRefs"> (optional)</param>
/// <param name="waitForSeconds"> (optional, default to 10)</param>
/// <returns>WorkflowRun</returns>
WorkflowRun UpdateWorkflow(string workflowId, WorkflowStateUpdate request,
List<string> waitUntilTaskRefs = null, int? waitForSeconds = null);

#endregion Synchronous Operations

#region Asynchronous Operations
Expand Down Expand Up @@ -428,9 +454,11 @@ public interface IWorkflowResourceApi : IApiAccessor
/// <summary>
/// Asynchronous Update the value of the workflow variables for the given workflow id
/// </summary>
/// <param name="workflow"></param>
/// <returns>ApiResponse of Object(void)</returns>
ThreadTask.Task<Object> UpdateWorkflowVariablesAsync(Workflow workflow);
/// <param name="workflowId"></param>
/// /// <param name="variables"></param>
/// <returns>Workflow</returns>
ThreadTask.Task<Workflow> UpdateWorkflowVariablesAsync(string workflowId, Dictionary<string, Object> variables);


/// <summary>
/// Asynchronous Gets the workflow by workflow id
Expand All @@ -445,6 +473,18 @@ public interface IWorkflowResourceApi : IApiAccessor
/// <returns>Workflow</returns>
ThreadTask.Task<Workflow> GetExecutionStatusAsync(string workflowId, bool? includeTasks = null, bool? summarize = null);

/// <summary>
/// Asynchronous Gets the workflow by workflow id
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="Conductor.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="workflowId"></param>
/// <param name="includeTasks"> (optional, default to true)</param>
/// <returns>Workflow</returns>
ThreadTask.Task<Workflow> GetWorkflowAsync(string workflowId, bool? includeTasks = null);

/// <summary>
/// Asynchronous Gets the workflow tasks by workflow id
/// </summary>
Expand Down Expand Up @@ -758,6 +798,18 @@ public interface IWorkflowResourceApi : IApiAccessor
/// <returns>Object</returns>
ThreadTask.Task<Object> UploadCompletedWorkflowsAsync();

/// <summary>
/// Update a workflow state by updating variables or in progress task Updates the workflow variables, tasks and triggers evaluation.
/// </summary>
/// <exception cref="Conductor.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="request"></param>
/// <param name="workflowId"></param>
/// <param name="waitUntilTaskRefs"> (optional)</param>
/// <param name="waitForSeconds"> (optional, default to 10)</param>
/// <returns>WorkflowRun</returns>
ThreadTask.Task<WorkflowRun> UpdateWorkflowAsync(string workflowId, WorkflowStateUpdate request,
List<string> waitUntilTaskRefs = null, int? waitForSeconds = null);

#endregion Asynchronous Operations
}
}
135 changes: 126 additions & 9 deletions Conductor/Api/TaskResourceApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1532,14 +1532,131 @@ public ApiResponse<string> UpdateTaskWithHttpInfo(Dictionary<string, Object> bod
(string)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(string)));
}

// public ExternalStorageLocation GetExternalStorageLocation(string path, string operation, string payloadType)
// {
// throw new NotImplementedException();
// }

// public ApiResponse<ExternalStorageLocation> GetExternalStorageLocationWithHttpInfo(string path, string operation, string payloadType)
// {
// throw new NotImplementedException();
// }
/// <summary>
/// Update a task By Ref Name, evaluates the workflow and returns the updated workflow
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="Conductor.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="output"></param>
/// <param name="workflowId"></param>
/// <param name="taskRefName"></param>
/// <param name="status"></param>
/// <param name="workerid"> (optional)</param>
/// <returns>Workflow</returns>
public Workflow UpdateTaskSync(Dictionary<string, Object> output, string workflowId, string taskRefName,
TaskResult.StatusEnum status, string workerid = null)
{
var response = UpdateTaskSyncWithHttpInfo(output, workflowId, taskRefName, status, workerid);
return response.Data;
}

/// <summary>
/// Update a task By Ref Name, evaluates the workflow and returns the updated workflow
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="Conductor.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="output"></param>
/// <param name="workflowId"></param>
/// <param name="taskRefName"></param>
/// <param name="status"></param>
/// <param name="workerid"> (optional)</param>
/// <returns>Workflow</returns>
public async ThreadTask.Task<Workflow> UpdateTaskSyncAsync(Dictionary<string, Object> output, string workflowId,
string taskRefName, TaskResult.StatusEnum status, string workerid = null)
{
ApiResponse<Workflow> localVarResponse = await ThreadTask.Task.FromResult(UpdateTaskSyncWithHttpInfo(output, workflowId, taskRefName, status, workerid));
return localVarResponse.Data;
}

/// <summary>
/// Update a task By Ref Name
/// </summary>
/// <exception cref="Conductor.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="output"></param>
/// <param name="workflowId"></param>
/// <param name="taskRefName"></param>
/// <param name="status"></param>
/// <returns>ApiResponse of string</returns>
public ApiResponse<Workflow> UpdateTaskSyncWithHttpInfo(Dictionary<string, Object> 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<String, String>();
var localVarQueryParams = new List<KeyValuePair<String, String>>();
var localVarHeaderParams = new Dictionary<String, String>(this.Configuration.DefaultHeader);
var localVarFormParams = new Dictionary<String, String>();
var localVarFileParams = new Dictionary<String, FileParameter>();
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<Workflow>(localVarStatusCode,
localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)),
(Workflow)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(Workflow)));
}
}
}
Loading

0 comments on commit 00a4bec

Please sign in to comment.