Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(orchestrator): pass businessKey for assessments #2558

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/spicy-owls-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@janus-idp/backstage-plugin-orchestrator-backend": patch
"@janus-idp/backstage-plugin-orchestrator-common": patch
"@janus-idp/backstage-plugin-orchestrator": patch
---

The parent assessment link is shown again thanks to fixing passing of the businessKey when "execute" action is trigerred.
2 changes: 2 additions & 0 deletions plugins/orchestrator-backend/src/service/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,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
2 changes: 1 addition & 1 deletion plugins/orchestrator-common/src/generated/.METADATA.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f4fd9f652a05159a3d506540493e275885d54dcd
b87c7d385fe5965d9eb4cc87056d13f92070965f

Large diffs are not rendered by default.

22 changes: 15 additions & 7 deletions plugins/orchestrator-common/src/generated/client/api.ts
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
60 changes: 50 additions & 10 deletions plugins/orchestrator-common/src/generated/docs/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1867,7 +1867,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 @@ -1889,9 +1889,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 @@ -1909,9 +1910,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 @@ -1928,9 +1930,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 @@ -1950,10 +1953,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 @@ -1972,6 +1977,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 @@ -1980,7 +1988,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 @@ -2005,10 +2013,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 @@ -2027,9 +2036,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 @@ -2046,9 +2056,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 @@ -2067,10 +2078,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 @@ -2082,9 +2094,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 @@ -2179,6 +2192,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
6 changes: 6 additions & 0 deletions plugins/orchestrator-common/src/openapi/openapi.yaml
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
21 changes: 17 additions & 4 deletions plugins/orchestrator/src/api/OrchestratorClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,16 @@ 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 @@ -116,6 +119,7 @@ describe('OrchestratorClient', () => {
expect(executeWorkflowSpy).toHaveBeenCalledWith(
workflowId,
{ inputData: parameters },
businessKey,
getDefaultTestRequestConfig(),
);
};
Expand All @@ -138,25 +142,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 @@ -167,6 +179,7 @@ describe('OrchestratorClient', () => {
mockExecResponse,
executeWorkflowSpy,
parameters,
businessKey,
),
).not.toThrow();
});
Expand Down
1 change: 1 addition & 0 deletions plugins/orchestrator/src/api/OrchestratorClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class OrchestratorClient implements OrchestratorApi {
return await defaultApi.executeWorkflow(
args.workflowId,
{ inputData: args.parameters },
args.businessKey,
reqConfigOption,
);
} catch (err) {
Expand Down
Loading
Loading