feat(Rundeck Node): Add support for node filters (#5633)

This commit is contained in:
qg-horie 2023-07-24 23:01:49 +09:00 committed by GitHub
parent 052d82b220
commit 1f70f49ce5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 3 deletions

View file

@ -119,6 +119,21 @@ export class Rundeck implements INodeType {
}, },
], ],
}, },
{
displayName: 'Filter',
name: 'filter',
type: 'string',
displayOptions: {
show: {
operation: ['execute'],
resource: ['job'],
},
},
default: '',
placeholder: 'Add Filters',
required: false,
description: 'Filter Rundeck nodes by name',
},
// ---------------------------------- // ----------------------------------
// job:getMetadata // job:getMetadata
@ -161,7 +176,8 @@ export class Rundeck implements INodeType {
const jobid = this.getNodeParameter('jobid', i) as string; const jobid = this.getNodeParameter('jobid', i) as string;
const rundeckArguments = (this.getNodeParameter('arguments', i) as IDataObject) const rundeckArguments = (this.getNodeParameter('arguments', i) as IDataObject)
.arguments as IDataObject[]; .arguments as IDataObject[];
const response = await rundeckApi.executeJob(jobid, rundeckArguments); const filter = this.getNodeParameter('filter', i) as string;
const response = await rundeckApi.executeJob(jobid, rundeckArguments, filter);
returnData.push(response); returnData.push(response);
} else if (operation === 'getMetadata') { } else if (operation === 'getMetadata') {

View file

@ -49,7 +49,7 @@ export class RundeckApi {
this.credentials = credentials as unknown as RundeckCredentials; this.credentials = credentials as unknown as RundeckCredentials;
} }
async executeJob(jobId: string, args: IDataObject[]): Promise<IDataObject> { async executeJob(jobId: string, args: IDataObject[], filter?: string): Promise<IDataObject> {
let params = ''; let params = '';
if (args) { if (args) {
@ -62,7 +62,12 @@ export class RundeckApi {
argString: params, argString: params,
}; };
return this.request('POST', `/api/14/job/${jobId}/run`, body, {}); const query: IDataObject = {};
if (filter) {
query.filter = filter;
}
return this.request('POST', `/api/14/job/${jobId}/run`, body, query);
} }
async getJobMetadata(jobId: string): Promise<IDataObject> { async getJobMetadata(jobId: string): Promise<IDataObject> {