#Automatically generated from https://xapi-project.github.io/xen-api/classes/event.html
import xenbridge
from .xenobject import XenObject, XenEndpoint, XenMethod, XenProperty, XenEnum
from typing import List, Dict, Any, Optional
import datetime


class EventOperation(XenEnum):
    ADD = 'add'
    DEL = 'del'
    MOD = 'mod'

class Event(XenObject):
    xenpath='event'

    class_: str = XenProperty(XenProperty.READONLY, 'The name of the class of the object that changed')
    id: int = XenProperty(XenProperty.READONLY, 'An ID, monotonically increasing, and local to the current session')
    obj_uuid: str = XenProperty(XenProperty.READONLY, 'The uuid of the object that changed')
    operation: EventOperation = XenProperty(XenProperty.READONLY, 'The operation that was performed')
    ref: str = XenProperty(XenProperty.READONLY, 'A reference to the object that changed')
    snapshot = XenProperty(XenProperty.READONLY, 'The record of the database object that was added, changed or deleted')
    timestamp: datetime.datetime = XenProperty(XenProperty.READONLY, 'The time at which the event occurred')


class EventEndpoint(XenEndpoint):
    xenpath='event'
    @XenMethod
    def from_(self, classes: List[str], token: str, timeout: float):
        """Blocking call which returns a new token and a (possibly empty) batch of events.
        The returned token can be used in subsequent calls to this function."""
    @XenMethod
    def get_current_id(self) -> int:
        """Return the ID of the next event to be generated by the system"""
    @XenMethod
    def inject(self, class_: str, ref: str) -> str:
        """Injects an artificial event on the given object and returns the corresponding ID
        in the form of a token, which can be used as a point of reference for database
        events. For example, to check whether an object has reached the right state
        before attempting an operation, one can inject an artificial event on the object
        and wait until the token returned by consecutive event.from calls is
        lexicographically greater than the one returned by event.inject."""
    @XenMethod
    def next(self) -> List[Dict[str, Any]]:
        """Blocking call which returns a (possibly empty) batch of events. This method is
        only recommended for legacy use. New development should use event.from which
        supercedes this method."""
    @XenMethod
    def register(self, classes: List[str]) -> None:
        """Registers this session with the event system for a set of given classes. This
        method is only recommended for legacy use in conjunction with event.next."""
    @XenMethod
    def unregister(self, classes: List[str]) -> None:
        """Removes this session's registration with the event system for a set of given
        classes. This method is only recommended for legacy use in conjunction with
        event.next."""
