-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathFunction.cs
28 lines (23 loc) · 858 Bytes
/
Function.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System.Threading.Tasks;
using Amazon.Lambda.Core;
using Amazon.Translate;
using Amazon.Translate.Model;
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]
namespace ArmLambdaFunction
{
public class Function
{
IAmazonTranslate _translateClient = new AmazonTranslateClient();
public async Task<string> FunctionHandler(string input, ILambdaContext context)
{
var response = await _translateClient.TranslateTextAsync(new TranslateTextRequest
{
SourceLanguageCode = "en",
TargetLanguageCode = "es",
Text = input
});
return response.TranslatedText;
}
}
}