FutureProcessing / glpi-webhook

GNU Affero General Public License v3.0
7 stars 4 forks source link

GLPI FPWebhook

General Information

This plugin creates support for webhooks for GLPI.

Requirements

GLPI 9.5.* or GLPI 10.0.x

Installation instructions

Installation is similar to those of other plugins: copy to plugins/ directory, ensure that name of the folder that contains the plugin files is fpwebhook, and then install and enable from Administration/Plugins section. This will create the database tables.

Uninstallation instructions

Use Uninstall option in Administration/Plugins section.

Please keep in mind that this will remove the database tables, including all subscriptions and trigger history.

Basic use

  1. Install and enable on the plugin list
  2. Visit top menu > Plugins > Webhook subscriptions; this will open the form
  3. Enter the name (any non-empty), enter the URL to receive data (make sure it can receive and respond), select the desired type of the event, and click Add
  4. You will be redirected to the list with an added position
  5. Trigger the event - depending on the chosen event type, this may require creating an event, solving the event, adding a followup, or adding or resolving an approval
  6. During the next minute-long cron cycle, the URL will receive a packet with IDs and content.
  7. If the URL responded with a 2xx or 3xx status, the queue object will be removed; if the response was 4xx or 5xx, it will stay there with increased attempts count; if the reply was a 410 Gone, the subscription will be deactivated.

Database details

Detailed behavior

This is an example based on the first implemented event,TicketCreated.

  1. When a ticket is created, TicketCreated event is triggered
  2. In reaction to the event, a content record is created and the request to send it is placed in the queue
  3. Every minute, a cron task sends messages in packages of 5 (configurable), starting from the "cleanest" (ones with the fewest failures), followed by those that failed more times
    • If an auth token configuration variable is set, its value is sent in the message's header
  4. Every result (status and reply) are archived; successes are removed from the queue, the failures stay
  5. If any reply contains 410 Gone status, the subscription is immediately disabled
  6. If any queue item fails 3 times (configurable), failures count for its subscription is increased
  7. Every 24h a cleaning is performed via a cron task
    • everything that has exceeded the failure count or belongs to inactive subscription is removed from the queue
    • Sufficiently failed subscriptions are also set to inactive.

Filtering mechanism

Filtering is an optional functionality that allows to set two parameters: a ticket category and a title-matching regular expression. If the category is chosen, only tickets belonging to this category will trigger the event - others will be ignored. If the filtering regex is non-empty, only the tickets with the title matching the expression will trigger the event.

The filters are applied together - if both filters are set, the event will trigger only if the ticket has both a matching title and a correct category.

To remove the filtering from the subscription, simply empty the regular expression field and unset the category field.

The regular expression should be entered without delimiters. Since the delimiters used are |, this character is disallowed in the regular expression.

Note: the regular expression is applied as case-sensitive.

Available events

TicketCreated

On ticket creation, returns:

TicketSolved

On ticket solution added, returns:

TicketFollowupAdded

On ticket follow-up added, returns:

TicketApprovalAdded

On ticket approval request (ticket validation) added, returns:

TicketApprovalResolved

On ticket approval request (ticket validation) added, returns:

Notes