2
2
import json
3
3
import warnings
4
4
from dataclasses import dataclass , field
5
- from typing import Any , Callable , Dict , Iterator , List , Optional
5
+ from typing import Any , Callable , ClassVar , Dict , Iterator , List , Optional , Tuple
6
6
7
7
from typing_extensions import Literal
8
8
@@ -62,6 +62,8 @@ class KinesisFirehoseDataTransformationRecord:
62
62
- https://docs.aws.amazon.com/firehose/latest/dev/data-transformation.html
63
63
"""
64
64
65
+ _valid_result_types : ClassVar [Tuple [str , str , str ]] = ("Ok" , "Dropped" , "ProcessingFailed" )
66
+
65
67
record_id : str
66
68
result : Literal ["Ok" , "Dropped" , "ProcessingFailed" ] = "Ok"
67
69
data : str = ""
@@ -71,7 +73,7 @@ class KinesisFirehoseDataTransformationRecord:
71
73
_json_data : Optional [Any ] = None
72
74
73
75
def asdict (self ) -> Dict :
74
- if self .result not in [ "Ok" , "Dropped" , "ProcessingFailed" ] :
76
+ if self .result not in self . _valid_result_types :
75
77
warnings .warn (
76
78
stacklevel = 1 ,
77
79
message = f'The result "{ self .result } " is not valid, Choose from "Ok", "Dropped", "ProcessingFailed"' ,
@@ -132,7 +134,7 @@ def add_record(self, record: KinesisFirehoseDataTransformationRecord):
132
134
133
135
def asdict (self ) -> Dict :
134
136
if not self .records :
135
- raise ValueError ("Kinesis Firehose doesn't accept empty response" )
137
+ raise ValueError ("Amazon Kinesis Data Firehose doesn't accept empty response" )
136
138
137
139
return {"records" : [record .asdict () for record in self .records ]}
138
140
@@ -216,7 +218,8 @@ def build_data_transformation_response(
216
218
data : str = "" ,
217
219
metadata : Optional [KinesisFirehoseDataTransformationRecordMetadata ] = None ,
218
220
) -> KinesisFirehoseDataTransformationRecord :
219
- """create a KinesisFirehoseResponseRecord directly using the record_id and given values
221
+ """Create a KinesisFirehoseResponseRecord directly using the record_id and given values
222
+
220
223
Parameters
221
224
----------
222
225
result : Literal["Ok", "Dropped", "ProcessingFailed"]
0 commit comments