| :mod:`airflow.operators.slack_operator` |
| ======================================= |
| |
| .. py:module:: airflow.operators.slack_operator |
| |
| |
| Module Contents |
| --------------- |
| |
| .. py:class:: SlackAPIOperator(slack_conn_id=None, token=None, method=None, api_params=None, *args, **kwargs) |
| |
| Bases: :class:`airflow.models.BaseOperator` |
| |
| Base Slack Operator |
| The SlackAPIPostOperator is derived from this operator. |
| In the future additional Slack API Operators will be derived from this class as well |
| |
| :param slack_conn_id: Slack connection ID which its password is Slack API token |
| :type slack_conn_id: str |
| :param token: Slack API token (https://api.slack.com/web) |
| :type token: str |
| :param method: The Slack API Method to Call (https://api.slack.com/methods) |
| :type method: str |
| :param api_params: API Method call parameters (https://api.slack.com/methods) |
| :type api_params: dict |
| |
| |
| .. method:: construct_api_call_params(self) |
| |
| Used by the execute function. Allows templating on the source fields |
| of the api_call_params dict before construction |
| |
| Override in child classes. |
| Each SlackAPIOperator child class is responsible for |
| having a construct_api_call_params function |
| which sets self.api_call_params with a dict of |
| API call parameters (https://api.slack.com/methods) |
| |
| |
| |
| |
| .. method:: execute(self, **kwargs) |
| |
| SlackAPIOperator calls will not fail even if the call is not unsuccessful. |
| It should not prevent a DAG from completing in success |
| |
| |
| |
| |
| .. py:class:: SlackAPIPostOperator(channel='#general', username='Airflow', text='No message has been set.\nHere is a cat video instead\nhttps://www.youtube.com/watch?v=J---aiyznGQ', icon_url='https://raw.githubusercontent.com/apache/airflow/master/airflow/www/static/pin_100.png', attachments=None, blocks=None, *args, **kwargs) |
| |
| Bases: :class:`airflow.operators.slack_operator.SlackAPIOperator` |
| |
| Posts messages to a slack channel |
| |
| :param channel: channel in which to post message on slack name (#general) or |
| ID (C12318391). (templated) |
| :type channel: str |
| :param username: Username that airflow will be posting to Slack as. (templated) |
| :type username: str |
| :param text: message to send to slack. (templated) |
| :type text: str |
| :param icon_url: url to icon used for this message |
| :type icon_url: str |
| :param attachments: extra formatting details. (templated) |
| - see https://api.slack.com/docs/attachments. |
| :type attachments: list of hashes |
| :param blocks: extra block layouts. (templated) |
| - see https://api.slack.com/reference/block-kit/blocks. |
| :type blocks: list of hashes |
| |
| .. attribute:: template_fields |
| :annotation: = ['username', 'text', 'attachments', 'blocks', 'channel'] |
| |
| |
| |
| .. attribute:: ui_color |
| :annotation: = #FFBA40 |
| |
| |
| |
| |
| .. method:: construct_api_call_params(self) |
| |
| |
| |
| |