pycfmodel 1.1.1__tar.gz → 1.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. {pycfmodel-1.1.1 → pycfmodel-1.1.2}/PKG-INFO +2 -2
  2. pycfmodel-1.1.2/pycfmodel/__init__.py +5 -0
  3. pycfmodel-1.1.2/pycfmodel/action_expander.py +49 -0
  4. pycfmodel-1.1.2/pycfmodel/cloudformation_actions.py +18581 -0
  5. pycfmodel-1.1.2/pycfmodel/constants.py +30 -0
  6. pycfmodel-1.1.2/pycfmodel/resolver.py +223 -0
  7. pycfmodel-1.1.2/pycfmodel/utils.py +29 -0
  8. {pycfmodel-1.1.1/pycfmodel → pycfmodel-1.1.2}/pycfmodel.egg-info/PKG-INFO +2 -2
  9. pycfmodel-1.1.2/pycfmodel.egg-info/SOURCES.txt +24 -0
  10. {pycfmodel-1.1.1/pycfmodel → pycfmodel-1.1.2}/pycfmodel.egg-info/requires.txt +1 -1
  11. pycfmodel-1.1.2/pycfmodel.egg-info/top_level.txt +1 -0
  12. {pycfmodel-1.1.1 → pycfmodel-1.1.2}/pyproject.toml +3 -3
  13. pycfmodel-1.1.1/pycfmodel/model/base.py +0 -18
  14. pycfmodel-1.1.1/pycfmodel/model/cf_model.py +0 -141
  15. pycfmodel-1.1.1/pycfmodel/model/generic.py +0 -92
  16. pycfmodel-1.1.1/pycfmodel/model/parameter.py +0 -54
  17. pycfmodel-1.1.1/pycfmodel/model/resources/ec2_vpc_endpoint_policy.py +0 -53
  18. pycfmodel-1.1.1/pycfmodel/model/resources/es_domain.py +0 -61
  19. pycfmodel-1.1.1/pycfmodel/model/resources/generic_resource.py +0 -39
  20. pycfmodel-1.1.1/pycfmodel/model/resources/iam_group.py +0 -46
  21. pycfmodel-1.1.1/pycfmodel/model/resources/iam_managed_policy.py +0 -52
  22. pycfmodel-1.1.1/pycfmodel/model/resources/iam_policy.py +0 -48
  23. pycfmodel-1.1.1/pycfmodel/model/resources/iam_role.py +0 -68
  24. pycfmodel-1.1.1/pycfmodel/model/resources/iam_user.py +0 -63
  25. pycfmodel-1.1.1/pycfmodel/model/resources/kms_key.py +0 -50
  26. pycfmodel-1.1.1/pycfmodel/model/resources/opensearch_domain.py +0 -61
  27. pycfmodel-1.1.1/pycfmodel/model/resources/properties/policy.py +0 -17
  28. pycfmodel-1.1.1/pycfmodel/model/resources/properties/policy_document.py +0 -138
  29. pycfmodel-1.1.1/pycfmodel/model/resources/properties/property.py +0 -7
  30. pycfmodel-1.1.1/pycfmodel/model/resources/properties/security_group_egress_prop.py +0 -54
  31. pycfmodel-1.1.1/pycfmodel/model/resources/properties/security_group_ingress_prop.py +0 -78
  32. pycfmodel-1.1.1/pycfmodel/model/resources/properties/statement.py +0 -190
  33. pycfmodel-1.1.1/pycfmodel/model/resources/properties/statement_condition.py +0 -355
  34. pycfmodel-1.1.1/pycfmodel/model/resources/properties/tag.py +0 -22
  35. pycfmodel-1.1.1/pycfmodel/model/resources/properties/types.py +0 -19
  36. pycfmodel-1.1.1/pycfmodel/model/resources/resource.py +0 -90
  37. pycfmodel-1.1.1/pycfmodel/model/resources/s3_bucket.py +0 -70
  38. pycfmodel-1.1.1/pycfmodel/model/resources/s3_bucket_policy.py +0 -38
  39. pycfmodel-1.1.1/pycfmodel/model/resources/security_group.py +0 -73
  40. pycfmodel-1.1.1/pycfmodel/model/resources/security_group_egress.py +0 -44
  41. pycfmodel-1.1.1/pycfmodel/model/resources/security_group_ingress.py +0 -56
  42. pycfmodel-1.1.1/pycfmodel/model/resources/sns_topic_policy.py +0 -38
  43. pycfmodel-1.1.1/pycfmodel/model/resources/sqs_queue_policy.py +0 -38
  44. pycfmodel-1.1.1/pycfmodel/model/resources/types.py +0 -45
  45. pycfmodel-1.1.1/pycfmodel/model/types.py +0 -151
  46. pycfmodel-1.1.1/pycfmodel/model/utils.py +0 -10
  47. pycfmodel-1.1.1/pycfmodel/pycfmodel.egg-info/SOURCES.txt +0 -52
  48. pycfmodel-1.1.1/pycfmodel/pycfmodel.egg-info/top_level.txt +0 -1
  49. {pycfmodel-1.1.1 → pycfmodel-1.1.2}/LICENSE.md +0 -0
  50. {pycfmodel-1.1.1 → pycfmodel-1.1.2}/README.md +0 -0
  51. {pycfmodel-1.1.1/pycfmodel → pycfmodel-1.1.2}/pycfmodel.egg-info/dependency_links.txt +0 -0
  52. {pycfmodel-1.1.1 → pycfmodel-1.1.2}/setup.cfg +0 -0
  53. {pycfmodel-1.1.1 → pycfmodel-1.1.2}/tests/test_action_expander.py +0 -0
  54. {pycfmodel-1.1.1 → pycfmodel-1.1.2}/tests/test_cf_model.py +0 -0
  55. {pycfmodel-1.1.1 → pycfmodel-1.1.2}/tests/test_constants.py +0 -0
  56. {pycfmodel-1.1.1 → pycfmodel-1.1.2}/tests/test_generic.py +0 -0
  57. {pycfmodel-1.1.1 → pycfmodel-1.1.2}/tests/test_parameter.py +0 -0
  58. {pycfmodel-1.1.1 → pycfmodel-1.1.2}/tests/test_regexs.py +0 -0
  59. {pycfmodel-1.1.1 → pycfmodel-1.1.2}/tests/test_resolver.py +0 -0
  60. {pycfmodel-1.1.1 → pycfmodel-1.1.2}/tests/test_resource.py +0 -0
  61. {pycfmodel-1.1.1 → pycfmodel-1.1.2}/tests/test_types.py +0 -0
  62. {pycfmodel-1.1.1 → pycfmodel-1.1.2}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pycfmodel
