magpie.api.webhooks

Module Contents

Classes

WebhookAction

Actions supported by webhooks.

Functions

process_webhook_requests(action, params, update_user_status_on_error=False)

Checks the config for any webhooks that correspond to the input action, and prepares corresponding requests.

replace_template(params, payload)

Replace each template parameter from the payload by its corresponding value.

send_webhook_request(webhook_config, params, update_user_status_on_error=False)

Sends a single webhook request using the input config.

webhook_update_error_status(user_name)

Updates the user’s status to indicate an error occured with the webhook requests.

magpie.api.webhooks.WEBHOOK_KEYS[source]
magpie.api.webhooks.WEBHOOK_TEMPLATE_PARAMS = ['user_name', 'tmp_url'][source]
magpie.api.webhooks.HTTP_METHODS = ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE'][source]
magpie.api.webhooks.LOGGER[source]
class magpie.api.webhooks.WebhookAction[source]

Bases: magpie.utils.ExtendedEnum

Actions supported by webhooks.

CREATE_USER = create_user[source]
DELETE_USER = delete_user[source]
magpie.api.webhooks.process_webhook_requests(action, params, update_user_status_on_error=False)[source]

Checks the config for any webhooks that correspond to the input action, and prepares corresponding requests.

Parameters
  • action – tag identifying which webhooks to use in the config

  • params – dictionary containing the required parameters for the request, they will replace templates found in the payload

  • update_user_status_on_error – update the user status or not in case of a webhook error

magpie.api.webhooks.replace_template(params, payload)[source]

Replace each template parameter from the payload by its corresponding value.

Parameters
  • params – the values of the template parameters

  • payload – structure containing the data to be processed by the template replacement

Returns

structure containing the data with the replaced template parameters

magpie.api.webhooks.send_webhook_request(webhook_config, params, update_user_status_on_error=False)[source]

Sends a single webhook request using the input config.

Parameters
  • webhook_config – dictionary containing the config data of a single webhook

  • params – dictionary containing the required parameters for the request, they will replace templates found in the payload

  • update_user_status_on_error – update the user status or not in case of a webhook error

magpie.api.webhooks.webhook_update_error_status(user_name)[source]

Updates the user’s status to indicate an error occured with the webhook requests.