clear-skies-aws 2.0.2__tar.gz → 2.0.3__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 (84) hide show
  1. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/CHANGELOG.md +34 -2
  2. clear_skies_aws-2.0.3/LATEST_CHANGELOG.md +34 -0
  3. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/PKG-INFO +2 -2
  4. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/pyproject.toml +3 -3
  5. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/__init__.py +14 -2
  6. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/contexts/__init__.py +5 -5
  7. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/contexts/cli_web_socket_mock.py +3 -2
  8. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/contexts/lambda_alb.py +8 -3
  9. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/contexts/lambda_api_gateway.py +13 -9
  10. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/contexts/lambda_api_gateway_web_socket.py +24 -2
  11. clear_skies_aws-2.0.3/src/clearskies_aws/contexts/lambda_invoke.py +138 -0
  12. clear_skies_aws-2.0.3/src/clearskies_aws/contexts/lambda_sns.py +124 -0
  13. clear_skies_aws-2.0.3/src/clearskies_aws/contexts/lambda_sqs_standard.py +139 -0
  14. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/endpoints/__init__.py +0 -1
  15. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/endpoints/secrets_manager_rotation.py +0 -1
  16. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/input_outputs/__init__.py +2 -2
  17. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/input_outputs/cli_web_socket_mock.py +2 -0
  18. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/input_outputs/lambda_api_gateway_web_socket.py +9 -7
  19. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/input_outputs/lambda_input_output.py +4 -2
  20. clear_skies_aws-2.0.2/src/clearskies_aws/input_outputs/lambda_invocation.py → clear_skies_aws-2.0.3/src/clearskies_aws/input_outputs/lambda_invoke.py +10 -7
  21. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/input_outputs/lambda_sns.py +27 -18
  22. clear_skies_aws-2.0.3/src/clearskies_aws/input_outputs/lambda_sqs_standard.py +86 -0
  23. clear_skies_aws-2.0.3/src/clearskies_aws/models/__init__.py +1 -0
  24. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/uv.lock +409 -341
  25. clear_skies_aws-2.0.2/LATEST_CHANGELOG.md +0 -9
  26. clear_skies_aws-2.0.2/src/clearskies_aws/contexts/lambda_invocation.py +0 -19
  27. clear_skies_aws-2.0.2/src/clearskies_aws/contexts/lambda_sns.py +0 -18
  28. clear_skies_aws-2.0.2/src/clearskies_aws/contexts/lambda_sqs_standard_partial_batch.py +0 -29
  29. clear_skies_aws-2.0.2/src/clearskies_aws/input_outputs/lambda_sqs_standard.py +0 -84
  30. clear_skies_aws-2.0.2/src/clearskies_aws/models/__init__.py +0 -0
  31. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/.copier-answers.yml +0 -0
  32. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/.editorconfig +0 -0
  33. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/.github/workflows/create-version.yaml +0 -0
  34. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/.github/workflows/docs.yaml +0 -0
  35. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/.github/workflows/run-tests.yml +0 -0
  36. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/.github/workflows/tests-matrix.yaml +0 -0
  37. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/.github/workflows/tests.yaml +0 -0
  38. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/.gitignore +0 -0
  39. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/.pre-commit-config.yaml +0 -0
  40. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/.python-version +0 -0
  41. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/LICENSE +0 -0
  42. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/README.md +0 -0
  43. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/cliff.toml +0 -0
  44. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/ruff.toml +0 -0
  45. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/actions/__init__.py +0 -0
  46. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/actions/action_aws.py +0 -0
  47. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/actions/assume_role.py +0 -0
  48. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/actions/ses.py +0 -0
  49. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/actions/sns.py +0 -0
  50. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/actions/sqs.py +0 -0
  51. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/actions/step_function.py +0 -0
  52. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/backends/__init__.py +0 -0
  53. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/backends/backend.py +0 -0
  54. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/backends/dynamo_db_backend.py +0 -0
  55. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/backends/dynamo_db_condition_parser.py +0 -0
  56. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/backends/dynamo_db_parti_ql_backend.py +0 -0
  57. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/backends/sqs_backend.py +0 -0
  58. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/configs/__init__.py +0 -0
  59. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/di/__init__.py +0 -0
  60. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/di/aws_additional_config_auto_import.py +0 -0
  61. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/di/inject/__init__.py +0 -0
  62. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/di/inject/boto3.py +0 -0
  63. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/di/inject/boto3_session.py +0 -0
  64. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/di/inject/parameter_store.py +0 -0
  65. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/endpoints/simple_body_routing.py +0 -0
  66. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/input_outputs/lambda_alb.py +0 -0
  67. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/input_outputs/lambda_api_gateway.py +0 -0
  68. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/mocks/__init__.py +0 -0
  69. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/mocks/actions/__init__.py +0 -0
  70. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/mocks/actions/ses.py +0 -0
  71. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/mocks/actions/sns.py +0 -0
  72. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/mocks/actions/sqs.py +0 -0
  73. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/mocks/actions/step_function.py +0 -0
  74. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/models/web_socket_connection_model.py +0 -0
  75. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/secrets/__init__.py +0 -0
  76. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/secrets/additional_configs/__init__.py +0 -0
  77. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/secrets/additional_configs/iam_db_auth.py +0 -0
  78. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/secrets/additional_configs/iam_db_auth_with_ssm.py +0 -0
  79. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/secrets/additional_configs/mysql_connection_dynamic_producer_via_ssh_cert_bastion.py +0 -0
  80. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/secrets/additional_configs/mysql_connection_dynamic_producer_via_ssm_bastion.py +0 -0
  81. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/secrets/akeyless_with_ssm_cache.py +0 -0
  82. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/secrets/parameter_store.py +0 -0
  83. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/secrets/secrets.py +0 -0
  84. {clear_skies_aws-2.0.2 → clear_skies_aws-2.0.3}/src/clearskies_aws/secrets/secrets_manager.py +0 -0
