-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(event_source): add CodeDeploy Lifecycle Hook event (#5219)
* feat: Add CodeDeploy Lifecycle Hook event definition * Add tests * Update aws_lambda_powertools/utilities/data_classes/code_deploy_lifecycle_hook_event.py Co-authored-by: Leandro Damascena <lcdama@amazon.pt> Signed-off-by: Mike W <12434761+mw-root@users.noreply.github.com> * Update aws_lambda_powertools/utilities/data_classes/__init__.py Co-authored-by: Leandro Damascena <lcdama@amazon.pt> Signed-off-by: Mike W <12434761+mw-root@users.noreply.github.com> * Update tests/unit/data_classes/required_dependencies/test_code_deploy_lifecycle_hook_event.py Co-authored-by: Leandro Damascena <lcdama@amazon.pt> Signed-off-by: Mike W <12434761+mw-root@users.noreply.github.com> * Update tests/unit/data_classes/required_dependencies/test_code_deploy_lifecycle_hook_event.py Co-authored-by: Leandro Damascena <lcdama@amazon.pt> Signed-off-by: Mike W <12434761+mw-root@users.noreply.github.com> * Update aws_lambda_powertools/utilities/data_classes/__init__.py Co-authored-by: Leandro Damascena <lcdama@amazon.pt> Signed-off-by: Mike W <12434761+mw-root@users.noreply.github.com> * Add docs * Update docs/utilities/data_classes.md Co-authored-by: Leandro Damascena <lcdama@amazon.pt> Signed-off-by: Mike W <12434761+mw-root@users.noreply.github.com> * Update docs/utilities/data_classes.md Co-authored-by: Leandro Damascena <lcdama@amazon.pt> Signed-off-by: Mike W <12434761+mw-root@users.noreply.github.com> --------- Signed-off-by: Mike W <12434761+mw-root@users.noreply.github.com> Co-authored-by: Leandro Damascena <lcdama@amazon.pt>
- Loading branch information
1 parent
4104f8b
commit 8329bf3
Showing
5 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
aws_lambda_powertools/utilities/data_classes/code_deploy_lifecycle_hook_event.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from aws_lambda_powertools.utilities.data_classes.common import DictWrapper | ||
|
||
|
||
class CodeDeployLifecycleHookEvent(DictWrapper): | ||
@property | ||
def deployment_id(self) -> str: | ||
"""The unique ID of the calling CodeDeploy Deployment.""" | ||
return self["DeploymentId"] | ||
|
||
@property | ||
def lifecycle_event_hook_execution_id(self) -> str: | ||
"""The unique ID of a deployments lifecycle hook.""" | ||
return self["LifecycleEventHookExecutionId"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"DeploymentId": "d-ABCDEF", | ||
"LifecycleEventHookExecutionId": "xxxxxxxxxxxxxxxxxxxxxxxx" | ||
} |
20 changes: 20 additions & 0 deletions
20
tests/unit/data_classes/required_dependencies/test_code_deploy_lifecycle_hook_event.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pytest | ||
|
||
from aws_lambda_powertools.utilities.data_classes import ( | ||
CodeDeployLifecycleHookEvent, | ||
) | ||
from tests.functional.utils import load_event | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"event_file", | ||
[ | ||
"codeDeployLifecycleHookEvent.json", | ||
], | ||
) | ||
def test_code_deploy_lifecycle_hook_event(event_file): | ||
raw_event = load_event(event_file) | ||
parsed_event = CodeDeployLifecycleHookEvent(raw_event) | ||
|
||
assert parsed_event.deployment_id == raw_event["DeploymentId"] | ||
assert parsed_event.lifecycle_event_hook_execution_id == raw_event["LifecycleEventHookExecutionId"] |