From 81384804f3f96a8b65f2374df67324454c1313b1 Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Thu, 23 Nov 2023 19:20:08 +0530 Subject: [PATCH 01/20] Workflow idempotency apis --- .../client/http/api/WorkflowResourceApi.java | 601 ++++++++++++++++++ 1 file changed, 601 insertions(+) diff --git a/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java b/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java index 3b6f110f..c76c5608 100644 --- a/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java +++ b/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java @@ -4011,5 +4011,606 @@ public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Ch String[] localVarAuthNames = new String[] { "api_key" }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } + /** + * Build call for executeWorkflow + * @param body (required) + * @param requestId (required) + * @param name (required) + * @param version (required) + * @param xIdempotencyKey (optional) + * @param xOnConflict (optional) + * @param waitUntilTaskRef (optional) + * @param waitForSeconds (optional, default to 10) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + private com.squareup.okhttp.Call executeWorkflowCall(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, String xOnConflict, String waitUntilTaskRef, Integer waitForSeconds, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = body; + + // create path and map variables + String localVarPath = "/api/workflow/execute/{name}/{version}" + .replaceAll("\\{" + "name" + "\\}", apiClient.escapeString(name.toString())) + .replaceAll("\\{" + "version" + "\\}", apiClient.escapeString(version.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + if (requestId != null) + localVarQueryParams.addAll(apiClient.parameterToPair("requestId", requestId)); + if (waitUntilTaskRef != null) + localVarQueryParams.addAll(apiClient.parameterToPair("waitUntilTaskRef", waitUntilTaskRef)); + if (waitForSeconds != null) + localVarQueryParams.addAll(apiClient.parameterToPair("waitForSeconds", waitForSeconds)); + + Map localVarHeaderParams = new HashMap(); + if (xIdempotencyKey != null) + localVarHeaderParams.put("X-Idempotency-key", apiClient.parameterToString(xIdempotencyKey)); + if (xOnConflict != null) + localVarHeaderParams.put("X-on-conflict", apiClient.parameterToString(xOnConflict)); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { "api_key" }; + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call executeWorkflowValidateBeforeCall(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, String xOnConflict, String waitUntilTaskRef, Integer waitForSeconds, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException("Missing the required parameter 'body' when calling executeWorkflow(Async)"); + } + // verify the required parameter 'requestId' is set + if (requestId == null) { + throw new ApiException("Missing the required parameter 'requestId' when calling executeWorkflow(Async)"); + } + // verify the required parameter 'name' is set + if (name == null) { + throw new ApiException("Missing the required parameter 'name' when calling executeWorkflow(Async)"); + } + // verify the required parameter 'version' is set + if (version == null) { + throw new ApiException("Missing the required parameter 'version' when calling executeWorkflow(Async)"); + } + + com.squareup.okhttp.Call call = executeWorkflowCall(body, requestId, name, version, xIdempotencyKey, xOnConflict, waitUntilTaskRef, waitForSeconds, progressListener, progressRequestListener); + return call; + } + + /** + * Execute a workflow synchronously + * + * @param body (required) + * @param requestId (required) + * @param name (required) + * @param version (required) + * @param xIdempotencyKey (optional) + * @param xOnConflict (optional) + * @param waitUntilTaskRef (optional) + * @param waitForSeconds (optional, default to 10) + * @return WorkflowRun + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public WorkflowRun executeWorkflow(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, String xOnConflict, String waitUntilTaskRef, Integer waitForSeconds) throws ApiException { + ApiResponse resp = executeWorkflowWithHttpInfo(body, requestId, name, version, xIdempotencyKey, xOnConflict, waitUntilTaskRef, waitForSeconds); + return resp.getData(); + } + + /** + * Execute a workflow synchronously + * + * @param body (required) + * @param requestId (required) + * @param name (required) + * @param version (required) + * @param xIdempotencyKey (optional) + * @param xOnConflict (optional) + * @param waitUntilTaskRef (optional) + * @param waitForSeconds (optional, default to 10) + * @return ApiResponse<WorkflowRun> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + private ApiResponse executeWorkflowWithHttpInfo(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, String xOnConflict, String waitUntilTaskRef, Integer waitForSeconds) throws ApiException { + com.squareup.okhttp.Call call = executeWorkflowValidateBeforeCall(body, requestId, name, version, xIdempotencyKey, xOnConflict, waitUntilTaskRef, waitForSeconds, null, null); + Type localVarReturnType = new TypeReference(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + /** + * Build call for executeWorkflowAsAPI + * @param body (required) + * @param name (required) + * @param requestId (optional) + * @param waitUntilTaskRef (optional) + * @param waitForSeconds (optional, default to 10) + * @param authorization (optional) + * @param xIdempotencyKey (optional) + * @param xOnConflict (optional) + * @param version (optional) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + private com.squareup.okhttp.Call executeWorkflowAsAPICall(Map body, String name, String requestId, String waitUntilTaskRef, Integer waitForSeconds, String authorization, String xIdempotencyKey, String xOnConflict, Integer version, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = body; + + // create path and map variables + String localVarPath = "/api/workflow/execute/{name}" + .replaceAll("\\{" + "name" + "\\}", apiClient.escapeString(name.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + if (version != null) + localVarQueryParams.addAll(apiClient.parameterToPair("version", version)); + + Map localVarHeaderParams = new HashMap(); + if (requestId != null) + localVarHeaderParams.put("requestId", apiClient.parameterToString(requestId)); + if (waitUntilTaskRef != null) + localVarHeaderParams.put("waitUntilTaskRef", apiClient.parameterToString(waitUntilTaskRef)); + if (waitForSeconds != null) + localVarHeaderParams.put("waitForSeconds", apiClient.parameterToString(waitForSeconds)); + if (authorization != null) + localVarHeaderParams.put("authorization", apiClient.parameterToString(authorization)); + if (xIdempotencyKey != null) + localVarHeaderParams.put("X-Idempotency-key", apiClient.parameterToString(xIdempotencyKey)); + if (xOnConflict != null) + localVarHeaderParams.put("X-on-conflict", apiClient.parameterToString(xOnConflict)); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { "api_key" }; + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call executeWorkflowAsAPIValidateBeforeCall(Map body, String name, String requestId, String waitUntilTaskRef, Integer waitForSeconds, String authorization, String xIdempotencyKey, String xOnConflict, Integer version, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException("Missing the required parameter 'body' when calling executeWorkflowAsAPI(Async)"); + } + // verify the required parameter 'name' is set + if (name == null) { + throw new ApiException("Missing the required parameter 'name' when calling executeWorkflowAsAPI(Async)"); + } + + com.squareup.okhttp.Call call = executeWorkflowAsAPICall(body, name, requestId, waitUntilTaskRef, waitForSeconds, authorization, xIdempotencyKey, xOnConflict, version, progressListener, progressRequestListener); + return call; + } + + /** + * Execute a workflow synchronously with input and outputs + * + * @param body (required) + * @param name (required) + * @param requestId (optional) + * @param waitUntilTaskRef (optional) + * @param waitForSeconds (optional, default to 10) + * @param authorization (optional) + * @param xIdempotencyKey (optional) + * @param xOnConflict (optional) + * @param version (optional) + * @return Map<String, Object> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public Map executeWorkflowAsAPI(Map body, String name, String requestId, String waitUntilTaskRef, Integer waitForSeconds, String authorization, String xIdempotencyKey, String xOnConflict, Integer version) throws ApiException { + ApiResponse> resp = executeWorkflowAsAPIWithHttpInfo(body, name, requestId, waitUntilTaskRef, waitForSeconds, authorization, xIdempotencyKey, xOnConflict, version); + return resp.getData(); + } + + /** + * Execute a workflow synchronously with input and outputs + * + * @param body (required) + * @param name (required) + * @param requestId (optional) + * @param waitUntilTaskRef (optional) + * @param waitForSeconds (optional, default to 10) + * @param authorization (optional) + * @param xIdempotencyKey (optional) + * @param xOnConflict (optional) + * @param version (optional) + * @return ApiResponse<Map<String, Object>> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + private ApiResponse> executeWorkflowAsAPIWithHttpInfo(Map body, String name, String requestId, String waitUntilTaskRef, Integer waitForSeconds, String authorization, String xIdempotencyKey, String xOnConflict, Integer version) throws ApiException { + com.squareup.okhttp.Call call = executeWorkflowAsAPIValidateBeforeCall(body, name, requestId, waitUntilTaskRef, waitForSeconds, authorization, xIdempotencyKey, xOnConflict, version, null, null); + Type localVarReturnType = new TypeReference>(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + /** + * Execute a workflow synchronously with input and outputs using get api + * + * @param name (required) + * @param version (optional) + * @param requestId (optional) + * @param waitUntilTaskRef (optional) + * @param waitForSeconds (optional, default to 10) + * @param authorization (optional) + * @param xIdempotencyKey (optional) + * @param xOnConflict (optional) + * @return Map<String, Object> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public Map executeWorkflowAsGetAPI(String name, Integer version, String requestId, String waitUntilTaskRef, Integer waitForSeconds, String authorization, String xIdempotencyKey, String xOnConflict) throws ApiException { + ApiResponse> resp = executeWorkflowAsGetAPIWithHttpInfo(name, version, requestId, waitUntilTaskRef, waitForSeconds, authorization, xIdempotencyKey, xOnConflict); + return resp.getData(); + } + + /** + * Execute a workflow synchronously with input and outputs using get api + * + * @param name (required) + * @param version (optional) + * @param requestId (optional) + * @param waitUntilTaskRef (optional) + * @param waitForSeconds (optional, default to 10) + * @param authorization (optional) + * @param xIdempotencyKey (optional) + * @param xOnConflict (optional) + * @return ApiResponse<Map<String, Object>> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + private ApiResponse> executeWorkflowAsGetAPIWithHttpInfo(String name, Integer version, String requestId, String waitUntilTaskRef, Integer waitForSeconds, String authorization, String xIdempotencyKey, String xOnConflict) throws ApiException { + com.squareup.okhttp.Call call = executeWorkflowAsGetAPIValidateBeforeCall(name, version, requestId, waitUntilTaskRef, waitForSeconds, authorization, xIdempotencyKey, xOnConflict, null, null); + Type localVarReturnType = new TypeReference>(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call executeWorkflowAsGetAPIValidateBeforeCall(String name, Integer version, String requestId, String waitUntilTaskRef, Integer waitForSeconds, String authorization, String xIdempotencyKey, String xOnConflict, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + // verify the required parameter 'name' is set + if (name == null) { + throw new ApiException("Missing the required parameter 'name' when calling executeWorkflowAsGetAPI(Async)"); + } + + com.squareup.okhttp.Call call = executeWorkflowAsGetAPICall(name, version, requestId, waitUntilTaskRef, waitForSeconds, authorization, xIdempotencyKey, xOnConflict, progressListener, progressRequestListener); + return call; + } + + /** + * Build call for executeWorkflowAsGetAPI + * @param name (required) + * @param version (optional) + * @param requestId (optional) + * @param waitUntilTaskRef (optional) + * @param waitForSeconds (optional, default to 10) + * @param authorization (optional) + * @param xIdempotencyKey (optional) + * @param xOnConflict (optional) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + private com.squareup.okhttp.Call executeWorkflowAsGetAPICall(String name, Integer version, String requestId, String waitUntilTaskRef, Integer waitForSeconds, String authorization, String xIdempotencyKey, String xOnConflict, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/api/workflow/execute/{name}" + .replaceAll("\\{" + "name" + "\\}", apiClient.escapeString(name.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + if (version != null) + localVarQueryParams.addAll(apiClient.parameterToPair("version", version)); + + Map localVarHeaderParams = new HashMap(); + if (requestId != null) + localVarHeaderParams.put("requestId", apiClient.parameterToString(requestId)); + if (waitUntilTaskRef != null) + localVarHeaderParams.put("waitUntilTaskRef", apiClient.parameterToString(waitUntilTaskRef)); + if (waitForSeconds != null) + localVarHeaderParams.put("waitForSeconds", apiClient.parameterToString(waitForSeconds)); + if (authorization != null) + localVarHeaderParams.put("authorization", apiClient.parameterToString(authorization)); + if (xIdempotencyKey != null) + localVarHeaderParams.put("X-Idempotency-key", apiClient.parameterToString(xIdempotencyKey)); + if (xOnConflict != null) + localVarHeaderParams.put("X-on-conflict", apiClient.parameterToString(xOnConflict)); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { "api_key" }; + return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + /** + * Build call for startWorkflow + * @param body (required) + * @param xIdempotencyKey (optional) + * @param xOnConflict (optional) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + public com.squareup.okhttp.Call startWorkflowCall(StartWorkflowRequest body, String xIdempotencyKey, String xOnConflict, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = body; + + // create path and map variables + String localVarPath = "/api/workflow"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + if (xIdempotencyKey != null) + localVarHeaderParams.put("X-Idempotency-key", apiClient.parameterToString(xIdempotencyKey)); + if (xOnConflict != null) + localVarHeaderParams.put("X-on-conflict", apiClient.parameterToString(xOnConflict)); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "text/plain" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { "api_key" }; + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call startWorkflowValidateBeforeCall(StartWorkflowRequest body, String xIdempotencyKey, String xOnConflict, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException("Missing the required parameter 'body' when calling startWorkflow(Async)"); + } + + com.squareup.okhttp.Call call = startWorkflowCall(body, xIdempotencyKey, xOnConflict, progressListener, progressRequestListener); + return call; + + + + + + } + + /** + * Start a new workflow with StartWorkflowRequest, which allows task to be executed in a domain + * + * @param body (required) + * @param xIdempotencyKey (optional) + * @param xOnConflict (optional) + * @return String + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public String startWorkflow(StartWorkflowRequest body, String xIdempotencyKey, String xOnConflict) throws ApiException { + ApiResponse resp = startWorkflowWithHttpInfo(body, xIdempotencyKey, xOnConflict); + return resp.getData(); + } + + /** + * Start a new workflow with StartWorkflowRequest, which allows task to be executed in a domain + * + * @param body (required) + * @param xIdempotencyKey (optional) + * @param xOnConflict (optional) + * @return ApiResponse<String> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + private ApiResponse startWorkflowWithHttpInfo(StartWorkflowRequest body, String xIdempotencyKey, String xOnConflict) throws ApiException { + com.squareup.okhttp.Call call = startWorkflowValidateBeforeCall(body, xIdempotencyKey, xOnConflict, null, null); + Type localVarReturnType = new TypeReference(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + /** + * Build call for startWorkflow1 + * @param body (required) + * @param name (required) + * @param xIdempotencyKey (optional) + * @param xOnConflict (optional) + * @param version (optional) + * @param correlationId (optional) + * @param priority (optional, default to 0) + * @param progressListener Progress listener + * @param progressRequestListener Progress request listener + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + */ + private com.squareup.okhttp.Call startWorkflow1Call(Map body, String name, String xIdempotencyKey, String xOnConflict, Integer version, String correlationId, Integer priority, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = body; + + // create path and map variables + String localVarPath = "/api/workflow/{name}" + .replaceAll("\\{" + "name" + "\\}", apiClient.escapeString(name.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + if (version != null) + localVarQueryParams.addAll(apiClient.parameterToPair("version", version)); + if (correlationId != null) + localVarQueryParams.addAll(apiClient.parameterToPair("correlationId", correlationId)); + if (priority != null) + localVarQueryParams.addAll(apiClient.parameterToPair("priority", priority)); + + Map localVarHeaderParams = new HashMap(); + if (xIdempotencyKey != null) + localVarHeaderParams.put("X-Idempotency-key", apiClient.parameterToString(xIdempotencyKey)); + if (xOnConflict != null) + localVarHeaderParams.put("X-on-conflict", apiClient.parameterToString(xOnConflict)); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "text/plain" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { "api_key" }; + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call startWorkflow1ValidateBeforeCall(Map body, String name, String xIdempotencyKey, String xOnConflict, Integer version, String correlationId, Integer priority, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException("Missing the required parameter 'body' when calling startWorkflow1(Async)"); + } + // verify the required parameter 'name' is set + if (name == null) { + throw new ApiException("Missing the required parameter 'name' when calling startWorkflow1(Async)"); + } + + com.squareup.okhttp.Call call = startWorkflow1Call(body, name, xIdempotencyKey, xOnConflict, version, correlationId, priority, progressListener, progressRequestListener); + return call; + + + + + + } + + /** + * Start a new workflow. Returns the ID of the workflow instance that can be later used for tracking + * + * @param body (required) + * @param name (required) + * @param xIdempotencyKey (optional) + * @param xOnConflict (optional) + * @param version (optional) + * @param correlationId (optional) + * @param priority (optional, default to 0) + * @return String + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public String startWorkflow1(Map body, String name, String xIdempotencyKey, String xOnConflict, Integer version, String correlationId, Integer priority) throws ApiException { + ApiResponse resp = startWorkflow1WithHttpInfo(body, name, xIdempotencyKey, xOnConflict, version, correlationId, priority); + return resp.getData(); + } + + /** + * Start a new workflow. Returns the ID of the workflow instance that can be later used for tracking + * + * @param body (required) + * @param name (required) + * @param xIdempotencyKey (optional) + * @param xOnConflict (optional) + * @param version (optional) + * @param correlationId (optional) + * @param priority (optional, default to 0) + * @return ApiResponse<String> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + private ApiResponse startWorkflow1WithHttpInfo(Map body, String name, String xIdempotencyKey, String xOnConflict, Integer version, String correlationId, Integer priority) throws ApiException { + com.squareup.okhttp.Call call = startWorkflow1ValidateBeforeCall(body, name, xIdempotencyKey, xOnConflict, version, correlationId, priority, null, null); + Type localVarReturnType = new TypeReference(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } } From a7448f74e3fcfc86a29fbecb054da19a3efa805c Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Thu, 23 Nov 2023 21:41:30 +0530 Subject: [PATCH 02/20] changes --- .../conductor/client/WorkflowClient.java | 3 + .../client/http/api/WorkflowResourceApi.java | 375 +----------------- 2 files changed, 14 insertions(+), 364 deletions(-) diff --git a/src/main/java/io/orkes/conductor/client/WorkflowClient.java b/src/main/java/io/orkes/conductor/client/WorkflowClient.java index 9b443c2b..16c850fd 100644 --- a/src/main/java/io/orkes/conductor/client/WorkflowClient.java +++ b/src/main/java/io/orkes/conductor/client/WorkflowClient.java @@ -19,6 +19,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; +import com.netflix.conductor.common.metadata.workflow.IdempotencyStrategy; import com.netflix.conductor.common.metadata.workflow.StartWorkflowRequest; import com.netflix.conductor.common.metadata.workflow.UpgradeWorkflowRequest; import com.netflix.conductor.common.model.BulkResponse; @@ -38,6 +39,8 @@ public abstract class WorkflowClient extends com.netflix.conductor.client.http.W public abstract CompletableFuture executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Integer waitForSeconds); public abstract WorkflowRun executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Duration waitTimeout) throws ExecutionException, InterruptedException, TimeoutException; + public abstract CompletableFuture executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Integer waitForSeconds, String xIdempotencyKey, IdempotencyStrategy xOnConflict ); + public abstract WorkflowRun executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Duration waitTimeout, String xIdempotencyKey, IdempotencyStrategy xOnConflict) throws ExecutionException, InterruptedException, TimeoutException; public abstract BulkResponse pauseWorkflow(List workflowIds) throws ApiException; diff --git a/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java b/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java index c76c5608..b261d67f 100644 --- a/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java +++ b/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java @@ -20,6 +20,7 @@ import java.util.Map; import com.netflix.conductor.common.metadata.workflow.*; +import com.netflix.conductor.common.metadata.workflow.IdempotencyStrategy; import com.netflix.conductor.common.run.Workflow; import com.netflix.conductor.common.run.WorkflowTestRequest; @@ -4026,11 +4027,11 @@ public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Ch * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - private com.squareup.okhttp.Call executeWorkflowCall(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, String xOnConflict, String waitUntilTaskRef, Integer waitForSeconds, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private com.squareup.okhttp.Call executeWorkflowCall(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTaskRef, Integer waitForSeconds, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; // create path and map variables - String localVarPath = "/api/workflow/execute/{name}/{version}" + String localVarPath = "/workflow/execute/{name}/{version}" .replaceAll("\\{" + "name" + "\\}", apiClient.escapeString(name.toString())) .replaceAll("\\{" + "version" + "\\}", apiClient.escapeString(version.toString())); @@ -4080,7 +4081,7 @@ public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Ch } @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call executeWorkflowValidateBeforeCall(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, String xOnConflict, String waitUntilTaskRef, Integer waitForSeconds, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private com.squareup.okhttp.Call executeWorkflowValidateBeforeCall(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTaskRef, Integer waitForSeconds, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { // verify the required parameter 'body' is set if (body == null) { throw new ApiException("Missing the required parameter 'body' when calling executeWorkflow(Async)"); @@ -4116,7 +4117,7 @@ private com.squareup.okhttp.Call executeWorkflowValidateBeforeCall(StartWorkflow * @return WorkflowRun * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public WorkflowRun executeWorkflow(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, String xOnConflict, String waitUntilTaskRef, Integer waitForSeconds) throws ApiException { + public WorkflowRun executeWorkflow(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTaskRef, Integer waitForSeconds) throws ApiException { ApiResponse resp = executeWorkflowWithHttpInfo(body, requestId, name, version, xIdempotencyKey, xOnConflict, waitUntilTaskRef, waitForSeconds); return resp.getData(); } @@ -4135,361 +4136,12 @@ public WorkflowRun executeWorkflow(StartWorkflowRequest body, String requestId, * @return ApiResponse<WorkflowRun> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - private ApiResponse executeWorkflowWithHttpInfo(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, String xOnConflict, String waitUntilTaskRef, Integer waitForSeconds) throws ApiException { + private ApiResponse executeWorkflowWithHttpInfo(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTaskRef, Integer waitForSeconds) throws ApiException { com.squareup.okhttp.Call call = executeWorkflowValidateBeforeCall(body, requestId, name, version, xIdempotencyKey, xOnConflict, waitUntilTaskRef, waitForSeconds, null, null); Type localVarReturnType = new TypeReference(){}.getType(); return apiClient.execute(call, localVarReturnType); } - /** - * Build call for executeWorkflowAsAPI - * @param body (required) - * @param name (required) - * @param requestId (optional) - * @param waitUntilTaskRef (optional) - * @param waitForSeconds (optional, default to 10) - * @param authorization (optional) - * @param xIdempotencyKey (optional) - * @param xOnConflict (optional) - * @param version (optional) - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - private com.squareup.okhttp.Call executeWorkflowAsAPICall(Map body, String name, String requestId, String waitUntilTaskRef, Integer waitForSeconds, String authorization, String xIdempotencyKey, String xOnConflict, Integer version, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = body; - - // create path and map variables - String localVarPath = "/api/workflow/execute/{name}" - .replaceAll("\\{" + "name" + "\\}", apiClient.escapeString(name.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - if (version != null) - localVarQueryParams.addAll(apiClient.parameterToPair("version", version)); - - Map localVarHeaderParams = new HashMap(); - if (requestId != null) - localVarHeaderParams.put("requestId", apiClient.parameterToString(requestId)); - if (waitUntilTaskRef != null) - localVarHeaderParams.put("waitUntilTaskRef", apiClient.parameterToString(waitUntilTaskRef)); - if (waitForSeconds != null) - localVarHeaderParams.put("waitForSeconds", apiClient.parameterToString(waitForSeconds)); - if (authorization != null) - localVarHeaderParams.put("authorization", apiClient.parameterToString(authorization)); - if (xIdempotencyKey != null) - localVarHeaderParams.put("X-Idempotency-key", apiClient.parameterToString(xIdempotencyKey)); - if (xOnConflict != null) - localVarHeaderParams.put("X-on-conflict", apiClient.parameterToString(xOnConflict)); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call executeWorkflowAsAPIValidateBeforeCall(Map body, String name, String requestId, String waitUntilTaskRef, Integer waitForSeconds, String authorization, String xIdempotencyKey, String xOnConflict, Integer version, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException("Missing the required parameter 'body' when calling executeWorkflowAsAPI(Async)"); - } - // verify the required parameter 'name' is set - if (name == null) { - throw new ApiException("Missing the required parameter 'name' when calling executeWorkflowAsAPI(Async)"); - } - - com.squareup.okhttp.Call call = executeWorkflowAsAPICall(body, name, requestId, waitUntilTaskRef, waitForSeconds, authorization, xIdempotencyKey, xOnConflict, version, progressListener, progressRequestListener); - return call; - } - - /** - * Execute a workflow synchronously with input and outputs - * - * @param body (required) - * @param name (required) - * @param requestId (optional) - * @param waitUntilTaskRef (optional) - * @param waitForSeconds (optional, default to 10) - * @param authorization (optional) - * @param xIdempotencyKey (optional) - * @param xOnConflict (optional) - * @param version (optional) - * @return Map<String, Object> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public Map executeWorkflowAsAPI(Map body, String name, String requestId, String waitUntilTaskRef, Integer waitForSeconds, String authorization, String xIdempotencyKey, String xOnConflict, Integer version) throws ApiException { - ApiResponse> resp = executeWorkflowAsAPIWithHttpInfo(body, name, requestId, waitUntilTaskRef, waitForSeconds, authorization, xIdempotencyKey, xOnConflict, version); - return resp.getData(); - } - - /** - * Execute a workflow synchronously with input and outputs - * - * @param body (required) - * @param name (required) - * @param requestId (optional) - * @param waitUntilTaskRef (optional) - * @param waitForSeconds (optional, default to 10) - * @param authorization (optional) - * @param xIdempotencyKey (optional) - * @param xOnConflict (optional) - * @param version (optional) - * @return ApiResponse<Map<String, Object>> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - private ApiResponse> executeWorkflowAsAPIWithHttpInfo(Map body, String name, String requestId, String waitUntilTaskRef, Integer waitForSeconds, String authorization, String xIdempotencyKey, String xOnConflict, Integer version) throws ApiException { - com.squareup.okhttp.Call call = executeWorkflowAsAPIValidateBeforeCall(body, name, requestId, waitUntilTaskRef, waitForSeconds, authorization, xIdempotencyKey, xOnConflict, version, null, null); - Type localVarReturnType = new TypeReference>(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Execute a workflow synchronously with input and outputs using get api - * - * @param name (required) - * @param version (optional) - * @param requestId (optional) - * @param waitUntilTaskRef (optional) - * @param waitForSeconds (optional, default to 10) - * @param authorization (optional) - * @param xIdempotencyKey (optional) - * @param xOnConflict (optional) - * @return Map<String, Object> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public Map executeWorkflowAsGetAPI(String name, Integer version, String requestId, String waitUntilTaskRef, Integer waitForSeconds, String authorization, String xIdempotencyKey, String xOnConflict) throws ApiException { - ApiResponse> resp = executeWorkflowAsGetAPIWithHttpInfo(name, version, requestId, waitUntilTaskRef, waitForSeconds, authorization, xIdempotencyKey, xOnConflict); - return resp.getData(); - } - - /** - * Execute a workflow synchronously with input and outputs using get api - * - * @param name (required) - * @param version (optional) - * @param requestId (optional) - * @param waitUntilTaskRef (optional) - * @param waitForSeconds (optional, default to 10) - * @param authorization (optional) - * @param xIdempotencyKey (optional) - * @param xOnConflict (optional) - * @return ApiResponse<Map<String, Object>> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - private ApiResponse> executeWorkflowAsGetAPIWithHttpInfo(String name, Integer version, String requestId, String waitUntilTaskRef, Integer waitForSeconds, String authorization, String xIdempotencyKey, String xOnConflict) throws ApiException { - com.squareup.okhttp.Call call = executeWorkflowAsGetAPIValidateBeforeCall(name, version, requestId, waitUntilTaskRef, waitForSeconds, authorization, xIdempotencyKey, xOnConflict, null, null); - Type localVarReturnType = new TypeReference>(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call executeWorkflowAsGetAPIValidateBeforeCall(String name, Integer version, String requestId, String waitUntilTaskRef, Integer waitForSeconds, String authorization, String xIdempotencyKey, String xOnConflict, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - // verify the required parameter 'name' is set - if (name == null) { - throw new ApiException("Missing the required parameter 'name' when calling executeWorkflowAsGetAPI(Async)"); - } - - com.squareup.okhttp.Call call = executeWorkflowAsGetAPICall(name, version, requestId, waitUntilTaskRef, waitForSeconds, authorization, xIdempotencyKey, xOnConflict, progressListener, progressRequestListener); - return call; - } - - /** - * Build call for executeWorkflowAsGetAPI - * @param name (required) - * @param version (optional) - * @param requestId (optional) - * @param waitUntilTaskRef (optional) - * @param waitForSeconds (optional, default to 10) - * @param authorization (optional) - * @param xIdempotencyKey (optional) - * @param xOnConflict (optional) - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - private com.squareup.okhttp.Call executeWorkflowAsGetAPICall(String name, Integer version, String requestId, String waitUntilTaskRef, Integer waitForSeconds, String authorization, String xIdempotencyKey, String xOnConflict, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/api/workflow/execute/{name}" - .replaceAll("\\{" + "name" + "\\}", apiClient.escapeString(name.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - if (version != null) - localVarQueryParams.addAll(apiClient.parameterToPair("version", version)); - - Map localVarHeaderParams = new HashMap(); - if (requestId != null) - localVarHeaderParams.put("requestId", apiClient.parameterToString(requestId)); - if (waitUntilTaskRef != null) - localVarHeaderParams.put("waitUntilTaskRef", apiClient.parameterToString(waitUntilTaskRef)); - if (waitForSeconds != null) - localVarHeaderParams.put("waitForSeconds", apiClient.parameterToString(waitForSeconds)); - if (authorization != null) - localVarHeaderParams.put("authorization", apiClient.parameterToString(authorization)); - if (xIdempotencyKey != null) - localVarHeaderParams.put("X-Idempotency-key", apiClient.parameterToString(xIdempotencyKey)); - if (xOnConflict != null) - localVarHeaderParams.put("X-on-conflict", apiClient.parameterToString(xOnConflict)); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - /** - * Build call for startWorkflow - * @param body (required) - * @param xIdempotencyKey (optional) - * @param xOnConflict (optional) - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call startWorkflowCall(StartWorkflowRequest body, String xIdempotencyKey, String xOnConflict, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = body; - - // create path and map variables - String localVarPath = "/api/workflow"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - if (xIdempotencyKey != null) - localVarHeaderParams.put("X-Idempotency-key", apiClient.parameterToString(xIdempotencyKey)); - if (xOnConflict != null) - localVarHeaderParams.put("X-on-conflict", apiClient.parameterToString(xOnConflict)); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "text/plain" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call startWorkflowValidateBeforeCall(StartWorkflowRequest body, String xIdempotencyKey, String xOnConflict, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException("Missing the required parameter 'body' when calling startWorkflow(Async)"); - } - - com.squareup.okhttp.Call call = startWorkflowCall(body, xIdempotencyKey, xOnConflict, progressListener, progressRequestListener); - return call; - - - - - - } - - /** - * Start a new workflow with StartWorkflowRequest, which allows task to be executed in a domain - * - * @param body (required) - * @param xIdempotencyKey (optional) - * @param xOnConflict (optional) - * @return String - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public String startWorkflow(StartWorkflowRequest body, String xIdempotencyKey, String xOnConflict) throws ApiException { - ApiResponse resp = startWorkflowWithHttpInfo(body, xIdempotencyKey, xOnConflict); - return resp.getData(); - } - - /** - * Start a new workflow with StartWorkflowRequest, which allows task to be executed in a domain - * - * @param body (required) - * @param xIdempotencyKey (optional) - * @param xOnConflict (optional) - * @return ApiResponse<String> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - private ApiResponse startWorkflowWithHttpInfo(StartWorkflowRequest body, String xIdempotencyKey, String xOnConflict) throws ApiException { - com.squareup.okhttp.Call call = startWorkflowValidateBeforeCall(body, xIdempotencyKey, xOnConflict, null, null); - Type localVarReturnType = new TypeReference(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - /** * Build call for startWorkflow1 * @param body (required) @@ -4504,11 +4156,11 @@ private ApiResponse startWorkflowWithHttpInfo(StartWorkflowRequest body, * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - private com.squareup.okhttp.Call startWorkflow1Call(Map body, String name, String xIdempotencyKey, String xOnConflict, Integer version, String correlationId, Integer priority, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private com.squareup.okhttp.Call startWorkflow1Call(Map body, String name, String xIdempotencyKey, IdempotencyStrategy xOnConflict, Integer version, String correlationId, Integer priority, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; // create path and map variables - String localVarPath = "/api/workflow/{name}" + String localVarPath = "/workflow/{name}" .replaceAll("\\{" + "name" + "\\}", apiClient.escapeString(name.toString())); List localVarQueryParams = new ArrayList(); @@ -4557,7 +4209,7 @@ public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Ch } @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call startWorkflow1ValidateBeforeCall(Map body, String name, String xIdempotencyKey, String xOnConflict, Integer version, String correlationId, Integer priority, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private com.squareup.okhttp.Call startWorkflow1ValidateBeforeCall(Map body, String name, String xIdempotencyKey, IdempotencyStrategy xOnConflict, Integer version, String correlationId, Integer priority, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { // verify the required parameter 'body' is set if (body == null) { throw new ApiException("Missing the required parameter 'body' when calling startWorkflow1(Async)"); @@ -4569,11 +4221,6 @@ private com.squareup.okhttp.Call startWorkflow1ValidateBeforeCall(Map body, String name, String xIdempotencyKey, String xOnConflict, Integer version, String correlationId, Integer priority) throws ApiException { + public String startWorkflow1(Map body, String name, String xIdempotencyKey, IdempotencyStrategy xOnConflict, Integer version, String correlationId, Integer priority) throws ApiException { ApiResponse resp = startWorkflow1WithHttpInfo(body, name, xIdempotencyKey, xOnConflict, version, correlationId, priority); return resp.getData(); } @@ -4607,7 +4254,7 @@ public String startWorkflow1(Map body, String name, String xIdem * @return ApiResponse<String> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - private ApiResponse startWorkflow1WithHttpInfo(Map body, String name, String xIdempotencyKey, String xOnConflict, Integer version, String correlationId, Integer priority) throws ApiException { + private ApiResponse startWorkflow1WithHttpInfo(Map body, String name, String xIdempotencyKey, IdempotencyStrategy xOnConflict, Integer version, String correlationId, Integer priority) throws ApiException { com.squareup.okhttp.Call call = startWorkflow1ValidateBeforeCall(body, name, xIdempotencyKey, xOnConflict, version, correlationId, priority, null, null); Type localVarReturnType = new TypeReference(){}.getType(); return apiClient.execute(call, localVarReturnType); From bf6c72b1ffff416b8f529cb26a5326ccaed4ca8f Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Wed, 29 Nov 2023 12:33:55 +0530 Subject: [PATCH 03/20] Use local image --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b30bfed4..2706f196 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ ext { versions = [ awaitility : '4.2.0', commonsLang : '3.12.0', - conductor : '3.9.21-orkes', + conductor : '3.9.23-SNAPSHOT', jackson : '2.11.4!!', junit : '5.9.0', slf4j : '1.7.36', From 98872ce5d3df9015c24e6befa8b18de0c3c9d73e Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Wed, 29 Nov 2023 18:23:49 +0530 Subject: [PATCH 04/20] changes --- .../client/http/api/WorkflowResourceApi.java | 118 ------------------ 1 file changed, 118 deletions(-) diff --git a/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java b/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java index b261d67f..a3c0b2d6 100644 --- a/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java +++ b/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java @@ -4142,122 +4142,4 @@ private ApiResponse executeWorkflowWithHttpInfo(StartWorkflowReques return apiClient.execute(call, localVarReturnType); } - /** - * Build call for startWorkflow1 - * @param body (required) - * @param name (required) - * @param xIdempotencyKey (optional) - * @param xOnConflict (optional) - * @param version (optional) - * @param correlationId (optional) - * @param priority (optional, default to 0) - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - private com.squareup.okhttp.Call startWorkflow1Call(Map body, String name, String xIdempotencyKey, IdempotencyStrategy xOnConflict, Integer version, String correlationId, Integer priority, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = body; - - // create path and map variables - String localVarPath = "/workflow/{name}" - .replaceAll("\\{" + "name" + "\\}", apiClient.escapeString(name.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - if (version != null) - localVarQueryParams.addAll(apiClient.parameterToPair("version", version)); - if (correlationId != null) - localVarQueryParams.addAll(apiClient.parameterToPair("correlationId", correlationId)); - if (priority != null) - localVarQueryParams.addAll(apiClient.parameterToPair("priority", priority)); - - Map localVarHeaderParams = new HashMap(); - if (xIdempotencyKey != null) - localVarHeaderParams.put("X-Idempotency-key", apiClient.parameterToString(xIdempotencyKey)); - if (xOnConflict != null) - localVarHeaderParams.put("X-on-conflict", apiClient.parameterToString(xOnConflict)); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "text/plain" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call startWorkflow1ValidateBeforeCall(Map body, String name, String xIdempotencyKey, IdempotencyStrategy xOnConflict, Integer version, String correlationId, Integer priority, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException("Missing the required parameter 'body' when calling startWorkflow1(Async)"); - } - // verify the required parameter 'name' is set - if (name == null) { - throw new ApiException("Missing the required parameter 'name' when calling startWorkflow1(Async)"); - } - - com.squareup.okhttp.Call call = startWorkflow1Call(body, name, xIdempotencyKey, xOnConflict, version, correlationId, priority, progressListener, progressRequestListener); - return call; - } - - /** - * Start a new workflow. Returns the ID of the workflow instance that can be later used for tracking - * - * @param body (required) - * @param name (required) - * @param xIdempotencyKey (optional) - * @param xOnConflict (optional) - * @param version (optional) - * @param correlationId (optional) - * @param priority (optional, default to 0) - * @return String - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public String startWorkflow1(Map body, String name, String xIdempotencyKey, IdempotencyStrategy xOnConflict, Integer version, String correlationId, Integer priority) throws ApiException { - ApiResponse resp = startWorkflow1WithHttpInfo(body, name, xIdempotencyKey, xOnConflict, version, correlationId, priority); - return resp.getData(); - } - - /** - * Start a new workflow. Returns the ID of the workflow instance that can be later used for tracking - * - * @param body (required) - * @param name (required) - * @param xIdempotencyKey (optional) - * @param xOnConflict (optional) - * @param version (optional) - * @param correlationId (optional) - * @param priority (optional, default to 0) - * @return ApiResponse<String> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - private ApiResponse startWorkflow1WithHttpInfo(Map body, String name, String xIdempotencyKey, IdempotencyStrategy xOnConflict, Integer version, String correlationId, Integer priority) throws ApiException { - com.squareup.okhttp.Call call = startWorkflow1ValidateBeforeCall(body, name, xIdempotencyKey, xOnConflict, version, correlationId, priority, null, null); - Type localVarReturnType = new TypeReference(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - } From ca65afdf2cf4ac8751fbf27ecda20117c137d23a Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Wed, 29 Nov 2023 18:44:19 +0530 Subject: [PATCH 05/20] Sync clients --- .../client/http/OrkesWorkflowClient.java | 60 +++++++++++++ .../client/http/api/WorkflowResourceApi.java | 86 +++++++++++++++++++ 2 files changed, 146 insertions(+) diff --git a/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java b/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java index 5610ad18..baea94e5 100644 --- a/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java +++ b/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java @@ -115,6 +115,17 @@ public WorkflowRun executeWorkflow(StartWorkflowRequest request, String waitUnti return future.get(waitTimeout.get(ChronoUnit.MILLIS), TimeUnit.MILLISECONDS); } + @Override + public CompletableFuture executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Integer waitForSeconds, String xIdempotencyKey, IdempotencyStrategy xOnConflict) { + return executeWorkflowWithIdempotencyHttp(request, xIdempotencyKey, xOnConflict, waitUntilTask, waitForSeconds); + } + + @Override + public WorkflowRun executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Duration waitTimeout, String xIdempotencyKey, IdempotencyStrategy xOnConflict) throws ExecutionException, InterruptedException, TimeoutException { + CompletableFuture future = executeWorkflowWithIdempotencyHttp(request, xIdempotencyKey, xOnConflict, waitUntilTask); + return future.get(waitTimeout.get(ChronoUnit.MILLIS), TimeUnit.MILLISECONDS); + } + private CompletableFuture executeWorkflowHttp(StartWorkflowRequest startWorkflowRequest, String waitUntilTask) { CompletableFuture future = new CompletableFuture<>(); String requestId = UUID.randomUUID().toString(); @@ -160,6 +171,55 @@ private CompletableFuture executeWorkflowHttp(StartWorkflowRequest return future; } + private CompletableFuture executeWorkflowWithIdempotencyHttp(StartWorkflowRequest startWorkflowRequest, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTask, Integer waitForSeconds) { + CompletableFuture future = new CompletableFuture<>(); + String requestId = UUID.randomUUID().toString(); + executorService.submit( + () -> { + try { + WorkflowRun response = + httpClient.executeWorkflow( + startWorkflowRequest, + requestId, + startWorkflowRequest.getName(), + startWorkflowRequest.getVersion(), + xIdempotencyKey, + xOnConflict, + waitUntilTask, + waitForSeconds); + future.complete(response); + } catch (Throwable t) { + future.completeExceptionally(t); + } + }); + + return future; + } + + private CompletableFuture executeWorkflowWithIdempotencyHttp(StartWorkflowRequest startWorkflowRequest, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTask) { + CompletableFuture future = new CompletableFuture<>(); + String requestId = UUID.randomUUID().toString(); + executorService.submit( + () -> { + try { + WorkflowRun response = + httpClient.executeWorkflow( + startWorkflowRequest, + requestId, + startWorkflowRequest.getName(), + startWorkflowRequest.getVersion(), + xIdempotencyKey, + xOnConflict, + waitUntilTask); + future.complete(response); + } catch (Throwable t) { + future.completeExceptionally(t); + } + }); + + return future; + } + @Override public Workflow getWorkflow(String workflowId, boolean includeTasks) { return httpClient.getExecutionStatus(workflowId, includeTasks); diff --git a/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java b/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java index a3c0b2d6..f6c9f846 100644 --- a/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java +++ b/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java @@ -4142,4 +4142,90 @@ private ApiResponse executeWorkflowWithHttpInfo(StartWorkflowReques return apiClient.execute(call, localVarReturnType); } + public WorkflowRun executeWorkflow(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTaskRef) throws ApiException { + ApiResponse resp = executeWorkflowWithHttpInfo(body, requestId, name, version, xIdempotencyKey, xOnConflict, waitUntilTaskRef); + return resp.getData(); + } + + private ApiResponse executeWorkflowWithHttpInfo(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTaskRef) throws ApiException { + com.squareup.okhttp.Call call = executeWorkflowValidateBeforeCall(body, requestId, name, version, xIdempotencyKey, xOnConflict, waitUntilTaskRef, null, null); + Type localVarReturnType = new TypeReference(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + @SuppressWarnings("rawtypes") + private com.squareup.okhttp.Call executeWorkflowValidateBeforeCall(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTaskRef, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException("Missing the required parameter 'body' when calling executeWorkflow(Async)"); + } + // verify the required parameter 'requestId' is set + if (requestId == null) { + throw new ApiException("Missing the required parameter 'requestId' when calling executeWorkflow(Async)"); + } + // verify the required parameter 'name' is set + if (name == null) { + throw new ApiException("Missing the required parameter 'name' when calling executeWorkflow(Async)"); + } + // verify the required parameter 'version' is set + if (version == null) { + throw new ApiException("Missing the required parameter 'version' when calling executeWorkflow(Async)"); + } + + com.squareup.okhttp.Call call = executeWorkflowCall(body, requestId, name, version, xIdempotencyKey, xOnConflict, waitUntilTaskRef, progressListener, progressRequestListener); + return call; + } + + private com.squareup.okhttp.Call executeWorkflowCall(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTaskRef, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = body; + + // create path and map variables + String localVarPath = "/workflow/execute/{name}/{version}" + .replaceAll("\\{" + "name" + "\\}", apiClient.escapeString(name.toString())) + .replaceAll("\\{" + "version" + "\\}", apiClient.escapeString(version.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + if (requestId != null) + localVarQueryParams.addAll(apiClient.parameterToPair("requestId", requestId)); + if (waitUntilTaskRef != null) + localVarQueryParams.addAll(apiClient.parameterToPair("waitUntilTaskRef", waitUntilTaskRef)); + + Map localVarHeaderParams = new HashMap(); + if (xIdempotencyKey != null) + localVarHeaderParams.put("X-Idempotency-key", apiClient.parameterToString(xIdempotencyKey)); + if (xOnConflict != null) + localVarHeaderParams.put("X-on-conflict", apiClient.parameterToString(xOnConflict)); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { + @Override + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { "api_key" }; + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + } From 92df2b8bc0c99e0edf38ef048c57eb0e29366d56 Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Thu, 30 Nov 2023 12:16:27 +0530 Subject: [PATCH 06/20] use oss release --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 2706f196..7f712c13 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ ext { versions = [ awaitility : '4.2.0', commonsLang : '3.12.0', - conductor : '3.9.23-SNAPSHOT', + conductor : '3.9.26-orkes', jackson : '2.11.4!!', junit : '5.9.0', slf4j : '1.7.36', From 5f6c876a86939ce725175caba287b6900c5b6cde Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Fri, 1 Dec 2023 11:36:39 +0530 Subject: [PATCH 07/20] fix --- .../client/http/api/WorkflowResourceApi.java | 56 +++++++++---------- .../conductor/client/model/TagObject.java | 2 + .../orkes/conductor/client/util/Commons.java | 4 +- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java b/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java index f6c9f846..f585e80d 100644 --- a/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java +++ b/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java @@ -4018,8 +4018,8 @@ public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Ch * @param requestId (required) * @param name (required) * @param version (required) - * @param xIdempotencyKey (optional) - * @param xOnConflict (optional) + * @param idempotencyKey (optional) + * @param onConflict (optional) * @param waitUntilTaskRef (optional) * @param waitForSeconds (optional, default to 10) * @param progressListener Progress listener @@ -4027,7 +4027,7 @@ public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Ch * @return Call to execute * @throws ApiException If fail to serialize the request body object */ - private com.squareup.okhttp.Call executeWorkflowCall(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTaskRef, Integer waitForSeconds, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private com.squareup.okhttp.Call executeWorkflowCall(StartWorkflowRequest body, String requestId, String name, Integer version, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTaskRef, Integer waitForSeconds, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -4045,10 +4045,10 @@ private com.squareup.okhttp.Call executeWorkflowCall(StartWorkflowRequest body, localVarQueryParams.addAll(apiClient.parameterToPair("waitForSeconds", waitForSeconds)); Map localVarHeaderParams = new HashMap(); - if (xIdempotencyKey != null) - localVarHeaderParams.put("X-Idempotency-key", apiClient.parameterToString(xIdempotencyKey)); - if (xOnConflict != null) - localVarHeaderParams.put("X-on-conflict", apiClient.parameterToString(xOnConflict)); + if (idempotencyKey != null) + localVarHeaderParams.put("X-Idempotency-key", apiClient.parameterToString(idempotencyKey)); + if (onConflict != null) + localVarHeaderParams.put("X-on-conflict", apiClient.parameterToString(onConflict)); Map localVarFormParams = new HashMap(); @@ -4081,7 +4081,7 @@ public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Ch } @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call executeWorkflowValidateBeforeCall(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTaskRef, Integer waitForSeconds, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private com.squareup.okhttp.Call executeWorkflowValidateBeforeCall(StartWorkflowRequest body, String requestId, String name, Integer version, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTaskRef, Integer waitForSeconds, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { // verify the required parameter 'body' is set if (body == null) { throw new ApiException("Missing the required parameter 'body' when calling executeWorkflow(Async)"); @@ -4099,7 +4099,7 @@ private com.squareup.okhttp.Call executeWorkflowValidateBeforeCall(StartWorkflow throw new ApiException("Missing the required parameter 'version' when calling executeWorkflow(Async)"); } - com.squareup.okhttp.Call call = executeWorkflowCall(body, requestId, name, version, xIdempotencyKey, xOnConflict, waitUntilTaskRef, waitForSeconds, progressListener, progressRequestListener); + com.squareup.okhttp.Call call = executeWorkflowCall(body, requestId, name, version, idempotencyKey, onConflict, waitUntilTaskRef, waitForSeconds, progressListener, progressRequestListener); return call; } @@ -4110,15 +4110,15 @@ private com.squareup.okhttp.Call executeWorkflowValidateBeforeCall(StartWorkflow * @param requestId (required) * @param name (required) * @param version (required) - * @param xIdempotencyKey (optional) - * @param xOnConflict (optional) + * @param idempotencyKey (optional) + * @param onConflict (optional) * @param waitUntilTaskRef (optional) * @param waitForSeconds (optional, default to 10) * @return WorkflowRun * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public WorkflowRun executeWorkflow(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTaskRef, Integer waitForSeconds) throws ApiException { - ApiResponse resp = executeWorkflowWithHttpInfo(body, requestId, name, version, xIdempotencyKey, xOnConflict, waitUntilTaskRef, waitForSeconds); + public WorkflowRun executeWorkflow(StartWorkflowRequest body, String requestId, String name, Integer version, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTaskRef, Integer waitForSeconds) throws ApiException { + ApiResponse resp = executeWorkflowWithHttpInfo(body, requestId, name, version, idempotencyKey, onConflict, waitUntilTaskRef, waitForSeconds); return resp.getData(); } @@ -4129,32 +4129,32 @@ public WorkflowRun executeWorkflow(StartWorkflowRequest body, String requestId, * @param requestId (required) * @param name (required) * @param version (required) - * @param xIdempotencyKey (optional) - * @param xOnConflict (optional) + * @param idempotencyKey (optional) + * @param onConflict (optional) * @param waitUntilTaskRef (optional) * @param waitForSeconds (optional, default to 10) * @return ApiResponse<WorkflowRun> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - private ApiResponse executeWorkflowWithHttpInfo(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTaskRef, Integer waitForSeconds) throws ApiException { - com.squareup.okhttp.Call call = executeWorkflowValidateBeforeCall(body, requestId, name, version, xIdempotencyKey, xOnConflict, waitUntilTaskRef, waitForSeconds, null, null); + private ApiResponse executeWorkflowWithHttpInfo(StartWorkflowRequest body, String requestId, String name, Integer version, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTaskRef, Integer waitForSeconds) throws ApiException { + com.squareup.okhttp.Call call = executeWorkflowValidateBeforeCall(body, requestId, name, version, idempotencyKey, onConflict, waitUntilTaskRef, waitForSeconds, null, null); Type localVarReturnType = new TypeReference(){}.getType(); return apiClient.execute(call, localVarReturnType); } - public WorkflowRun executeWorkflow(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTaskRef) throws ApiException { - ApiResponse resp = executeWorkflowWithHttpInfo(body, requestId, name, version, xIdempotencyKey, xOnConflict, waitUntilTaskRef); + public WorkflowRun executeWorkflow(StartWorkflowRequest body, String requestId, String name, Integer version, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTaskRef) throws ApiException { + ApiResponse resp = executeWorkflowWithHttpInfo(body, requestId, name, version, idempotencyKey, onConflict, waitUntilTaskRef); return resp.getData(); } - private ApiResponse executeWorkflowWithHttpInfo(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTaskRef) throws ApiException { - com.squareup.okhttp.Call call = executeWorkflowValidateBeforeCall(body, requestId, name, version, xIdempotencyKey, xOnConflict, waitUntilTaskRef, null, null); + private ApiResponse executeWorkflowWithHttpInfo(StartWorkflowRequest body, String requestId, String name, Integer version, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTaskRef) throws ApiException { + com.squareup.okhttp.Call call = executeWorkflowValidateBeforeCall(body, requestId, name, version, idempotencyKey, onConflict, waitUntilTaskRef, null, null); Type localVarReturnType = new TypeReference(){}.getType(); return apiClient.execute(call, localVarReturnType); } @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call executeWorkflowValidateBeforeCall(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTaskRef, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private com.squareup.okhttp.Call executeWorkflowValidateBeforeCall(StartWorkflowRequest body, String requestId, String name, Integer version, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTaskRef, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { // verify the required parameter 'body' is set if (body == null) { throw new ApiException("Missing the required parameter 'body' when calling executeWorkflow(Async)"); @@ -4172,11 +4172,11 @@ private com.squareup.okhttp.Call executeWorkflowValidateBeforeCall(StartWorkflow throw new ApiException("Missing the required parameter 'version' when calling executeWorkflow(Async)"); } - com.squareup.okhttp.Call call = executeWorkflowCall(body, requestId, name, version, xIdempotencyKey, xOnConflict, waitUntilTaskRef, progressListener, progressRequestListener); + com.squareup.okhttp.Call call = executeWorkflowCall(body, requestId, name, version, idempotencyKey, onConflict, waitUntilTaskRef, progressListener, progressRequestListener); return call; } - private com.squareup.okhttp.Call executeWorkflowCall(StartWorkflowRequest body, String requestId, String name, Integer version, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTaskRef, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private com.squareup.okhttp.Call executeWorkflowCall(StartWorkflowRequest body, String requestId, String name, Integer version, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTaskRef, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; // create path and map variables @@ -4192,10 +4192,10 @@ private com.squareup.okhttp.Call executeWorkflowCall(StartWorkflowRequest body, localVarQueryParams.addAll(apiClient.parameterToPair("waitUntilTaskRef", waitUntilTaskRef)); Map localVarHeaderParams = new HashMap(); - if (xIdempotencyKey != null) - localVarHeaderParams.put("X-Idempotency-key", apiClient.parameterToString(xIdempotencyKey)); - if (xOnConflict != null) - localVarHeaderParams.put("X-on-conflict", apiClient.parameterToString(xOnConflict)); + if (idempotencyKey != null) + localVarHeaderParams.put("X-Idempotency-key", apiClient.parameterToString(idempotencyKey)); + if (onConflict != null) + localVarHeaderParams.put("X-on-conflict", apiClient.parameterToString(onConflict)); Map localVarFormParams = new HashMap(); diff --git a/src/main/java/io/orkes/conductor/client/model/TagObject.java b/src/main/java/io/orkes/conductor/client/model/TagObject.java index 6a487301..8edbf79c 100644 --- a/src/main/java/io/orkes/conductor/client/model/TagObject.java +++ b/src/main/java/io/orkes/conductor/client/model/TagObject.java @@ -55,6 +55,8 @@ public static TypeEnum fromValue(String input) { } @SerializedName("type") + @Deprecated + // Type has been moved to WorkflowDef.RateLimitConfig private TypeEnum type = null; @SerializedName("value") diff --git a/src/test/java/io/orkes/conductor/client/util/Commons.java b/src/test/java/io/orkes/conductor/client/util/Commons.java index 91edcb14..4c92caf3 100644 --- a/src/test/java/io/orkes/conductor/client/util/Commons.java +++ b/src/test/java/io/orkes/conductor/client/util/Commons.java @@ -32,7 +32,7 @@ public class Commons { public static TagObject getTagObject() { TagObject tagObject = new TagObject(); - tagObject.setType(TagObject.TypeEnum.METADATA); + tagObject.setType(null); tagObject.setKey("a"); tagObject.setValue("b"); return tagObject; @@ -40,7 +40,7 @@ public static TagObject getTagObject() { public static TagString getTagString() { TagString tagString = new TagString(); - tagString.setType(TagString.TypeEnum.METADATA); + tagString.setType(null); tagString.setKey("a"); tagString.setValue("b"); return tagString; From 46ac4bd4805f40d881e5e5b3424aef6251a7ee2d Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Fri, 1 Dec 2023 18:45:09 +0530 Subject: [PATCH 08/20] fix tests --- .../conductor/client/AuthorizationClient.java | 2 +- .../conductor/client/SchedulerClient.java | 2 +- .../client/http/OrkesAuthorizationClient.java | 2 +- .../client/http/OrkesSchedulerClient.java | 2 +- .../http/api/AuthorizationResourceApi.java | 9 ++--- .../conductor/client/model/ResourceType.java | 36 +++++++++++++++++++ .../client/api/AuthorizationClientTests.java | 4 +-- .../client/api/SchedulerClientTests.java | 5 +-- .../client/api/SecretClientTests.java | 2 +- 9 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 src/main/java/io/orkes/conductor/client/model/ResourceType.java diff --git a/src/main/java/io/orkes/conductor/client/AuthorizationClient.java b/src/main/java/io/orkes/conductor/client/AuthorizationClient.java index db5ea1e1..0f5a0d64 100644 --- a/src/main/java/io/orkes/conductor/client/AuthorizationClient.java +++ b/src/main/java/io/orkes/conductor/client/AuthorizationClient.java @@ -21,7 +21,7 @@ public interface AuthorizationClient { // Permissions - Map> getPermissions(String type, String id); + Map> getPermissions(ResourceType type, String id); void grantPermissions(AuthorizationRequest authorizationRequest); diff --git a/src/main/java/io/orkes/conductor/client/SchedulerClient.java b/src/main/java/io/orkes/conductor/client/SchedulerClient.java index 86eb1137..b1278732 100644 --- a/src/main/java/io/orkes/conductor/client/SchedulerClient.java +++ b/src/main/java/io/orkes/conductor/client/SchedulerClient.java @@ -41,7 +41,7 @@ List getNextFewSchedules( void saveSchedule(SaveScheduleRequest saveScheduleRequest); - SearchResultWorkflowScheduleExecutionModel searchV22( + SearchResultWorkflowScheduleExecutionModel searchV2( Integer start, Integer size, String sort, String freeText, String query); void setSchedulerTags(List body, String name); diff --git a/src/main/java/io/orkes/conductor/client/http/OrkesAuthorizationClient.java b/src/main/java/io/orkes/conductor/client/http/OrkesAuthorizationClient.java index 8b866f64..891bea27 100644 --- a/src/main/java/io/orkes/conductor/client/http/OrkesAuthorizationClient.java +++ b/src/main/java/io/orkes/conductor/client/http/OrkesAuthorizationClient.java @@ -40,7 +40,7 @@ public OrkesAuthorizationClient(ApiClient apiClient) { } @Override - public Map> getPermissions(String type, String id) throws ApiException { + public Map> getPermissions(ResourceType type, String id) throws ApiException { return authorizationResourceApi.getPermissions(type, id); } diff --git a/src/main/java/io/orkes/conductor/client/http/OrkesSchedulerClient.java b/src/main/java/io/orkes/conductor/client/http/OrkesSchedulerClient.java index 5b42c0d1..377f111e 100644 --- a/src/main/java/io/orkes/conductor/client/http/OrkesSchedulerClient.java +++ b/src/main/java/io/orkes/conductor/client/http/OrkesSchedulerClient.java @@ -85,7 +85,7 @@ public void saveSchedule(SaveScheduleRequest saveScheduleRequest) throws ApiExce } @Override - public SearchResultWorkflowScheduleExecutionModel searchV22( + public SearchResultWorkflowScheduleExecutionModel searchV2( Integer start, Integer size, String sort, String freeText, String query) throws ApiException { return schedulerResourceApi.searchV22(start, size, sort, freeText, query); diff --git a/src/main/java/io/orkes/conductor/client/http/api/AuthorizationResourceApi.java b/src/main/java/io/orkes/conductor/client/http/api/AuthorizationResourceApi.java index a2126172..7a54e166 100644 --- a/src/main/java/io/orkes/conductor/client/http/api/AuthorizationResourceApi.java +++ b/src/main/java/io/orkes/conductor/client/http/api/AuthorizationResourceApi.java @@ -22,6 +22,7 @@ import io.orkes.conductor.client.ApiClient; import io.orkes.conductor.client.http.*; import io.orkes.conductor.client.model.AuthorizationRequest; +import io.orkes.conductor.client.model.ResourceType; import io.orkes.conductor.client.model.Subject; import com.fasterxml.jackson.core.type.TypeReference; @@ -56,7 +57,7 @@ public void setApiClient(ApiClient apiClient) { * @throws ApiException If fail to serialize the request body object */ public com.squareup.okhttp.Call getPermissionsCall( - String type, + ResourceType type, String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) @@ -122,7 +123,7 @@ public com.squareup.okhttp.Response intercept( } private com.squareup.okhttp.Call getPermissionsValidateBeforeCall( - String type, + ResourceType type, String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) @@ -152,7 +153,7 @@ private com.squareup.okhttp.Call getPermissionsValidateBeforeCall( * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the * response body */ - public Map> getPermissions(String type, String id) throws ApiException { + public Map> getPermissions(ResourceType type, String id) throws ApiException { ApiResponse>> resp = getPermissionsWithHttpInfo(type, id); return resp.getData(); } @@ -167,7 +168,7 @@ public Map> getPermissions(String type, String id) throws * response body */ private ApiResponse>> getPermissionsWithHttpInfo( - String type, String id) throws ApiException { + ResourceType type, String id) throws ApiException { com.squareup.okhttp.Call call = getPermissionsValidateBeforeCall(type, id, null, null); Type localVarReturnType = new TypeReference>>() {}.getType(); return apiClient.execute(call, localVarReturnType); diff --git a/src/main/java/io/orkes/conductor/client/model/ResourceType.java b/src/main/java/io/orkes/conductor/client/model/ResourceType.java new file mode 100644 index 00000000..8601a675 --- /dev/null +++ b/src/main/java/io/orkes/conductor/client/model/ResourceType.java @@ -0,0 +1,36 @@ +package io.orkes.conductor.client.model; + +import java.util.Arrays; +import java.util.Set; + +import static java.util.stream.Collectors.toSet; + +public enum ResourceType { + + WORKFLOW, + WORKFLOW_DEF, + WORKFLOW_SCHEDULE, + TASK_DEF, + TASK_REF_NAME, + TASK_ID, + APPLICATION, + USER, + SECRET_NAME, + TAG, + DOMAIN, + INTEGRATION_PROVIDER, + INTEGRATION, + PROMPT; + + public static final Set RESOURCE_NAMES = Arrays.stream(ResourceType.values()) + .map(Enum::name) + .collect(toSet()); + + public static boolean isValid(String resourceName) { + return RESOURCE_NAMES.contains(resourceName.toUpperCase()); + } + + public static ResourceType from(String resourceType) { + return ResourceType.valueOf(resourceType.toUpperCase()); + } +} diff --git a/src/test/java/io/orkes/conductor/client/api/AuthorizationClientTests.java b/src/test/java/io/orkes/conductor/client/api/AuthorizationClientTests.java index c929fc51..de2e61ec 100644 --- a/src/test/java/io/orkes/conductor/client/api/AuthorizationClientTests.java +++ b/src/test/java/io/orkes/conductor/client/api/AuthorizationClientTests.java @@ -255,7 +255,7 @@ void testMethods() { } } assertTrue(found); - authorizationClient.getPermissions("abc", Commons.GROUP_ID); + authorizationClient.getPermissions(ResourceType.TAG, Commons.GROUP_ID); assertEquals(authorizationClient.getApplication(applicationId).getId(), applicationId); assertTrue( authorizationClient @@ -325,7 +325,7 @@ AuthorizationRequest getAuthorizationRequest() { private List getTagObject() { TagObject tagObject = new TagObject(); - tagObject.setType(TagObject.TypeEnum.METADATA); + tagObject.setType(null); tagObject.setKey("department"); tagObject.setValue("accounts"); return List.of(tagObject); diff --git a/src/test/java/io/orkes/conductor/client/api/SchedulerClientTests.java b/src/test/java/io/orkes/conductor/client/api/SchedulerClientTests.java index 07b82c8e..fc863f9a 100644 --- a/src/test/java/io/orkes/conductor/client/api/SchedulerClientTests.java +++ b/src/test/java/io/orkes/conductor/client/api/SchedulerClientTests.java @@ -37,13 +37,14 @@ public SchedulerClientTests() { @Test void testMethods() { schedulerClient.deleteSchedule(NAME); + List existingTags = schedulerClient.getSchedulerTags(NAME); + schedulerClient.deleteSchedulerTags(existingTags, NAME); assertTrue(schedulerClient.getNextFewSchedules(CRON_EXPRESSION, 0L, 0L, 0).isEmpty()); schedulerClient.saveSchedule(getSaveScheduleRequest()); assertEquals(1, schedulerClient.getAllSchedules(Commons.WORKFLOW_NAME).size()); WorkflowSchedule workflowSchedule = schedulerClient.getSchedule(NAME); assertEquals(NAME, workflowSchedule.getName()); assertEquals(CRON_EXPRESSION, workflowSchedule.getCronExpression()); - assertFalse(schedulerClient.searchV22(0, 10, "ASC", "*", "").getResults().isEmpty()); schedulerClient.setSchedulerTags(getTagObject(), NAME); assertEquals(getTagObject(), schedulerClient.getSchedulerTags(NAME)); schedulerClient.deleteSchedulerTags(getTagObject(), NAME); @@ -73,7 +74,7 @@ SaveScheduleRequest getSaveScheduleRequest() { private List getTagObject() { TagObject tagObject = new TagObject(); - tagObject.setType(TagObject.TypeEnum.METADATA); + tagObject.setType(null); tagObject.setKey("department"); tagObject.setValue("accounts"); return List.of(tagObject); diff --git a/src/test/java/io/orkes/conductor/client/api/SecretClientTests.java b/src/test/java/io/orkes/conductor/client/api/SecretClientTests.java index ba23c490..8e08088c 100644 --- a/src/test/java/io/orkes/conductor/client/api/SecretClientTests.java +++ b/src/test/java/io/orkes/conductor/client/api/SecretClientTests.java @@ -58,7 +58,7 @@ void testMethods() { private TagObject getTagObject() { TagObject tagObject = new TagObject(); - tagObject.setType(TagObject.TypeEnum.METADATA); + tagObject.setType(null); tagObject.setKey("department"); tagObject.setValue("accounts"); return tagObject; From 20777caf75fdb542c5972d635c3acb15da30158b Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Fri, 1 Dec 2023 18:56:23 +0530 Subject: [PATCH 09/20] delete secret tags before setting again --- .../java/io/orkes/conductor/client/api/SecretClientTests.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/io/orkes/conductor/client/api/SecretClientTests.java b/src/test/java/io/orkes/conductor/client/api/SecretClientTests.java index 8e08088c..9da0c2ac 100644 --- a/src/test/java/io/orkes/conductor/client/api/SecretClientTests.java +++ b/src/test/java/io/orkes/conductor/client/api/SecretClientTests.java @@ -45,6 +45,9 @@ void testMethods() { secretClient.putSecret(SECRET_NAME, SECRET_KEY); secretClient.setSecretTags(List.of(getTagObject()), SECRET_KEY); List tags = secretClient.getSecretTags(SECRET_KEY); + secretClient.deleteSecretTags(tags, SECRET_KEY); + secretClient.putSecret(SECRET_NAME, SECRET_KEY); + secretClient.setSecretTags(List.of(getTagObject()), SECRET_KEY); assertEquals(tags.size(), 1); assertEquals(tags.get(0), getTagObject()); secretClient.deleteSecretTags(List.of(getTagObject()), SECRET_KEY); From d91abcd5cd198503dbd04eaf4e994f5c99670ea1 Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Fri, 1 Dec 2023 20:57:58 +0530 Subject: [PATCH 10/20] updates --- .../io/orkes/conductor/client/ApiClient.java | 14 ++++ .../conductor/client/WorkflowClient.java | 4 +- .../client/http/ConflictException.java | 83 +++++++++++++++++++ .../client/http/OrkesWorkflowClient.java | 22 ++--- 4 files changed, 110 insertions(+), 13 deletions(-) create mode 100644 src/main/java/io/orkes/conductor/client/http/ConflictException.java diff --git a/src/main/java/io/orkes/conductor/client/ApiClient.java b/src/main/java/io/orkes/conductor/client/ApiClient.java index d1737ca2..fcfbc11b 100644 --- a/src/main/java/io/orkes/conductor/client/ApiClient.java +++ b/src/main/java/io/orkes/conductor/client/ApiClient.java @@ -41,6 +41,7 @@ import javax.net.ssl.*; +import com.netflix.conductor.common.validation.ErrorResponse; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -863,6 +864,19 @@ public T handleResponse(Response response, Type returnType) throws ApiExcept if (response.body() != null) { try { respBody = response.body().string(); + if (response.code() == 409) { + ErrorResponse errorResponse = json.deserialize(respBody, ErrorResponse.class); + String message = null; + if (errorResponse != null && errorResponse.getMessage() != null) { + message = errorResponse.getMessage(); + } else { + message = response.message(); + } + throw new ConflictException( + message, + response.code(), + response.headers().toMultimap(), respBody); + } } catch (IOException e) { throw new ApiException( response.message(), diff --git a/src/main/java/io/orkes/conductor/client/WorkflowClient.java b/src/main/java/io/orkes/conductor/client/WorkflowClient.java index 16c850fd..fb70a889 100644 --- a/src/main/java/io/orkes/conductor/client/WorkflowClient.java +++ b/src/main/java/io/orkes/conductor/client/WorkflowClient.java @@ -39,8 +39,8 @@ public abstract class WorkflowClient extends com.netflix.conductor.client.http.W public abstract CompletableFuture executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Integer waitForSeconds); public abstract WorkflowRun executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Duration waitTimeout) throws ExecutionException, InterruptedException, TimeoutException; - public abstract CompletableFuture executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Integer waitForSeconds, String xIdempotencyKey, IdempotencyStrategy xOnConflict ); - public abstract WorkflowRun executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Duration waitTimeout, String xIdempotencyKey, IdempotencyStrategy xOnConflict) throws ExecutionException, InterruptedException, TimeoutException; + public abstract CompletableFuture executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Integer waitForSeconds, String idempotencyKey, IdempotencyStrategy onConflict ); + public abstract WorkflowRun executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Duration waitTimeout, String idempotencyKey, IdempotencyStrategy onConflict) throws ExecutionException, InterruptedException, TimeoutException; public abstract BulkResponse pauseWorkflow(List workflowIds) throws ApiException; diff --git a/src/main/java/io/orkes/conductor/client/http/ConflictException.java b/src/main/java/io/orkes/conductor/client/http/ConflictException.java new file mode 100644 index 00000000..0471c498 --- /dev/null +++ b/src/main/java/io/orkes/conductor/client/http/ConflictException.java @@ -0,0 +1,83 @@ +/* + * Copyright 2023 Orkes, Inc. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package io.orkes.conductor.client.http; + +import com.netflix.conductor.client.exception.ConductorClientException; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; +import java.util.Map; + +public class ConflictException extends ConductorClientException { + + private int code = 0; + private Map> responseHeaders = null; + + private String responseBody = null; + + private String message = null; + + public ConflictException( + String message, + Throwable throwable, + int code, + Map> responseHeaders, + String responseBody) { + super(message, throwable); + super.setCode(String.valueOf(code)); + super.setStatus(code); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + this.message = message; + } + + public ConflictException(String message, int code, Map> responseHeaders, String responseBody) { + this(message, null, code, responseHeaders, responseBody); + super.setCode(String.valueOf(code)); + super.setStatus(code); + super.setMessage(message); + this.code = code; + this.message = message; + this.responseBody = responseBody; + } + + /** + * + * @return HTTP status code + */ + public int getStatusCode() { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return A map of list of string + */ + public Map> getResponseHeaders() { + return responseHeaders; + } + + @Override + public String getMessage() { + return getStatusCode() + + ":" + + (StringUtils.isBlank(responseBody) ? super.getMessage() : responseBody); + } + + @Override + public String toString() { + return responseBody; + } +} diff --git a/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java b/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java index baea94e5..65b10cb7 100644 --- a/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java +++ b/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java @@ -87,7 +87,7 @@ public WorkflowClient withConnectTimeout(int connectTimeout) { } @Override - public String startWorkflow(StartWorkflowRequest startWorkflowRequest) { + public String startWorkflow(StartWorkflowRequest startWorkflowRequest) throws ConflictException { return httpClient.startWorkflow(startWorkflowRequest); } @@ -116,13 +116,13 @@ public WorkflowRun executeWorkflow(StartWorkflowRequest request, String waitUnti } @Override - public CompletableFuture executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Integer waitForSeconds, String xIdempotencyKey, IdempotencyStrategy xOnConflict) { - return executeWorkflowWithIdempotencyHttp(request, xIdempotencyKey, xOnConflict, waitUntilTask, waitForSeconds); + public CompletableFuture executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Integer waitForSeconds, String idempotencyKey, IdempotencyStrategy onConflict) { + return executeWorkflowWithIdempotencyHttp(request, idempotencyKey, onConflict, waitUntilTask, waitForSeconds); } @Override - public WorkflowRun executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Duration waitTimeout, String xIdempotencyKey, IdempotencyStrategy xOnConflict) throws ExecutionException, InterruptedException, TimeoutException { - CompletableFuture future = executeWorkflowWithIdempotencyHttp(request, xIdempotencyKey, xOnConflict, waitUntilTask); + public WorkflowRun executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Duration waitTimeout, String idempotencyKey, IdempotencyStrategy onConflict) throws ExecutionException, InterruptedException, TimeoutException { + CompletableFuture future = executeWorkflowWithIdempotencyHttp(request, idempotencyKey, onConflict, waitUntilTask); return future.get(waitTimeout.get(ChronoUnit.MILLIS), TimeUnit.MILLISECONDS); } @@ -171,7 +171,7 @@ private CompletableFuture executeWorkflowHttp(StartWorkflowRequest return future; } - private CompletableFuture executeWorkflowWithIdempotencyHttp(StartWorkflowRequest startWorkflowRequest, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTask, Integer waitForSeconds) { + private CompletableFuture executeWorkflowWithIdempotencyHttp(StartWorkflowRequest startWorkflowRequest, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTask, Integer waitForSeconds) { CompletableFuture future = new CompletableFuture<>(); String requestId = UUID.randomUUID().toString(); executorService.submit( @@ -183,8 +183,8 @@ private CompletableFuture executeWorkflowWithIdempotencyHttp(StartW requestId, startWorkflowRequest.getName(), startWorkflowRequest.getVersion(), - xIdempotencyKey, - xOnConflict, + idempotencyKey, + onConflict, waitUntilTask, waitForSeconds); future.complete(response); @@ -196,7 +196,7 @@ private CompletableFuture executeWorkflowWithIdempotencyHttp(StartW return future; } - private CompletableFuture executeWorkflowWithIdempotencyHttp(StartWorkflowRequest startWorkflowRequest, String xIdempotencyKey, IdempotencyStrategy xOnConflict, String waitUntilTask) { + private CompletableFuture executeWorkflowWithIdempotencyHttp(StartWorkflowRequest startWorkflowRequest, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTask) { CompletableFuture future = new CompletableFuture<>(); String requestId = UUID.randomUUID().toString(); executorService.submit( @@ -208,8 +208,8 @@ private CompletableFuture executeWorkflowWithIdempotencyHttp(StartW requestId, startWorkflowRequest.getName(), startWorkflowRequest.getVersion(), - xIdempotencyKey, - xOnConflict, + idempotencyKey, + onConflict, waitUntilTask); future.complete(response); } catch (Throwable t) { From d412967ae4c6f72f2fd7817055a41b19784bf6d6 Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Fri, 1 Dec 2023 23:33:05 +0530 Subject: [PATCH 11/20] review comments. --- .../conductor/client/AuthorizationClient.java | 2 +- .../client/http/ConflictException.java | 17 +++++---- .../client/http/OrkesAuthorizationClient.java | 2 +- .../http/api/AuthorizationResourceApi.java | 9 +++-- .../conductor/client/model/ResourceType.java | 36 ------------------- .../client/WorkflowRetryExamples.java | 10 +++++- .../client/api/AuthorizationClientTests.java | 2 +- 7 files changed, 27 insertions(+), 51 deletions(-) delete mode 100644 src/main/java/io/orkes/conductor/client/model/ResourceType.java diff --git a/src/main/java/io/orkes/conductor/client/AuthorizationClient.java b/src/main/java/io/orkes/conductor/client/AuthorizationClient.java index 0f5a0d64..db5ea1e1 100644 --- a/src/main/java/io/orkes/conductor/client/AuthorizationClient.java +++ b/src/main/java/io/orkes/conductor/client/AuthorizationClient.java @@ -21,7 +21,7 @@ public interface AuthorizationClient { // Permissions - Map> getPermissions(ResourceType type, String id); + Map> getPermissions(String type, String id); void grantPermissions(AuthorizationRequest authorizationRequest); diff --git a/src/main/java/io/orkes/conductor/client/http/ConflictException.java b/src/main/java/io/orkes/conductor/client/http/ConflictException.java index 0471c498..93ee2970 100644 --- a/src/main/java/io/orkes/conductor/client/http/ConflictException.java +++ b/src/main/java/io/orkes/conductor/client/http/ConflictException.java @@ -12,20 +12,20 @@ */ package io.orkes.conductor.client.http; -import com.netflix.conductor.client.exception.ConductorClientException; +import io.orkes.conductor.client.OrkesClientException; import org.apache.commons.lang3.StringUtils; import java.util.List; import java.util.Map; -public class ConflictException extends ConductorClientException { +public class ConflictException extends OrkesClientException { - private int code = 0; - private Map> responseHeaders = null; + private int code; + private Map> responseHeaders; - private String responseBody = null; + private String responseBody; - private String message = null; + private String message; public ConflictException( String message, @@ -80,4 +80,9 @@ public String getMessage() { public String toString() { return responseBody; } + + @Override + public boolean isClientError() { + return code > 399 && code < 499; + } } diff --git a/src/main/java/io/orkes/conductor/client/http/OrkesAuthorizationClient.java b/src/main/java/io/orkes/conductor/client/http/OrkesAuthorizationClient.java index 891bea27..8b866f64 100644 --- a/src/main/java/io/orkes/conductor/client/http/OrkesAuthorizationClient.java +++ b/src/main/java/io/orkes/conductor/client/http/OrkesAuthorizationClient.java @@ -40,7 +40,7 @@ public OrkesAuthorizationClient(ApiClient apiClient) { } @Override - public Map> getPermissions(ResourceType type, String id) throws ApiException { + public Map> getPermissions(String type, String id) throws ApiException { return authorizationResourceApi.getPermissions(type, id); } diff --git a/src/main/java/io/orkes/conductor/client/http/api/AuthorizationResourceApi.java b/src/main/java/io/orkes/conductor/client/http/api/AuthorizationResourceApi.java index 7a54e166..a2126172 100644 --- a/src/main/java/io/orkes/conductor/client/http/api/AuthorizationResourceApi.java +++ b/src/main/java/io/orkes/conductor/client/http/api/AuthorizationResourceApi.java @@ -22,7 +22,6 @@ import io.orkes.conductor.client.ApiClient; import io.orkes.conductor.client.http.*; import io.orkes.conductor.client.model.AuthorizationRequest; -import io.orkes.conductor.client.model.ResourceType; import io.orkes.conductor.client.model.Subject; import com.fasterxml.jackson.core.type.TypeReference; @@ -57,7 +56,7 @@ public void setApiClient(ApiClient apiClient) { * @throws ApiException If fail to serialize the request body object */ public com.squareup.okhttp.Call getPermissionsCall( - ResourceType type, + String type, String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) @@ -123,7 +122,7 @@ public com.squareup.okhttp.Response intercept( } private com.squareup.okhttp.Call getPermissionsValidateBeforeCall( - ResourceType type, + String type, String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) @@ -153,7 +152,7 @@ private com.squareup.okhttp.Call getPermissionsValidateBeforeCall( * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the * response body */ - public Map> getPermissions(ResourceType type, String id) throws ApiException { + public Map> getPermissions(String type, String id) throws ApiException { ApiResponse>> resp = getPermissionsWithHttpInfo(type, id); return resp.getData(); } @@ -168,7 +167,7 @@ public Map> getPermissions(ResourceType type, String id) t * response body */ private ApiResponse>> getPermissionsWithHttpInfo( - ResourceType type, String id) throws ApiException { + String type, String id) throws ApiException { com.squareup.okhttp.Call call = getPermissionsValidateBeforeCall(type, id, null, null); Type localVarReturnType = new TypeReference>>() {}.getType(); return apiClient.execute(call, localVarReturnType); diff --git a/src/main/java/io/orkes/conductor/client/model/ResourceType.java b/src/main/java/io/orkes/conductor/client/model/ResourceType.java deleted file mode 100644 index 8601a675..00000000 --- a/src/main/java/io/orkes/conductor/client/model/ResourceType.java +++ /dev/null @@ -1,36 +0,0 @@ -package io.orkes.conductor.client.model; - -import java.util.Arrays; -import java.util.Set; - -import static java.util.stream.Collectors.toSet; - -public enum ResourceType { - - WORKFLOW, - WORKFLOW_DEF, - WORKFLOW_SCHEDULE, - TASK_DEF, - TASK_REF_NAME, - TASK_ID, - APPLICATION, - USER, - SECRET_NAME, - TAG, - DOMAIN, - INTEGRATION_PROVIDER, - INTEGRATION, - PROMPT; - - public static final Set RESOURCE_NAMES = Arrays.stream(ResourceType.values()) - .map(Enum::name) - .collect(toSet()); - - public static boolean isValid(String resourceName) { - return RESOURCE_NAMES.contains(resourceName.toUpperCase()); - } - - public static ResourceType from(String resourceType) { - return ResourceType.valueOf(resourceType.toUpperCase()); - } -} diff --git a/src/test/java/io/orkes/conductor/client/WorkflowRetryExamples.java b/src/test/java/io/orkes/conductor/client/WorkflowRetryExamples.java index a64fb2a1..d2649261 100644 --- a/src/test/java/io/orkes/conductor/client/WorkflowRetryExamples.java +++ b/src/test/java/io/orkes/conductor/client/WorkflowRetryExamples.java @@ -14,6 +14,7 @@ import java.util.*; +import com.netflix.conductor.common.metadata.workflow.IdempotencyStrategy; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -65,7 +66,14 @@ public void testRetry() { startWorkflowRequest.setName(workflowName); startWorkflowRequest.setVersion(1); startWorkflowRequest.setInput(new HashMap<>()); - String workflowId = workflowClient.startWorkflow(startWorkflowRequest); + startWorkflowRequest.setIdempotencyKey("test"); + startWorkflowRequest.setIdempotencyStrategy(IdempotencyStrategy.FAIL); + String workflowId = null; + try { + workflowId = workflowClient.startWorkflow(startWorkflowRequest); + } catch(Exception e) { + System.out.println(e); + } Workflow workflow = workflowClient.getWorkflow(workflowId, true); String taskId = workflow.getTasks().get(0).getTaskId(); diff --git a/src/test/java/io/orkes/conductor/client/api/AuthorizationClientTests.java b/src/test/java/io/orkes/conductor/client/api/AuthorizationClientTests.java index de2e61ec..3e511ebe 100644 --- a/src/test/java/io/orkes/conductor/client/api/AuthorizationClientTests.java +++ b/src/test/java/io/orkes/conductor/client/api/AuthorizationClientTests.java @@ -255,7 +255,7 @@ void testMethods() { } } assertTrue(found); - authorizationClient.getPermissions(ResourceType.TAG, Commons.GROUP_ID); +// authorizationClient.getPermissions("", Commons.GROUP_ID); assertEquals(authorizationClient.getApplication(applicationId).getId(), applicationId); assertTrue( authorizationClient From acf3b9f7548a1aba1832054a8038b61fe2c3fc79 Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:16:16 +0530 Subject: [PATCH 12/20] update orkes build --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7f712c13..14ae0015 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ ext { versions = [ awaitility : '4.2.0', commonsLang : '3.12.0', - conductor : '3.9.26-orkes', + conductor : '3.9.28-orkes', jackson : '2.11.4!!', junit : '5.9.0', slf4j : '1.7.36', From d2503fa91b2411154178d41c2ed87c0b7a173e22 Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Tue, 5 Dec 2023 18:19:39 +0530 Subject: [PATCH 13/20] revert --- .../conductor/sdk/examples/WorkflowManagement.java | 10 +++++++++- .../io/orkes/conductor/client/SchedulerClient.java | 2 +- .../conductor/client/http/OrkesSchedulerClient.java | 2 +- .../conductor/client/http/OrkesWorkflowClient.java | 4 ++-- .../orkes/conductor/client/WorkflowRetryExamples.java | 10 +--------- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/example/java/io/orkes/conductor/sdk/examples/WorkflowManagement.java b/example/java/io/orkes/conductor/sdk/examples/WorkflowManagement.java index 12ad5974..f4a032c0 100644 --- a/example/java/io/orkes/conductor/sdk/examples/WorkflowManagement.java +++ b/example/java/io/orkes/conductor/sdk/examples/WorkflowManagement.java @@ -14,6 +14,7 @@ import java.util.Arrays; +import com.netflix.conductor.common.metadata.workflow.IdempotencyStrategy; import com.netflix.conductor.common.metadata.workflow.StartWorkflowRequest; import io.orkes.conductor.client.OrkesClients; @@ -51,9 +52,16 @@ private void workflowOperations() { startWorkflowRequest.setName(workflowDef.getName()); startWorkflowRequest.setVersion(workflowDef.getVersion()); startWorkflowRequest.setCorrelationId("test_workflow"); + startWorkflowRequest.setIdempotencyKey("test"); + startWorkflowRequest.setIdempotencyStrategy(IdempotencyStrategy.FAIL); // Start the workflow - String workflowId = workflowClient.startWorkflow(startWorkflowRequest); + String workflowId = null; + try { + workflowId = workflowClient.startWorkflow(startWorkflowRequest); + }catch (Exception e) { + System.out.println(e); + } // Get the workflow execution status workflowClient.getWorkflow(workflowId, true); // Pause the workflow diff --git a/src/main/java/io/orkes/conductor/client/SchedulerClient.java b/src/main/java/io/orkes/conductor/client/SchedulerClient.java index b1278732..86eb1137 100644 --- a/src/main/java/io/orkes/conductor/client/SchedulerClient.java +++ b/src/main/java/io/orkes/conductor/client/SchedulerClient.java @@ -41,7 +41,7 @@ List getNextFewSchedules( void saveSchedule(SaveScheduleRequest saveScheduleRequest); - SearchResultWorkflowScheduleExecutionModel searchV2( + SearchResultWorkflowScheduleExecutionModel searchV22( Integer start, Integer size, String sort, String freeText, String query); void setSchedulerTags(List body, String name); diff --git a/src/main/java/io/orkes/conductor/client/http/OrkesSchedulerClient.java b/src/main/java/io/orkes/conductor/client/http/OrkesSchedulerClient.java index 377f111e..5b42c0d1 100644 --- a/src/main/java/io/orkes/conductor/client/http/OrkesSchedulerClient.java +++ b/src/main/java/io/orkes/conductor/client/http/OrkesSchedulerClient.java @@ -85,7 +85,7 @@ public void saveSchedule(SaveScheduleRequest saveScheduleRequest) throws ApiExce } @Override - public SearchResultWorkflowScheduleExecutionModel searchV2( + public SearchResultWorkflowScheduleExecutionModel searchV22( Integer start, Integer size, String sort, String freeText, String query) throws ApiException { return schedulerResourceApi.searchV22(start, size, sort, freeText, query); diff --git a/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java b/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java index 65b10cb7..53d18947 100644 --- a/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java +++ b/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java @@ -92,7 +92,7 @@ public String startWorkflow(StartWorkflowRequest startWorkflowRequest) throws Co } @Override - public CompletableFuture executeWorkflow(StartWorkflowRequest request, String waitUntilTask) { + public CompletableFuture executeWorkflow(StartWorkflowRequest request, String waitUntilTask) throws ConflictException { if(apiClient.isUseGRPC()) { return grpcWorkflowClient.executeWorkflow(request, waitUntilTask); } else { @@ -101,7 +101,7 @@ public CompletableFuture executeWorkflow(StartWorkflowRequest reque } @Override - public CompletableFuture executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Integer waitForSeconds) { + public CompletableFuture executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Integer waitForSeconds) throws ConflictException { if(apiClient.isUseGRPC()) { return grpcWorkflowClient.executeWorkflow(request, waitUntilTask, waitForSeconds); } else { diff --git a/src/test/java/io/orkes/conductor/client/WorkflowRetryExamples.java b/src/test/java/io/orkes/conductor/client/WorkflowRetryExamples.java index d2649261..a64fb2a1 100644 --- a/src/test/java/io/orkes/conductor/client/WorkflowRetryExamples.java +++ b/src/test/java/io/orkes/conductor/client/WorkflowRetryExamples.java @@ -14,7 +14,6 @@ import java.util.*; -import com.netflix.conductor.common.metadata.workflow.IdempotencyStrategy; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -66,14 +65,7 @@ public void testRetry() { startWorkflowRequest.setName(workflowName); startWorkflowRequest.setVersion(1); startWorkflowRequest.setInput(new HashMap<>()); - startWorkflowRequest.setIdempotencyKey("test"); - startWorkflowRequest.setIdempotencyStrategy(IdempotencyStrategy.FAIL); - String workflowId = null; - try { - workflowId = workflowClient.startWorkflow(startWorkflowRequest); - } catch(Exception e) { - System.out.println(e); - } + String workflowId = workflowClient.startWorkflow(startWorkflowRequest); Workflow workflow = workflowClient.getWorkflow(workflowId, true); String taskId = workflow.getTasks().get(0).getTaskId(); From 19b07596d68edc580a2cca5ca2b547a5d3d9f7b1 Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Tue, 5 Dec 2023 18:59:47 +0530 Subject: [PATCH 14/20] revert --- .../conductor/sdk/examples/WorkflowManagement.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/example/java/io/orkes/conductor/sdk/examples/WorkflowManagement.java b/example/java/io/orkes/conductor/sdk/examples/WorkflowManagement.java index f4a032c0..12ad5974 100644 --- a/example/java/io/orkes/conductor/sdk/examples/WorkflowManagement.java +++ b/example/java/io/orkes/conductor/sdk/examples/WorkflowManagement.java @@ -14,7 +14,6 @@ import java.util.Arrays; -import com.netflix.conductor.common.metadata.workflow.IdempotencyStrategy; import com.netflix.conductor.common.metadata.workflow.StartWorkflowRequest; import io.orkes.conductor.client.OrkesClients; @@ -52,16 +51,9 @@ private void workflowOperations() { startWorkflowRequest.setName(workflowDef.getName()); startWorkflowRequest.setVersion(workflowDef.getVersion()); startWorkflowRequest.setCorrelationId("test_workflow"); - startWorkflowRequest.setIdempotencyKey("test"); - startWorkflowRequest.setIdempotencyStrategy(IdempotencyStrategy.FAIL); // Start the workflow - String workflowId = null; - try { - workflowId = workflowClient.startWorkflow(startWorkflowRequest); - }catch (Exception e) { - System.out.println(e); - } + String workflowId = workflowClient.startWorkflow(startWorkflowRequest); // Get the workflow execution status workflowClient.getWorkflow(workflowId, true); // Pause the workflow From f265331be4f16f5b13638b6b5864b9c5a7a9ea10 Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Tue, 5 Dec 2023 21:48:09 +0530 Subject: [PATCH 15/20] remove not required changes. --- .../conductor/client/WorkflowClient.java | 3 - .../client/http/OrkesWorkflowClient.java | 60 ----- .../client/http/api/WorkflowResourceApi.java | 220 +----------------- 3 files changed, 4 insertions(+), 279 deletions(-) diff --git a/src/main/java/io/orkes/conductor/client/WorkflowClient.java b/src/main/java/io/orkes/conductor/client/WorkflowClient.java index fb70a889..0fb49d94 100644 --- a/src/main/java/io/orkes/conductor/client/WorkflowClient.java +++ b/src/main/java/io/orkes/conductor/client/WorkflowClient.java @@ -39,9 +39,6 @@ public abstract class WorkflowClient extends com.netflix.conductor.client.http.W public abstract CompletableFuture executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Integer waitForSeconds); public abstract WorkflowRun executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Duration waitTimeout) throws ExecutionException, InterruptedException, TimeoutException; - public abstract CompletableFuture executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Integer waitForSeconds, String idempotencyKey, IdempotencyStrategy onConflict ); - public abstract WorkflowRun executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Duration waitTimeout, String idempotencyKey, IdempotencyStrategy onConflict) throws ExecutionException, InterruptedException, TimeoutException; - public abstract BulkResponse pauseWorkflow(List workflowIds) throws ApiException; public abstract BulkResponse restartWorkflow(List workflowIds, Boolean useLatestDefinitions) diff --git a/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java b/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java index 53d18947..100db70f 100644 --- a/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java +++ b/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java @@ -115,17 +115,6 @@ public WorkflowRun executeWorkflow(StartWorkflowRequest request, String waitUnti return future.get(waitTimeout.get(ChronoUnit.MILLIS), TimeUnit.MILLISECONDS); } - @Override - public CompletableFuture executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Integer waitForSeconds, String idempotencyKey, IdempotencyStrategy onConflict) { - return executeWorkflowWithIdempotencyHttp(request, idempotencyKey, onConflict, waitUntilTask, waitForSeconds); - } - - @Override - public WorkflowRun executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Duration waitTimeout, String idempotencyKey, IdempotencyStrategy onConflict) throws ExecutionException, InterruptedException, TimeoutException { - CompletableFuture future = executeWorkflowWithIdempotencyHttp(request, idempotencyKey, onConflict, waitUntilTask); - return future.get(waitTimeout.get(ChronoUnit.MILLIS), TimeUnit.MILLISECONDS); - } - private CompletableFuture executeWorkflowHttp(StartWorkflowRequest startWorkflowRequest, String waitUntilTask) { CompletableFuture future = new CompletableFuture<>(); String requestId = UUID.randomUUID().toString(); @@ -171,55 +160,6 @@ private CompletableFuture executeWorkflowHttp(StartWorkflowRequest return future; } - private CompletableFuture executeWorkflowWithIdempotencyHttp(StartWorkflowRequest startWorkflowRequest, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTask, Integer waitForSeconds) { - CompletableFuture future = new CompletableFuture<>(); - String requestId = UUID.randomUUID().toString(); - executorService.submit( - () -> { - try { - WorkflowRun response = - httpClient.executeWorkflow( - startWorkflowRequest, - requestId, - startWorkflowRequest.getName(), - startWorkflowRequest.getVersion(), - idempotencyKey, - onConflict, - waitUntilTask, - waitForSeconds); - future.complete(response); - } catch (Throwable t) { - future.completeExceptionally(t); - } - }); - - return future; - } - - private CompletableFuture executeWorkflowWithIdempotencyHttp(StartWorkflowRequest startWorkflowRequest, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTask) { - CompletableFuture future = new CompletableFuture<>(); - String requestId = UUID.randomUUID().toString(); - executorService.submit( - () -> { - try { - WorkflowRun response = - httpClient.executeWorkflow( - startWorkflowRequest, - requestId, - startWorkflowRequest.getName(), - startWorkflowRequest.getVersion(), - idempotencyKey, - onConflict, - waitUntilTask); - future.complete(response); - } catch (Throwable t) { - future.completeExceptionally(t); - } - }); - - return future; - } - @Override public Workflow getWorkflow(String workflowId, boolean includeTasks) { return httpClient.getExecutionStatus(workflowId, includeTasks); diff --git a/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java b/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java index f585e80d..19f4a66b 100644 --- a/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java +++ b/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java @@ -341,6 +341,10 @@ public com.squareup.okhttp.Call executeWorkflowCall( apiClient.parameterToPair("waitForSeconds", waitForSeconds)); Map localVarHeaderParams = new HashMap(); + if (body.getIdempotencyKey() != null) + localVarHeaderParams.put("X-Idempotency-key", apiClient.parameterToString(body.getIdempotencyKey())); + if (body.getIdempotencyStrategy() != null) + localVarHeaderParams.put("X-on-conflict", apiClient.parameterToString(body.getIdempotencyStrategy())); Map localVarFormParams = new HashMap(); @@ -4012,220 +4016,4 @@ public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Ch String[] localVarAuthNames = new String[] { "api_key" }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } - /** - * Build call for executeWorkflow - * @param body (required) - * @param requestId (required) - * @param name (required) - * @param version (required) - * @param idempotencyKey (optional) - * @param onConflict (optional) - * @param waitUntilTaskRef (optional) - * @param waitForSeconds (optional, default to 10) - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - private com.squareup.okhttp.Call executeWorkflowCall(StartWorkflowRequest body, String requestId, String name, Integer version, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTaskRef, Integer waitForSeconds, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = body; - - // create path and map variables - String localVarPath = "/workflow/execute/{name}/{version}" - .replaceAll("\\{" + "name" + "\\}", apiClient.escapeString(name.toString())) - .replaceAll("\\{" + "version" + "\\}", apiClient.escapeString(version.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - if (requestId != null) - localVarQueryParams.addAll(apiClient.parameterToPair("requestId", requestId)); - if (waitUntilTaskRef != null) - localVarQueryParams.addAll(apiClient.parameterToPair("waitUntilTaskRef", waitUntilTaskRef)); - if (waitForSeconds != null) - localVarQueryParams.addAll(apiClient.parameterToPair("waitForSeconds", waitForSeconds)); - - Map localVarHeaderParams = new HashMap(); - if (idempotencyKey != null) - localVarHeaderParams.put("X-Idempotency-key", apiClient.parameterToString(idempotencyKey)); - if (onConflict != null) - localVarHeaderParams.put("X-on-conflict", apiClient.parameterToString(onConflict)); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call executeWorkflowValidateBeforeCall(StartWorkflowRequest body, String requestId, String name, Integer version, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTaskRef, Integer waitForSeconds, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException("Missing the required parameter 'body' when calling executeWorkflow(Async)"); - } - // verify the required parameter 'requestId' is set - if (requestId == null) { - throw new ApiException("Missing the required parameter 'requestId' when calling executeWorkflow(Async)"); - } - // verify the required parameter 'name' is set - if (name == null) { - throw new ApiException("Missing the required parameter 'name' when calling executeWorkflow(Async)"); - } - // verify the required parameter 'version' is set - if (version == null) { - throw new ApiException("Missing the required parameter 'version' when calling executeWorkflow(Async)"); - } - - com.squareup.okhttp.Call call = executeWorkflowCall(body, requestId, name, version, idempotencyKey, onConflict, waitUntilTaskRef, waitForSeconds, progressListener, progressRequestListener); - return call; - } - - /** - * Execute a workflow synchronously - * - * @param body (required) - * @param requestId (required) - * @param name (required) - * @param version (required) - * @param idempotencyKey (optional) - * @param onConflict (optional) - * @param waitUntilTaskRef (optional) - * @param waitForSeconds (optional, default to 10) - * @return WorkflowRun - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public WorkflowRun executeWorkflow(StartWorkflowRequest body, String requestId, String name, Integer version, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTaskRef, Integer waitForSeconds) throws ApiException { - ApiResponse resp = executeWorkflowWithHttpInfo(body, requestId, name, version, idempotencyKey, onConflict, waitUntilTaskRef, waitForSeconds); - return resp.getData(); - } - - /** - * Execute a workflow synchronously - * - * @param body (required) - * @param requestId (required) - * @param name (required) - * @param version (required) - * @param idempotencyKey (optional) - * @param onConflict (optional) - * @param waitUntilTaskRef (optional) - * @param waitForSeconds (optional, default to 10) - * @return ApiResponse<WorkflowRun> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - private ApiResponse executeWorkflowWithHttpInfo(StartWorkflowRequest body, String requestId, String name, Integer version, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTaskRef, Integer waitForSeconds) throws ApiException { - com.squareup.okhttp.Call call = executeWorkflowValidateBeforeCall(body, requestId, name, version, idempotencyKey, onConflict, waitUntilTaskRef, waitForSeconds, null, null); - Type localVarReturnType = new TypeReference(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - public WorkflowRun executeWorkflow(StartWorkflowRequest body, String requestId, String name, Integer version, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTaskRef) throws ApiException { - ApiResponse resp = executeWorkflowWithHttpInfo(body, requestId, name, version, idempotencyKey, onConflict, waitUntilTaskRef); - return resp.getData(); - } - - private ApiResponse executeWorkflowWithHttpInfo(StartWorkflowRequest body, String requestId, String name, Integer version, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTaskRef) throws ApiException { - com.squareup.okhttp.Call call = executeWorkflowValidateBeforeCall(body, requestId, name, version, idempotencyKey, onConflict, waitUntilTaskRef, null, null); - Type localVarReturnType = new TypeReference(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call executeWorkflowValidateBeforeCall(StartWorkflowRequest body, String requestId, String name, Integer version, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTaskRef, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException("Missing the required parameter 'body' when calling executeWorkflow(Async)"); - } - // verify the required parameter 'requestId' is set - if (requestId == null) { - throw new ApiException("Missing the required parameter 'requestId' when calling executeWorkflow(Async)"); - } - // verify the required parameter 'name' is set - if (name == null) { - throw new ApiException("Missing the required parameter 'name' when calling executeWorkflow(Async)"); - } - // verify the required parameter 'version' is set - if (version == null) { - throw new ApiException("Missing the required parameter 'version' when calling executeWorkflow(Async)"); - } - - com.squareup.okhttp.Call call = executeWorkflowCall(body, requestId, name, version, idempotencyKey, onConflict, waitUntilTaskRef, progressListener, progressRequestListener); - return call; - } - - private com.squareup.okhttp.Call executeWorkflowCall(StartWorkflowRequest body, String requestId, String name, Integer version, String idempotencyKey, IdempotencyStrategy onConflict, String waitUntilTaskRef, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = body; - - // create path and map variables - String localVarPath = "/workflow/execute/{name}/{version}" - .replaceAll("\\{" + "name" + "\\}", apiClient.escapeString(name.toString())) - .replaceAll("\\{" + "version" + "\\}", apiClient.escapeString(version.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - if (requestId != null) - localVarQueryParams.addAll(apiClient.parameterToPair("requestId", requestId)); - if (waitUntilTaskRef != null) - localVarQueryParams.addAll(apiClient.parameterToPair("waitUntilTaskRef", waitUntilTaskRef)); - - Map localVarHeaderParams = new HashMap(); - if (idempotencyKey != null) - localVarHeaderParams.put("X-Idempotency-key", apiClient.parameterToString(idempotencyKey)); - if (onConflict != null) - localVarHeaderParams.put("X-on-conflict", apiClient.parameterToString(onConflict)); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - } From d16dda2c2cafdbd662c9746e82832a39c5c641bb Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Tue, 5 Dec 2023 22:09:57 +0530 Subject: [PATCH 16/20] not required changes --- .../orkes/conductor/client/http/api/WorkflowResourceApi.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java b/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java index 19f4a66b..188cc5a5 100644 --- a/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java +++ b/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java @@ -341,10 +341,6 @@ public com.squareup.okhttp.Call executeWorkflowCall( apiClient.parameterToPair("waitForSeconds", waitForSeconds)); Map localVarHeaderParams = new HashMap(); - if (body.getIdempotencyKey() != null) - localVarHeaderParams.put("X-Idempotency-key", apiClient.parameterToString(body.getIdempotencyKey())); - if (body.getIdempotencyStrategy() != null) - localVarHeaderParams.put("X-on-conflict", apiClient.parameterToString(body.getIdempotencyStrategy())); Map localVarFormParams = new HashMap(); From 3d970885fdee0f51a97086bbc86e6c0b1facd055 Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Tue, 5 Dec 2023 22:11:20 +0530 Subject: [PATCH 17/20] revert --- src/main/java/io/orkes/conductor/client/WorkflowClient.java | 2 +- .../io/orkes/conductor/client/http/api/WorkflowResourceApi.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/orkes/conductor/client/WorkflowClient.java b/src/main/java/io/orkes/conductor/client/WorkflowClient.java index 0fb49d94..9b443c2b 100644 --- a/src/main/java/io/orkes/conductor/client/WorkflowClient.java +++ b/src/main/java/io/orkes/conductor/client/WorkflowClient.java @@ -19,7 +19,6 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; -import com.netflix.conductor.common.metadata.workflow.IdempotencyStrategy; import com.netflix.conductor.common.metadata.workflow.StartWorkflowRequest; import com.netflix.conductor.common.metadata.workflow.UpgradeWorkflowRequest; import com.netflix.conductor.common.model.BulkResponse; @@ -39,6 +38,7 @@ public abstract class WorkflowClient extends com.netflix.conductor.client.http.W public abstract CompletableFuture executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Integer waitForSeconds); public abstract WorkflowRun executeWorkflow(StartWorkflowRequest request, String waitUntilTask, Duration waitTimeout) throws ExecutionException, InterruptedException, TimeoutException; + public abstract BulkResponse pauseWorkflow(List workflowIds) throws ApiException; public abstract BulkResponse restartWorkflow(List workflowIds, Boolean useLatestDefinitions) diff --git a/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java b/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java index 188cc5a5..3b6f110f 100644 --- a/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java +++ b/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java @@ -20,7 +20,6 @@ import java.util.Map; import com.netflix.conductor.common.metadata.workflow.*; -import com.netflix.conductor.common.metadata.workflow.IdempotencyStrategy; import com.netflix.conductor.common.run.Workflow; import com.netflix.conductor.common.run.WorkflowTestRequest; @@ -4012,4 +4011,5 @@ public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Ch String[] localVarAuthNames = new String[] { "api_key" }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); } + } From 9de5975f051679c6976ac69caf43c94d63348747 Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Tue, 5 Dec 2023 22:27:08 +0530 Subject: [PATCH 18/20] review comments. --- .../java/com/netflix/conductor/client/http/WorkflowClient.java | 3 ++- src/main/java/io/orkes/conductor/client/model/TagObject.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/netflix/conductor/client/http/WorkflowClient.java b/src/main/java/com/netflix/conductor/client/http/WorkflowClient.java index 914c08a9..fc4dab3f 100644 --- a/src/main/java/com/netflix/conductor/client/http/WorkflowClient.java +++ b/src/main/java/com/netflix/conductor/client/http/WorkflowClient.java @@ -22,6 +22,7 @@ import com.netflix.conductor.common.run.WorkflowSummary; import com.netflix.conductor.common.run.WorkflowTestRequest; import com.netflix.conductor.common.utils.ExternalPayloadStorage; +import io.orkes.conductor.client.http.ConflictException; public abstract class WorkflowClient { @@ -39,7 +40,7 @@ public WorkflowClient() { * @param startWorkflowRequest the {@link StartWorkflowRequest} object to start the workflow * @return the id of the workflow instance that can be used for tracking */ - public abstract String startWorkflow(StartWorkflowRequest startWorkflowRequest); + public abstract String startWorkflow(StartWorkflowRequest startWorkflowRequest) throws ConflictException; /** * Retrieve a workflow by workflow id diff --git a/src/main/java/io/orkes/conductor/client/model/TagObject.java b/src/main/java/io/orkes/conductor/client/model/TagObject.java index 8edbf79c..5c2bdba4 100644 --- a/src/main/java/io/orkes/conductor/client/model/TagObject.java +++ b/src/main/java/io/orkes/conductor/client/model/TagObject.java @@ -56,7 +56,7 @@ public static TypeEnum fromValue(String input) { @SerializedName("type") @Deprecated - // Type has been moved to WorkflowDef.RateLimitConfig + // This is not required anymore. Type has been moved to WorkflowDef.RateLimitConfig as METADATA type private TypeEnum type = null; @SerializedName("value") From 2f2825595b4e68d3caf5d06fd77f137d1d869e61 Mon Sep 17 00:00:00 2001 From: manan164 <1897158+manan164@users.noreply.github.com> Date: Tue, 5 Dec 2023 22:42:35 +0530 Subject: [PATCH 19/20] remove jump task api --- .../conductor/client/WorkflowClient.java | 3 - .../client/http/OrkesWorkflowClient.java | 6 -- .../client/http/api/WorkflowResourceApi.java | 89 ------------------- .../model/JumpWorkflowExecutionRequest.java | 36 -------- 4 files changed, 134 deletions(-) delete mode 100644 src/main/java/io/orkes/conductor/client/model/JumpWorkflowExecutionRequest.java diff --git a/src/main/java/io/orkes/conductor/client/WorkflowClient.java b/src/main/java/io/orkes/conductor/client/WorkflowClient.java index 9b443c2b..cd07e1e9 100644 --- a/src/main/java/io/orkes/conductor/client/WorkflowClient.java +++ b/src/main/java/io/orkes/conductor/client/WorkflowClient.java @@ -26,7 +26,6 @@ import com.netflix.conductor.common.run.WorkflowTestRequest; import io.orkes.conductor.client.http.ApiException; -import io.orkes.conductor.client.model.JumpWorkflowExecutionRequest; import io.orkes.conductor.client.model.WorkflowStatus; import io.orkes.conductor.common.model.WorkflowRun; @@ -93,7 +92,5 @@ public abstract Map> getWorkflowsByNamesAndCorrelationIds */ public abstract Workflow updateVariables(String workflowId, Map variables); - public abstract void jumpToTask(String workflowId, JumpWorkflowExecutionRequest jumpWorkflowExecutionRequest); - public abstract void upgradeRunningWorkflow(String workflowId, UpgradeWorkflowRequest body); } diff --git a/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java b/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java index 100db70f..1ad9667a 100644 --- a/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java +++ b/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java @@ -20,7 +20,6 @@ import java.util.concurrent.*; import com.netflix.conductor.common.metadata.workflow.*; -import io.orkes.conductor.client.model.JumpWorkflowExecutionRequest; import org.apache.commons.lang.StringUtils; import com.netflix.conductor.common.model.BulkResponse; @@ -342,11 +341,6 @@ public void shutdown() { } } - @Override - public void jumpToTask(String workflowId, JumpWorkflowExecutionRequest jumpWorkflowExecutionRequest) { - httpClient.jumpToTaskWithHttpInfo(jumpWorkflowExecutionRequest, workflowId); - } - @Override public void upgradeRunningWorkflow(String workflowId, UpgradeWorkflowRequest upgradeWorkflowRequest ) { httpClient.upgradeRunningWorkflow(upgradeWorkflowRequest, workflowId); diff --git a/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java b/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java index 3b6f110f..104a10c5 100644 --- a/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java +++ b/src/main/java/io/orkes/conductor/client/http/api/WorkflowResourceApi.java @@ -3833,95 +3833,6 @@ private Call updateVariablesCall(String workflowId, Map variable null); } - /** - * Build call for jumpToTask - * @param body (required) - * @param workflowId (required) - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call jumpToTaskCall(JumpWorkflowExecutionRequest body, String workflowId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = body; - - // create path and map variables - String localVarPath = "/workflow/{workflowId}/jump" - .replaceAll("\\{" + "workflowId" + "\\}", apiClient.escapeString(workflowId.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call jumpToTaskValidateBeforeCall(JumpWorkflowExecutionRequest body, String workflowId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException("Missing the required parameter 'body' when calling jumpToTask(Async)"); - } - // verify the required parameter 'workflowId' is set - if (workflowId == null) { - throw new ApiException("Missing the required parameter 'workflowId' when calling jumpToTask(Async)"); - } - - com.squareup.okhttp.Call call = jumpToTaskCall(body, workflowId, progressListener, progressRequestListener); - return call; - } - - /** - * Jump workflow execution to given task - * Jump workflow execution to given task. - * @param body (required) - * @param workflowId (required) - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public void jumpToTask(JumpWorkflowExecutionRequest body, String workflowId) throws ApiException { - jumpToTaskWithHttpInfo(body, workflowId); - } - - /** - * Jump workflow execution to given task - * Jump workflow execution to given task. - * @param body (required) - * @param workflowId (required) - * @return ApiResponse<Void> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse jumpToTaskWithHttpInfo(JumpWorkflowExecutionRequest body, String workflowId) throws ApiException { - com.squareup.okhttp.Call call = jumpToTaskValidateBeforeCall(body, workflowId, null, null); - return apiClient.execute(call); - } /** * Upgrade running workflow to newer version * Upgrade running workflow to newer version diff --git a/src/main/java/io/orkes/conductor/client/model/JumpWorkflowExecutionRequest.java b/src/main/java/io/orkes/conductor/client/model/JumpWorkflowExecutionRequest.java deleted file mode 100644 index 2d7a30fa..00000000 --- a/src/main/java/io/orkes/conductor/client/model/JumpWorkflowExecutionRequest.java +++ /dev/null @@ -1,36 +0,0 @@ -package io.orkes.conductor.client.model; - -import java.util.Map; - -public class JumpWorkflowExecutionRequest { - - public Map getSkippedTasksOutput() { - return skippedTasksOutput; - } - - public void setSkippedTasksOutput(Map skippedTasksOutput) { - this.skippedTasksOutput = skippedTasksOutput; - } - - public Map getJumpTaskInput() { - return jumpTaskInput; - } - - public void setJumpTaskInput(Map jumpTaskInput) { - this.jumpTaskInput = jumpTaskInput; - } - - public String getTaskReferenceName() { - return taskReferenceName; - } - - public void setTaskReferenceName(String taskReferenceName) { - this.taskReferenceName = taskReferenceName; - } - private Map skippedTasksOutput; - - private Map jumpTaskInput; - - private String taskReferenceName; - -} From 2b8e595bfa999d2a8a392af7909ae09e961c2531 Mon Sep 17 00:00:00 2001 From: Viren Baraiya Date: Sun, 28 Jan 2024 17:04:26 -0800 Subject: [PATCH 20/20] tests and formatting --- build.gradle | 2 +- .../conductor/client/http/WorkflowClient.java | 1 + .../io/orkes/conductor/client/ApiClient.java | 3 +- .../conductor/client/WorkflowClient.java | 2 +- .../client/http/ConflictException.java | 7 +++-- .../client/http/OrkesWorkflowClient.java | 2 +- .../conductor/client/api/ClientTest.java | 1 + .../client/api/WorkflowClientTests.java | 1 + .../client/api/WorkflowStateUpdateTests.java | 29 +++++++++++++++++++ 9 files changed, 41 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 36ae3def..25a7f546 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ ext { versions = [ awaitility : '4.2.0', commonsLang : '3.12.0', - conductor : '3.9.24-orkes', + conductor : '3.9.30-orkes', jackson : '2.11.4!!', junit : '5.9.0', slf4j : '1.7.36', diff --git a/src/main/java/com/netflix/conductor/client/http/WorkflowClient.java b/src/main/java/com/netflix/conductor/client/http/WorkflowClient.java index fc4dab3f..dbd37c2b 100644 --- a/src/main/java/com/netflix/conductor/client/http/WorkflowClient.java +++ b/src/main/java/com/netflix/conductor/client/http/WorkflowClient.java @@ -22,6 +22,7 @@ import com.netflix.conductor.common.run.WorkflowSummary; import com.netflix.conductor.common.run.WorkflowTestRequest; import com.netflix.conductor.common.utils.ExternalPayloadStorage; + import io.orkes.conductor.client.http.ConflictException; public abstract class WorkflowClient { diff --git a/src/main/java/io/orkes/conductor/client/ApiClient.java b/src/main/java/io/orkes/conductor/client/ApiClient.java index fcfbc11b..bdf234df 100644 --- a/src/main/java/io/orkes/conductor/client/ApiClient.java +++ b/src/main/java/io/orkes/conductor/client/ApiClient.java @@ -41,7 +41,6 @@ import javax.net.ssl.*; -import com.netflix.conductor.common.validation.ErrorResponse; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,6 +48,8 @@ import org.threeten.bp.OffsetDateTime; import org.threeten.bp.format.DateTimeFormatter; +import com.netflix.conductor.common.validation.ErrorResponse; + import io.orkes.conductor.client.http.*; import io.orkes.conductor.client.http.api.TokenResourceApi; import io.orkes.conductor.client.http.auth.ApiKeyAuth; diff --git a/src/main/java/io/orkes/conductor/client/WorkflowClient.java b/src/main/java/io/orkes/conductor/client/WorkflowClient.java index 0c79e19c..b5e08958 100644 --- a/src/main/java/io/orkes/conductor/client/WorkflowClient.java +++ b/src/main/java/io/orkes/conductor/client/WorkflowClient.java @@ -104,7 +104,7 @@ public abstract Map> getWorkflowsByNamesAndCorrelationIds * the call will return with the current status of the workflow * @param updateRequest Payload for updating state of workflow. * - * @return + * @return Returns updated workflow execution */ public abstract WorkflowRun updateWorkflow(String workflowId, List waitUntilTaskRefNames, Integer waitForSeconds, WorkflowStateUpdate updateRequest); diff --git a/src/main/java/io/orkes/conductor/client/http/ConflictException.java b/src/main/java/io/orkes/conductor/client/http/ConflictException.java index 93ee2970..ae4d54f2 100644 --- a/src/main/java/io/orkes/conductor/client/http/ConflictException.java +++ b/src/main/java/io/orkes/conductor/client/http/ConflictException.java @@ -12,12 +12,13 @@ */ package io.orkes.conductor.client.http; -import io.orkes.conductor.client.OrkesClientException; -import org.apache.commons.lang3.StringUtils; - import java.util.List; import java.util.Map; +import org.apache.commons.lang3.StringUtils; + +import io.orkes.conductor.client.OrkesClientException; + public class ConflictException extends OrkesClientException { private int code; diff --git a/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java b/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java index f6f64794..3eca4225 100644 --- a/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java +++ b/src/main/java/io/orkes/conductor/client/http/OrkesWorkflowClient.java @@ -19,9 +19,9 @@ import java.util.UUID; import java.util.concurrent.*; -import com.netflix.conductor.common.metadata.workflow.*; import org.apache.commons.lang.StringUtils; +import com.netflix.conductor.common.metadata.workflow.*; import com.netflix.conductor.common.model.BulkResponse; import com.netflix.conductor.common.run.SearchResult; import com.netflix.conductor.common.run.Workflow; diff --git a/src/test/java/io/orkes/conductor/client/api/ClientTest.java b/src/test/java/io/orkes/conductor/client/api/ClientTest.java index 81171714..f162b2af 100644 --- a/src/test/java/io/orkes/conductor/client/api/ClientTest.java +++ b/src/test/java/io/orkes/conductor/client/api/ClientTest.java @@ -16,6 +16,7 @@ import io.orkes.conductor.client.util.ApiUtil; public abstract class ClientTest { + protected static OrkesClients orkesClients; static { diff --git a/src/test/java/io/orkes/conductor/client/api/WorkflowClientTests.java b/src/test/java/io/orkes/conductor/client/api/WorkflowClientTests.java index b793c5f5..e5a104c9 100644 --- a/src/test/java/io/orkes/conductor/client/api/WorkflowClientTests.java +++ b/src/test/java/io/orkes/conductor/client/api/WorkflowClientTests.java @@ -206,6 +206,7 @@ public void testSkipTaskFromWorkflow() throws Exception { () -> workflowClient.terminateWorkflowsWithFailure(List.of(workflowId), null, false)); } + @Test public void testUpdateVariables() { ConductorWorkflow workflow = new ConductorWorkflow<>(workflowExecutor); workflow.add(new SimpleTask("simple_task", "simple_task_ref")); diff --git a/src/test/java/io/orkes/conductor/client/api/WorkflowStateUpdateTests.java b/src/test/java/io/orkes/conductor/client/api/WorkflowStateUpdateTests.java index 1505179f..e18f85b8 100644 --- a/src/test/java/io/orkes/conductor/client/api/WorkflowStateUpdateTests.java +++ b/src/test/java/io/orkes/conductor/client/api/WorkflowStateUpdateTests.java @@ -15,6 +15,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -23,16 +24,19 @@ import com.netflix.conductor.common.metadata.tasks.Task; import com.netflix.conductor.common.metadata.tasks.TaskResult; +import com.netflix.conductor.common.metadata.workflow.IdempotencyStrategy; import com.netflix.conductor.common.metadata.workflow.StartWorkflowRequest; import com.netflix.conductor.common.run.Workflow; import io.orkes.conductor.client.WorkflowClient; +import io.orkes.conductor.client.http.ConflictException; import io.orkes.conductor.client.model.WorkflowStateUpdate; import io.orkes.conductor.common.model.WorkflowRun; import lombok.SneakyThrows; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class WorkflowStateUpdateTests extends ClientTest { @@ -96,4 +100,29 @@ public void test() { .collect(Collectors.toList())); } + + @Test + public void testIdempotency() { + StartWorkflowRequest startWorkflowRequest = new StartWorkflowRequest(); + startWorkflowRequest.setName("sync_task_variable_updates"); + startWorkflowRequest.setVersion(1); + String idempotencyKey = UUID.randomUUID().toString(); + startWorkflowRequest.setIdempotencyKey(idempotencyKey); + startWorkflowRequest.setIdempotencyStrategy(IdempotencyStrategy.FAIL); + String workflowId = workflowClient.startWorkflow(startWorkflowRequest); + + + startWorkflowRequest.setIdempotencyStrategy(IdempotencyStrategy.RETURN_EXISTING); + String workflowId2 = workflowClient.startWorkflow(startWorkflowRequest); + assertEquals(workflowId, workflowId2); + + startWorkflowRequest.setIdempotencyStrategy(IdempotencyStrategy.FAIL); + boolean conflict = false; + try { + workflowClient.startWorkflow(startWorkflowRequest); + } catch (ConflictException ce) { + conflict = true; + } + assertTrue(conflict); + } }