@@ -5,9 +5,22 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.0.3] - 2026-01-05
9
+
10
+ ### Changed
11
+ - Merge pull request #7 from clearskies-py/contexts by @cmancone in [#7](https://github.com/clearskies-py/aws/pull/7)
12
+ - Require latest clearskies version per added feature by @cmancone
13
+ - Bring up-to-date by @cmancone
14
+
15
+ ### Fixed
16
+ - Inverted flag by @cmancone
17
+ - Tooling by @cmancone
18
+ - Mypy by @cmancone
19
+
8
20
  ## [2.0.2] - 2025-10-30
9
21
 
10
22
  ### Changed
23
+ - Bump version to v2.0.2 by @github-actions[bot]
11
24
  - Update lock file
12
25
 
13
26
  ### Fixed
@@ -21,6 +34,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
21
34
  - Add parameter_store tests
22
35
  - Add actions
23
36
  - Add AwsAdditionalConfigAutoImport
37
+ - Add __init__.py and imports for test module
38
+ - Add parameter_store tests
39
+ - Add actions
40
+ - Add AwsAdditionalConfigAutoImport
24
41
 
25
42
  ### Changed
26
43
  - Bump version to v2.0.1 by @github-actions[bot]
@@ -33,19 +50,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
33
50
  - Use same backend for all
34
51
  - Mark failing test as broken
35
52
  - More migration work
53
+ - Cleanup/tests by @cmancone
54
+ - Working through basics by @cmancone
55
+ - Moving along by @cmancone
56
+ - Moving along by @cmancone
57
+ - Try lambda sqs standard partial batch
58
+ - Combine the v1 / v2 gateway to one
59
+ - Input outputs
60
+ - Use same backend for all
61
+ - Mark failing test as broken
62
+ - More migration work
36
63
  - First commit: Import from WIP by @cmancone
37
64
 
38
65
  ### Fixed
39
66
  - Rewrite sqs test
67
+ - Merge in Tom's stuff by @cmancone
68
+ - Rewrite sqs test
40
69
 
41
70
  ### Removed
42
71
  - Remove unneeded dependency
43
72
  - Remove clearskies_aws.di
73
+ - Remove unneeded dependency
74
+ - Remove clearskies_aws.di
44
75
 
45
76
  ## New Contributors
