mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
⚡ Fetch observable data types from TheHive (#1291)
This commit is contained in:
@@ -195,6 +195,50 @@ export class TheHive implements INodeType {
|
||||
];
|
||||
return options;
|
||||
},
|
||||
async loadObservableTypes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const version = this.getCredentials('theHiveApi')?.apiVersion;
|
||||
const endpoint = version === 'v1' ? '/observable/type?range=all' : '/list/list_artifactDataType';
|
||||
|
||||
const dataTypes = await theHiveApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
endpoint as string,
|
||||
);
|
||||
|
||||
let returnData: INodePropertyOptions[] = [];
|
||||
|
||||
if (version === 'v1') {
|
||||
returnData = dataTypes.map((dataType: IDataObject) => {
|
||||
return {
|
||||
name: dataType.name as string,
|
||||
value: dataType.name as string,
|
||||
};
|
||||
});
|
||||
}
|
||||
else {
|
||||
returnData = Object.keys(dataTypes).map(key => {
|
||||
const dataType = dataTypes[key] as string;
|
||||
|
||||
return {
|
||||
name: dataType,
|
||||
value: dataType,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// Sort the array by option name
|
||||
returnData.sort((a, b) => {
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
return returnData;
|
||||
},
|
||||
async loadTaskOptions(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const version = this.getCredentials('theHiveApi')?.apiVersion;
|
||||
const options = [
|
||||
|
||||
Reference in New Issue
Block a user