| 300 | |
| 301 | |
| 302 | class ActionsBlock(Block): |
| 303 | type = "actions" |
| 304 | elements_max_length = 25 |
| 305 | |
| 306 | @property |
| 307 | def attributes(self) -> Set[str]: # type: ignore[override] |
| 308 | return super().attributes.union({"elements"}) |
| 309 | |
| 310 | def __init__( |
| 311 | self, |
| 312 | *, |
| 313 | elements: Sequence[Union[dict, InteractiveElement]], |
| 314 | block_id: Optional[str] = None, |
| 315 | **others: dict, |
| 316 | ): |
| 317 | """A block that is used to hold interactive elements. |
| 318 | https://docs.slack.dev/reference/block-kit/blocks/actions-block |
| 319 | |
| 320 | Args: |
| 321 | elements (required): An array of interactive element objects - buttons, select menus, overflow menus, |
| 322 | or date pickers. There is a maximum of 25 elements in each action block. |
| 323 | block_id: A string acting as a unique identifier for a block. |
| 324 | If not specified, a block_id will be generated. |
| 325 | You can use this block_id when you receive an interaction payload to identify the source of the action. |
| 326 | Maximum length for this field is 255 characters. |
| 327 | block_id should be unique for each message and each iteration of a message. |
| 328 | If a message is updated, use a new block_id. |
| 329 | """ |
| 330 | super().__init__(type=self.type, block_id=block_id) |
| 331 | show_unknown_key_warning(self, others) |
| 332 | |
| 333 | self.elements = BlockElement.parse_all(elements) |
| 334 | |
| 335 | @JsonValidator(f"elements attribute cannot exceed {elements_max_length} elements") |
| 336 | def _validate_elements_length(self): |
| 337 | return self.elements is None or len(self.elements) <= self.elements_max_length |
| 338 | |
| 339 | |
| 340 | class ContextBlock(Block): |
no outgoing calls