46
- * @github-actions[bot] made their first contribution
47
- * @ made their first contribution in [#4](https://github.com/clearskies-py/aws/pull/4)
48
77
  * @cmancone made their first contribution
78
+ * @ made their first contribution
79
+ * @github-actions[bot] made their first contribution
80
+ [2.0.3]: https://github.com/clearskies-py/aws/compare/v2.0.2..v2.0.3
49
81
  [2.0.2]: https://github.com/clearskies-py/aws/compare/v2.0.1..v2.0.2
50
82
 
51
83
  <!-- generated by git-cliff -->
@@ -0,0 +1,34 @@
1
+ ## [2.0.3] - 2026-01-05
2
+
3
+ ### Added
4
+ - Add __init__.py and imports for test module
5
+ - Add parameter_store tests
6
+ - Add actions
7
+ - Add AwsAdditionalConfigAutoImport
8
+
9
+ ### Changed
10
+ - Merge pull request #7 from clearskies-py/contexts by @cmancone in [#7](https://github.com/clearskies-py/aws/pull/7)
11
+ - Require latest clearskies version per added feature by @cmancone
12
+ - Bring up-to-date by @cmancone
13
+ - Cleanup/tests by @cmancone
14
+ - Working through basics by @cmancone
15
+ - Moving along by @cmancone
16
+ - Moving along by @cmancone
17
+ - Try lambda sqs standard partial batch
18
+ - Combine the v1 / v2 gateway to one
19
+ - Input outputs
20
+ - Use same backend for all
21
+ - Mark failing test as broken
22
+ - More migration work
23
+
24
+ ### Fixed
25
+ - Inverted flag by @cmancone
26
+ - Tooling by @cmancone
27
+ - Mypy by @cmancone
28
+ - Merge in Tom's stuff by @cmancone
29
+ - Rewrite sqs test
30
+
31
+ ### Removed
32
+ - Remove unneeded dependency
33
+ - Remove clearskies_aws.di
34
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clear-skies-aws
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: clearskies bindings for working in AWS
5
5
  Project-URL: Repository, https://github.com/clearskies-py/clearskies-aws
6
6
  Project-URL: Issues, https://github.com/clearskies-py/clearskies-aws/issues
@@ -16,7 +16,7 @@ Classifier: License :: OSI Approved :: MIT License
16
16
  Classifier: Programming Language :: Python :: 3
17
17
  Requires-Python: <4.0,>=3.11
18
18
  Requires-Dist: boto3<2.0.0,>=1.26.148
19
- Requires-Dist: clear-skies<3.0.0,>=2.0.2
19
+ Requires-Dist: clear-skies<3.0.0,>=2.0.20
20
20
  Requires-Dist: types-boto3[dynamodb,sns,sqs]<2.0.0,>=1.38.13
21
21
  Provides-Extra: akeyless
22
22
  Requires-Dist: akeyless-cloud-id<0.5.0,>=0.2.3; extra == 'akeyless'
@@ -3,14 +3,14 @@
3
3
  name = "clear-skies-aws"
4
4
  description = "clearskies bindings for working in AWS"
5
5
  license = "MIT"
6
- version = "2.0.2"
6
+ version = "2.0.3"
7
7
  readme = "./README.md"
8
8
  authors = [{name = "tnijboer"}, {name = "Conor Mancone", email = "cmancone@gmail.com"}]
9
9
  requires-python = '>=3.11,<4.0'
10
10
  dependencies = [
11
11
  'boto3 (>=1.26.148,<2.0.0)',
12
- "clear-skies (>=2.0.2,<3.0.0)",
13
- 'types-boto3[dynamodb,sns,sqs] (>=1.38.13,<2.0.0)',
12
+ 'clear-skies (>=2.0.20,<3.0.0)',
13
+ 'types-boto3[dynamodb,sns,sqs] (>=1.38.13,<2.0.0)',
14
14
  ]
15
15
  classifiers = [
16
16
  "Development Status :: 5 - Production/Stable",
@@ -1,15 +1,27 @@
1
1
  from __future__ import annotations
2
2
 
3
- from clearskies_aws import actions, backends, contexts, di, endpoints, input_outputs, mocks, models, secrets
3
+ from clearskies_aws import (
4
+ actions,
5
+ backends,
6
+ contexts,
7
+ di,
8
+ endpoints,
9
+ handlers,
10
+ input_outputs,
11
+ mocks,
12
+ models,
13
+ secrets,
14
+ )
4
15
 
5
16
  __all__ = [
6
- "models",
7
17
  "actions",
8
18
  "backends",
9
19
  "contexts",
10
20
  "di",
11
21
  "endpoints",
22
+ "handlers",
12
23
  "input_outputs",
13
24
  "mocks",
25
+ "models",
14
26
  "secrets",
15
27
  ]
@@ -6,10 +6,10 @@ from clearskies_aws.contexts.lambda_api_gateway import LambdaApiGateway
6
6
  from clearskies_aws.contexts.lambda_api_gateway_web_socket import (
7
7
  LambdaApiGatewayWebSocket,
8
8
  )
9
- from clearskies_aws.contexts.lambda_invocation import LambdaInvocation
9
+ from clearskies_aws.contexts.lambda_invoke import LambdaInvoke
10
10
  from clearskies_aws.contexts.lambda_sns import LambdaSns
11
- from clearskies_aws.contexts.lambda_sqs_standard_partial_batch import (
12
- LambdaSqsStandardPartialBatch,
11
+ from clearskies_aws.contexts.lambda_sqs_standard import (
12
+ LambdaSqsStandard,
13
13
  )
14
14
 
15
15
  __all__ = [
@@ -17,7 +17,7 @@ __all__ = [
17
17
  "LambdaAlb",
18
18
  "LambdaApiGateway",
19
19
  "LambdaApiGatewayWebSocket",
20
- "LambdaInvocation",
20
+ "LambdaInvoke",
21
21
  "LambdaSns",
22
- "LambdaSqsStandardPartialBatch",
22
+ "LambdaSqsStandard",
23
23
  ]
@@ -12,8 +12,9 @@ class CliWebSocketMock(cli.Cli):
12
12
  The LambdaApiGatewayWebSocket context makes it easy to run websocket applications, but testing
13
13
  these locally is literally impossible. This context provides a close analogue to the way
14
14
  the LambdaApiGatewayWebSocket context works to give some testing capabilities when running
15
- locally.
15
+ locally. It works identically to `clearskies.contexts.Cli` but you have to provide a
16
+ `connection_id` property in the JSON body.
16
17
  """
17
18
 
18
19
  def __call__(self):
19
- return self.execute_application(CliWebSocketMockInputOutput())
20
+ return self.execute_application(CLIWebSocketMockInputOutput())
@@ -65,11 +65,16 @@ class LambdaAlb(Context):
65
65
  return application(event, context)
66
66
  ```
67
67
 
68
- ### Context for Callables
68
+ ### Context Specifics
69
69
 
70
70
  When using this context, two additional named arguments become available to any callables invoked by clearskies:
71
- `event` and `context`. These correspond to the original `event` and `context` variables provided by AWS to
72
- the lambda.
71
+
72
+ ```
73
+ | Name | Type | Description |
74
+ |:-------------:|:----------------:|----------------------------------|
75
+ | `event` | `dict[str, Any]` | The lambda `event` object |
76
+ | `context` | `dict[str, Any]` | The lambda `context` object |
77
+ ```
73
78
  """
74
79
 
75
80
  def __call__(self, event: dict[str, Any], context: dict[str, Any]) -> Any: # type: ignore[override]
@@ -59,19 +59,23 @@ class LambdaApiGateway(Context):
59
59
  return application(event, context)
60
60
  ```
61
61
 
62
- ### Context for Callables
62
+ ### Context Specifics
63
63
 
64
64
  When using this context, a number of additional named arguments become available to any callables invoked by
65
65
  clearskies:
66
66
 
67
- 1. `event`
68
- 2. `context`
69
- 3. `resource`
70
- 4. `stage`
71
- 5. `request_id`
72
- 6. `api_id`
73
- 7. `api_version` (v1 or v2)
67
+ ```
68
+ | Name | Type | Description |
69
+ |:-------------:|:----------------:|----------------------------------|
70
+ | ` event` | `dict[str, Any]` | The lambda `event` object |
71
+ | `context` | `dict[str, Any]` | The lambda `context` object |
72
+ | `resource` | `str` | The route resource |
73
+ | `stage` | `str` | The stage of the lambda function |
74
+ | `request_id` | `str` | The AWS request id for the call |
75
+ | `api_id` | `str` | The id of the API |
76
+ | `api_version` | `str` | "v1" or "v2" |
77
+ ```
74
78
  """
75
79
 
76
- def __call__(self, event: dict[str, Any], context: dict[str, Any]) -> Any: # type: ignore[override]
80
+ def __call__(self, event: dict[str, Any], context: dict[str, Any]) -> dict[str, Any]: # type: ignore[override]
77
81
  return self.execute_application(LambdaApiGatewayInputOutput(event, context))
@@ -37,7 +37,7 @@ class LambdaApiGatewayWebSocket(Context):
37
37
  having to handle such things themselves, since the typical standards of web frameworks won't match up. In
38
38
  the case of routing with an API Gateway, it has its own suggested standard of setting a routekey where the
39
39
  API gateway will check for an application-defined route parameter in the request body and use this to route
40
- to an appropriate lambda. With clearskies, you can also use the `clearskies.endpoints.JsonParamEndpointGroup`
40
+ to an appropriate lambda. With clearskies, you can also use the `clearskies.endpoints.BodyParameterRouting`
41
41
  to accomplish the same.
42
42
 
43
43
  With a websocket through API Gateway, headers are available during the `on_connect` phase, so you can always
@@ -51,7 +51,29 @@ class LambdaApiGatewayWebSocket(Context):
51
51
  there is a base model class in `clearskies_aws.models.WebSocketConnectionModel`. Check the documentation for
52
52
  this class to understand how this is managed and see a "starter" websocket application.
53
53
 
54
+ ### Context Specifics
55
+
56
+ The following parameters are made available by name to any function invoked by clearskies when using
57
+ this context:
58
+
59
+ ```
60
+ | Name | Type | Description |
61
+ |:---------------:|:----------------:|--------------------------------------------------|
62
+ | `event` | `dict[str, Any]` | The lambda `event` object |
63
+ | `context` | `dict[str, Any]` | The lambda `context` object |
64
+ | `connection_id` | `str` | The Connection ID |
65
+ | `route_key` | `str` | The value of the route key, as determined by AWS |
66
+ | `stage` | `str` | The stage of the lambda function |
67
+ | `request_id` | `str` | The AWS request id for the call |
68
+ | `api_id` | `str` | The id of the API |
69
+ | `domain_name` | `str` | The domain name |
70
+ | `event_type` | `str` | One of "MESSAGE", "CONNECT", or "DISCONNECT" |
71
+ | `connected_at` | `str` | The connection time |
72
+ ```
73
+
54
74
  """
55
75
 
56
- def __call__(self, event: dict[str, Any], context: dict[str, Any], url: str = "") -> Any: # type: ignore[override]
76
+ def __call__(
77
+ self, event: dict[str, Any], context: dict[str, Any], url: str = "", request_method: str = ""
78
+ ) -> dict[str, Any]: # type: ignore[override]
57
79
  return self.execute_application(LambdaApiGatewayWebSocketInputOutput(event, context, url))
@@ -0,0 +1,138 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+
5
+ from clearskies.authentication import Public
6
+ from clearskies.contexts.context import Context
7
+
8
+ from clearskies_aws.input_outputs import LambdaInvoke as LambdaInvokeInputOutput
9
+
10
+
11
+ class LambdaInvoke(Context):
12
+ """
13
+ Execute a lambda directly.
14
+
15
+ This context is used when your clearskies application is running in a lambda that is executed
16
+ directly by some variation of `aws lambda invoke`. For this context, the `event` object passed
17
+ to the lambda handler becomes the request body in the clearskies application. Note that, unlike
18
+ other lambda execution strategies (ALB, Api Gateway, etc...) the event object is exactly equal
19
+ to the body sent in with the lambda function.
20
+
21
+ ### Usage
22
+
23
+ Here's a simple example:
24
+
25
+ ```
26
+ import clearskies
27
+
28
+
29
+ def my_function(request_data):
30
+ return request_data
31
+
32
+
33
+ lambda_invoke = clearskies_aws.contexts.LambdaInvoke(
34
+ clearskies.endpoints.Callable(
35
+ my_function,
36
+ return_standard_response=False,
37
+ )
38
+ )
39
+
40
+
41
+ def lambda_handler(event, context):
42
+ return lambda_invoke(event, context)
43
+ ```
44
+
45
+ You can attach this to a lambda and might invoke it like so, with the following response:
46
+
47
+ ```
48
+ $ aws lambda invoke --function-name [function_name] --cli-binary-format raw-in-base64-out --payload '{"some":"data"}' | jq
49
+ { "Payload": {"some": "data"} }
50
+ ```
51
+
52
+ Invoking a lambda doesn't happen from an http context, so there is no URL/request method/headers/etc.
53
+ This typically means that clearskies applications in this context don't do routing and don't have
54
+ authentication configured. If you wanted to though, you could use `clearskies.endpoints.BodyParameterRouting`
55
+ to setup some basic routing and let the invoking client choose a route by providing a parameter in the
56
+ payload passed to lambda invoke.
57
+
58
+ You can pass a URL/request method into the context when you invoke it, which is often used to simplify
59
+ configuration: you can setup a standard clearskies applications with multiple endpoints, and then
60
+ use that one application in multiple lambdas, specifying which endpoint to call for each lambda.
61
+ This can also be helpful if you already have a clearskies application prepared for a standard http context
62
+ and want to execute some subset of those endpoints in a lambda invoke context. It looks something like this:
63
+
64
+ ```
65
+ import clearskies
66
+
67
+
68
+ def some_function(request_data):
69
+ return request_data
70
+
71
+
72
+ def some_other_function(request_data):
73
+ return request_data
74
+
75
+
76
+ def something_else(request_data):
77
+ return request_data
78
+
79
+
80
+ lambda_invoke = clearskies_aws.contexts.LambdaInvoke(
81
+ clearskies.endpoints.EndpointGroup(
82
+ [
83
+ clearskies.endpoints.Callable(
84
+ some_function,
85
+ url="some_function",
86
+ ),
87
+ clearskies.endpoints.Callable(
88
+ some_other_function,
89
+ url="some_other_function",
90
+ ),
91
+ clearskies.endpoints.Callable(
92
+ something_else,
93
+ url="something_else",
94
+ ),
95
+ ]
96
+ )
97
+ )
98
+
99
+
100
+ def some_function_handler(event, context):
101
+ return lambda_invoke(event, context, url="some_function")
102
+
103
+
104
+ def some_other_function_handler(event, context):
105
+ return lambda_invoke(event, context, url="some_other_function")
106
+
107
+
108
+ def something_else_handler(event, context):
109
+ return lambda_invoke(event, context, url="something_else")
110
+ ```
111
+
112
+ ### Context Specifics
113
+
114
+ When using the lambda_invoke context, it exposes a few context specific parameters which can be injected into
115
+ any function called by clearskies:
116
+
117
+ | Name | Type | Description |
118
+ |:------------------:|:----------------:|:-------------------------------:|
119
+ | `event` | `dict[str, Any]` | The lambda `event` object |
120
+ | `context` | `dict[str, Any]` | The lambda `context` object |
121
+ | `invocation_type` | `str` | Always `"direct"` |
122
+ | `function_name` | `str` | The name of the lambda function |
123
+ | `function_version` | `str` | The function version |
124
+ | `request_id` | `str` | The AWS request id for the call |
125
+
126
+ """
127
+
128
+ def __call__(
129
+ self, event: dict[str, Any], context: dict[str, Any], request_method: str = "", url: str = ""
130
+ ) -> dict[str, Any]: # type: ignore[override]
131
+ return self.execute_application(
132
+ LambdaInvokeInputOutput(
133
+ event,
134
+ context,
135
+ request_method=request_method,
136
+ url=url,
137
+ )
138
+ )
@@ -0,0 +1,124 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+
5
+ from clearskies.authentication import Public
6
+ from clearskies.contexts.context import Context
7
+
8
+ from clearskies_aws.input_outputs import LambdaSns as LambdaSnsInputOutput
9
+
10
+
11
+ class LambdaSns(Context):
12
+ """
13
+ Execute a clearskies application when attached to a lambda triggered by SNS.
14
+
15
+ This one is very straight-forward: just attach your clearskies application to work with an
16
+ SNS-triggered lambda. `request_data` provided to the clearskies application will be the
17
+ message sent to the SNS. Since this is no longer an http context, the various http parameters
18
+ (url, request method, headers, and even responses) do not exist. Routing won't exist unless
19
+ you use `clearskies.endpoints.BodyParameterRouting` and include the route parameter in your
20
+ SNS message body.
21
+
22
+ ### Usage
23
+
24
+ Here's a simple example:
25
+
26
+ ```
27
+ import clearskies
28
+
29
+
30
+ def my_function(request_data):
31
+ print(request_data)
32
+
33
+
34
+ lambda_invoke = clearskies_aws.contexts.LambdaInvoke(
35
+ clearskies.endpoints.Callable(
36
+ my_function,
37
+ return_standard_response=False,
38
+ )
39
+ )
40
+
41
+
42
+ def lambda_handler(event, context):
43
+ return lambda_invoke(event, context)
44
+ ```
45
+
46
+ Note the lack of a return value. You can return a value if you want, but it will be ignored
47
+ because SNS has no concept of a return response.
48
+
49
+ If you have a number of Lambda/SNS handlers, you can bundle them together for ease-of-management
50
+ and specify the URL when you invoke them:
51
+
52
+ ```
53
+ import clearskies
54
+
55
+
56
+ def some_function(request_data):
57
+ return request_data
58
+
59
+
60
+ def some_other_function(request_data):
61
+ return request_data
62
+
63
+
64
+ def something_else(request_data):
65
+ return request_data
66
+
67
+
68
+ lambda_invoke = clearskies_aws.contexts.LambdaSns(
69
+ clearskies.endpoints.EndpointGroup(
70
+ [
71
+ clearskies.endpoints.Callable(
72
+ some_function,
73
+ url="some_function",
74
+ ),
75
+ clearskies.endpoints.Callable(
76
+ some_other_function,
77
+ url="some_other_function",
78
+ ),
79
+ clearskies.endpoints.Callable(
80
+ something_else,
81
+ url="something_else",
82
+ ),
83
+ ]
84
+ )
85
+ )
86
+
87
+
88
+ def some_function_handler(event, context):
89
+ return lambda_invoke(event, context, url="some_function")
90
+
91
+
92
+ def some_other_function_handler(event, context):
93
+ return lambda_invoke(event, context, url="some_other_function")
94
+
95
+
96
+ def something_else_handler(event, context):
97
+ return lambda_invoke(event, context, url="something_else")
98
+ ```
99
+
100
+ ### Context Specifics
101
+
102
+ When you use the LambdaSns context, it makes the following named parameters available
103
+ to any callable that is invoked by clearskies:
104
+
105
+ ```
106
+ | Name | Type | Description |
107
+ |:------------:|:----------------:|------------------------------------------------|
108
+ | `event` | `dict[str, Any]` | The lambda `event` object |
109
+ | `context` | `dict[str, Any]` | The lambda `context` object |
110
+ | `message_id` | `str` | The AWS message id |
111
+ | `topic_arn` | `str` | The ARN of the SNS topic that sent the message |
112
+ | `subject` | `str` | Any subject attached to the SNS message |
113
+ | `timestamp` | `str` | The timestamp when the message was sent |
114
+ ```
115
+ """
116
+
117
+ def __call__(self, event: dict[str, Any], context: dict[str, Any], request_method: str = "", url: str = ""): # type: ignore[override]
118
+ try:
119
+ return self.execute_application(
120
+ LambdaSnsInputOutput(event, context, request_method=request_method, url=url)
121
+ )
122
+ except Exception as e:
123
+ print("Failed message " + event["Records"][0]["Sns"]["MessageId"] + ". Error error: " + str(e))
124
+ raise e