mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 13:27:31 -08:00
✨ Add WS comprehend detect entities + Load more Lambda functions (#1742)
* Functions are listed recursively if the number of functions exceeds 50 * Added the DetectEntities action to the Aws Comprehend Node
This commit is contained in:
parent
5809b1e098
commit
71ec72493c
|
@ -140,6 +140,27 @@ export class AwsLambda implements INodeType {
|
||||||
value: func.FunctionArn as string,
|
value: func.FunctionArn as string,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.NextMarker) {
|
||||||
|
let marker: string = data.NextMarker;
|
||||||
|
while (true) {
|
||||||
|
const dataLoop = await awsApiRequestREST.call(this, 'lambda', 'GET', `/2015-03-31/functions/?MaxItems=50&Marker=${encodeURIComponent(marker)}`);
|
||||||
|
|
||||||
|
for (const func of dataLoop.Functions!) {
|
||||||
|
returnData.push({
|
||||||
|
name: func.FunctionName as string,
|
||||||
|
value: func.FunctionArn as string,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dataLoop.NextMarker) {
|
||||||
|
marker = dataLoop.NextMarker;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return returnData;
|
return returnData;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -63,6 +63,11 @@ export class AwsComprehend implements INodeType {
|
||||||
value: 'detectSentiment',
|
value: 'detectSentiment',
|
||||||
description: 'Analyse the sentiment of the text',
|
description: 'Analyse the sentiment of the text',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Detect Entities',
|
||||||
|
value: 'detectEntities',
|
||||||
|
description: 'Inspects text for named entities, and returns information about them',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
default: 'detectDominantLanguage',
|
default: 'detectDominantLanguage',
|
||||||
description: 'The operation to perform.',
|
description: 'The operation to perform.',
|
||||||
|
@ -129,6 +134,7 @@ export class AwsComprehend implements INodeType {
|
||||||
],
|
],
|
||||||
operation: [
|
operation: [
|
||||||
'detectSentiment',
|
'detectSentiment',
|
||||||
|
'detectEntities',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -168,6 +174,26 @@ export class AwsComprehend implements INodeType {
|
||||||
default: true,
|
default: true,
|
||||||
description: 'When set to true a simplify version of the response will be used else the raw data.',
|
description: 'When set to true a simplify version of the response will be used else the raw data.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Endpoint Arn',
|
||||||
|
name: 'endpointArn',
|
||||||
|
type: 'string',
|
||||||
|
typeOptions: {
|
||||||
|
alwaysOpenEditWindow: true,
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'text',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'detectEntities',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The Amazon Resource Name of an endpoint that is associated with a custom entity recognition model.',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -209,6 +235,25 @@ export class AwsComprehend implements INodeType {
|
||||||
};
|
};
|
||||||
responseData = await awsApiRequestREST.call(this, 'comprehend', 'POST', '', JSON.stringify(body), { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' });
|
responseData = await awsApiRequestREST.call(this, 'comprehend', 'POST', '', JSON.stringify(body), { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//https://docs.aws.amazon.com/comprehend/latest/dg/API_DetectEntities.html
|
||||||
|
if (operation === 'detectEntities') {
|
||||||
|
const action = 'Comprehend_20171127.DetectEntities';
|
||||||
|
const text = this.getNodeParameter('text', i) as string;
|
||||||
|
const languageCode = this.getNodeParameter('languageCode', i) as string;
|
||||||
|
const endpointArn = this.getNodeParameter('endpointArn', i) as string;
|
||||||
|
|
||||||
|
const body: IDataObject = {
|
||||||
|
Text: text,
|
||||||
|
LanguageCode: languageCode,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (endpointArn && endpointArn !== '') {
|
||||||
|
body.EndpointArn = endpointArn;
|
||||||
|
}
|
||||||
|
|
||||||
|
responseData = await awsApiRequestREST.call(this, 'comprehend', 'POST', '', JSON.stringify(body), { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(responseData)) {
|
if (Array.isArray(responseData)) {
|
||||||
|
|
Loading…
Reference in a new issue