|
1 | 1 | from re import Match
|
2 |
| -from typing import Any, Dict |
| 2 | +from typing import Any, Callable, Dict, List, Optional |
3 | 3 |
|
4 | 4 | from typing_extensions import override
|
5 | 5 |
|
6 | 6 | from aws_lambda_powertools.event_handler import ApiGatewayResolver
|
7 | 7 | from aws_lambda_powertools.event_handler.api_gateway import (
|
| 8 | + _DEFAULT_OPENAPI_RESPONSE_DESCRIPTION, |
8 | 9 | ProxyEventType,
|
9 | 10 | ResponseBuilder,
|
10 | 11 | )
|
| 12 | +from aws_lambda_powertools.event_handler.openapi.types import OpenAPIResponse |
11 | 13 | from aws_lambda_powertools.utilities.data_classes import BedrockAgentEvent
|
12 | 14 |
|
13 | 15 |
|
@@ -83,6 +85,166 @@ def __init__(self, debug: bool = False, enable_validation: bool = True):
|
83 | 85 | )
|
84 | 86 | self._response_builder_class = BedrockResponseBuilder
|
85 | 87 |
|
| 88 | + # Note: we need ignore[override] because we are making the optional `description` field required. |
| 89 | + @override |
| 90 | + def get( # type: ignore[override] |
| 91 | + self, |
| 92 | + rule: str, |
| 93 | + description: str, |
| 94 | + cors: Optional[bool] = None, |
| 95 | + compress: bool = False, |
| 96 | + cache_control: Optional[str] = None, |
| 97 | + summary: Optional[str] = None, |
| 98 | + responses: Optional[Dict[int, OpenAPIResponse]] = None, |
| 99 | + response_description: str = _DEFAULT_OPENAPI_RESPONSE_DESCRIPTION, |
| 100 | + tags: Optional[List[str]] = None, |
| 101 | + operation_id: Optional[str] = None, |
| 102 | + include_in_schema: bool = True, |
| 103 | + middlewares: Optional[List[Callable[..., Any]]] = None, |
| 104 | + ) -> Callable[[Callable[..., Any]], Callable[..., Any]]: |
| 105 | + return super(BedrockAgentResolver, self).get( |
| 106 | + rule, |
| 107 | + cors, |
| 108 | + compress, |
| 109 | + cache_control, |
| 110 | + summary, |
| 111 | + description, |
| 112 | + responses, |
| 113 | + response_description, |
| 114 | + tags, |
| 115 | + operation_id, |
| 116 | + include_in_schema, |
| 117 | + middlewares, |
| 118 | + ) |
| 119 | + |
| 120 | + # Note: we need ignore[override] because we are making the optional `description` field required. |
| 121 | + @override |
| 122 | + def post( # type: ignore[override] |
| 123 | + self, |
| 124 | + rule: str, |
| 125 | + description: str, |
| 126 | + cors: Optional[bool] = None, |
| 127 | + compress: bool = False, |
| 128 | + cache_control: Optional[str] = None, |
| 129 | + summary: Optional[str] = None, |
| 130 | + responses: Optional[Dict[int, OpenAPIResponse]] = None, |
| 131 | + response_description: str = _DEFAULT_OPENAPI_RESPONSE_DESCRIPTION, |
| 132 | + tags: Optional[List[str]] = None, |
| 133 | + operation_id: Optional[str] = None, |
| 134 | + include_in_schema: bool = True, |
| 135 | + middlewares: Optional[List[Callable[..., Any]]] = None, |
| 136 | + ): |
| 137 | + return super().post( |
| 138 | + rule, |
| 139 | + cors, |
| 140 | + compress, |
| 141 | + cache_control, |
| 142 | + summary, |
| 143 | + description, |
| 144 | + responses, |
| 145 | + response_description, |
| 146 | + tags, |
| 147 | + operation_id, |
| 148 | + include_in_schema, |
| 149 | + middlewares, |
| 150 | + ) |
| 151 | + |
| 152 | + # Note: we need ignore[override] because we are making the optional `description` field required. |
| 153 | + @override |
| 154 | + def put( # type: ignore[override] |
| 155 | + self, |
| 156 | + rule: str, |
| 157 | + description: str, |
| 158 | + cors: Optional[bool] = None, |
| 159 | + compress: bool = False, |
| 160 | + cache_control: Optional[str] = None, |
| 161 | + summary: Optional[str] = None, |
| 162 | + responses: Optional[Dict[int, OpenAPIResponse]] = None, |
| 163 | + response_description: str = _DEFAULT_OPENAPI_RESPONSE_DESCRIPTION, |
| 164 | + tags: Optional[List[str]] = None, |
| 165 | + operation_id: Optional[str] = None, |
| 166 | + include_in_schema: bool = True, |
| 167 | + middlewares: Optional[List[Callable[..., Any]]] = None, |
| 168 | + ): |
| 169 | + return super().put( |
| 170 | + rule, |
| 171 | + cors, |
| 172 | + compress, |
| 173 | + cache_control, |
| 174 | + summary, |
| 175 | + description, |
| 176 | + responses, |
| 177 | + response_description, |
| 178 | + tags, |
| 179 | + operation_id, |
| 180 | + include_in_schema, |
| 181 | + middlewares, |
| 182 | + ) |
| 183 | + |
| 184 | + # Note: we need ignore[override] because we are making the optional `description` field required. |
| 185 | + @override |
| 186 | + def patch( # type: ignore[override] |
| 187 | + self, |
| 188 | + rule: str, |
| 189 | + description: str, |
| 190 | + cors: Optional[bool] = None, |
| 191 | + compress: bool = False, |
| 192 | + cache_control: Optional[str] = None, |
| 193 | + summary: Optional[str] = None, |
| 194 | + responses: Optional[Dict[int, OpenAPIResponse]] = None, |
| 195 | + response_description: str = _DEFAULT_OPENAPI_RESPONSE_DESCRIPTION, |
| 196 | + tags: Optional[List[str]] = None, |
| 197 | + operation_id: Optional[str] = None, |
| 198 | + include_in_schema: bool = True, |
| 199 | + middlewares: Optional[List[Callable]] = None, |
| 200 | + ): |
| 201 | + return super().patch( |
| 202 | + rule, |
| 203 | + cors, |
| 204 | + compress, |
| 205 | + cache_control, |
| 206 | + summary, |
| 207 | + description, |
| 208 | + responses, |
| 209 | + response_description, |
| 210 | + tags, |
| 211 | + operation_id, |
| 212 | + include_in_schema, |
| 213 | + middlewares, |
| 214 | + ) |
| 215 | + |
| 216 | + # Note: we need ignore[override] because we are making the optional `description` field required. |
| 217 | + @override |
| 218 | + def delete( # type: ignore[override] |
| 219 | + self, |
| 220 | + rule: str, |
| 221 | + description: str, |
| 222 | + cors: Optional[bool] = None, |
| 223 | + compress: bool = False, |
| 224 | + cache_control: Optional[str] = None, |
| 225 | + summary: Optional[str] = None, |
| 226 | + responses: Optional[Dict[int, OpenAPIResponse]] = None, |
| 227 | + response_description: str = _DEFAULT_OPENAPI_RESPONSE_DESCRIPTION, |
| 228 | + tags: Optional[List[str]] = None, |
| 229 | + operation_id: Optional[str] = None, |
| 230 | + include_in_schema: bool = True, |
| 231 | + middlewares: Optional[List[Callable[..., Any]]] = None, |
| 232 | + ): |
| 233 | + return super().delete( |
| 234 | + rule, |
| 235 | + cors, |
| 236 | + compress, |
| 237 | + cache_control, |
| 238 | + summary, |
| 239 | + description, |
| 240 | + responses, |
| 241 | + response_description, |
| 242 | + tags, |
| 243 | + operation_id, |
| 244 | + include_in_schema, |
| 245 | + middlewares, |
| 246 | + ) |
| 247 | + |
86 | 248 | @override
|
87 | 249 | def _convert_matches_into_route_keys(self, match: Match) -> Dict[str, str]:
|
88 | 250 | # In Bedrock Agents, all the parameters come inside the "parameters" key, not on the apiPath
|
|
0 commit comments