summaryrefslogtreecommitdiff
path: root/python-b-lambda-layer-common.spec
blob: ac8c3239bb9afc8c57ea9ac93d83c40c31e61d65 (plain)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
%global _empty_manifest_terminate_build 0
Name:		python-b-lambda-layer-common
Version:	4.4.0
Release:	1
Summary:	Common opinionated utilities for every day development.
License:	Apache License 2.0
URL:		https://github.com/biomapas/B.LambdaLayerCommon.git
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/77/8b/9810a4cf739be0171bdf5e2a45b90c7d9afd7366120bf81c34e3d888c035/b_lambda_layer_common-4.4.0.tar.gz
BuildArch:	noarch


%description
# B.LambdaLayerCommon

![Pipeline](https://github.com/Biomapas/B.LambdaLayerCommon/workflows/Pipeline/badge.svg?branch=master)

> **DEPRECATION WARNING !!!**</br></br>
> This library no longer supports lambda layers and eventually will be moved to another repository. 
> It is a simple python library of common methods to develop in AWS environment.
> Create your own lambda layer using ![B.CfnLambdaLayer](https://github.com/Biomapas/B.CfnLambdaLayer)
> and specify this library as a dependency. Example given below.
> ```python
> from b_cfn_lambda_layer.lambda_layer import LambdaLayer
> layer = LambdaLayer(
>   ...,
>   dependencies={
>      'b-lambda_layer_common': PackageVersion.from_string_version('4.0.0'),
>   }
> )
> ```

### Description

This is a simple python library, that contains various useful methods that will make infrastructure development 
much easier. 

### Remarks

[Biomapas](https://www.biomapas.com/) aims to modernise life-science industry by sharing its IT knowledge with other companies and the community. 
This is an open source library intended to be used by anyone. 
Improvements and pull requests are welcome. 

### Related technology

- Python3
- Docker
- AWS CDK
- AWS Lambda

### Assumptions

This project assumes you have good knowledge in AWS. 

- Good Python skills and basis of OOP.

### Useful sources

- None.

### Install

Before installing this library, ensure you have these tools setup:

- Python / Pip

To install this project from source run:

```
pip install .
```

Or you can install it from a PyPi repository:

```
pip install b-lambda_layer_common
```

### Usage & Examples

Main modules:

- _api_gateway_
  <br>Contains various functionalities related to API Gateway service and integrations.
<br><br>
- _cache_
  <br>Contains caching mechanisms for lambda functions.
<br><br>
- _events_
  <br>Contains functionality that supports event-driven architectures.
<br><br>  
- _exceptions_
  <br>Contains advanced exception handling and propagation between lambda function chains.
<br><br>  
- _ssm_
  <br>Contains SSM parameter store handling logic.
<br><br>  
- _util_
  <br>Contains random fun stuff ;) 
<br><br>
- _validation_
  <br>Various value validations for python.
<br><br>  
- _ws_api_gateway_
  <br>Contains various functionalities related to API Gateway websocket service and integrations.

### Testing

This package has unit tests based on **pytest**.
To run tests simply run:

```
pytest --cov=b_lambda_layer_common b_lambda_layer_common_test/unit --cov-fail-under=80
```

### Contribution

Found a bug? Want to add or suggest a new feature? 
Contributions of any kind are gladly welcome. 
You may contact us directly, create a pull-request or an issue in github platform. 
Lets modernize the world together.


# Release history

### 4.4.0
* Add decorator `remove_header` removing desired headers from API Gateway integration lambda event.

### 4.3.0
* Improve `ValueValidator` by adding `not_contains_whitespace` method.
* Make `ValueValidatorPresets` more flexible.

### 4.2.2
* Make `MalformedPermissionErorr` inherit straight from `HttpException`.

### 4.2.1
* Typehint fixes.

### 4.2.0
* Add more custom `BException` exceptions.
* 420 hehe...

### 4.1.0
* Add ability to specify custom exception when performing value validation.

### 4.0.0
* Deprecate lambda layer functionality. Now this is a simple python lib with common AWS-related functionality.
  Use https://github.com/Biomapas/B.CfnLambdaLayer to create lambda layers.
* Remove `DynamoDb` & `PynamoDb` functionality from this code. It has been moved and improved. 
  Find everything here: https://github.com/Biomapas/B.DynamoDbCommon. 

### 3.3.0
* Allow access of the value within validators.

### 3.2.0
* Add epic validation!
* Add `ValueValidator` for basic validation.
* Add `ValueValidatorPreset` for convenient validation.

### 3.1.0
* Extract api key from lambda event.
* Extract body from lambda event.

### 3.0.1
* Extend boto3 step-functions call timeout to maximum lambda execution time (15 minutes).

### 3.0.0
* Use the newest base layer `B.CfnLambdaLayer` 
  which uses new asset bundling mechanism (Dockerfile).

### 2.4.0
* Add Boto3 client validation under SfnCall function.

### 2.3.4
* Add functionality to pass Boto3 client to SfnCall function for multithreding support.

### 2.3.3
* Fix api empty dict serialization.

### 2.3.2
* Improve parsing of JWT claims from API Gateway authorizer output.

### 2.3.1
* If you want to use `cryptography` module, you must use Python 3.8.
* Add explanations for Python 3.8 versions.
* Fix supported layer python versions.

### 2.3.0
* Add Fernet encryption PynamoDB attribute.

### 2.2.1
* Fix KmsAttribute by introducing base64 encode/decode.

### 2.2.0
* Add field validator in util directory. Simple string validation.
* Add KMS attribute for PynamoDB.

### 2.1.2
* Add a list bytes batching utility.

### 2.0.6
* Handle errors when raising ValueError in SfnCall class.

### 2.0.4
* Simple return JSON of an output if SfnCall raised ValueError.

### 2.0.1
* Include .txt files.

### 2.0.0
* Complete refactor.
* Fix ugly if/else imports.
* Run unit tests inside lambda functions.
* Use b_cfn_lambda_layer dependency.
* Write more unit and integration tests.
* Add README documentation.

### 1.20.0
* Add validation when bundling with Docker.

### 1.19.0
* General testing improvements.
* Add Layer V2 integration tests.

### 1.18.0
* Add V2 Layer class to enable installation of dependencies.

### 1.16.0
* Add response method to return any type.
* Add `text/html` and `text/plain` headers.
* Add missing `fields` parameter support to `NeighbourEndpoint` class.

### 1.15.1
* Improve function return value handling for `InMemoryDataCache` class.

### 1.15.0
* Add in-memory data caching functionality.

### 1.14.0
* Add `fields` parameter support to `HttpEndpoint` class.

### 1.11.1
* Update DoNotUpdate class to be usable as a type.

### 1.11.0
* Add WebSocket Api Gateway message class to form consistent messages.

### 1.10.2
* Allow for changing HttpEndpoint behavior.

### 1.10.1
* Add ability to specify if to fail to errors.
* Try to read from env event bus name.

### 1.10.0
* Add factory to emit EventBridge events.

### 1.9.5
* Make the code a little more robust and less error prone.

### 1.9.4
* Assets input may contain garbage files too, hence, apply
cleanup commands directly on asset outputs folder.

### 1.9.3
* Add builds badge.

### 1.9.2
* Remove leftover code.
* Update requirements.

### 1.9.1
* Delete unnecessary files which result in different asset hash.
* Calculate hash when bundling.

### 1.9.0
* Add CSV headers.

### 1.8.3
* Ensure everything works with a robust integration test.

### 1.8.2
* Improve Boto3Version class.

### 1.8.1
* Fix bug when boto3 version is specified project files
are not copied.

### 1.8.0
* Change asset bundling to asset docker bundling if additional
dependencies are specified.
* Add ability to install boto3 library.
* Add more unit tests.
* Add integration tests to deploy and test the Layer in AWS.

### 1.7.0
* Simplify SSM parameters functionality.
* Add robust SSM parameter tests.

### 1.6.2
* Do not serialize returned ssm parameters.

### 1.6.1
* Add more logging for better visibility.

### 1.6.0
* SSM should_refresh function should be public.

### 1.5.1
* Add logging on ssm error decorator.

### 1.5.0
* Force using error_class to error_classes.

### 1.4.0
* Add functionality to fetch and cache SSM parameters.
* Add OS type parameters.

### 1.3.0
* Add media Response and wav/mpeg headers.

### 1.2.0
* Add DoNotUpdate class, useful when checking what parameters to update and what not.

### 1.1.3
* Implement retrying logic to HttpCall.

### 1.1.2
* Make sure test coverage is at least 80%.
* Add CI/CD pipeline.
* Add more encodings to decode responses.

### 1.1.1
* Add urllib3 dependency.

### 1.1.0
* Add DynamoDBEncoder that subclasses DecimalEncoder and additionally encodes sets as lists.

### 1.0.3
* Modify call_to_json function by checking whether the response contains body.

### 1.0.2
* Add exception logging for failed imports.

### 1.0.1
* Expose http_endpoint on NeigbourEndpoint class.

### 1.0.0
* Release version with major braking changes.
* Consistent naming for imports.
* Unit tests to cover all functions and classes.
* Add neighbour endpoint.
* General code improvements and cleanup.

### 0.0.16
* Fix logging imports.
* Add logging of exception tracebacks to exception_middleware.
* Add logging about HTTP requests.
* Set request scheme for parent API Gateway urls depending on current protocol.

### 0.0.15
* Add a CognitoAccessToken for parsing access token information provided by the API Gateway using Cognito authorizer.

### 0.0.14
* Add a LoggingManager for setting up logging configuration

### 0.0.13
* Add custom JSON encoder with support for decimal.Decimal encoding

### 0.0.12
* Implement API Gateway body parsing.

### 0.0.11
* Fix imports.

### 0.0.10
* Implement exceptions.

### 0.0.9
* Fix api gateway url.

### 0.0.8
* Add xml to dict converter utility. No dependencies.

### 0.0.7
* Fix imports.

### 0.0.6
* Add ability to check whether singleton was initialized.

### 0.0.5
* Remove description.

### 0.0.4
* Do not create an extra stack.

### 0.0.3
* Add safe initialization.

### 0.0.2
* Add Layer class and Singleton.

### 0.0.1
* Initial build.



%package -n python3-b-lambda-layer-common
Summary:	Common opinionated utilities for every day development.
Provides:	python-b-lambda-layer-common
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-b-lambda-layer-common
# B.LambdaLayerCommon

![Pipeline](https://github.com/Biomapas/B.LambdaLayerCommon/workflows/Pipeline/badge.svg?branch=master)

> **DEPRECATION WARNING !!!**</br></br>
> This library no longer supports lambda layers and eventually will be moved to another repository. 
> It is a simple python library of common methods to develop in AWS environment.
> Create your own lambda layer using ![B.CfnLambdaLayer](https://github.com/Biomapas/B.CfnLambdaLayer)
> and specify this library as a dependency. Example given below.
> ```python
> from b_cfn_lambda_layer.lambda_layer import LambdaLayer
> layer = LambdaLayer(
>   ...,
>   dependencies={
>      'b-lambda_layer_common': PackageVersion.from_string_version('4.0.0'),
>   }
> )
> ```

### Description

This is a simple python library, that contains various useful methods that will make infrastructure development 
much easier. 

### Remarks

[Biomapas](https://www.biomapas.com/) aims to modernise life-science industry by sharing its IT knowledge with other companies and the community. 
This is an open source library intended to be used by anyone. 
Improvements and pull requests are welcome. 

### Related technology

- Python3
- Docker
- AWS CDK
- AWS Lambda

### Assumptions

This project assumes you have good knowledge in AWS. 

- Good Python skills and basis of OOP.

### Useful sources

- None.

### Install

Before installing this library, ensure you have these tools setup:

- Python / Pip

To install this project from source run:

```
pip install .
```

Or you can install it from a PyPi repository:

```
pip install b-lambda_layer_common
```

### Usage & Examples

Main modules:

- _api_gateway_
  <br>Contains various functionalities related to API Gateway service and integrations.
<br><br>
- _cache_
  <br>Contains caching mechanisms for lambda functions.
<br><br>
- _events_
  <br>Contains functionality that supports event-driven architectures.
<br><br>  
- _exceptions_
  <br>Contains advanced exception handling and propagation between lambda function chains.
<br><br>  
- _ssm_
  <br>Contains SSM parameter store handling logic.
<br><br>  
- _util_
  <br>Contains random fun stuff ;) 
<br><br>
- _validation_
  <br>Various value validations for python.
<br><br>  
- _ws_api_gateway_
  <br>Contains various functionalities related to API Gateway websocket service and integrations.

### Testing

This package has unit tests based on **pytest**.
To run tests simply run:

```
pytest --cov=b_lambda_layer_common b_lambda_layer_common_test/unit --cov-fail-under=80
```

### Contribution

Found a bug? Want to add or suggest a new feature? 
Contributions of any kind are gladly welcome. 
You may contact us directly, create a pull-request or an issue in github platform. 
Lets modernize the world together.


# Release history

### 4.4.0
* Add decorator `remove_header` removing desired headers from API Gateway integration lambda event.

### 4.3.0
* Improve `ValueValidator` by adding `not_contains_whitespace` method.
* Make `ValueValidatorPresets` more flexible.

### 4.2.2
* Make `MalformedPermissionErorr` inherit straight from `HttpException`.

### 4.2.1
* Typehint fixes.

### 4.2.0
* Add more custom `BException` exceptions.
* 420 hehe...

### 4.1.0
* Add ability to specify custom exception when performing value validation.

### 4.0.0
* Deprecate lambda layer functionality. Now this is a simple python lib with common AWS-related functionality.
  Use https://github.com/Biomapas/B.CfnLambdaLayer to create lambda layers.
* Remove `DynamoDb` & `PynamoDb` functionality from this code. It has been moved and improved. 
  Find everything here: https://github.com/Biomapas/B.DynamoDbCommon. 

### 3.3.0
* Allow access of the value within validators.

### 3.2.0
* Add epic validation!
* Add `ValueValidator` for basic validation.
* Add `ValueValidatorPreset` for convenient validation.

### 3.1.0
* Extract api key from lambda event.
* Extract body from lambda event.

### 3.0.1
* Extend boto3 step-functions call timeout to maximum lambda execution time (15 minutes).

### 3.0.0
* Use the newest base layer `B.CfnLambdaLayer` 
  which uses new asset bundling mechanism (Dockerfile).

### 2.4.0
* Add Boto3 client validation under SfnCall function.

### 2.3.4
* Add functionality to pass Boto3 client to SfnCall function for multithreding support.

### 2.3.3
* Fix api empty dict serialization.

### 2.3.2
* Improve parsing of JWT claims from API Gateway authorizer output.

### 2.3.1
* If you want to use `cryptography` module, you must use Python 3.8.
* Add explanations for Python 3.8 versions.
* Fix supported layer python versions.

### 2.3.0
* Add Fernet encryption PynamoDB attribute.

### 2.2.1
* Fix KmsAttribute by introducing base64 encode/decode.

### 2.2.0
* Add field validator in util directory. Simple string validation.
* Add KMS attribute for PynamoDB.

### 2.1.2
* Add a list bytes batching utility.

### 2.0.6
* Handle errors when raising ValueError in SfnCall class.

### 2.0.4
* Simple return JSON of an output if SfnCall raised ValueError.

### 2.0.1
* Include .txt files.

### 2.0.0
* Complete refactor.
* Fix ugly if/else imports.
* Run unit tests inside lambda functions.
* Use b_cfn_lambda_layer dependency.
* Write more unit and integration tests.
* Add README documentation.

### 1.20.0
* Add validation when bundling with Docker.

### 1.19.0
* General testing improvements.
* Add Layer V2 integration tests.

### 1.18.0
* Add V2 Layer class to enable installation of dependencies.

### 1.16.0
* Add response method to return any type.
* Add `text/html` and `text/plain` headers.
* Add missing `fields` parameter support to `NeighbourEndpoint` class.

### 1.15.1
* Improve function return value handling for `InMemoryDataCache` class.

### 1.15.0
* Add in-memory data caching functionality.

### 1.14.0
* Add `fields` parameter support to `HttpEndpoint` class.

### 1.11.1
* Update DoNotUpdate class to be usable as a type.

### 1.11.0
* Add WebSocket Api Gateway message class to form consistent messages.

### 1.10.2
* Allow for changing HttpEndpoint behavior.

### 1.10.1
* Add ability to specify if to fail to errors.
* Try to read from env event bus name.

### 1.10.0
* Add factory to emit EventBridge events.

### 1.9.5
* Make the code a little more robust and less error prone.

### 1.9.4
* Assets input may contain garbage files too, hence, apply
cleanup commands directly on asset outputs folder.

### 1.9.3
* Add builds badge.

### 1.9.2
* Remove leftover code.
* Update requirements.

### 1.9.1
* Delete unnecessary files which result in different asset hash.
* Calculate hash when bundling.

### 1.9.0
* Add CSV headers.

### 1.8.3
* Ensure everything works with a robust integration test.

### 1.8.2
* Improve Boto3Version class.

### 1.8.1
* Fix bug when boto3 version is specified project files
are not copied.

### 1.8.0
* Change asset bundling to asset docker bundling if additional
dependencies are specified.
* Add ability to install boto3 library.
* Add more unit tests.
* Add integration tests to deploy and test the Layer in AWS.

### 1.7.0
* Simplify SSM parameters functionality.
* Add robust SSM parameter tests.

### 1.6.2
* Do not serialize returned ssm parameters.

### 1.6.1
* Add more logging for better visibility.

### 1.6.0
* SSM should_refresh function should be public.

### 1.5.1
* Add logging on ssm error decorator.

### 1.5.0
* Force using error_class to error_classes.

### 1.4.0
* Add functionality to fetch and cache SSM parameters.
* Add OS type parameters.

### 1.3.0
* Add media Response and wav/mpeg headers.

### 1.2.0
* Add DoNotUpdate class, useful when checking what parameters to update and what not.

### 1.1.3
* Implement retrying logic to HttpCall.

### 1.1.2
* Make sure test coverage is at least 80%.
* Add CI/CD pipeline.
* Add more encodings to decode responses.

### 1.1.1
* Add urllib3 dependency.

### 1.1.0
* Add DynamoDBEncoder that subclasses DecimalEncoder and additionally encodes sets as lists.

### 1.0.3
* Modify call_to_json function by checking whether the response contains body.

### 1.0.2
* Add exception logging for failed imports.

### 1.0.1
* Expose http_endpoint on NeigbourEndpoint class.

### 1.0.0
* Release version with major braking changes.
* Consistent naming for imports.
* Unit tests to cover all functions and classes.
* Add neighbour endpoint.
* General code improvements and cleanup.

### 0.0.16
* Fix logging imports.
* Add logging of exception tracebacks to exception_middleware.
* Add logging about HTTP requests.
* Set request scheme for parent API Gateway urls depending on current protocol.

### 0.0.15
* Add a CognitoAccessToken for parsing access token information provided by the API Gateway using Cognito authorizer.

### 0.0.14
* Add a LoggingManager for setting up logging configuration

### 0.0.13
* Add custom JSON encoder with support for decimal.Decimal encoding

### 0.0.12
* Implement API Gateway body parsing.

### 0.0.11
* Fix imports.

### 0.0.10
* Implement exceptions.

### 0.0.9
* Fix api gateway url.

### 0.0.8
* Add xml to dict converter utility. No dependencies.

### 0.0.7
* Fix imports.

### 0.0.6
* Add ability to check whether singleton was initialized.

### 0.0.5
* Remove description.

### 0.0.4
* Do not create an extra stack.

### 0.0.3
* Add safe initialization.

### 0.0.2
* Add Layer class and Singleton.

### 0.0.1
* Initial build.



%package help
Summary:	Development documents and examples for b-lambda-layer-common
Provides:	python3-b-lambda-layer-common-doc
%description help
# B.LambdaLayerCommon

![Pipeline](https://github.com/Biomapas/B.LambdaLayerCommon/workflows/Pipeline/badge.svg?branch=master)

> **DEPRECATION WARNING !!!**</br></br>
> This library no longer supports lambda layers and eventually will be moved to another repository. 
> It is a simple python library of common methods to develop in AWS environment.
> Create your own lambda layer using ![B.CfnLambdaLayer](https://github.com/Biomapas/B.CfnLambdaLayer)
> and specify this library as a dependency. Example given below.
> ```python
> from b_cfn_lambda_layer.lambda_layer import LambdaLayer
> layer = LambdaLayer(
>   ...,
>   dependencies={
>      'b-lambda_layer_common': PackageVersion.from_string_version('4.0.0'),
>   }
> )
> ```

### Description

This is a simple python library, that contains various useful methods that will make infrastructure development 
much easier. 

### Remarks

[Biomapas](https://www.biomapas.com/) aims to modernise life-science industry by sharing its IT knowledge with other companies and the community. 
This is an open source library intended to be used by anyone. 
Improvements and pull requests are welcome. 

### Related technology

- Python3
- Docker
- AWS CDK
- AWS Lambda

### Assumptions

This project assumes you have good knowledge in AWS. 

- Good Python skills and basis of OOP.

### Useful sources

- None.

### Install

Before installing this library, ensure you have these tools setup:

- Python / Pip

To install this project from source run:

```
pip install .
```

Or you can install it from a PyPi repository:

```
pip install b-lambda_layer_common
```

### Usage & Examples

Main modules:

- _api_gateway_
  <br>Contains various functionalities related to API Gateway service and integrations.
<br><br>
- _cache_
  <br>Contains caching mechanisms for lambda functions.
<br><br>
- _events_
  <br>Contains functionality that supports event-driven architectures.
<br><br>  
- _exceptions_
  <br>Contains advanced exception handling and propagation between lambda function chains.
<br><br>  
- _ssm_
  <br>Contains SSM parameter store handling logic.
<br><br>  
- _util_
  <br>Contains random fun stuff ;) 
<br><br>
- _validation_
  <br>Various value validations for python.
<br><br>  
- _ws_api_gateway_
  <br>Contains various functionalities related to API Gateway websocket service and integrations.

### Testing

This package has unit tests based on **pytest**.
To run tests simply run:

```
pytest --cov=b_lambda_layer_common b_lambda_layer_common_test/unit --cov-fail-under=80
```

### Contribution

Found a bug? Want to add or suggest a new feature? 
Contributions of any kind are gladly welcome. 
You may contact us directly, create a pull-request or an issue in github platform. 
Lets modernize the world together.


# Release history

### 4.4.0
* Add decorator `remove_header` removing desired headers from API Gateway integration lambda event.

### 4.3.0
* Improve `ValueValidator` by adding `not_contains_whitespace` method.
* Make `ValueValidatorPresets` more flexible.

### 4.2.2
* Make `MalformedPermissionErorr` inherit straight from `HttpException`.

### 4.2.1
* Typehint fixes.

### 4.2.0
* Add more custom `BException` exceptions.
* 420 hehe...

### 4.1.0
* Add ability to specify custom exception when performing value validation.

### 4.0.0
* Deprecate lambda layer functionality. Now this is a simple python lib with common AWS-related functionality.
  Use https://github.com/Biomapas/B.CfnLambdaLayer to create lambda layers.
* Remove `DynamoDb` & `PynamoDb` functionality from this code. It has been moved and improved. 
  Find everything here: https://github.com/Biomapas/B.DynamoDbCommon. 

### 3.3.0
* Allow access of the value within validators.

### 3.2.0
* Add epic validation!
* Add `ValueValidator` for basic validation.
* Add `ValueValidatorPreset` for convenient validation.

### 3.1.0
* Extract api key from lambda event.
* Extract body from lambda event.

### 3.0.1
* Extend boto3 step-functions call timeout to maximum lambda execution time (15 minutes).

### 3.0.0
* Use the newest base layer `B.CfnLambdaLayer` 
  which uses new asset bundling mechanism (Dockerfile).

### 2.4.0
* Add Boto3 client validation under SfnCall function.

### 2.3.4
* Add functionality to pass Boto3 client to SfnCall function for multithreding support.

### 2.3.3
* Fix api empty dict serialization.

### 2.3.2
* Improve parsing of JWT claims from API Gateway authorizer output.

### 2.3.1
* If you want to use `cryptography` module, you must use Python 3.8.
* Add explanations for Python 3.8 versions.
* Fix supported layer python versions.

### 2.3.0
* Add Fernet encryption PynamoDB attribute.

### 2.2.1
* Fix KmsAttribute by introducing base64 encode/decode.

### 2.2.0
* Add field validator in util directory. Simple string validation.
* Add KMS attribute for PynamoDB.

### 2.1.2
* Add a list bytes batching utility.

### 2.0.6
* Handle errors when raising ValueError in SfnCall class.

### 2.0.4
* Simple return JSON of an output if SfnCall raised ValueError.

### 2.0.1
* Include .txt files.

### 2.0.0
* Complete refactor.
* Fix ugly if/else imports.
* Run unit tests inside lambda functions.
* Use b_cfn_lambda_layer dependency.
* Write more unit and integration tests.
* Add README documentation.

### 1.20.0
* Add validation when bundling with Docker.

### 1.19.0
* General testing improvements.
* Add Layer V2 integration tests.

### 1.18.0
* Add V2 Layer class to enable installation of dependencies.

### 1.16.0
* Add response method to return any type.
* Add `text/html` and `text/plain` headers.
* Add missing `fields` parameter support to `NeighbourEndpoint` class.

### 1.15.1
* Improve function return value handling for `InMemoryDataCache` class.

### 1.15.0
* Add in-memory data caching functionality.

### 1.14.0
* Add `fields` parameter support to `HttpEndpoint` class.

### 1.11.1
* Update DoNotUpdate class to be usable as a type.

### 1.11.0
* Add WebSocket Api Gateway message class to form consistent messages.

### 1.10.2
* Allow for changing HttpEndpoint behavior.

### 1.10.1
* Add ability to specify if to fail to errors.
* Try to read from env event bus name.

### 1.10.0
* Add factory to emit EventBridge events.

### 1.9.5
* Make the code a little more robust and less error prone.

### 1.9.4
* Assets input may contain garbage files too, hence, apply
cleanup commands directly on asset outputs folder.

### 1.9.3
* Add builds badge.

### 1.9.2
* Remove leftover code.
* Update requirements.

### 1.9.1
* Delete unnecessary files which result in different asset hash.
* Calculate hash when bundling.

### 1.9.0
* Add CSV headers.

### 1.8.3
* Ensure everything works with a robust integration test.

### 1.8.2
* Improve Boto3Version class.

### 1.8.1
* Fix bug when boto3 version is specified project files
are not copied.

### 1.8.0
* Change asset bundling to asset docker bundling if additional
dependencies are specified.
* Add ability to install boto3 library.
* Add more unit tests.
* Add integration tests to deploy and test the Layer in AWS.

### 1.7.0
* Simplify SSM parameters functionality.
* Add robust SSM parameter tests.

### 1.6.2
* Do not serialize returned ssm parameters.

### 1.6.1
* Add more logging for better visibility.

### 1.6.0
* SSM should_refresh function should be public.

### 1.5.1
* Add logging on ssm error decorator.

### 1.5.0
* Force using error_class to error_classes.

### 1.4.0
* Add functionality to fetch and cache SSM parameters.
* Add OS type parameters.

### 1.3.0
* Add media Response and wav/mpeg headers.

### 1.2.0
* Add DoNotUpdate class, useful when checking what parameters to update and what not.

### 1.1.3
* Implement retrying logic to HttpCall.

### 1.1.2
* Make sure test coverage is at least 80%.
* Add CI/CD pipeline.
* Add more encodings to decode responses.

### 1.1.1
* Add urllib3 dependency.

### 1.1.0
* Add DynamoDBEncoder that subclasses DecimalEncoder and additionally encodes sets as lists.

### 1.0.3
* Modify call_to_json function by checking whether the response contains body.

### 1.0.2
* Add exception logging for failed imports.

### 1.0.1
* Expose http_endpoint on NeigbourEndpoint class.

### 1.0.0
* Release version with major braking changes.
* Consistent naming for imports.
* Unit tests to cover all functions and classes.
* Add neighbour endpoint.
* General code improvements and cleanup.

### 0.0.16
* Fix logging imports.
* Add logging of exception tracebacks to exception_middleware.
* Add logging about HTTP requests.
* Set request scheme for parent API Gateway urls depending on current protocol.

### 0.0.15
* Add a CognitoAccessToken for parsing access token information provided by the API Gateway using Cognito authorizer.

### 0.0.14
* Add a LoggingManager for setting up logging configuration

### 0.0.13
* Add custom JSON encoder with support for decimal.Decimal encoding

### 0.0.12
* Implement API Gateway body parsing.

### 0.0.11
* Fix imports.

### 0.0.10
* Implement exceptions.

### 0.0.9
* Fix api gateway url.

### 0.0.8
* Add xml to dict converter utility. No dependencies.

### 0.0.7
* Fix imports.

### 0.0.6
* Add ability to check whether singleton was initialized.

### 0.0.5
* Remove description.

### 0.0.4
* Do not create an extra stack.

### 0.0.3
* Add safe initialization.

### 0.0.2
* Add Layer class and Singleton.

### 0.0.1
* Initial build.



%prep
%autosetup -n b-lambda-layer-common-4.4.0

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-b-lambda-layer-common -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 4.4.0-1
- Package Spec generated