|
| 1 | +from typing import Dict, List |
| 2 | + |
| 3 | +from aws_lambda_powertools.utilities.data_classes.common import DictWrapper |
| 4 | + |
| 5 | + |
| 6 | +class BedrockAgentInfo(DictWrapper): |
| 7 | + @property |
| 8 | + def name(self) -> str: |
| 9 | + return self["name"] |
| 10 | + |
| 11 | + @property |
| 12 | + def id(self) -> str: # noqa: A003 |
| 13 | + return self["id"] |
| 14 | + |
| 15 | + @property |
| 16 | + def alias(self) -> str: |
| 17 | + return self["alias"] |
| 18 | + |
| 19 | + @property |
| 20 | + def version(self) -> str: |
| 21 | + return self["version"] |
| 22 | + |
| 23 | + |
| 24 | +class BedrockAgentProperty(DictWrapper): |
| 25 | + @property |
| 26 | + def name(self) -> str: |
| 27 | + return self["name"] |
| 28 | + |
| 29 | + @property |
| 30 | + def type(self) -> str: # noqa: A003 |
| 31 | + return self["type"] |
| 32 | + |
| 33 | + @property |
| 34 | + def value(self) -> str: |
| 35 | + return self["value"] |
| 36 | + |
| 37 | + |
| 38 | +class BedrockAgentRequestMedia(DictWrapper): |
| 39 | + @property |
| 40 | + def properties(self) -> List[BedrockAgentProperty]: |
| 41 | + return [BedrockAgentProperty(x) for x in self["properties"]] |
| 42 | + |
| 43 | + |
| 44 | +class BedrockAgentRequestBody(DictWrapper): |
| 45 | + @property |
| 46 | + def content(self) -> Dict[str, BedrockAgentRequestMedia]: |
| 47 | + return {k: BedrockAgentRequestMedia(v) for k, v in self["content"].items()} |
| 48 | + |
| 49 | + |
| 50 | +class BedrockAgentEvent(DictWrapper): |
| 51 | + @property |
| 52 | + def message_version(self) -> str: |
| 53 | + return self["messageVersion"] |
| 54 | + |
| 55 | + @property |
| 56 | + def input_text(self) -> str: |
| 57 | + return self["inputText"] |
| 58 | + |
| 59 | + @property |
| 60 | + def session_id(self) -> str: |
| 61 | + return self["sessionId"] |
| 62 | + |
| 63 | + @property |
| 64 | + def action_group(self) -> str: |
| 65 | + return self["actionGroup"] |
| 66 | + |
| 67 | + @property |
| 68 | + def api_path(self) -> str: |
| 69 | + return self["apiPath"] |
| 70 | + |
| 71 | + @property |
| 72 | + def http_method(self) -> str: |
| 73 | + return self["httpMethod"] |
| 74 | + |
| 75 | + @property |
| 76 | + def parameters(self) -> List[BedrockAgentProperty]: |
| 77 | + return [BedrockAgentProperty(x) for x in self["parameters"]] |
| 78 | + |
| 79 | + @property |
| 80 | + def session_attributes(self) -> Dict[str, str]: |
| 81 | + return self["sessionAttributes"] |
| 82 | + |
| 83 | + |
| 84 | +class BedrockAgentResponseMedia(DictWrapper): |
| 85 | + @property |
| 86 | + def body(self) -> str: |
| 87 | + return self["body"] |
| 88 | + |
| 89 | + |
| 90 | +class BedrockAgentResponsePayload(DictWrapper): |
| 91 | + @property |
| 92 | + def action_group(self) -> str: |
| 93 | + return self["actionGroup"] |
| 94 | + |
| 95 | + @property |
| 96 | + def api_path(self) -> str: |
| 97 | + return self["apiPath"] |
| 98 | + |
| 99 | + @property |
| 100 | + def http_method(self) -> str: |
| 101 | + return self["httpMethod"] |
| 102 | + |
| 103 | + @property |
| 104 | + def http_status_code(self) -> int: |
| 105 | + return self["httpStatusCode"] |
| 106 | + |
| 107 | + @property |
| 108 | + def response_body(self) -> Dict[str, BedrockAgentResponseMedia]: |
| 109 | + return {k: BedrockAgentResponseMedia(v) for k, v in self["responseBody"].items()} |
| 110 | + |
| 111 | + |
| 112 | +class BedrockAgentResponseEvent(DictWrapper): |
| 113 | + @property |
| 114 | + def message_version(self) -> str: |
| 115 | + return self["messageVersion"] |
| 116 | + |
| 117 | + @property |
| 118 | + def response(self) -> BedrockAgentResponsePayload: |
| 119 | + return BedrockAgentResponsePayload(self["response"]) |
0 commit comments