Document toolboxDocument toolbox

Python Script: interface _1.py

Description

The interface_1.py script is a prototype script that defines an interface using the zope.interface module. It is used as a reference when working with the sample_Script_session_vars 1.py script and the vp_scheduler_n_events_1.py script.

The interface includes an IEventHandler and IScheduler, and is designed to provide contracts for event processing and task scheduling.

This script is utilized when customers upload their own script instead of subscribing to an AppDirect marketplace script. If customers are using automation scripts from the marketplace, there is no need to upload this script. For information on uploading your own scripts for use with Data Connector, see Uploading Python Automation Scripts for Use with the Cloud Services Portal.

Here's how you can utilize the interfaces defined in the script:

Benefits of Using the Script

  1. Consistency: Ensure all event handlers and schedulers follow a consistent structure and API.

  2. Flexibility: Easily swap out different implementations as needed.

  3. Extensibility: Add new event handlers or schedulers without modifying existing code.

  4. Testability: Write unit tests and mock objects for event handlers and schedulers.

  5. Maintainability: Improve code maintainability by adhering to a clear contract for processing events and scheduling tasks.

import zope.interface class IEventHandler(zope.interface.Interface):     """Provides a public contract to     processing any kind of event from various cloud sources.     Context fields:         - request_id         - ophid     """     def process(context, event):         """         Process one event at once         """         pass class IScheduler(zope.interface.Interface):     """     Provides a public contract to process scheduled scripts     """     def schedule(self, context):         pass