Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
get workflow by project id
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardW98 authored and openshift-merge-robot committed May 4, 2023
1 parent 97e4503 commit 717ba82
Show file tree
Hide file tree
Showing 38 changed files with 1,509 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.redhat.parodos.sdk.model.WorkFlowDefinitionResponseDTO;
import com.redhat.parodos.sdk.model.WorkFlowRequestDTO;
import com.redhat.parodos.sdk.model.WorkFlowResponseDTO;
import com.redhat.parodos.sdk.model.WorkFlowResponseDTO.WorkStatusEnum;
import com.redhat.parodos.sdk.model.WorkFlowStatusResponseDTO;
import com.redhat.parodos.sdk.model.WorkRequestDTO;
import com.redhat.parodos.workflow.utils.CredUtils;
Expand Down Expand Up @@ -67,10 +66,10 @@ public void runComplexWorkFlow() throws ApiException, InterruptedException {
.arguments(List.of(new ArgumentRequestDTO().key("GIT_REPO_URL").value("git_repo_url")))));

WorkFlowResponseDTO workFlowResponseDTO = workflowApi.execute(workFlowRequestDTO);
assertEquals(WorkStatusEnum.COMPLETED, workFlowResponseDTO.getWorkStatus());
assertEquals(WorkFlowResponseDTO.WorkStatusEnum.COMPLETED, workFlowResponseDTO.getWorkStatus());
log.info("workflow finished successfully with response: {}", workFlowResponseDTO);
if (workFlowResponseDTO.getWorkFlowOptions() == null
|| workFlowResponseDTO.getWorkStatus() != WorkStatusEnum.COMPLETED) {
|| workFlowResponseDTO.getWorkStatus() != WorkFlowResponseDTO.WorkStatusEnum.COMPLETED) {
fail("There is no valid INFRASTRUCTURE_OPTION");
}

