handlers.conditionally_create_resource_handler

class ConditionallyCreateResourceHandler(handlers.eventhandler.EventHandler):

Whenever all conditions are fulfilled, we create a resource.

Configuration:
condition: Key/value pair that will be checked, e.g. approvalStatus: approved. If the condition holds true, we will set the field as specified. If the condition value starts with "!", the condition is negated (must not match).
resource: Data of the resource to be created.

name = 'Conditionally create resource'
description = "Whenever certain conditions are fulfilled, create a resource if it doesn't exist yet."
conditions = {'event_types': ['FactSheetUpdatedEvent']}
supports_initial_sync = True
config_template = {'fs_types': ['Project'], 'field': 'preDecision', 'condition': {'preDecision': 'approved', 'soundingBoard': '!iTSSC'}, 'resource': {'name': 'Approval Document', 'url': 'https://example.com/', 'resourceType': 'website', 'description': None}, 'delete_resources_if_condition_is_false': True}
def handle(self, event, fs, **kwargs):

Called automatically whenever a matching event comes in via webhook.