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:
Alexander Mustafin 2021-05-08 06:31:04 +03:00 committed by GitHub
parent 5809b1e098
commit 71ec72493c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 66 additions and 0 deletions

View file

@ -140,6 +140,27 @@ export class AwsLambda implements INodeType {
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;
},
},

View file

@ -63,6 +63,11 @@ export class AwsComprehend implements INodeType {
value: 'detectSentiment',
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',
description: 'The operation to perform.',
@ -129,6 +134,7 @@ export class AwsComprehend implements INodeType {
],
operation: [
'detectSentiment',
'detectEntities',
],
},
},
@ -168,6 +174,26 @@ export class AwsComprehend implements INodeType {
default: true,
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' });
}
//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)) {