omnibot.routes package¶
Submodules¶
omnibot.routes.api module¶
API module for omnibot, to handle events from slack, or to handle service-to-service calls.
Endpoints in this module may be access controlled through the authorization configuration; see documentation on checks:
omnibot.authnz:enforce_checks()
-
omnibot.routes.api.
get_bot_ims
(team_name, bot_name)¶ Returns list of IMs (DMs with a bot), for the provided bot_name and team_name.
Example request:
GET /api/v1/slack/get_ims/myteam/mybot
Example response:
HTTP/1.1 200 OK Content-Type: application/json {"ims": [ { "id": 'D1234567', "created": 1518129625, "is_im": true, "is_org_shared": true, "user": "U1234567" "is_user_deleted": false, "priority": 0.01234567 } ] }
- Parameters
team_name (str) – The team to search for this user, as configured in omnibot.
bot_name (str) – The bot to use for the request, as configured in omnibot.
-
omnibot.routes.api.
get_channel_by_name
(team_name, bot_name, channel_name)¶ Returns a channel object from slack, for the provided channel_name in the team_name using the specified bot_name.
Example request:
GET /api/v1/slack/get_channel/myteam/mybot/general HTTP/1.1
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "channel": { "id": "C4VQ6NUNN", "name": "general", "is_channel": true, "created": 1491515285, "creator": "U4WF56QGP", "is_archived": false, "is_general": true, "unlinked": 0, "name_normalized": "general", "is_shared": false, "is_org_shared": false, "is_member": false, "is_private": false, "is_mpim": false, "members": [ "U4WF56QGP", "U6HQQ19EC", "U6J3LTKSQ", "U6J4EGP44", "U6JDF1JBU", "U6JEGTFDZ", "U6JERPMJ7", "U6JG691MJ", "U6JGEQ0J0", "U6SAVUK44", "U750C7B37", "U7DH0H802" ], "topic": { "value": "test123", "creator": "U6J3LTKSQ", "last_set": 1507156612 }, "purpose": { "value": "This channel is for team-wide communication.", "creator": "", "last_set": 0 }, "previous_names": [], "num_members": 9 } }
- Parameters
team_name (str) – The team to search for this channel, as configured in omnibot.
bot_name (str) – The bot to use for the request, as configured in omnibot.
channel_name (str) – The name of the channel to get.
- Reqheader x-envoy-internal
Header that indicates whether or not this request is coming from an internal service or not. This is auto-set by envoy and doesn’t need to be explicitly set.
- Resheader Content-Type
application/json
- Statuscode 200
success
- Statuscode 404
channel with specified channel_name could not be found in the specified team using the specified bot.
-
omnibot.routes.api.
get_team_id_by_name
(team_name)¶ Get a team_id, from its team_name.
Example request:
GET /api/v1/slack/get_team/myteam HTTP/1.1
Example response:
HTTP/1.1 200 OK Content-Type: application/json {"team_id": "T123456"}
- Parameters
team_name (str) – The team to search for this user, as configured in omnibot.
- Reqheader x-envoy-internal
Header that indicates whether or not this request is coming from an internal service or not. This is auto-set by envoy and doesn’t need to be explicitly set.
- Resheader Content-Type
application/json
- Statuscode 200
success
- Statuscode 404
team is not configured
-
omnibot.routes.api.
get_user_v2
(team_name, bot_name, email)¶ Returns basic user information, for the provided email in the team_name using the specified bot_name.
Example request:
GET /api/v1/slack/get_user/myteam/mybot/user@example.com HTTP/1.1
Example response:
HTTP/1.1 200 OK Content-Type: application/json {"email": "user@example.com", "name": "Test User", "team_id": "T123456", "user_id": "U123ABC"}
- Parameters
team_name (str) – The team to search for this user, as configured in omnibot.
bot_name (str) – The bot to use for the request, as configured in omnibot.
email (str) – The email address of the user to get.
- Reqheader x-envoy-internal
Header that indicates whether or not this request is coming from an internal service or not. This is auto-set by envoy and doesn’t need to be explicitly set.
- Resheader Content-Type
application/json
- Statuscode 200
success
- Statuscode 404
user with specified email could not be found using the specified bot.
-
omnibot.routes.api.
healthcheck
()¶
-
omnibot.routes.api.
instrument_event
(bot, event)¶
-
omnibot.routes.api.
queue_event
(bot, event, event_type)¶
-
omnibot.routes.api.
send_bot_im
(team_name, bot_name, email)¶ Sends a message as a bot user to an IM (direct message) channel between a team member and a bot user, for the provided team_name, bot_name, and email.
Example request:
GET /api/v1/slack/send_im/myteam/mybot/myemail@example.com
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "channel": "DC1234567", "message": { "bot_id": "BC1234567", "subtype": "bot_message", "text": "HI!", "ts": "1538593287.000100", "type": "message", "username": "mybot" }, "ok": true, "ts": "1538593287.000100" }
- Parameters
team_name (str) – The team to search for the given bot, as configured in omnibot.
bot_name (str) – The bot sending the IM to the user, as configured in omnibot.
email (str) – The email address of user to send message to
- Resheader Content-Type
application/json
- Statuscode 200
success
- Statuscode 400
slack call returned a non-OK status
- Statuscode 404
team, bot, IM unable to be found, or user deleted from slack team
-
omnibot.routes.api.
slack_action_v2
(team_name, bot_name)¶ Perform an action against slack, as the provided bot_name in the provided team_name.
Example request:
POST /api/v1/slack/action/myteam/mybot HTTP/1.1 Content-Type: application/json { "action": "chat.postMessage", "kwargs": { "channel": "test-omnibot", "text": "@example see #general and use @here", "as_user": true, "omnibot_parse": { "text": ["channels", "users", "specials"] } } }
- <json string action
slack api action to perform. example: chat.postMessage
- <json dict kwargs
keyword arguments you’d pass into the associated slack api action. example: “text”: “@example see #general and use @here”
- <json dict omnibot_parse
The keyword argument you’d like omnibot to parse, with a list of things to parse. example: {“text”: [“channels”, “users”, “specials”]}
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "channel": "C12345", "message": { "bot_id": "B456123", "subtype": "bot_message", "text": "<@UABC123|example> see <#C12345|general> and use <!here|here>", "ts": "1523557397.000335", "type": "message", "username": "mybot" }, "ok": true, "ts": "1523557397.000335" }
- Parameters
team_name (str) – The team to perform this action against, as configured in omnibot.
bot_name (str) – The bot to use for the request, as configured in omnibot.
- Reqheader x-envoy-internal
Header that indicates whether or not this request is coming from an internal service or not. This is auto-set by envoy and doesn’t need to be explicitly set.
- Resheader Content-Type
application/json
- Statuscode 200
success
- Statuscode 400
slack call returned a non-OK status
-
omnibot.routes.api.
slack_event
()¶ Handle event subscription API webhooks from slack.
-
omnibot.routes.api.
slack_interactive_component
()¶
-
omnibot.routes.api.
slack_slash_command
()¶
-
omnibot.routes.api.
verify_bot
(f)¶