Resolves policy dynamically based on the COMMAND output.
| 254 | |
| 255 | |
| 256 | class DynamicPolicyResolver(BasePolicyResolver): |
| 257 | """ |
| 258 | Resolves policy dynamically based on the COMMAND output. |
| 259 | """ |
| 260 | |
| 261 | def __init__( |
| 262 | self, commands_parser: CommandsParser, fallback: Optional[PolicyResolver] = None |
| 263 | ) -> None: |
| 264 | """ |
| 265 | Parameters: |
| 266 | commands_parser (CommandsParser): COMMAND output parser. |
| 267 | fallback (Optional[PolicyResolver]): An optional resolver to be used when the |
| 268 | primary policies cannot handle a specific request. |
| 269 | """ |
| 270 | self._commands_parser = commands_parser |
| 271 | super().__init__(commands_parser.get_command_policies(), fallback) |
| 272 | |
| 273 | def with_fallback(self, fallback: "PolicyResolver") -> "PolicyResolver": |
| 274 | return DynamicPolicyResolver(self._commands_parser, fallback) |
| 275 | |
| 276 | |
| 277 | class StaticPolicyResolver(BasePolicyResolver): |
no outgoing calls