1
- """Collection of classes as models and builder functions
2
- that provide classes as data representation for
3
- key data used in more than one place.
4
- """
5
-
6
- from enum import Enum
7
-
8
-
9
1
class LambdaContextModel :
10
2
"""A handful of Lambda Runtime Context fields
11
3
12
4
Full Lambda Context object: https://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html
13
5
14
- NOTE
15
- ----
16
-
17
- Originally, memory_size is `int` but we cast to `str` in this model
18
- due to aws_lambda_logging library use of `%` during formatting
19
- Ref: https://gitlab.com/hadrien/aws_lambda_logging/blob/master/aws_lambda_logging.py#L47
20
-
21
6
Parameters
22
7
----------
23
8
function_name: str
24
9
Lambda function name, by default "UNDEFINED"
25
10
e.g. "test"
26
- function_memory_size: str
27
- Lambda function memory in MB, by default "UNDEFINED"
28
- e.g. "128"
29
- casting from int to str due to aws_lambda_logging using `%` when enumerating fields
11
+ function_memory_size: int
12
+ Lambda function memory in MB, by default 128
30
13
function_arn: str
31
14
Lambda function ARN, by default "UNDEFINED"
32
15
e.g. "arn:aws:lambda:eu-west-1:809313241:function:test"
@@ -38,7 +21,7 @@ class LambdaContextModel:
38
21
def __init__ (
39
22
self ,
40
23
function_name : str = "UNDEFINED" ,
41
- function_memory_size : str = "UNDEFINED" ,
24
+ function_memory_size : int = 128 ,
42
25
function_arn : str = "UNDEFINED" ,
43
26
function_request_id : str = "UNDEFINED" ,
44
27
):
@@ -70,32 +53,3 @@ def build_lambda_context_model(context: object) -> LambdaContextModel:
70
53
}
71
54
72
55
return LambdaContextModel (** context )
73
-
74
-
75
- class MetricUnit (Enum ):
76
- Seconds = "Seconds"
77
- Microseconds = "Microseconds"
78
- Milliseconds = "Milliseconds"
79
- Bytes = "Bytes"
80
- Kilobytes = "Kilobytes"
81
- Megabytes = "Megabytes"
82
- Gigabytes = "Gigabytes"
83
- Terabytes = "Terabytes"
84
- Bits = "Bits"
85
- Kilobits = "Kilobits"
86
- Megabits = "Megabits"
87
- Gigabits = "Gigabits"
88
- Terabits = "Terabits"
89
- Percent = "Percent"
90
- Count = "Count"
91
- BytesPerSecond = "Bytes/Second"
92
- KilobytesPerSecond = "Kilobytes/Second"
93
- MegabytesPerSecond = "Megabytes/Second"
94
- GigabytesPerSecond = "Gigabytes/Second"
95
- TerabytesPerSecond = "Terabytes/Second"
96
- BitsPerSecond = "Bits/Second"
97
- KilobitsPerSecond = "Kilobits/Second"
98
- MegabitsPerSecond = "Megabits/Second"
99
- GigabitsPerSecond = "Gigabits/Second"
100
- TerabitsPerSecond = "Terabits/Second"
101
- CountPerSecond = "Count/Second"
0 commit comments