/
LambdaFuncGet.cs
82 lines (59 loc) · 2.16 KB
/
LambdaFuncGet.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using Amazon.Lambda.Core;
using Amazon.Lambda.APIGatewayEvents;
using Amazon.Lambda.Serialization.SystemTextJson;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Net;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace am
{
/*======================================================================================================*/
public partial class LambdaFuncGetEnv : LambdaBaseArg
{
/*==[ env params ]=====================================================================*/
public string s3Bucket { get; set; } = "";
public string s3DirObject { get; set; } = "LambdaFuncGetData/";
}
/*======================================================================================================*/
public class LambdaFuncGetResponse
{
public string status { get; set; } = "";
public string result { get; set; } = "";
}
/*======================================================================================================*/
public class LambdaFuncGet : LambdaGetBase {
ILambdaContext? m_ctx;
APIGatewayHttpApiV2ProxyRequest? m_data;
public override string Handler(APIGatewayHttpApiV2ProxyRequest data, ILambdaContext context){
m_ctx = context;
m_data = data;
m_ctx.Log("Start Process");
var result = Job(data, context);
var resp = JsonSerializer.Serialize(result.Result);
m_ctx.Log("Complete Process ( Wait Async Method )");
return resp;
}
public static async Task<LambdaFuncGetResponse> Job(APIGatewayHttpApiV2ProxyRequest data, ILambdaContext ctx){
var ret = await Task.Run(() => {
var resp = new LambdaFuncGetResponse{
status = ApiError.E_CHAOS.ToString(),
result = ""
};
try {
resp.status = ApiError.E_OK.ToString();
}
catch(Exception e){
ctx.Log(e.ToString());
resp.status = ApiError.E_CRITICAL.ToString();
}
return resp;
});
return ret;
}
}
/*======================================================================================================*/
}