Expand Down Expand Up @@ -112,15 +111,15 @@ public void runComplexWorkFlow() throws ApiException, InterruptedException {
workFlowResponseDTO = workflowApi.execute(workFlowRequestDTO);

assertNotNull("There is no valid WorkFlowExecutionId", workFlowResponseDTO.getWorkFlowExecutionId());
assertEquals(workFlowResponseDTO.getWorkStatus(), WorkStatusEnum.IN_PROGRESS);
assertEquals(workFlowResponseDTO.getWorkStatus(), WorkFlowResponseDTO.WorkStatusEnum.IN_PROGRESS);
log.info("Onboarding workflow execution id: {}", workFlowResponseDTO.getWorkFlowExecutionId());

WorkFlowStatusResponseDTO workFlowStatusResponseDTO = waitWorkflowStatusAsync(workflowApi,
workFlowResponseDTO.getWorkFlowExecutionId());

assertNotNull(workFlowStatusResponseDTO);
assertNotNull(workFlowStatusResponseDTO.getWorkFlowExecutionId());
assertEquals(WorkStatusEnum.COMPLETED.toString(), workFlowStatusResponseDTO.getStatus());
assertEquals(WorkFlowResponseDTO.WorkStatusEnum.COMPLETED.toString(), workFlowStatusResponseDTO.getStatus());
log.info("Onboarding workflow execution completed with status {}", workFlowStatusResponseDTO.getStatus());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.redhat.parodos.sdk.model.ProjectResponseDTO;
import com.redhat.parodos.sdk.model.WorkFlowRequestDTO;
import com.redhat.parodos.sdk.model.WorkFlowResponseDTO;
import com.redhat.parodos.sdk.model.WorkFlowResponseDTO.WorkStatusEnum;
import com.redhat.parodos.sdk.model.WorkFlowStatusResponseDTO;
import com.redhat.parodos.workflow.utils.CredUtils;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -57,7 +56,7 @@ public void runEscalationFlow() throws ApiException, InterruptedException {
WorkFlowResponseDTO workFlowResponseDTO = workflowApi.execute(workFlowRequestDTO);

assertNotNull("There is no valid WorkFlowExecutionId", workFlowResponseDTO.getWorkFlowExecutionId());
assertEquals(workFlowResponseDTO.getWorkStatus(), WorkStatusEnum.IN_PROGRESS);
assertEquals(workFlowResponseDTO.getWorkStatus(), WorkFlowResponseDTO.WorkStatusEnum.IN_PROGRESS);
log.info("Simple escalation workflow execution id: {}", workFlowResponseDTO.getWorkFlowExecutionId());
log.info("Simple Escalation Flow {}", workFlowResponseDTO.getWorkStatus());
log.info("Waiting for checkers to complete...");
Expand All @@ -67,7 +66,7 @@ public void runEscalationFlow() throws ApiException, InterruptedException {

assertNotNull(workFlowStatusResponseDTO);
assertNotNull(workFlowStatusResponseDTO.getWorkFlowExecutionId());
assertEquals(WorkStatusEnum.COMPLETED.toString(), workFlowStatusResponseDTO.getStatus());
assertEquals(WorkFlowResponseDTO.WorkStatusEnum.COMPLETED.toString(), workFlowStatusResponseDTO.getStatus());
log.info("******** Simple Escalation Flow {} ********", workFlowStatusResponseDTO.getStatus());

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.redhat.parodos.examples.integration;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.redhat.parodos.examples.integration.utils.ExamplesUtils;
import com.redhat.parodos.sdk.api.WorkflowApi;
import com.redhat.parodos.sdk.api.WorkflowDefinitionApi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import com.redhat.parodos.sdk.invoker.Configuration;
import com.redhat.parodos.sdk.model.ProjectResponseDTO;
import com.redhat.parodos.sdk.model.WorkFlowDefinitionResponseDTO;
import com.redhat.parodos.sdk.model.WorkFlowResponseDTO;
import com.redhat.parodos.sdk.model.WorkRequestDTO;
import com.redhat.parodos.sdk.model.ArgumentRequestDTO;
import com.redhat.parodos.sdk.model.WorkFlowRequestDTO;
import com.redhat.parodos.sdk.model.WorkFlowResponseDTO;
import com.redhat.parodos.workflow.consts.WorkFlowConstants;
import com.redhat.parodos.workflow.enums.WorkFlowType;
import com.redhat.parodos.workflow.enums.WorkType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.redhat.parodos.sdk.model.WorkFlowDefinitionResponseDTO;
import com.redhat.parodos.sdk.model.WorkFlowRequestDTO;
import com.redhat.parodos.sdk.model.WorkFlowResponseDTO;
import com.redhat.parodos.sdk.model.WorkFlowResponseDTO.WorkStatusEnum;
import com.redhat.parodos.sdk.model.WorkRequestDTO;
import com.redhat.parodos.workflow.consts.WorkFlowConstants;
import com.redhat.parodos.workflow.enums.WorkFlowType;
Expand Down Expand Up @@ -114,7 +113,7 @@ public void runSimpleWorkFlow() throws ApiException, InterruptedException {
assertNotNull(workFlowResponseDTO.getWorkFlowExecutionId());
assertNull(workFlowResponseDTO.getWorkFlowOptions());
assertNotNull(workFlowResponseDTO.getWorkStatus());
assertEquals(WorkStatusEnum.COMPLETED, workFlowResponseDTO.getWorkStatus());
assertEquals(WorkFlowResponseDTO.WorkStatusEnum.COMPLETED, workFlowResponseDTO.getWorkStatus());

log.info("workflow finished successfully with response: {}", workFlowResponseDTO);
log.info("******** Simple Sequence Flow Completed ********");
Expand Down
2 changes: 2 additions & 0 deletions workflow-service-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ Class | Method | HTTP request | Description
*ProjectApi* | [**getProjects**](docs/ProjectApi.md#getProjects) | **GET** /api/v1/projects | Returns a list of project
*WorkflowApi* | [**execute**](docs/WorkflowApi.md#execute) | **POST** /api/v1/workflows | Executes a workflow
*WorkflowApi* | [**getStatus**](docs/WorkflowApi.md#getStatus) | **GET** /api/v1/workflows/{workFlowExecutionId}/status | Returns a workflow status
*WorkflowApi* | [**getStatusByProjectId**](docs/WorkflowApi.md#getStatusByProjectId) | **GET** /api/v1/workflows | Returns workflows by project id
*WorkflowApi* | [**getWorkflowParameters**](docs/WorkflowApi.md#getWorkflowParameters) | **GET** /api/v1/workflows/{workFlowExecutionId}/context | Returns workflow context parameters
*WorkflowApi* | [**updateWorkFlowCheckerTaskStatus**](docs/WorkflowApi.md#updateWorkFlowCheckerTaskStatus) | **POST** /api/v1/workflows/{workFlowExecutionId}/checkers/{workFlowCheckerTaskName} | Updates a workflow checker task status
*WorkflowDefinitionApi* | [**getWorkFlowDefinitionById**](docs/WorkflowDefinitionApi.md#getWorkFlowDefinitionById) | **GET** /api/v1/workflowdefinitions/{id} | Returns information about a workflow definition by id
Expand All @@ -127,6 +128,7 @@ Class | Method | HTTP request | Description
## Documentation for Models

- [ArgumentRequestDTO](docs/ArgumentRequestDTO.md)
- [GetStatusByProjectId200Response](docs/GetStatusByProjectId200Response.md)
- [ProjectRequestDTO](docs/ProjectRequestDTO.md)
- [ProjectResponseDTO](docs/ProjectResponseDTO.md)
- [UpdateParameter200Response](docs/UpdateParameter200Response.md)
Expand Down
45 changes: 45 additions & 0 deletions workflow-service-sdk/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,32 @@ paths:
x-content-type: application/json
x-accepts: application/json
/api/v1/workflows:
get:
operationId: getStatusByProjectId
parameters:
- explode: true
in: query
name: projectId
required: false
schema:
format: uuid
type: string
style: form
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/getStatusByProjectId_200_response'
description: Succeeded
"401":
description: Unauthorized
"403":
description: Forbidden
summary: Returns workflows by project id
tags:
- Workflow
x-accepts: application/json
post:
operationId: execute
requestBody:
Expand Down Expand Up @@ -921,6 +947,7 @@ components:
WorkFlowResponseDTO:
example:
workStatus: FAILED
workFlowName: workFlowName
workFlowOptions:
continuationOptions:
- identifier: identifier
Expand Down Expand Up @@ -1006,11 +1033,26 @@ components:
details:
- details
- details
endDate: endDate
workFlowExecutionId: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
createUser: createUser
projectId: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
startDate: startDate
properties:
createUser:
type: string
endDate:
type: string
projectId:
format: uuid
type: string
startDate:
type: string
workFlowExecutionId:
format: uuid
type: string
workFlowName:
type: string
workFlowOptions:
$ref: '#/components/schemas/WorkFlowOptions'
workStatus:
Expand Down Expand Up @@ -1117,4 +1159,7 @@ components:
updateParameter_200_response:
allOf:
- $ref: '#/components/schemas/WorkParameterValueResponseDTO'
getStatusByProjectId_200_response:
allOf:
- $ref: '#/components/schemas/WorkFlowStatusResponseDTO'

16 changes: 16 additions & 0 deletions workflow-service-sdk/docs/GetStatusByProjectId200Response.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


# GetStatusByProjectId200Response


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**status** | **String** | | [optional] |
|**workFlowExecutionId** | **UUID** | | [optional] |
|**workFlowName** | **String** | | [optional] |
|**works** | [**List<WorkStatusResponseDTO>**](WorkStatusResponseDTO.md) | | [optional] |



5 changes: 5 additions & 0 deletions workflow-service-sdk/docs/WorkFlowResponseDTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**createUser** | **String** | | [optional] |
|**endDate** | **String** | | [optional] |
|**projectId** | **UUID** | | [optional] |
|**startDate** | **String** | | [optional] |
|**workFlowExecutionId** | **UUID** | | [optional] |
|**workFlowName** | **String** | | [optional] |
|**workFlowOptions** | [**WorkFlowOptions**](WorkFlowOptions.md) | | [optional] |
|**workStatus** | [**WorkStatusEnum**](#WorkStatusEnum) | | [optional] |

Expand Down
63 changes: 63 additions & 0 deletions workflow-service-sdk/docs/WorkflowApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All URIs are relative to *http://localhost:8080*
|------------- | ------------- | -------------|
| [**execute**](WorkflowApi.md#execute) | **POST** /api/v1/workflows | Executes a workflow |
| [**getStatus**](WorkflowApi.md#getStatus) | **GET** /api/v1/workflows/{workFlowExecutionId}/status | Returns a workflow status |
| [**getStatusByProjectId**](WorkflowApi.md#getStatusByProjectId) | **GET** /api/v1/workflows | Returns workflows by project id |
| [**getWorkflowParameters**](WorkflowApi.md#getWorkflowParameters) | **GET** /api/v1/workflows/{workFlowExecutionId}/context | Returns workflow context parameters |
| [**updateWorkFlowCheckerTaskStatus**](WorkflowApi.md#updateWorkFlowCheckerTaskStatus) | **POST** /api/v1/workflows/{workFlowExecutionId}/checkers/{workFlowCheckerTaskName} | Updates a workflow checker task status |

Expand Down Expand Up @@ -134,6 +135,68 @@ No authorization required
| **401** | Unauthorized | - |
| **403** | Forbidden | - |

<a name="getStatusByProjectId"></a>
# **getStatusByProjectId**
> GetStatusByProjectId200Response getStatusByProjectId(projectId)
Returns workflows by project id

### Example
```java
// Import classes:
import com.redhat.parodos.sdk.invoker.ApiClient;
import com.redhat.parodos.sdk.invoker.ApiException;
import com.redhat.parodos.sdk.invoker.Configuration;
import com.redhat.parodos.sdk.invoker.models.*;
import com.redhat.parodos.sdk.api.WorkflowApi;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://localhost:8080");

WorkflowApi apiInstance = new WorkflowApi(defaultClient);
UUID projectId = UUID.randomUUID(); // UUID |
try {
GetStatusByProjectId200Response result = apiInstance.getStatusByProjectId(projectId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling WorkflowApi#getStatusByProjectId");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
```

### Parameters

| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **projectId** | **UUID**| | [optional] |

### Return type

[**GetStatusByProjectId200Response**](GetStatusByProjectId200Response.md)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Succeeded | - |
| **401** | Unauthorized | - |
| **403** | Forbidden | - |

<a name="getWorkflowParameters"></a>
# **getWorkflowParameters**
> WorkFlowContextResponseDTO getWorkflowParameters(workFlowExecutionId, param)
Expand Down
Loading

0 comments on commit 717ba82

Please sign in to comment.