Skip to content

Commit

Permalink
Merge pull request #80 from mareklibra/FLPATH-1881.backport.passBusin…
Browse files Browse the repository at this point in the history
…nessKey.AssignedBy

fix(orchestrator): pass businessKey for assessments
  • Loading branch information
batzionb authored Dec 1, 2024
2 parents fe61722 + 6471a68 commit 8c112f4
Show file tree
Hide file tree
Showing 11 changed files with 356 additions and 264 deletions.
7 changes: 7 additions & 0 deletions workspaces/orchestrator/.changeset/six-poems-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@red-hat-developer-hub/backstage-plugin-orchestrator-backend': patch
'@red-hat-developer-hub/backstage-plugin-orchestrator-common': patch
'@red-hat-developer-hub/backstage-plugin-orchestrator': patch
---

The parent assessment link is shown again thanks to fixing passing of the businessKey when "execute" action is trigerred.
Original file line number Diff line number Diff line change
Expand Up @@ -733,10 +733,12 @@ function setupInternalRoutes(
if (decision.result === AuthorizeResult.DENY) {
manageDenyAuthorization(endpointName, endpoint, _req);
}

const includeAssessment = routerApi.v2.extractQueryParam(
c.request,
QUERY_PARAM_INCLUDE_ASSESSMENT,
);

return routerApi.v2
.getInstanceById(instanceId, !!includeAssessment)
.then(result => res.status(200).json(result))
Expand Down
492 changes: 252 additions & 240 deletions workspaces/orchestrator/plugins/orchestrator-common/report.api.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
fc8d7c1e837b67d3de9b235126aeb829972a98ce
5fcc8d37339b5241ec2435343b540d2aec5c6873

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -927,10 +927,11 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati
* @summary Execute a workflow
* @param {string} workflowId ID of the workflow to execute
* @param {ExecuteWorkflowRequestDTO} executeWorkflowRequestDTO
* @param {string} [businessKey] ID of the parent workflow
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
executeWorkflow: async (workflowId: string, executeWorkflowRequestDTO: ExecuteWorkflowRequestDTO, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
executeWorkflow: async (workflowId: string, executeWorkflowRequestDTO: ExecuteWorkflowRequestDTO, businessKey?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'workflowId' is not null or undefined
assertParamExists('executeWorkflow', 'workflowId', workflowId)
// verify required parameter 'executeWorkflowRequestDTO' is not null or undefined
Expand All @@ -948,6 +949,10 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;

if (businessKey !== undefined) {
localVarQueryParameter['businessKey'] = businessKey;
}



localVarHeaderParameter['Content-Type'] = 'application/json';
Expand Down Expand Up @@ -1306,11 +1311,12 @@ export const DefaultApiFp = function(configuration?: Configuration) {
* @summary Execute a workflow
* @param {string} workflowId ID of the workflow to execute
* @param {ExecuteWorkflowRequestDTO} executeWorkflowRequestDTO
* @param {string} [businessKey] ID of the parent workflow
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async executeWorkflow(workflowId: string, executeWorkflowRequestDTO: ExecuteWorkflowRequestDTO, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ExecuteWorkflowResponseDTO>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.executeWorkflow(workflowId, executeWorkflowRequestDTO, options);
async executeWorkflow(workflowId: string, executeWorkflowRequestDTO: ExecuteWorkflowRequestDTO, businessKey?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ExecuteWorkflowResponseDTO>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.executeWorkflow(workflowId, executeWorkflowRequestDTO, businessKey, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['DefaultApi.executeWorkflow']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
Expand Down Expand Up @@ -1456,11 +1462,12 @@ export const DefaultApiFactory = function (configuration?: Configuration, basePa
* @summary Execute a workflow
* @param {string} workflowId ID of the workflow to execute
* @param {ExecuteWorkflowRequestDTO} executeWorkflowRequestDTO
* @param {string} [businessKey] ID of the parent workflow
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
executeWorkflow(workflowId: string, executeWorkflowRequestDTO: ExecuteWorkflowRequestDTO, options?: any): AxiosPromise<ExecuteWorkflowResponseDTO> {
return localVarFp.executeWorkflow(workflowId, executeWorkflowRequestDTO, options).then((request) => request(axios, basePath));
executeWorkflow(workflowId: string, executeWorkflowRequestDTO: ExecuteWorkflowRequestDTO, businessKey?: string, options?: any): AxiosPromise<ExecuteWorkflowResponseDTO> {
return localVarFp.executeWorkflow(workflowId, executeWorkflowRequestDTO, businessKey, options).then((request) => request(axios, basePath));
},
/**
* Get a workflow execution/run (instance)
Expand Down Expand Up @@ -1578,12 +1585,13 @@ export class DefaultApi extends BaseAPI {
* @summary Execute a workflow
* @param {string} workflowId ID of the workflow to execute
* @param {ExecuteWorkflowRequestDTO} executeWorkflowRequestDTO
* @param {string} [businessKey] ID of the parent workflow
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApi
*/
public executeWorkflow(workflowId: string, executeWorkflowRequestDTO: ExecuteWorkflowRequestDTO, options?: RawAxiosRequestConfig) {
return DefaultApiFp(this.configuration).executeWorkflow(workflowId, executeWorkflowRequestDTO, options).then((request) => request(this.axios, this.basePath));
public executeWorkflow(workflowId: string, executeWorkflowRequestDTO: ExecuteWorkflowRequestDTO, businessKey?: string, options?: RawAxiosRequestConfig) {
return DefaultApiFp(this.configuration).executeWorkflow(workflowId, executeWorkflowRequestDTO, businessKey, options).then((request) => request(this.axios, this.basePath));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1866,7 +1866,7 @@ <h3>Usage and SDK Samples</h3>
<pre class="prettyprint"><code class="language-bsh">curl -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
"http://localhost/v2/workflows/{workflowId}/execute" \
"http://localhost/v2/workflows/{workflowId}/execute?businessKey=businessKey_example" \
-d '{
&quot;inputData&quot; : &quot;{}&quot;
}'
Expand All @@ -1888,9 +1888,10 @@ <h3>Usage and SDK Samples</h3>
DefaultApi apiInstance = new DefaultApi();
String workflowId = workflowId_example; // String | ID of the workflow to execute
ExecuteWorkflowRequestDTO executeWorkflowRequestDTO = ; // ExecuteWorkflowRequestDTO |
String businessKey = businessKey_example; // String | ID of the parent workflow

try {
ExecuteWorkflowResponseDTO result = apiInstance.executeWorkflow(workflowId, executeWorkflowRequestDTO);
ExecuteWorkflowResponseDTO result = apiInstance.executeWorkflow(workflowId, executeWorkflowRequestDTO, businessKey);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DefaultApi#executeWorkflow");
Expand All @@ -1908,9 +1909,10 @@ <h3>Usage and SDK Samples</h3>

final String workflowId = new String(); // String | ID of the workflow to execute
final ExecuteWorkflowRequestDTO executeWorkflowRequestDTO = new ExecuteWorkflowRequestDTO(); // ExecuteWorkflowRequestDTO |
final String businessKey = new String(); // String | ID of the parent workflow

try {
final result = await api_instance.executeWorkflow(workflowId, executeWorkflowRequestDTO);
final result = await api_instance.executeWorkflow(workflowId, executeWorkflowRequestDTO, businessKey);
print(result);
} catch (e) {
print('Exception when calling DefaultApi->executeWorkflow: $e\n');
Expand All @@ -1927,9 +1929,10 @@ <h3>Usage and SDK Samples</h3>
DefaultApi apiInstance = new DefaultApi();
String workflowId = workflowId_example; // String | ID of the workflow to execute
ExecuteWorkflowRequestDTO executeWorkflowRequestDTO = ; // ExecuteWorkflowRequestDTO |
String businessKey = businessKey_example; // String | ID of the parent workflow

try {
ExecuteWorkflowResponseDTO result = apiInstance.executeWorkflow(workflowId, executeWorkflowRequestDTO);
ExecuteWorkflowResponseDTO result = apiInstance.executeWorkflow(workflowId, executeWorkflowRequestDTO, businessKey);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DefaultApi#executeWorkflow");
Expand All @@ -1949,10 +1952,12 @@ <h3>Usage and SDK Samples</h3>
DefaultApi *apiInstance = [[DefaultApi alloc] init];
String *workflowId = workflowId_example; // ID of the workflow to execute (default to null)
ExecuteWorkflowRequestDTO *executeWorkflowRequestDTO = ; //
String *businessKey = businessKey_example; // ID of the parent workflow (optional) (default to null)

// Execute a workflow
[apiInstance executeWorkflowWith:workflowId
executeWorkflowRequestDTO:executeWorkflowRequestDTO
businessKey:businessKey
completionHandler: ^(ExecuteWorkflowResponseDTO output, NSError* error) {
if (output) {
NSLog(@"%@", output);
Expand All @@ -1971,6 +1976,9 @@ <h3>Usage and SDK Samples</h3>
var api = new OrchestratorPlugin.DefaultApi()
var workflowId = workflowId_example; // {String} ID of the workflow to execute
var executeWorkflowRequestDTO = ; // {ExecuteWorkflowRequestDTO}
var opts = {
'businessKey': businessKey_example // {String} ID of the parent workflow
};

var callback = function(error, data, response) {
if (error) {
Expand All @@ -1979,7 +1987,7 @@ <h3>Usage and SDK Samples</h3>
console.log('API called successfully. Returned data: ' + data);
}
};
api.executeWorkflow(workflowId, executeWorkflowRequestDTO, callback);
api.executeWorkflow(workflowId, executeWorkflowRequestDTO, opts, callback);
</code></pre>
</div>

Expand All @@ -2004,10 +2012,11 @@ <h3>Usage and SDK Samples</h3>
var apiInstance = new DefaultApi();
var workflowId = workflowId_example; // String | ID of the workflow to execute (default to null)
var executeWorkflowRequestDTO = new ExecuteWorkflowRequestDTO(); // ExecuteWorkflowRequestDTO |
var businessKey = businessKey_example; // String | ID of the parent workflow (optional) (default to null)

try {
// Execute a workflow
ExecuteWorkflowResponseDTO result = apiInstance.executeWorkflow(workflowId, executeWorkflowRequestDTO);
ExecuteWorkflowResponseDTO result = apiInstance.executeWorkflow(workflowId, executeWorkflowRequestDTO, businessKey);
Debug.WriteLine(result);
} catch (Exception e) {
Debug.Print("Exception when calling DefaultApi.executeWorkflow: " + e.Message );
Expand All @@ -2026,9 +2035,10 @@ <h3>Usage and SDK Samples</h3>
$api_instance = new OpenAPITools\Client\Api\DefaultApi();
$workflowId = workflowId_example; // String | ID of the workflow to execute
$executeWorkflowRequestDTO = ; // ExecuteWorkflowRequestDTO |
$businessKey = businessKey_example; // String | ID of the parent workflow

try {
$result = $api_instance->executeWorkflow($workflowId, $executeWorkflowRequestDTO);
$result = $api_instance->executeWorkflow($workflowId, $executeWorkflowRequestDTO, $businessKey);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling DefaultApi->executeWorkflow: ', $e->getMessage(), PHP_EOL;
Expand All @@ -2045,9 +2055,10 @@ <h3>Usage and SDK Samples</h3>
my $api_instance = WWW::OPenAPIClient::DefaultApi->new();
my $workflowId = workflowId_example; # String | ID of the workflow to execute
my $executeWorkflowRequestDTO = WWW::OPenAPIClient::Object::ExecuteWorkflowRequestDTO->new(); # ExecuteWorkflowRequestDTO |
my $businessKey = businessKey_example; # String | ID of the parent workflow

eval {
my $result = $api_instance->executeWorkflow(workflowId => $workflowId, executeWorkflowRequestDTO => $executeWorkflowRequestDTO);
my $result = $api_instance->executeWorkflow(workflowId => $workflowId, executeWorkflowRequestDTO => $executeWorkflowRequestDTO, businessKey => $businessKey);
print Dumper($result);
};
if ($@) {
Expand All @@ -2066,10 +2077,11 @@ <h3>Usage and SDK Samples</h3>
api_instance = openapi_client.DefaultApi()
workflowId = workflowId_example # String | ID of the workflow to execute (default to null)
executeWorkflowRequestDTO = # ExecuteWorkflowRequestDTO |
businessKey = businessKey_example # String | ID of the parent workflow (optional) (default to null)

try:
# Execute a workflow
api_response = api_instance.execute_workflow(workflowId, executeWorkflowRequestDTO)
api_response = api_instance.execute_workflow(workflowId, executeWorkflowRequestDTO, businessKey=businessKey)
pprint(api_response)
except ApiException as e:
print("Exception when calling DefaultApi->executeWorkflow: %s\n" % e)</code></pre>
Expand All @@ -2081,9 +2093,10 @@ <h3>Usage and SDK Samples</h3>
pub fn main() {
let workflowId = workflowId_example; // String
let executeWorkflowRequestDTO = ; // ExecuteWorkflowRequestDTO
let businessKey = businessKey_example; // String

let mut context = DefaultApi::Context::default();
let result = client.executeWorkflow(workflowId, executeWorkflowRequestDTO, &context).wait();
let result = client.executeWorkflow(workflowId, executeWorkflowRequestDTO, businessKey, &context).wait();

println!("{:?}", result);
}
Expand Down Expand Up @@ -2178,6 +2191,33 @@ <h2>Parameters</h2>
</table>


<div class="methodsubtabletitle">Query parameters</div>
<table id="methodsubtable">
<tr>
<th width="150px">Name</th>
<th>Description</th>
</tr>
<tr><td style="width:150px;">businessKey</td>
<td>


<div id="d2e199_executeWorkflow_businessKey">
<div class="json-schema-view">
<div class="primitive">
<span class="type">
String
</span>

<div class="inner description marked">
ID of the parent workflow
</div>
</div>
</div>
</div>
</td>
</tr>

</table>

<h2>Responses</h2>
<h3 id="examples-Default-executeWorkflow-title-200"></h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ No authorization required

<a name="executeWorkflow"></a>
# **executeWorkflow**
> ExecuteWorkflowResponseDTO executeWorkflow(workflowId, ExecuteWorkflowRequestDTO)
> ExecuteWorkflowResponseDTO executeWorkflow(workflowId, ExecuteWorkflowRequestDTO, businessKey)
Execute a workflow

Expand All @@ -58,6 +58,7 @@ Execute a workflow
|------------- | ------------- | ------------- | -------------|
| **workflowId** | **String**| ID of the workflow to execute | [default to null] |
| **ExecuteWorkflowRequestDTO** | [**ExecuteWorkflowRequestDTO**](../Models/ExecuteWorkflowRequestDTO.md)| | |
| **businessKey** | **String**| ID of the parent workflow | [optional] [default to null] |

### Return type

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ paths:
required: true
schema:
type: string
- name: businessKey
in: query
description: ID of the parent workflow
required: false
schema:
type: string
requestBody:
required: true
content:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,18 @@ describe('OrchestratorClient', () => {
mockExecResponse: ExecuteWorkflowResponseDTO,
executeWorkflowSpy: jest.SpyInstance,
parameters: JsonObject,
businessKey?: string,
) => {
return () => {
expect(result).toBeDefined();
expect(result.data).toEqual(mockExecResponse);
expect(axios.request).toHaveBeenCalledTimes(1);
expect(axios.request).toHaveBeenCalledWith({
...getAxiosTestRequest(`/v2/workflows/${workflowId}/execute`),
...getAxiosTestRequest(
`/v2/workflows/${workflowId}/execute${
businessKey ? `?businessKey=${businessKey}` : ''
}`,
),
data: JSON.stringify({ inputData: parameters }),
method: 'POST',
headers: {
Expand All @@ -131,6 +136,7 @@ describe('OrchestratorClient', () => {
expect(executeWorkflowSpy).toHaveBeenCalledWith(
workflowId,
{ inputData: parameters },
businessKey,
getDefaultTestRequestConfig(),
);
};
Expand All @@ -153,25 +159,33 @@ describe('OrchestratorClient', () => {
});
it('should execute workflow with business key', async () => {
// Given
const businessKey = 'business123';
const { mockExecResponse, executeWorkflowSpy, args } = setupTest(
'execId001',
{},
'business123',
businessKey,
);

const result = await orchestratorClient.executeWorkflow(args);

expect(
getExpectations(result, mockExecResponse, executeWorkflowSpy, {}),
getExpectations(
result,
mockExecResponse,
executeWorkflowSpy,
{},
businessKey,
),
).not.toThrow();
});
it('should execute workflow with parameters and business key', async () => {
// Given
const businessKey = 'business123';
const parameters = { param1: 'one', param2: 2, param3: true };
const { mockExecResponse, executeWorkflowSpy, args } = setupTest(
'execId001',
parameters,
'business123',
businessKey,
);

const result = await orchestratorClient.executeWorkflow(args);
Expand All @@ -182,6 +196,7 @@ describe('OrchestratorClient', () => {
mockExecResponse,
executeWorkflowSpy,
parameters,
businessKey,
),
).not.toThrow();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export class OrchestratorClient implements OrchestratorApi {
return await defaultApi.executeWorkflow(
args.workflowId,
{ inputData: args.parameters },
args.businessKey,
reqConfigOption,
);
} catch (err) {
Expand Down

0 comments on commit 8c112f4

Please sign in to comment.