Skip to content

Latest commit

 

History

History
31 lines (27 loc) · 25.8 KB

File metadata and controls

31 lines (27 loc) · 25.8 KB

Webhook Context

When a webhook is invoked, the client sends the context of the invocation to the webhook server. The specifics of what is in the context is dependent on the invocation type of the webhook, and includes information about what is being acted upon by the webhook. If information is needed by the webhook outside of what is made available in the context, then additional webservice calls must be made to query that information from the client.

When using SapioPyLib, the context that the client sends to the webhook is parsed into a SapioWebhookContext object. This object contains the following variables, which may or may not be present depending on the invocation type. Webhooks should take full advantage of the context provided to them.

Context Object Purpose For Invocation(s)
user Information about the user who initiated the webhook. All invocations
end_point_type An enum that records the invocation point of the webhook. All invocations
client_callback_result The result object from the client for any client callback request that the webhook may have sent back to the client. All invocations
is_client_callback
_available
A boolean that says if the client_callback_result is not None. All invocations
data_record The singular data record being acted upon.

If there are multiple data records being acted upon, they will be present in the data_record_list, and this value will be the first value from that list. As such, the “For Invocation(s)“ column only contains invocation points where this is expected to be the only record in the list.

For ELN Main Toolbar and ELN Menu/Grabber, this is the experiment record.

For Scheduled Webhook, this is the root directory.
ELN Main Toolbar
ELN Entry Toolbar (for form entries)
ELN Menu/Grabber
Scheduled Webhook
Data Type Record Toolbar
Data Type Record Action Button
Data Type Record Action Text Field
Data Type Record Selection List Field
data_record_list A list of data records being acted upon.

Will contain the data_record if one is present. As such, the “For Invocation(s)” column only contains invocation points where this list is expected to be populated with more than just the data_record.

If the webhook that populates this list is invoked from a table, the list will only include those records that the user had selected when they invoked the webhook. If the user had no records selected, then it will include all the records from the table from all pages (for tables that have paging).
For On Save Rule Actions, only the records for the primary data type for the rule is present in the list. That is, if a rule is created as a samples on save, then this list will be populated with the samples that triggered the rule.
ELN Entry Toolbar (for table entries)
Data Type Table Toolbar
On Save Rule Action
base_data_record If a webhook is invoked from a component on a data record form, such as through a button on the toolbar of a table of child samples related to the current record form being viewed, then this will populate with the data record that the component is on, while the data_record, data_record_list, and other context objects will be for the records within the component. Data type webhooks invoked from record form components
data_type_name The data type name of the data records being acted upon.

For ELN Main Toolbar and ELN Menu/Grabber, this is the experiment record’s data type name.

For Scheduled Webhook, this is the root directory’s data type name.
ELN Main Toolbar
ELN Entry Toolbar
ELN Menu/Grabber
Data Type Record Toolbar
Data Type Table Toolbar
Data Type Record Action Button
Data Type Record Action Text Field
On Save Rule Action
Data Type Record Selection List Field
data_field_name The name of the field on the record that the webhook was invoked from. Data Type Record Action Button
Data Type Record Action Text Field
Data Type Record Selection List Field
velox_on_save_result
_map
Contains data record and relationship information relevant to the on save rule. On Save Rule Action
velox_on_save_field
_map<_result_map
Contains field map and relationship information relevant to the on save rule for any records are no longer accessible (e.g. records that were deleted when the rule was triggered). On Save Rule Action
velox_eln_rule_result
_map
Contains data record and relationship information relevant to the ELN rule. ELN Rule Action
velox_eln_rule_field
_map_result_map
Contains field map and relationship information relevant to the ELN rule for any records are no longer accessible (e.g. records that were deleted when the rule was triggered). ELN Rule Action
eln_experiment The experiment that the webhook was invoked from. ELN Main Toolbar
ELN Entry Toolbar
ELN Menu/Grabber
ELN Rule Action
active_protocol A wrapper for eln_experiment with additional functions. ELN Main Toolbar
ELN Entry Toolbar
ELN Menu/Grabber
ELN Rule Action
experiment_entry The experiment entry that the webhook was invoked from. ELN Entry Toolbar
active_step A wrapper for experiment_entry with additional functions. ELN Entry Toolbar
experiment_entry_list The experiment entries that were involved in the conditional half of the ELN Rule that invoked the webhook. ELN Rule Action
entry_position Position information about where the webhook was invoked from.

For ELN Main Toolbar, this only includes the tab ID that the user was on when the button was pressed.

For ELN Menu/Grabber, this includes the tab ID and entry order that the grabber was activated from.
ELN Main Toolbar
ELN Menu/Grabber
field_map The field map for the data record that the selection list field is from. If invoked from a multi data type table, includes fields from the other data types and denotes the data type that the fields come from. Data Type Record Selection List Field
field_map_list The list of field maps for the data records that the selection list field is from. If invoked from a multi data type table, includes fields from the other data types and denotes the data type that the fields come from. Data Type Record Selection List Field

Note that the above table is not necessarily exhaustive, and as versions change, there may be more or less context present for each invocation type. It's advised that you always check the context you receive to see what's present when developing your webhooks.