glados.request module — GLaDOS 0.0.1-alpha1 documentation

# glados.request module

class `glados.request.` `GladosRequest`(route_type, route, slack_verify=None, bot_name=None, json=None, **kwargs)

  Bases: `object`

  GLaDOS Request Object. This holds all the data required to process the request.

  Parameters

    - route_type (RouteType) – what type of route is this

    - route (str) – what is the route to be called

    - slack_verify (SlackVerification) – slack data used for verifying the request came from Slack

    - bot_name (str) – The name of the bot to send the request to. This is used for select RouteTypes

    - json (`Union`[`str`, `dict`, `None`]) – the json paylod of the request

    - kwargs –

  Examples

      >>> request = GladosRequest(RouteType.SendMessage, "send_mock", json={"message":"my message"})
      >>> print(request.json.message)
      my message
      >>> try:
      ...    print(request.json.other_param)
      ... except AttributeError:
      ...     print("ERROR")
      ERROR

  property `route`

    the actual route

    If the route automatically prefixed the route with the bot name, it will return the route with the prefix

    Return type

      `str`

class `glados.request.` `SlackVerification`(data, timestamp=None, signature=None)

  Bases: `object`

  An object to hold slack verification data

  Parameters

    - data (str) – raw request body. This is used to verify the message is from slack.

    - timestamp (str) – The X-Slack-Request-Timestamp from the headers of the request. This is used to verify the message is from slack.

    - signature (str) – The X-Slack-Signature from the headers of the request. This is used to verify the message is from slack.

  property `json`
    Return type

      `dict`