3
- Version: 1.1.1
3
+ Version: 1.1.2
4
4
  Summary: A python model for Cloud Formation scripts
5
5
  Author-email: Skyscanner Security <security@skyscanner.net>
6
6
  Project-URL: Homepage, https://github.com/Skyscanner/pycfmodel
@@ -22,7 +22,7 @@ Requires-Dist: AutoMacDoc==0.3; extra == "docs"
22
22
  Requires-Dist: livereload==2.7.1; extra == "docs"
23
23
  Requires-Dist: mkdocs-material==9.6.11; extra == "docs"
24
24
  Requires-Dist: mkdocs==1.6.0; extra == "docs"
25
- Requires-Dist: mkdocstrings==0.10.0; extra == "docs"
25
+ Requires-Dist: mkdocstrings==0.28.3; extra == "docs"
26
26
  Dynamic: license-file
27
27
 
28
28
  # pycfmodel
@@ -0,0 +1,5 @@
1
+ from pycfmodel.model.cf_model import CFModel
2
+
3
+
4
+ def parse(template):
5
+ return CFModel.model_validate(template)
@@ -0,0 +1,49 @@
1
+ from typing import List, Union
2
+
3
+ from pycfmodel.cloudformation_actions import CLOUDFORMATION_ACTIONS
4
+ from pycfmodel.utils import regex_from_cf_string
5
+
6
+
7
+ def _expand_action(action: str, not_action=False) -> List[str]:
8
+ if isinstance(action, str):
9
+ pattern = regex_from_cf_string(action)
10
+ if not_action:
11
+ return sorted(
12
+ set(CLOUDFORMATION_ACTIONS) - set(action for action in CLOUDFORMATION_ACTIONS if pattern.match(action))
13
+ )
14
+ return sorted(set(action for action in CLOUDFORMATION_ACTIONS if pattern.match(action)))
15
+
16
+ raise ValueError(f"Not supported type: {type(action)}")
17
+
18
+
19
+ def _expand_actions(actions: Union[str, List[str]], not_action=False) -> List[str]:
20
+ if isinstance(actions, str):
21
+ return _expand_action(actions, not_action=not_action)
22
+
23
+ if isinstance(actions, list):
24
+ expanded_actions = set()
25
+ for action in actions:
26
+ expanded_actions.update(_expand_action(action))
27
+ if not_action:
28
+ return sorted(set(CLOUDFORMATION_ACTIONS) - expanded_actions)
29
+ return sorted(expanded_actions)
30
+
31
+ raise ValueError(f"Not supported type: {type(actions)}")
32
+
33
+
34
+ def expand_actions(obj):
35
+ if isinstance(obj, dict):
36
+ for key, value in obj.items():
37
+ if value is None:
38
+ continue # or obj[key] = None
39
+ elif key == "Action":
40
+ obj[key] = _expand_actions(value)
41
+ elif key == "NotAction":
42
+ obj[key] = _expand_actions(value, not_action=True)
43
+ else:
44
+ obj[key] = expand_actions(value)
45
+
46
+ if isinstance(obj, list):
47
+ obj = [expand_actions(value) for value in obj]
48
+
49
+ return obj