Skip to content

refactor(data_classes): remove duplicated code #6288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
4 changes: 0 additions & 4 deletions aws_lambda_powertools/utilities/data_classes/alb_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ class ALBEvent(BaseProxyEvent):
def request_context(self) -> ALBEventRequestContext:
return ALBEventRequestContext(self["requestContext"])

@property
def multi_value_query_string_parameters(self) -> dict[str, list[str]]:
return self.get("multiValueQueryStringParameters") or {}

@property
def resolved_query_string_parameters(self) -> dict[str, list[str]]:
return self.multi_value_query_string_parameters or super().resolved_query_string_parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,9 @@ def resource(self) -> str:
def multi_value_headers(self) -> dict[str, list[str]]:
return CaseInsensitiveDict(self.get("multiValueHeaders"))

@property
def multi_value_query_string_parameters(self) -> dict[str, list[str]]:
return self.get("multiValueQueryStringParameters") or {} # key might exist but can be `null`

@property
def resolved_query_string_parameters(self) -> dict[str, list[str]]:
if self.multi_value_query_string_parameters:
return self.multi_value_query_string_parameters

return super().resolved_query_string_parameters
return self.multi_value_query_string_parameters or super().resolved_query_string_parameters

@property
def resolved_headers_field(self) -> dict[str, Any]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class BedrockAgentEvent(BaseProxyEvent):
See https://docs.aws.amazon.com/bedrock/latest/userguide/agents-create.html
"""

# httpMethod is inherited from BaseProxyEvent class.

@property
def message_version(self) -> str:
return self["messageVersion"]
Expand All @@ -77,10 +79,6 @@ def action_group(self) -> str:
def api_path(self) -> str:
return self["apiPath"]

@property
def http_method(self) -> str:
return self["httpMethod"]

@property
def parameters(self) -> list[BedrockAgentProperty]:
parameters = self.get("parameters") or []
Expand Down
12 changes: 2 additions & 10 deletions aws_lambda_powertools/utilities/data_classes/vpc_lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@


class VPCLatticeEventBase(BaseProxyEvent):
# is_base64_encoded and path are inherited from BaseProxyEvent class.

@property
def body(self) -> str:
"""The VPC Lattice body."""
Expand Down Expand Up @@ -169,16 +171,6 @@ def version(self) -> str:
"""The VPC Lattice v2 Event version"""
return self["version"]

@property
def is_base64_encoded(self) -> bool | None:
"""A boolean flag to indicate if the applicable request payload is Base64-encode"""
return self.get("isBase64Encoded")

@property
def path(self) -> str:
"""The VPC Lattice v2 Event path"""
return self["path"]

@property
def request_context(self) -> vpcLatticeEventV2RequestContext:
"""The VPC Lattice v2 Event request context."""
Expand Down
Loading